diff --git a/Jakefile.js b/Jakefile.js index 4fd3be57e4f..1aba38fddb6 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -571,7 +571,7 @@ var typingsInstallerFile = path.join(builtLocalDirectory, "typingsInstaller.js") compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false }); var serverFile = path.join(builtLocalDirectory, "tsserver.js"); -compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"] }); +compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true }); var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js"); var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts"); compileFile( @@ -580,7 +580,7 @@ compileFile( [builtLocalDirectory, copyright, builtLocalCompiler].concat(languageServiceLibrarySources).concat(libraryTargets), /*prefixes*/[copyright], /*useBuiltCompiler*/ true, - { noOutFile: false, generateDeclarations: true, stripInternal: true }, + { noOutFile: false, generateDeclarations: true, stripInternal: true, preserveConstEnums: true }, /*callback*/ function () { prependFile(copyright, tsserverLibraryDefinitionFile); diff --git a/lib/cancellationToken.js b/lib/cancellationToken.js index 003999d2e8a..378255a37ee 100644 --- a/lib/cancellationToken.js +++ b/lib/cancellationToken.js @@ -15,6 +15,15 @@ and limitations under the License. "use strict"; var fs = require("fs"); +function pipeExists(name) { + try { + fs.statSync(name); + return true; + } + catch (e) { + return false; + } +} function createCancellationToken(args) { var cancellationPipeName; for (var i = 0; i < args.length - 1; i++) { @@ -24,18 +33,39 @@ function createCancellationToken(args) { } } if (!cancellationPipeName) { - return { isCancellationRequested: function () { return false; } }; + return { + isCancellationRequested: function () { return false; }, + setRequest: function (_requestId) { return void 0; }, + resetRequest: function (_requestId) { return void 0; } + }; } - return { - isCancellationRequested: function () { - try { - fs.statSync(cancellationPipeName); - return true; - } - catch (e) { - return false; - } + if (cancellationPipeName.charAt(cancellationPipeName.length - 1) === "*") { + var namePrefix_1 = cancellationPipeName.slice(0, -1); + if (namePrefix_1.length === 0 || namePrefix_1.indexOf("*") >= 0) { + throw new Error("Invalid name for template cancellation pipe: it should have length greater than 2 characters and contain only one '*'."); } - }; + var perRequestPipeName_1; + var currentRequestId_1; + return { + isCancellationRequested: function () { return perRequestPipeName_1 !== undefined && pipeExists(perRequestPipeName_1); }, + setRequest: function (requestId) { + currentRequestId_1 = currentRequestId_1; + perRequestPipeName_1 = namePrefix_1 + requestId; + }, + resetRequest: function (requestId) { + if (currentRequestId_1 !== requestId) { + throw new Error("Mismatched request id, expected " + currentRequestId_1 + ", actual " + requestId); + } + perRequestPipeName_1 = undefined; + } + }; + } + else { + return { + isCancellationRequested: function () { return pipeExists(cancellationPipeName); }, + setRequest: function (_requestId) { return void 0; }, + resetRequest: function (_requestId) { return void 0; } + }; + } } module.exports = createCancellationToken; diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 6a4e8ec5216..126e5d82ac4 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -157,23 +157,17 @@ interface ObjectConstructor { getOwnPropertyNames(o: any): string[]; /** - * Creates an object that has null prototype. - * @param o Object to use as a prototype. May be null + * Creates an object that has the specified prototype or that has null prototype. + * @param o Object to use as a prototype. May be null. */ - create(o: null): any; - - /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - */ - create(o: T): T; + create(o: T | null): T | object; /** * Creates an object that has the specified prototype, and that optionally contains specified properties. * @param o Object to use as a prototype. May be null * @param properties JavaScript object that contains one or more property descriptors. */ - create(o: any, properties: PropertyDescriptorMap): any; + create(o: object | null, properties: PropertyDescriptorMap): any; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -361,14 +355,14 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string that represents the regular expression. + * @param searchValue A string to search for. * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string that represents the regular expression. + * @param searchValue A string to search for. * @param replacer A function that returns the replacement text. */ replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; @@ -1336,39 +1330,27 @@ interface PromiseLike { * @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) => T | PromiseLike) | undefined | null, - onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): PromiseLike; + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): PromiseLike; +} +/** + * Represents the completion of an asynchronous operation + */ +interface Promise { /** * 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) => T | PromiseLike) | undefined | null, - onrejected: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. + * Attaches a callback for only the rejection of the Promise. * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. + * @returns A Promise for the completion of the callback. */ - then( - onfulfilled: (value: T) => TResult | PromiseLike, - onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): 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) => TResult1 | PromiseLike, - onrejected: (reason: any) => TResult2 | PromiseLike): PromiseLike; + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; } interface ArrayLike { @@ -4201,18 +4183,50 @@ interface Date { /// IE DOM APIs ///////////////////////////// +interface Account { + rpDisplayName?: string; + displayName?: string; + id?: string; + name?: string; + imageURL?: string; +} + interface Algorithm { name: string; } -interface AriaRequestEventInit extends EventInit { - attributeName?: string; - attributeValue?: string; +interface AnimationEventInit extends EventInit { + animationName?: string; + elapsedTime?: number; } -interface CommandEventInit extends EventInit { - commandName?: string; - detail?: string; +interface AssertionOptions { + timeoutSeconds?: number; + rpId?: USVString; + allowList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface CacheQueryOptions { + ignoreSearch?: boolean; + ignoreMethod?: boolean; + ignoreVary?: boolean; + cacheName?: string; +} + +interface ClientData { + challenge?: string; + origin?: string; + rpId?: string; + hashAlg?: string | Algorithm; + tokenBinding?: string; + extensions?: WebAuthnExtensions; +} + +interface CloseEventInit extends EventInit { + wasClean?: boolean; + code?: number; + reason?: string; } interface CompositionEventInit extends UIEventInit { @@ -4252,6 +4266,13 @@ interface CustomEventInit extends EventInit { detail?: any; } +interface DOMRectInit { + x?: any; + y?: any; + width?: any; + height?: any; +} + interface DeviceAccelerationDict { x?: number; y?: number; @@ -4262,6 +4283,20 @@ interface DeviceLightEventInit extends EventInit { value?: number; } +interface DeviceMotionEventInit extends EventInit { + acceleration?: DeviceAccelerationDict; + accelerationIncludingGravity?: DeviceAccelerationDict; + rotationRate?: DeviceRotationRateDict; + interval?: number; +} + +interface DeviceOrientationEventInit extends EventInit { + alpha?: number; + beta?: number; + gamma?: number; + absolute?: boolean; +} + interface DeviceRotationRateDict { alpha?: number; beta?: number; @@ -4273,6 +4308,14 @@ interface DoubleRange { min?: number; } +interface ErrorEventInit extends EventInit { + message?: string; + filename?: string; + lineno?: number; + colno?: number; + error?: any; +} + interface EventInit { scoped?: boolean; bubbles?: boolean; @@ -4305,6 +4348,29 @@ interface FocusEventInit extends UIEventInit { relatedTarget?: EventTarget; } +interface FocusNavigationEventInit extends EventInit { + navigationReason?: string; + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface FocusNavigationOrigin { + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface GamepadEventInit extends EventInit { + gamepad?: Gamepad; +} + +interface GetNotificationOptions { + tag?: string; +} + interface HashChangeEventInit extends EventInit { newURL?: string; oldURL?: string; @@ -4320,6 +4386,20 @@ interface IDBObjectStoreParameters { keyPath?: IDBKeyPath; } +interface IntersectionObserverEntryInit { + time?: number; + rootBounds?: DOMRectInit; + boundingClientRect?: DOMRectInit; + intersectionRect?: DOMRectInit; + target?: Element; +} + +interface IntersectionObserverInit { + root?: Element; + rootMargin?: string; + threshold?: number | number[]; +} + interface KeyAlgorithm { name?: string; } @@ -4522,6 +4602,11 @@ interface MSPayloadBase extends RTCStats { payloadDescription?: string; } +interface MSPortRange { + min?: number; + max?: number; +} + interface MSRelayAddress { relayAddress?: string; port?: number; @@ -4572,7 +4657,7 @@ interface MSUtilization { } interface MSVideoPayload extends MSPayloadBase { - resoluton?: string; + resolution?: string; videoBitRateAvg?: number; videoBitRateMax?: number; videoFrameRateAvg?: number; @@ -4655,6 +4740,10 @@ interface MediaStreamErrorEventInit extends EventInit { error?: MediaStreamError; } +interface MediaStreamEventInit extends EventInit { + stream?: MediaStream; +} + interface MediaStreamTrackEventInit extends EventInit { track?: MediaStreamTrack; } @@ -4719,6 +4808,15 @@ interface MediaTrackSupportedConstraints { groupId?: boolean; } +interface MessageEventInit extends EventInit { + lastEventId?: string; + channel?: string; + data?: any; + origin?: string; + source?: Window; + ports?: MessagePort[]; +} + interface MouseEventInit extends EventModifierInit { screenX?: number; screenY?: number; @@ -4748,10 +4846,68 @@ interface MutationObserverInit { attributeFilter?: string[]; } +interface NotificationOptions { + dir?: string; + lang?: string; + body?: string; + tag?: string; + icon?: string; +} + interface ObjectURLOptions { oneTimeOnly?: boolean; } +interface PaymentCurrencyAmount { + currency?: string; + value?: string; + currencySystem?: string; +} + +interface PaymentDetails { + total?: PaymentItem; + displayItems?: PaymentItem[]; + shippingOptions?: PaymentShippingOption[]; + modifiers?: PaymentDetailsModifier[]; + error?: string; +} + +interface PaymentDetailsModifier { + supportedMethods?: string[]; + total?: PaymentItem; + additionalDisplayItems?: PaymentItem[]; + data?: any; +} + +interface PaymentItem { + label?: string; + amount?: PaymentCurrencyAmount; + pending?: boolean; +} + +interface PaymentMethodData { + supportedMethods?: string[]; + data?: any; +} + +interface PaymentOptions { + requestPayerName?: boolean; + requestPayerEmail?: boolean; + requestPayerPhone?: boolean; + requestShipping?: boolean; + shippingType?: string; +} + +interface PaymentRequestUpdateEventInit extends EventInit { +} + +interface PaymentShippingOption { + id?: string; + label?: string; + amount?: PaymentCurrencyAmount; + selected?: boolean; +} + interface PeriodicWaveConstraints { disableNormalization?: boolean; } @@ -4767,12 +4923,34 @@ interface PointerEventInit extends MouseEventInit { isPrimary?: boolean; } +interface PopStateEventInit extends EventInit { + state?: any; +} + interface PositionOptions { enableHighAccuracy?: boolean; timeout?: number; maximumAge?: number; } +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + +interface PushSubscriptionOptionsInit { + userVisibleOnly?: boolean; + applicationServerKey?: any; +} + +interface RTCConfiguration { + iceServers?: RTCIceServer[]; + iceTransportPolicy?: string; + bundlePolicy?: string; + peerIdentity?: string; +} + interface RTCDTMFToneChangeEventInit extends EventInit { tone?: string; } @@ -4787,18 +4965,6 @@ interface RTCDtlsParameters { fingerprints?: RTCDtlsFingerprint[]; } -interface RTCIceCandidate { - foundation?: string; - priority?: number; - ip?: string; - protocol?: string; - port?: number; - type?: string; - tcpType?: string; - relatedAddress?: string; - relatedPort?: number; -} - interface RTCIceCandidateAttributes extends RTCStats { ipAddress?: string; portNumber?: number; @@ -4811,9 +4977,28 @@ interface RTCIceCandidateAttributes extends RTCStats { interface RTCIceCandidateComplete { } +interface RTCIceCandidateDictionary { + foundation?: string; + priority?: number; + ip?: string; + protocol?: string; + port?: number; + type?: string; + tcpType?: string; + relatedAddress?: string; + relatedPort?: number; + msMTurnSessionId?: string; +} + +interface RTCIceCandidateInit { + candidate?: string; + sdpMid?: string; + sdpMLineIndex?: number; +} + interface RTCIceCandidatePair { - local?: RTCIceCandidate; - remote?: RTCIceCandidate; + local?: RTCIceCandidateDictionary; + remote?: RTCIceCandidateDictionary; } interface RTCIceCandidatePairStats extends RTCStats { @@ -4835,11 +5020,13 @@ interface RTCIceCandidatePairStats extends RTCStats { interface RTCIceGatherOptions { gatherPolicy?: string; iceservers?: RTCIceServer[]; + portRange?: MSPortRange; } interface RTCIceParameters { usernameFragment?: string; password?: string; + iceLite?: boolean; } interface RTCIceServer { @@ -4873,6 +5060,13 @@ interface RTCMediaStreamTrackStats extends RTCStats { echoReturnLossEnhancement?: number; } +interface RTCOfferOptions { + offerToReceiveVideo?: number; + offerToReceiveAudio?: number; + voiceActivityDetection?: boolean; + iceRestart?: boolean; +} + interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { packetsSent?: number; bytesSent?: number; @@ -4880,6 +5074,10 @@ interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { roundTripTime?: number; } +interface RTCPeerConnectionIceEventInit extends EventInit { + candidate?: RTCIceCandidate; +} + interface RTCRTPStreamStats extends RTCStats { ssrc?: string; associateStatsId?: string; @@ -4917,6 +5115,7 @@ interface RTCRtpCodecCapability { clockRate?: number; preferredPayloadType?: number; maxptime?: number; + ptime?: number; numChannels?: number; rtcpFeedback?: RTCRtcpFeedback[]; parameters?: any; @@ -4931,6 +5130,7 @@ interface RTCRtpCodecParameters { payloadType?: any; clockRate?: number; maxptime?: number; + ptime?: number; numChannels?: number; rtcpFeedback?: RTCRtcpFeedback[]; parameters?: any; @@ -4950,9 +5150,9 @@ interface RTCRtpEncodingParameters { priority?: number; maxBitrate?: number; minQuality?: number; - framerateBias?: number; resolutionScale?: number; framerateScale?: number; + maxFramerate?: number; active?: boolean; encodingId?: string; dependencyEncodingIds?: string[]; @@ -4983,6 +5183,7 @@ interface RTCRtpParameters { headerExtensions?: RTCRtpHeaderExtensionParameters[]; encodings?: RTCRtpEncodingParameters[]; rtcp?: RTCRtcpParameters; + degradationPreference?: string; } interface RTCRtpRtxParameters { @@ -4995,6 +5196,11 @@ interface RTCRtpUnhandled { muxId?: string; } +interface RTCSessionDescriptionInit { + type?: string; + sdp?: string; +} + interface RTCSrtpKeyParam { keyMethod?: string; keySalt?: string; @@ -5035,6 +5241,64 @@ interface RTCTransportStats extends RTCStats { remoteCertificateId?: string; } +interface RegistrationOptions { + scope?: string; +} + +interface RequestInit { + method?: string; + headers?: any; + body?: any; + referrer?: string; + referrerPolicy?: string; + mode?: string; + credentials?: string; + cache?: string; + redirect?: string; + integrity?: string; + keepalive?: boolean; + window?: any; +} + +interface ResponseInit { + status?: number; + statusText?: string; + headers?: any; +} + +interface ScopedCredentialDescriptor { + type?: string; + id?: any; + transports?: string[]; +} + +interface ScopedCredentialOptions { + timeoutSeconds?: number; + rpId?: USVString; + excludeList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface ScopedCredentialParameters { + type?: string; + algorithm?: string | Algorithm; +} + +interface ServiceWorkerMessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + source?: ServiceWorker | MessagePort; + ports?: MessagePort[]; +} + +interface SpeechSynthesisEventInit extends EventInit { + utterance?: SpeechSynthesisUtterance; + charIndex?: number; + elapsedTime?: number; + name?: string; +} + interface StoreExceptionsInformation extends ExceptionInformation { siteName?: string; explanationString?: string; @@ -5045,11 +5309,23 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat arrayOfDomainStrings?: string[]; } +interface TrackEventInit extends EventInit { + track?: VideoTrack | AudioTrack | TextTrack; +} + +interface TransitionEventInit extends EventInit { + propertyName?: string; + elapsedTime?: number; +} + interface UIEventInit extends EventInit { view?: Window; detail?: number; } +interface WebAuthnExtensions { +} + interface WebGLContextAttributes { failIfMajorPerformanceCaveat?: boolean; alpha?: boolean; @@ -5075,6 +5351,18 @@ interface EventListener { (evt: Event): void; } +interface WebKitEntriesCallback { + (evt: Event): void; +} + +interface WebKitErrorCallback { + (evt: Event): void; +} + +interface WebKitFileCallback { + (evt: Event): void; +} + interface ANGLE_instanced_arrays { drawArraysInstancedANGLE(mode: number, first: number, count: number, primcount: number): void; drawElementsInstancedANGLE(mode: number, count: number, type: number, offset: number, primcount: number): void; @@ -5113,14 +5401,14 @@ interface AnimationEvent extends Event { declare var AnimationEvent: { prototype: AnimationEvent; - new(): AnimationEvent; + new(typeArg: string, eventInitDict?: AnimationEventInit): AnimationEvent; } interface ApplicationCacheEventMap { "cached": Event; "checking": Event; "downloading": Event; - "error": ErrorEvent; + "error": Event; "noupdate": Event; "obsolete": Event; "progress": ProgressEvent; @@ -5131,7 +5419,7 @@ interface ApplicationCache extends EventTarget { oncached: (this: ApplicationCache, ev: Event) => any; onchecking: (this: ApplicationCache, ev: Event) => any; ondownloading: (this: ApplicationCache, ev: Event) => any; - onerror: (this: ApplicationCache, ev: ErrorEvent) => any; + onerror: (this: ApplicationCache, ev: Event) => any; onnoupdate: (this: ApplicationCache, ev: Event) => any; onobsolete: (this: ApplicationCache, ev: Event) => any; onprogress: (this: ApplicationCache, ev: ProgressEvent) => any; @@ -5161,16 +5449,6 @@ declare var ApplicationCache: { readonly UPDATEREADY: number; } -interface AriaRequestEvent extends Event { - readonly attributeName: string; - attributeValue: string | null; -} - -declare var AriaRequestEvent: { - prototype: AriaRequestEvent; - new(type: string, eventInitDict?: AriaRequestEventInit): AriaRequestEvent; -} - interface Attr extends Node { readonly name: string; readonly ownerElement: Element; @@ -5222,12 +5500,18 @@ declare var AudioBufferSourceNode: { new(): AudioBufferSourceNode; } -interface AudioContext extends EventTarget { +interface AudioContextEventMap { + "statechange": Event; +} + +interface AudioContextBase extends EventTarget { readonly currentTime: number; readonly destination: AudioDestinationNode; readonly listener: AudioListener; + onstatechange: (this: AudioContext, ev: Event) => any; readonly sampleRate: number; - state: string; + readonly state: string; + close(): Promise; createAnalyser(): AnalyserNode; createBiquadFilter(): BiquadFilterNode; createBuffer(numberOfChannels: number, length: number, sampleRate: number): AudioBuffer; @@ -5238,6 +5522,7 @@ interface AudioContext extends EventTarget { createDelay(maxDelayTime?: number): DelayNode; createDynamicsCompressor(): DynamicsCompressorNode; createGain(): GainNode; + createIIRFilter(feedforward: number[], feedback: number[]): IIRFilterNode; createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createMediaStreamSource(mediaStream: MediaStream): MediaStreamAudioSourceNode; createOscillator(): OscillatorNode; @@ -5246,7 +5531,14 @@ interface AudioContext extends EventTarget { createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; - decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): PromiseLike; + decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): Promise; + resume(): Promise; + addEventListener(type: K, listener: (this: AudioContext, ev: AudioContextEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface AudioContext extends AudioContextBase { + suspend(): Promise; } declare var AudioContext: { @@ -5283,7 +5575,7 @@ interface AudioNode extends EventTarget { readonly context: AudioContext; readonly numberOfInputs: number; readonly numberOfOutputs: number; - connect(destination: AudioNode, output?: number, input?: number): void; + connect(destination: AudioNode, output?: number, input?: number): AudioNode; disconnect(output?: number): void; disconnect(destination: AudioNode, output?: number, input?: number): void; disconnect(destination: AudioParam, output?: number): void; @@ -5297,12 +5589,12 @@ declare var AudioNode: { interface AudioParam { readonly defaultValue: number; value: number; - cancelScheduledValues(startTime: number): void; - exponentialRampToValueAtTime(value: number, endTime: number): void; - linearRampToValueAtTime(value: number, endTime: number): void; - setTargetAtTime(target: number, startTime: number, timeConstant: number): void; - setValueAtTime(value: number, startTime: number): void; - setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; + cancelScheduledValues(startTime: number): AudioParam; + exponentialRampToValueAtTime(value: number, endTime: number): AudioParam; + linearRampToValueAtTime(value: number, endTime: number): AudioParam; + setTargetAtTime(target: number, startTime: number, timeConstant: number): AudioParam; + setValueAtTime(value: number, startTime: number): AudioParam; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): AudioParam; } declare var AudioParam: { @@ -5679,10 +5971,16 @@ interface CSSStyleDeclaration { imeMode: string | null; justifyContent: string | null; kerning: string | null; + layoutGrid: string | null; + layoutGridChar: string | null; + layoutGridLine: string | null; + layoutGridMode: string | null; + layoutGridType: string | null; left: string | null; readonly length: number; letterSpacing: string | null; lightingColor: string | null; + lineBreak: string | null; lineHeight: string | null; listStyle: string | null; listStyleImage: string | null; @@ -5754,6 +6052,7 @@ interface CSSStyleDeclaration { orphans: string | null; outline: string | null; outlineColor: string | null; + outlineOffset: string | null; outlineStyle: string | null; outlineWidth: string | null; overflow: string | null; @@ -5774,9 +6073,11 @@ interface CSSStyleDeclaration { position: string | null; quotes: string | null; right: string | null; + rotate: string | null; rubyAlign: string | null; rubyOverhang: string | null; rubyPosition: string | null; + scale: string | null; stopColor: string | null; stopOpacity: string | null; stroke: string | null; @@ -5810,6 +6111,7 @@ interface CSSStyleDeclaration { transitionDuration: string | null; transitionProperty: string | null; transitionTimingFunction: string | null; + translate: string | null; unicodeBidi: string | null; verticalAlign: string | null; visibility: string | null; @@ -5870,6 +6172,9 @@ interface CSSStyleDeclaration { webkitTapHighlightColor: string | null; webkitTextFillColor: string | null; webkitTextSizeAdjust: any; + webkitTextStroke: string | null; + webkitTextStrokeColor: string | null; + webkitTextStrokeWidth: string | null; webkitTransform: string | null; webkitTransformOrigin: string | null; webkitTransformStyle: string | null; @@ -5891,6 +6196,7 @@ interface CSSStyleDeclaration { zIndex: string | null; zoom: string | null; resize: string | null; + userSelect: string | null; getPropertyPriority(propertyName: string): string; getPropertyValue(propertyName: string): string; item(index: number): string; @@ -5918,7 +6224,6 @@ declare var CSSStyleRule: { interface CSSStyleSheet extends StyleSheet { readonly cssRules: CSSRuleList; cssText: string; - readonly href: string; readonly id: string; readonly imports: StyleSheetList; readonly isAlternate: boolean; @@ -5950,6 +6255,34 @@ declare var CSSSupportsRule: { new(): CSSSupportsRule; } +interface Cache { + add(request: RequestInfo): Promise; + addAll(requests: RequestInfo[]): Promise; + delete(request: RequestInfo, options?: CacheQueryOptions): Promise; + keys(request?: RequestInfo, options?: CacheQueryOptions): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + put(request: RequestInfo, response: Response): Promise; +} + +declare var Cache: { + prototype: Cache; + new(): Cache; +} + +interface CacheStorage { + delete(cacheName: string): Promise; + has(cacheName: string): Promise; + keys(): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + open(cacheName: string): Promise; +} + +declare var CacheStorage: { + prototype: CacheStorage; + new(): CacheStorage; +} + interface CanvasGradient { addColorStop(offset: number, color: string): void; } @@ -5974,13 +6307,13 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { font: string; globalAlpha: number; globalCompositeOperation: string; + imageSmoothingEnabled: boolean; lineCap: string; lineDashOffset: number; lineJoin: string; lineWidth: number; miterLimit: number; msFillRule: string; - msImageSmoothingEnabled: boolean; shadowBlur: number; shadowColor: string; shadowOffsetX: number; @@ -5998,6 +6331,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + drawFocusIfNeeded(element: Element): 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; @@ -6013,7 +6347,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { scale(x: number, y: number): void; setLineDash(segments: number[]): void; setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - stroke(): void; + stroke(path?: Path2D): void; strokeRect(x: number, y: number, w: number, h: number): void; strokeText(text: string, x: number, y: number, maxWidth?: number): void; transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; @@ -6099,17 +6433,7 @@ interface CloseEvent extends Event { declare var CloseEvent: { prototype: CloseEvent; - new(): CloseEvent; -} - -interface CommandEvent extends Event { - readonly commandName: string; - readonly detail: string | null; -} - -declare var CommandEvent: { - prototype: CommandEvent; - new(type: string, eventInitDict?: CommandEventInit): CommandEvent; + new(typeArg: string, eventInitDict?: CloseEventInit): CloseEvent; } interface Comment extends CharacterData { @@ -6136,7 +6460,7 @@ interface Console { assert(test?: boolean, message?: string, ...optionalParams: any[]): void; clear(): void; count(countTitle?: string): void; - debug(message?: string, ...optionalParams: any[]): void; + debug(message?: any, ...optionalParams: any[]): void; dir(value?: any, ...optionalParams: any[]): void; dirxml(value: any): void; error(message?: any, ...optionalParams: any[]): void; @@ -6306,9 +6630,9 @@ declare var DOMException: { interface DOMImplementation { createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType): Document; - createDocumentType(qualifiedName: string, publicId: string | null, systemId: string | null): DocumentType; + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; createHTMLDocument(title: string): Document; - hasFeature(feature: string | null, version: string | null): boolean; + hasFeature(): boolean; } declare var DOMImplementation: { @@ -6347,7 +6671,7 @@ declare var DOMStringList: { } interface DOMStringMap { - [name: string]: string; + [name: string]: string | undefined; } declare var DOMStringMap: { @@ -6373,7 +6697,7 @@ declare var DOMTokenList: { interface DataCue extends TextTrackCue { data: ArrayBuffer; - addEventListener(type: K, listener: (this: TextTrackCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: DataCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6403,6 +6727,7 @@ interface DataTransferItem { readonly type: string; getAsFile(): File | null; getAsString(_callback: FunctionStringCallback | null): void; + webkitGetAsEntry(): any; } declare var DataTransferItem: { @@ -6463,7 +6788,7 @@ interface DeviceLightEvent extends Event { declare var DeviceLightEvent: { prototype: DeviceLightEvent; - new(type: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; + new(typeArg: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; } interface DeviceMotionEvent extends Event { @@ -6476,7 +6801,7 @@ interface DeviceMotionEvent extends Event { declare var DeviceMotionEvent: { prototype: DeviceMotionEvent; - new(): DeviceMotionEvent; + new(typeArg: string, eventInitDict?: DeviceMotionEventInit): DeviceMotionEvent; } interface DeviceOrientationEvent extends Event { @@ -6489,7 +6814,7 @@ interface DeviceOrientationEvent extends Event { declare var DeviceOrientationEvent: { prototype: DeviceOrientationEvent; - new(): DeviceOrientationEvent; + new(typeArg: string, eventInitDict?: DeviceOrientationEventInit): DeviceOrientationEvent; } interface DeviceRotationRate { @@ -6571,7 +6896,7 @@ interface DocumentEventMap extends GlobalEventHandlersEventMap { "pointerlockerror": Event; "progress": ProgressEvent; "ratechange": Event; - "readystatechange": ProgressEvent; + "readystatechange": Event; "reset": Event; "scroll": UIEvent; "seeked": Event; @@ -6642,10 +6967,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven readonly compatMode: string; cookie: string; readonly currentScript: HTMLScriptElement | SVGScriptElement; - /** - * Gets the default character set from the current regional language settings. - */ - readonly defaultCharset: string; readonly defaultView: Window; /** * Sets or gets a value that indicates whether the document can be edited. @@ -6952,7 +7273,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Fires when the state of the object has changed. * @param ev The event */ - onreadystatechange: (this: Document, ev: ProgressEvent) => any; + onreadystatechange: (this: Document, ev: Event) => any; /** * Fires when the user resets a form. * @param ev The event. @@ -7320,8 +7641,8 @@ interface DocumentType extends Node, ChildNode { readonly internalSubset: string | null; readonly name: string; readonly notations: NamedNodeMap; - readonly publicId: string | null; - readonly systemId: string | null; + readonly publicId: string; + readonly systemId: string; } declare var DocumentType: { @@ -7344,7 +7665,7 @@ interface DynamicsCompressorNode extends AudioNode { readonly attack: AudioParam; readonly knee: AudioParam; readonly ratio: AudioParam; - readonly reduction: AudioParam; + readonly reduction: number; readonly release: AudioParam; readonly threshold: AudioParam; } @@ -7375,8 +7696,8 @@ declare var EXT_texture_filter_anisotropic: { } interface ElementEventMap extends GlobalEventHandlersEventMap { - "ariarequest": AriaRequestEvent; - "command": CommandEvent; + "ariarequest": Event; + "command": Event; "gotpointercapture": PointerEvent; "lostpointercapture": PointerEvent; "MSGestureChange": MSGestureEvent; @@ -7412,10 +7733,11 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec readonly clientTop: number; readonly clientWidth: number; id: string; + innerHTML: string; msContentZoomFactor: number; readonly msRegionOverflow: string; - onariarequest: (this: Element, ev: AriaRequestEvent) => any; - oncommand: (this: Element, ev: CommandEvent) => any; + onariarequest: (this: Element, ev: Event) => any; + oncommand: (this: Element, ev: Event) => any; ongotpointercapture: (this: Element, ev: PointerEvent) => any; onlostpointercapture: (this: Element, ev: PointerEvent) => any; onmsgesturechange: (this: Element, ev: MSGestureEvent) => any; @@ -7441,13 +7763,13 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec ontouchstart: (ev: TouchEvent) => any; onwebkitfullscreenchange: (this: Element, ev: Event) => any; onwebkitfullscreenerror: (this: Element, ev: Event) => any; + outerHTML: string; readonly prefix: string | null; readonly scrollHeight: number; scrollLeft: number; scrollTop: number; readonly scrollWidth: number; readonly tagName: string; - innerHTML: string; readonly assignedSlot: HTMLSlotElement | null; slot: string; readonly shadowRoot: ShadowRoot | null; @@ -7471,7 +7793,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec msSetPointerCapture(pointerId: number): void; msZoomTo(args: MsZoomToOptions): void; releasePointerCapture(pointerId: number): void; - removeAttribute(name?: string): void; + removeAttribute(qualifiedName: string): void; removeAttributeNS(namespaceURI: string, localName: string): void; removeAttributeNode(oldAttr: Attr): Attr; requestFullscreen(): void; @@ -7518,7 +7840,7 @@ interface ErrorEvent extends Event { declare var ErrorEvent: { prototype: ErrorEvent; - new(): ErrorEvent; + new(type: string, errorEventInitDict?: ErrorEventInit): ErrorEvent; } interface Event { @@ -7547,7 +7869,7 @@ interface Event { declare var Event: { prototype: Event; - new(type: string, eventInitDict?: EventInit): Event; + new(typeArg: string, eventInitDict?: EventInit): Event; readonly AT_TARGET: number; readonly BUBBLING_PHASE: number; readonly CAPTURING_PHASE: number; @@ -7564,6 +7886,21 @@ declare var EventTarget: { new(): EventTarget; } +interface ExtensionScriptApis { + extensionIdToShortId(extensionId: string): number; + fireExtensionApiTelemetry(functionName: string, isSucceeded: boolean, isSupported: boolean): void; + genericFunction(routerAddress: any, parameters?: string, callbackId?: number): void; + genericSynchronousFunction(functionId: number, parameters?: string): string; + getExtensionId(): string; + registerGenericFunctionCallbackHandler(callbackHandler: any): void; + registerGenericPersistentCallbackHandler(callbackHandler: any): void; +} + +declare var ExtensionScriptApis: { + prototype: ExtensionScriptApis; + new(): ExtensionScriptApis; +} + interface External { } @@ -7600,7 +7937,7 @@ interface FileReader extends EventTarget, MSBaseReader { readAsBinaryString(blob: Blob): void; readAsDataURL(blob: Blob): void; readAsText(blob: Blob, encoding?: string): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7619,6 +7956,20 @@ declare var FocusEvent: { new(typeArg: string, eventInitDict?: FocusEventInit): FocusEvent; } +interface FocusNavigationEvent extends Event { + readonly navigationReason: string; + readonly originHeight: number; + readonly originLeft: number; + readonly originTop: number; + readonly originWidth: number; + requestFocus(): void; +} + +declare var FocusNavigationEvent: { + prototype: FocusNavigationEvent; + new(type: string, eventInitDict?: FocusNavigationEventInit): FocusNavigationEvent; +} + interface FormData { append(name: any, value: any, blobName?: string): void; } @@ -7668,7 +8019,7 @@ interface GamepadEvent extends Event { declare var GamepadEvent: { prototype: GamepadEvent; - new(): GamepadEvent; + new(typeArg: string, eventInitDict?: GamepadEventInit): GamepadEvent; } interface Geolocation { @@ -7682,8 +8033,11 @@ declare var Geolocation: { new(): Geolocation; } -interface HTMLAllCollection extends HTMLCollection { - namedItem(name: string): Element; +interface HTMLAllCollection { + readonly length: number; + item(nameOrIndex?: string): HTMLCollection | Element | null; + namedItem(name: string): HTMLCollection | Element | null; + [index: number]: Element; } declare var HTMLAllCollection: { @@ -7771,7 +8125,7 @@ interface HTMLAnchorElement extends HTMLElement { * Returns a string representation of an object. */ toString(): string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAnchorElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7845,7 +8199,7 @@ interface HTMLAppletElement extends HTMLElement { useMap: string; vspace: number; width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAppletElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7913,7 +8267,7 @@ interface HTMLAreaElement extends HTMLElement { * Returns a string representation of an object. */ toString(): string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7922,15 +8276,7 @@ declare var HTMLAreaElement: { new(): HTMLAreaElement; } -interface HTMLAreasCollection extends HTMLCollection { - /** - * Adds an element to the areas, controlRange, or options collection. - */ - add(element: HTMLElement, before?: HTMLElement | number): void; - /** - * Removes an element from the collection. - */ - remove(index?: number): void; +interface HTMLAreasCollection extends HTMLCollectionBase { } declare var HTMLAreasCollection: { @@ -7939,7 +8285,7 @@ declare var HTMLAreasCollection: { } interface HTMLAudioElement extends HTMLMediaElement { - addEventListener(type: K, listener: (this: HTMLMediaElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAudioElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7953,7 +8299,7 @@ interface HTMLBRElement extends HTMLElement { * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. */ clear: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7971,7 +8317,7 @@ interface HTMLBaseElement extends HTMLElement { * Sets or retrieves the window or frame at which to target content. */ target: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBaseElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7989,7 +8335,7 @@ interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty * Sets or retrieves the font size of the object. */ size: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBaseFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8015,6 +8361,7 @@ interface HTMLBodyElementEventMap extends HTMLElementEventMap { "pageshow": PageTransitionEvent; "popstate": PopStateEvent; "resize": UIEvent; + "scroll": UIEvent; "storage": StorageEvent; "unload": Event; } @@ -8042,6 +8389,7 @@ interface HTMLBodyElement extends HTMLElement { onpageshow: (this: HTMLBodyElement, ev: PageTransitionEvent) => any; onpopstate: (this: HTMLBodyElement, ev: PopStateEvent) => any; onresize: (this: HTMLBodyElement, ev: UIEvent) => any; + onscroll: (this: HTMLBodyElement, ev: UIEvent) => any; onstorage: (this: HTMLBodyElement, ev: StorageEvent) => any; onunload: (this: HTMLBodyElement, ev: Event) => any; text: any; @@ -8119,7 +8467,7 @@ interface HTMLButtonElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLButtonElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8154,7 +8502,7 @@ interface HTMLCanvasElement extends HTMLElement { */ toDataURL(type?: string, ...args: any[]): string; toBlob(callback: (result: Blob | null) => void, type?: string, ...arguments: any[]): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8163,7 +8511,7 @@ declare var HTMLCanvasElement: { new(): HTMLCanvasElement; } -interface HTMLCollection { +interface HTMLCollectionBase { /** * Sets or retrieves the number of objects in a collection. */ @@ -8172,11 +8520,14 @@ interface HTMLCollection { * Retrieves an object from various collections. */ item(index: number): Element; + [index: number]: Element; +} + +interface HTMLCollection extends HTMLCollectionBase { /** * Retrieves a select object or an object from an options collection. */ - namedItem(name: string): Element; - [index: number]: Element; + namedItem(name: string): Element | null; } declare var HTMLCollection: { @@ -8186,7 +8537,7 @@ declare var HTMLCollection: { interface HTMLDListElement extends HTMLElement { compact: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8195,9 +8546,20 @@ declare var HTMLDListElement: { new(): HTMLDListElement; } +interface HTMLDataElement extends HTMLElement { + value: string; + addEventListener(type: K, listener: (this: HTMLDataElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDataElement: { + prototype: HTMLDataElement; + new(): HTMLDataElement; +} + interface HTMLDataListElement extends HTMLElement { options: HTMLCollectionOf; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDataListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8208,7 +8570,7 @@ declare var HTMLDataListElement: { interface HTMLDirectoryElement extends HTMLElement { compact: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDirectoryElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8226,7 +8588,7 @@ interface HTMLDivElement extends HTMLElement { * Sets or retrieves whether the browser automatically performs wordwrap. */ noWrap: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8236,7 +8598,7 @@ declare var HTMLDivElement: { } interface HTMLDocument extends Document { - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8324,7 +8686,6 @@ interface HTMLElement extends Element { draggable: boolean; hidden: boolean; hideFocus: boolean; - innerHTML: string; innerText: string; readonly isContentEditable: boolean; lang: string; @@ -8400,7 +8761,6 @@ interface HTMLElement extends Element { ontimeupdate: (this: HTMLElement, ev: Event) => any; onvolumechange: (this: HTMLElement, ev: Event) => any; onwaiting: (this: HTMLElement, ev: Event) => any; - outerHTML: string; outerText: string; spellcheck: boolean; readonly style: CSSStyleDeclaration; @@ -8411,7 +8771,6 @@ interface HTMLElement extends Element { dragDrop(): boolean; focus(): void; msGetInputContext(): MSInputMethodContext; - setActive(): void; addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8468,7 +8827,7 @@ interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the width of the object. */ width: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLEmbedElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8487,6 +8846,7 @@ interface HTMLFieldSetElement extends HTMLElement { * Retrieves a reference to the form that the object is embedded in. */ readonly form: HTMLFormElement; + name: string; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. */ @@ -8508,7 +8868,7 @@ interface HTMLFieldSetElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFieldSetElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8522,7 +8882,7 @@ interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOM * Sets or retrieves the current typeface family. */ face: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8531,6 +8891,15 @@ declare var HTMLFontElement: { new(): HTMLFontElement; } +interface HTMLFormControlsCollection extends HTMLCollectionBase { + namedItem(name: string): HTMLCollection | Element | null; +} + +declare var HTMLFormControlsCollection: { + prototype: HTMLFormControlsCollection; + new(): HTMLFormControlsCollection; +} + interface HTMLFormElement extends HTMLElement { /** * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. @@ -8547,7 +8916,7 @@ interface HTMLFormElement extends HTMLElement { /** * Retrieves a collection, in source order, of all controls in a given form. */ - readonly elements: HTMLCollection; + readonly elements: HTMLFormControlsCollection; /** * Sets or retrieves the MIME encoding for the form. */ @@ -8598,7 +8967,7 @@ interface HTMLFormElement extends HTMLElement { * Fires when a FORM is about to be submitted. */ submit(): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFormElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [name: string]: any; } @@ -8687,6 +9056,7 @@ declare var HTMLFrameElement: { } interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { + "afterprint": Event; "beforeprint": Event; "beforeunload": BeforeUnloadEvent; "blur": FocusEvent; @@ -8700,7 +9070,9 @@ interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { "orientationchange": Event; "pagehide": PageTransitionEvent; "pageshow": PageTransitionEvent; + "popstate": PopStateEvent; "resize": UIEvent; + "scroll": UIEvent; "storage": StorageEvent; "unload": Event; } @@ -8744,7 +9116,9 @@ interface HTMLFrameSetElement extends HTMLElement { onorientationchange: (this: HTMLFrameSetElement, ev: Event) => any; onpagehide: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; onpageshow: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; + onpopstate: (this: HTMLFrameSetElement, ev: PopStateEvent) => any; onresize: (this: HTMLFrameSetElement, ev: UIEvent) => any; + onscroll: (this: HTMLFrameSetElement, ev: UIEvent) => any; onstorage: (this: HTMLFrameSetElement, ev: StorageEvent) => any; onunload: (this: HTMLFrameSetElement, ev: Event) => any; /** @@ -8773,7 +9147,7 @@ interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2 * Sets or retrieves the width of the object. */ width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8784,7 +9158,7 @@ declare var HTMLHRElement: { interface HTMLHeadElement extends HTMLElement { profile: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHeadElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8798,7 +9172,7 @@ interface HTMLHeadingElement extends HTMLElement { * Sets or retrieves a value that indicates the table alignment. */ align: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHeadingElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8812,7 +9186,7 @@ interface HTMLHtmlElement extends HTMLElement { * Sets or retrieves the DTD version that governs the current document. */ version: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHtmlElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8831,6 +9205,7 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { */ align: string; allowFullscreen: boolean; + allowPaymentRequest: boolean; /** * Specifies the properties of a border drawn around an object. */ @@ -8926,7 +9301,7 @@ interface HTMLImageElement extends HTMLElement { * Retrieves whether the object is fully loaded. */ readonly complete: boolean; - crossOrigin: string; + crossOrigin: string | null; readonly currentSrc: string; /** * Sets or retrieves the height of the object. @@ -8991,14 +9366,13 @@ interface HTMLImageElement extends HTMLElement { readonly x: number; readonly y: number; msGetAsCastingSource(): any; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLImageElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLImageElement: { prototype: HTMLImageElement; new(): HTMLImageElement; - create(): HTMLImageElement; } interface HTMLInputElement extends HTMLElement { @@ -9204,7 +9578,7 @@ interface HTMLInputElement extends HTMLElement { * @param n Value to increment the value by. */ stepUp(n?: number): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLInputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9219,7 +9593,7 @@ interface HTMLLIElement extends HTMLElement { * Sets or retrieves the value of a list item. */ value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLIElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9237,7 +9611,7 @@ interface HTMLLabelElement extends HTMLElement { * Sets or retrieves the object to which the given label object is assigned. */ htmlFor: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLabelElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9255,7 +9629,7 @@ interface HTMLLegendElement extends HTMLElement { * Retrieves a reference to the form that the object is embedded in. */ readonly form: HTMLFormElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9300,7 +9674,7 @@ interface HTMLLinkElement extends HTMLElement, LinkStyle { type: string; import?: Document; integrity: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLinkElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9318,7 +9692,7 @@ interface HTMLMapElement extends HTMLElement { * Sets or retrieves the name of the object. */ name: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMapElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9381,7 +9755,7 @@ interface HTMLMediaElement extends HTMLElement { * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). */ controls: boolean; - crossOrigin: string; + crossOrigin: string | null; /** * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. */ @@ -9522,7 +9896,7 @@ interface HTMLMediaElement extends HTMLElement { * Loads and starts playback of a media resource. */ play(): void; - setMediaKeys(mediaKeys: MediaKeys | null): PromiseLike; + setMediaKeys(mediaKeys: MediaKeys | null): Promise; readonly HAVE_CURRENT_DATA: number; readonly HAVE_ENOUGH_DATA: number; readonly HAVE_FUTURE_DATA: number; @@ -9553,7 +9927,7 @@ declare var HTMLMediaElement: { interface HTMLMenuElement extends HTMLElement { compact: boolean; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMenuElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9587,7 +9961,7 @@ interface HTMLMetaElement extends HTMLElement { * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. */ url: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMetaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9603,7 +9977,7 @@ interface HTMLMeterElement extends HTMLElement { min: number; optimum: number; value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMeterElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9621,7 +9995,7 @@ interface HTMLModElement extends HTMLElement { * Sets or retrieves the date and time of a modification to the object. */ dateTime: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLModElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9637,7 +10011,7 @@ interface HTMLOListElement extends HTMLElement { */ start: number; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9715,10 +10089,6 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the name of the object. */ name: string; - /** - * Retrieves the contained object. - */ - readonly object: any; readonly readyState: number; /** * Sets or retrieves a message to be displayed while an object is loading. @@ -9758,7 +10128,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLObjectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9797,7 +10167,7 @@ interface HTMLOptGroupElement extends HTMLElement { * Sets or retrieves the value which is returned to the server when the form control is submitted. */ value: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOptGroupElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9836,14 +10206,13 @@ interface HTMLOptionElement extends HTMLElement { * Sets or retrieves the value which is returned to the server when the form control is submitted. */ value: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLOptionElement: { prototype: HTMLOptionElement; new(): HTMLOptionElement; - create(): HTMLOptionElement; } interface HTMLOptionsCollection extends HTMLCollectionOf { @@ -9858,13 +10227,35 @@ declare var HTMLOptionsCollection: { new(): HTMLOptionsCollection; } +interface HTMLOutputElement extends HTMLElement { + defaultValue: string; + readonly form: HTMLFormElement; + readonly htmlFor: DOMSettableTokenList; + name: string; + readonly type: string; + readonly validationMessage: string; + readonly validity: ValidityState; + value: string; + readonly willValidate: boolean; + checkValidity(): boolean; + reportValidity(): boolean; + setCustomValidity(error: string): void; + addEventListener(type: K, listener: (this: HTMLOutputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLOutputElement: { + prototype: HTMLOutputElement; + new(): HTMLOutputElement; +} + interface HTMLParagraphElement extends HTMLElement { /** * Sets or retrieves how the object is aligned with adjacent text. */ align: string; clear: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLParagraphElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9890,7 +10281,7 @@ interface HTMLParamElement extends HTMLElement { * Sets or retrieves the data type of the value attribute. */ valueType: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLParamElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9900,7 +10291,7 @@ declare var HTMLParamElement: { } interface HTMLPictureElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLPictureElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9914,7 +10305,7 @@ interface HTMLPreElement extends HTMLElement { * Sets or gets a value that you can use to implement your own width functionality for the object. */ width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLPreElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9940,7 +10331,7 @@ interface HTMLProgressElement extends HTMLElement { * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. */ value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLProgressElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9954,7 +10345,7 @@ interface HTMLQuoteElement extends HTMLElement { * Sets or retrieves reference information about the object. */ cite: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLQuoteElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9969,6 +10360,7 @@ interface HTMLScriptElement extends HTMLElement { * Sets or retrieves the character set used to encode the object. */ charset: string; + crossOrigin: string | null; /** * Sets or retrieves the status of the script. */ @@ -9994,7 +10386,7 @@ interface HTMLScriptElement extends HTMLElement { */ type: string; integrity: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLScriptElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10090,7 +10482,7 @@ interface HTMLSelectElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSelectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [name: string]: any; } @@ -10116,7 +10508,7 @@ interface HTMLSourceElement extends HTMLElement { * Gets or sets the MIME type of a media resource. */ type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSourceElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10126,7 +10518,7 @@ declare var HTMLSourceElement: { } interface HTMLSpanElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSpanElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10145,7 +10537,7 @@ interface HTMLStyleElement extends HTMLElement, LinkStyle { * Retrieves the CSS language in which the style sheet is written. */ type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLStyleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10163,7 +10555,7 @@ interface HTMLTableCaptionElement extends HTMLElement { * Sets or retrieves whether the caption appears at the top or bottom of the table. */ vAlign: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableCaptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10218,7 +10610,7 @@ interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment { * Sets or retrieves the width of the object. */ width: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10240,7 +10632,7 @@ interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { * Sets or retrieves the width of the object. */ width: any; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableColElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10250,6 +10642,8 @@ declare var HTMLTableColElement: { } interface HTMLTableDataCellElement extends HTMLTableCellElement { + addEventListener(type: K, listener: (this: HTMLTableDataCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLTableDataCellElement: { @@ -10361,7 +10755,7 @@ interface HTMLTableElement extends HTMLElement { * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. */ insertRow(index?: number): HTMLTableRowElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10375,6 +10769,8 @@ interface HTMLTableHeaderCellElement extends HTMLTableCellElement { * Sets or retrieves the group of cells in a table to which the object's information applies. */ scope: string; + addEventListener(type: K, listener: (this: HTMLTableHeaderCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLTableHeaderCellElement: { @@ -10414,7 +10810,7 @@ interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment { * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. */ insertCell(index?: number): HTMLTableDataCellElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableRowElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10442,7 +10838,7 @@ interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment { * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. */ insertRow(index?: number): HTMLTableRowElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableSectionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10453,7 +10849,7 @@ declare var HTMLTableSectionElement: { interface HTMLTemplateElement extends HTMLElement { readonly content: DocumentFragment; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTemplateElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10560,7 +10956,7 @@ interface HTMLTextAreaElement extends HTMLElement { * @param end The offset into the text field for the end of the selection. */ setSelectionRange(start: number, end: number): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTextAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10569,12 +10965,23 @@ declare var HTMLTextAreaElement: { new(): HTMLTextAreaElement; } +interface HTMLTimeElement extends HTMLElement { + dateTime: string; + addEventListener(type: K, listener: (this: HTMLTimeElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTimeElement: { + prototype: HTMLTimeElement; + new(): HTMLTimeElement; +} + interface HTMLTitleElement extends HTMLElement { /** * Retrieves or sets the text of the object as a string. */ text: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTitleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10595,7 +11002,7 @@ interface HTMLTrackElement extends HTMLElement { readonly LOADED: number; readonly LOADING: number; readonly NONE: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTrackElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10611,7 +11018,7 @@ declare var HTMLTrackElement: { interface HTMLUListElement extends HTMLElement { compact: boolean; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLUListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10621,7 +11028,7 @@ declare var HTMLUListElement: { } interface HTMLUnknownElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLUnknownElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10692,7 +11099,21 @@ interface HashChangeEvent extends Event { declare var HashChangeEvent: { prototype: HashChangeEvent; - new(type: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; + new(typeArg: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; +} + +interface Headers { + append(name: string, value: string): void; + delete(name: string): void; + forEach(callback: ForEachCallback): void; + get(name: string): string | null; + has(name: string): boolean; + set(name: string, value: string): void; +} + +declare var Headers: { + prototype: Headers; + new(init?: any): Headers; } interface History { @@ -10746,14 +11167,14 @@ declare var IDBCursorWithValue: { interface IDBDatabaseEventMap { "abort": Event; - "error": ErrorEvent; + "error": Event; } interface IDBDatabase extends EventTarget { readonly name: string; readonly objectStoreNames: DOMStringList; onabort: (this: IDBDatabase, ev: Event) => any; - onerror: (this: IDBDatabase, ev: ErrorEvent) => any; + onerror: (this: IDBDatabase, ev: Event) => any; version: number; onversionchange: (ev: IDBVersionChangeEvent) => any; close(): void; @@ -10856,13 +11277,13 @@ declare var IDBOpenDBRequest: { } interface IDBRequestEventMap { - "error": ErrorEvent; + "error": Event; "success": Event; } interface IDBRequest extends EventTarget { readonly error: DOMError; - onerror: (this: IDBRequest, ev: ErrorEvent) => any; + onerror: (this: IDBRequest, ev: Event) => any; onsuccess: (this: IDBRequest, ev: Event) => any; readonly readyState: string; readonly result: any; @@ -10880,7 +11301,7 @@ declare var IDBRequest: { interface IDBTransactionEventMap { "abort": Event; "complete": Event; - "error": ErrorEvent; + "error": Event; } interface IDBTransaction extends EventTarget { @@ -10889,7 +11310,7 @@ interface IDBTransaction extends EventTarget { readonly mode: string; onabort: (this: IDBTransaction, ev: Event) => any; oncomplete: (this: IDBTransaction, ev: Event) => any; - onerror: (this: IDBTransaction, ev: ErrorEvent) => any; + onerror: (this: IDBTransaction, ev: Event) => any; abort(): void; objectStore(name: string): IDBObjectStore; readonly READ_ONLY: string; @@ -10917,6 +11338,15 @@ declare var IDBVersionChangeEvent: { new(): IDBVersionChangeEvent; } +interface IIRFilterNode extends AudioNode { + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; +} + +declare var IIRFilterNode: { + prototype: IIRFilterNode; + new(): IIRFilterNode; +} + interface ImageData { data: Uint8ClampedArray; readonly height: number; @@ -10929,6 +11359,35 @@ declare var ImageData: { new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +interface IntersectionObserver { + readonly root: Element | null; + readonly rootMargin: string; + readonly thresholds: number[]; + disconnect(): void; + observe(target: Element): void; + takeRecords(): IntersectionObserverEntry[]; + unobserve(target: Element): void; +} + +declare var IntersectionObserver: { + prototype: IntersectionObserver; + new(callback: IntersectionObserverCallback, options?: IntersectionObserverInit): IntersectionObserver; +} + +interface IntersectionObserverEntry { + readonly boundingClientRect: ClientRect; + readonly intersectionRatio: number; + readonly intersectionRect: ClientRect; + readonly rootBounds: ClientRect; + readonly target: Element; + readonly time: number; +} + +declare var IntersectionObserverEntry: { + prototype: IntersectionObserverEntry; + new(intersectionObserverEntryInit: IntersectionObserverEntryInit): IntersectionObserverEntry; +} + interface KeyboardEvent extends UIEvent { readonly altKey: boolean; readonly char: string | null; @@ -11015,7 +11474,7 @@ interface MSApp { execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; getCurrentPriority(): string; - getHtmlPrintDocumentSourceAsync(htmlDoc: any): PromiseLike; + getHtmlPrintDocumentSourceAsync(htmlDoc: any): Promise; getViewId(view: any): any; isTaskScheduledAtPriorityOrHigher(priority: string): boolean; pageHandlesAllApplicationActivations(enabled: boolean): void; @@ -11030,13 +11489,13 @@ declare var MSApp: MSApp; interface MSAppAsyncOperationEventMap { "complete": Event; - "error": ErrorEvent; + "error": Event; } interface MSAppAsyncOperation extends EventTarget { readonly error: DOMError; oncomplete: (this: MSAppAsyncOperation, ev: Event) => any; - onerror: (this: MSAppAsyncOperation, ev: ErrorEvent) => any; + onerror: (this: MSAppAsyncOperation, ev: Event) => any; readonly readyState: number; readonly result: any; start(): void; @@ -11076,8 +11535,8 @@ declare var MSBlobBuilder: { } interface MSCredentials { - getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): PromiseLike; - makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): PromiseLike; + getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): Promise; + makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): Promise; } declare var MSCredentials: { @@ -11193,12 +11652,13 @@ interface MSHTMLWebViewElement extends HTMLElement { goForward(): void; invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; navigate(uri: string): void; + navigateFocus(navigationReason: string, origin: FocusNavigationOrigin): void; navigateToLocalStreamUri(source: string, streamResolver: any): void; navigateToString(contents: string): void; navigateWithHttpRequestMessage(requestMessage: any): void; refresh(): void; stop(): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: MSHTMLWebViewElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11390,7 +11850,7 @@ interface MSStreamReader extends EventTarget, MSBaseReader { readAsBlob(stream: MSStream, size?: number): void; readAsDataURL(stream: MSStream, size?: number): void; readAsText(stream: MSStream, encoding?: string, size?: number): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: MSStreamReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11401,13 +11861,13 @@ declare var MSStreamReader: { interface MSWebViewAsyncOperationEventMap { "complete": Event; - "error": ErrorEvent; + "error": Event; } interface MSWebViewAsyncOperation extends EventTarget { readonly error: DOMError; oncomplete: (this: MSWebViewAsyncOperation, ev: Event) => any; - onerror: (this: MSWebViewAsyncOperation, ev: ErrorEvent) => any; + onerror: (this: MSWebViewAsyncOperation, ev: Event) => any; readonly readyState: number; readonly result: any; readonly target: MSHTMLWebViewElement; @@ -11464,7 +11924,7 @@ interface MediaDevices extends EventTarget { ondevicechange: (this: MediaDevices, ev: Event) => any; enumerateDevices(): any; getSupportedConstraints(): MediaTrackSupportedConstraints; - getUserMedia(constraints: MediaStreamConstraints): PromiseLike; + getUserMedia(constraints: MediaStreamConstraints): Promise; addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11523,15 +11983,15 @@ declare var MediaKeyMessageEvent: { } interface MediaKeySession extends EventTarget { - readonly closed: PromiseLike; + readonly closed: Promise; readonly expiration: number; readonly keyStatuses: MediaKeyStatusMap; readonly sessionId: string; - close(): PromiseLike; - generateRequest(initDataType: string, initData: any): PromiseLike; - load(sessionId: string): PromiseLike; - remove(): PromiseLike; - update(response: any): PromiseLike; + close(): Promise; + generateRequest(initDataType: string, initData: any): Promise; + load(sessionId: string): Promise; + remove(): Promise; + update(response: any): Promise; } declare var MediaKeySession: { @@ -11553,7 +12013,7 @@ declare var MediaKeyStatusMap: { interface MediaKeySystemAccess { readonly keySystem: string; - createMediaKeys(): PromiseLike; + createMediaKeys(): Promise; getConfiguration(): MediaKeySystemConfiguration; } @@ -11564,7 +12024,7 @@ declare var MediaKeySystemAccess: { interface MediaKeys { createSession(sessionType?: string): MediaKeySession; - setServerCertificate(serverCertificate: any): PromiseLike; + setServerCertificate(serverCertificate: any): Promise; } declare var MediaKeys: { @@ -11617,18 +12077,18 @@ declare var MediaSource: { interface MediaStreamEventMap { "active": Event; - "addtrack": TrackEvent; + "addtrack": MediaStreamTrackEvent; "inactive": Event; - "removetrack": TrackEvent; + "removetrack": MediaStreamTrackEvent; } interface MediaStream extends EventTarget { readonly active: boolean; readonly id: string; onactive: (this: MediaStream, ev: Event) => any; - onaddtrack: (this: MediaStream, ev: TrackEvent) => any; + onaddtrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; oninactive: (this: MediaStream, ev: Event) => any; - onremovetrack: (this: MediaStream, ev: TrackEvent) => any; + onremovetrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; addTrack(track: MediaStreamTrack): void; clone(): MediaStream; getAudioTracks(): MediaStreamTrack[]; @@ -11671,7 +12131,16 @@ interface MediaStreamErrorEvent extends Event { declare var MediaStreamErrorEvent: { prototype: MediaStreamErrorEvent; - new(type: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; + new(typeArg: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; +} + +interface MediaStreamEvent extends Event { + readonly stream: MediaStream | null; +} + +declare var MediaStreamEvent: { + prototype: MediaStreamEvent; + new(type: string, eventInitDict: MediaStreamEventInit): MediaStreamEvent; } interface MediaStreamTrackEventMap { @@ -11694,7 +12163,7 @@ interface MediaStreamTrack extends EventTarget { readonly readonly: boolean; readonly readyState: string; readonly remote: boolean; - applyConstraints(constraints: MediaTrackConstraints): PromiseLike; + applyConstraints(constraints: MediaTrackConstraints): Promise; clone(): MediaStreamTrack; getCapabilities(): MediaTrackCapabilities; getConstraints(): MediaTrackConstraints; @@ -11715,7 +12184,7 @@ interface MediaStreamTrackEvent extends Event { declare var MediaStreamTrackEvent: { prototype: MediaStreamTrackEvent; - new(type: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; + new(typeArg: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; } interface MessageChannel { @@ -11748,7 +12217,7 @@ interface MessagePortEventMap { interface MessagePort extends EventTarget { onmessage: (this: MessagePort, ev: MessageEvent) => any; close(): void; - postMessage(message?: any, ports?: any): void; + postMessage(message?: any, transfer?: any[]): void; start(): void; addEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -11910,9 +12379,10 @@ declare var NavigationEventWithReferrer: { new(): NavigationEventWithReferrer; } -interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorUserMedia { - readonly appCodeName: string; +interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia { + readonly authentication: WebAuthentication; readonly cookieEnabled: boolean; + gamepadInputEmulation: string; readonly language: string; readonly maxTouchPoints: number; readonly mimeTypes: MimeTypeArray; @@ -11921,12 +12391,13 @@ interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorConte readonly msPointerEnabled: boolean; readonly plugins: PluginArray; readonly pointerEnabled: boolean; + readonly serviceWorker: ServiceWorkerContainer; readonly webdriver: boolean; readonly hardwareConcurrency: number; getGamepads(): Gamepad[]; javaEnabled(): boolean; msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; - requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): PromiseLike; + requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): Promise; vibrate(pattern: number | number[]): boolean; } @@ -11952,7 +12423,7 @@ interface Node extends EventTarget { readonly parentNode: Node | null; readonly previousSibling: Node | null; textContent: string | null; - appendChild(newChild: Node): Node; + appendChild(newChild: T): T; cloneNode(deep?: boolean): Node; compareDocumentPosition(other: Node): number; contains(child: Node): boolean; @@ -12059,6 +12530,36 @@ declare var NodeList: { new(): NodeList; } +interface NotificationEventMap { + "click": Event; + "close": Event; + "error": Event; + "show": Event; +} + +interface Notification extends EventTarget { + readonly body: string; + readonly dir: string; + readonly icon: string; + readonly lang: string; + onclick: (this: Notification, ev: Event) => any; + onclose: (this: Notification, ev: Event) => any; + onerror: (this: Notification, ev: Event) => any; + onshow: (this: Notification, ev: Event) => any; + readonly permission: string; + readonly tag: string; + readonly title: string; + close(): void; + addEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Notification: { + prototype: Notification; + new(title: string, options?: NotificationOptions): Notification; + requestPermission(callback?: NotificationPermissionCallback): Promise; +} + interface OES_element_index_uint { } @@ -12093,6 +12594,24 @@ declare var OES_texture_float_linear: { new(): OES_texture_float_linear; } +interface OES_texture_half_float { + readonly HALF_FLOAT_OES: number; +} + +declare var OES_texture_half_float: { + prototype: OES_texture_half_float; + new(): OES_texture_half_float; + readonly HALF_FLOAT_OES: number; +} + +interface OES_texture_half_float_linear { +} + +declare var OES_texture_half_float_linear: { + prototype: OES_texture_half_float_linear; + new(): OES_texture_half_float_linear; +} + interface OfflineAudioCompletionEvent extends Event { readonly renderedBuffer: AudioBuffer; } @@ -12102,13 +12621,15 @@ declare var OfflineAudioCompletionEvent: { new(): OfflineAudioCompletionEvent; } -interface OfflineAudioContextEventMap { - "complete": Event; +interface OfflineAudioContextEventMap extends AudioContextEventMap { + "complete": OfflineAudioCompletionEvent; } -interface OfflineAudioContext extends AudioContext { - oncomplete: (this: OfflineAudioContext, ev: Event) => any; - startRendering(): PromiseLike; +interface OfflineAudioContext extends AudioContextBase { + readonly length: number; + oncomplete: (this: OfflineAudioContext, ev: OfflineAudioCompletionEvent) => any; + startRendering(): Promise; + suspend(suspendTime: number): Promise; addEventListener(type: K, listener: (this: OfflineAudioContext, ev: OfflineAudioContextEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12184,6 +12705,82 @@ declare var PannerNode: { new(): PannerNode; } +interface Path2D extends Object, CanvasPathMethods { +} + +declare var Path2D: { + prototype: Path2D; + new(path?: Path2D): Path2D; +} + +interface PaymentAddress { + readonly addressLine: string[]; + readonly city: string; + readonly country: string; + readonly dependentLocality: string; + readonly languageCode: string; + readonly organization: string; + readonly phone: string; + readonly postalCode: string; + readonly recipient: string; + readonly region: string; + readonly sortingCode: string; + toJSON(): any; +} + +declare var PaymentAddress: { + prototype: PaymentAddress; + new(): PaymentAddress; +} + +interface PaymentRequestEventMap { + "shippingaddresschange": Event; + "shippingoptionchange": Event; +} + +interface PaymentRequest extends EventTarget { + onshippingaddresschange: (this: PaymentRequest, ev: Event) => any; + onshippingoptionchange: (this: PaymentRequest, ev: Event) => any; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + readonly shippingType: string | null; + abort(): Promise; + show(): Promise; + addEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var PaymentRequest: { + prototype: PaymentRequest; + new(methodData: PaymentMethodData[], details: PaymentDetails, options?: PaymentOptions): PaymentRequest; +} + +interface PaymentRequestUpdateEvent extends Event { + updateWith(d: Promise): void; +} + +declare var PaymentRequestUpdateEvent: { + prototype: PaymentRequestUpdateEvent; + new(type: string, eventInitDict?: PaymentRequestUpdateEventInit): PaymentRequestUpdateEvent; +} + +interface PaymentResponse { + readonly details: any; + readonly methodName: string; + readonly payerEmail: string | null; + readonly payerName: string | null; + readonly payerPhone: string | null; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + complete(result?: string): Promise; + toJSON(): any; +} + +declare var PaymentResponse: { + prototype: PaymentResponse; + new(): PaymentResponse; +} + interface PerfWidgetExternal { readonly activeNetworkRequestCount: number; readonly averageFrameTime: number; @@ -12449,7 +13046,7 @@ interface PopStateEvent extends Event { declare var PopStateEvent: { prototype: PopStateEvent; - new(): PopStateEvent; + new(typeArg: string, eventInitDict?: PopStateEventInit): PopStateEvent; } interface Position { @@ -12500,23 +13097,57 @@ declare var ProgressEvent: { new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } +interface PushManager { + getSubscription(): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; + subscribe(options?: PushSubscriptionOptionsInit): Promise; +} + +declare var PushManager: { + prototype: PushManager; + new(): PushManager; +} + +interface PushSubscription { + readonly endpoint: USVString; + readonly options: PushSubscriptionOptions; + getKey(name: string): ArrayBuffer | null; + toJSON(): any; + unsubscribe(): Promise; +} + +declare var PushSubscription: { + prototype: PushSubscription; + new(): PushSubscription; +} + +interface PushSubscriptionOptions { + readonly applicationServerKey: ArrayBuffer | null; + readonly userVisibleOnly: boolean; +} + +declare var PushSubscriptionOptions: { + prototype: PushSubscriptionOptions; + new(): PushSubscriptionOptions; +} + interface RTCDTMFToneChangeEvent extends Event { readonly tone: string; } declare var RTCDTMFToneChangeEvent: { prototype: RTCDTMFToneChangeEvent; - new(type: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; + new(typeArg: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; } interface RTCDtlsTransportEventMap { "dtlsstatechange": RTCDtlsTransportStateChangedEvent; - "error": ErrorEvent; + "error": Event; } interface RTCDtlsTransport extends RTCStatsProvider { ondtlsstatechange: ((this: RTCDtlsTransport, ev: RTCDtlsTransportStateChangedEvent) => any) | null; - onerror: ((this: RTCDtlsTransport, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCDtlsTransport, ev: Event) => any) | null; readonly state: string; readonly transport: RTCIceTransport; getLocalParameters(): RTCDtlsParameters; @@ -12563,6 +13194,18 @@ declare var RTCDtmfSender: { new(sender: RTCRtpSender): RTCDtmfSender; } +interface RTCIceCandidate { + candidate: string | null; + sdpMLineIndex: number | null; + sdpMid: string | null; + toJSON(): any; +} + +declare var RTCIceCandidate: { + prototype: RTCIceCandidate; + new(candidateInitDict?: RTCIceCandidateInit): RTCIceCandidate; +} + interface RTCIceCandidatePairChangedEvent extends Event { readonly pair: RTCIceCandidatePair; } @@ -12573,16 +13216,16 @@ declare var RTCIceCandidatePairChangedEvent: { } interface RTCIceGathererEventMap { - "error": ErrorEvent; + "error": Event; "localcandidate": RTCIceGathererEvent; } interface RTCIceGatherer extends RTCStatsProvider { readonly component: string; - onerror: ((this: RTCIceGatherer, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCIceGatherer, ev: Event) => any) | null; onlocalcandidate: ((this: RTCIceGatherer, ev: RTCIceGathererEvent) => any) | null; createAssociatedGatherer(): RTCIceGatherer; - getLocalCandidates(): RTCIceCandidate[]; + getLocalCandidates(): RTCIceCandidateDictionary[]; getLocalParameters(): RTCIceParameters; addEventListener(type: K, listener: (this: RTCIceGatherer, ev: RTCIceGathererEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -12594,7 +13237,7 @@ declare var RTCIceGatherer: { } interface RTCIceGathererEvent extends Event { - readonly candidate: RTCIceCandidate | RTCIceCandidateComplete; + readonly candidate: RTCIceCandidateDictionary | RTCIceCandidateComplete; } declare var RTCIceGathererEvent: { @@ -12614,12 +13257,12 @@ interface RTCIceTransport extends RTCStatsProvider { onicestatechange: ((this: RTCIceTransport, ev: RTCIceTransportStateChangedEvent) => any) | null; readonly role: string; readonly state: string; - addRemoteCandidate(remoteCandidate: RTCIceCandidate | RTCIceCandidateComplete): void; + addRemoteCandidate(remoteCandidate: RTCIceCandidateDictionary | RTCIceCandidateComplete): void; createAssociatedTransport(): RTCIceTransport; getNominatedCandidatePair(): RTCIceCandidatePair | null; - getRemoteCandidates(): RTCIceCandidate[]; + getRemoteCandidates(): RTCIceCandidateDictionary[]; getRemoteParameters(): RTCIceParameters | null; - setRemoteCandidates(remoteCandidates: RTCIceCandidate[]): void; + setRemoteCandidates(remoteCandidates: RTCIceCandidateDictionary[]): void; start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: string): void; stop(): void; addEventListener(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, useCapture?: boolean): void; @@ -12640,12 +13283,67 @@ declare var RTCIceTransportStateChangedEvent: { new(): RTCIceTransportStateChangedEvent; } +interface RTCPeerConnectionEventMap { + "addstream": MediaStreamEvent; + "icecandidate": RTCPeerConnectionIceEvent; + "iceconnectionstatechange": Event; + "icegatheringstatechange": Event; + "negotiationneeded": Event; + "removestream": MediaStreamEvent; + "signalingstatechange": Event; +} + +interface RTCPeerConnection extends EventTarget { + readonly canTrickleIceCandidates: boolean | null; + readonly iceConnectionState: string; + readonly iceGatheringState: string; + readonly localDescription: RTCSessionDescription | null; + onaddstream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onicecandidate: (this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any; + oniceconnectionstatechange: (this: RTCPeerConnection, ev: Event) => any; + onicegatheringstatechange: (this: RTCPeerConnection, ev: Event) => any; + onnegotiationneeded: (this: RTCPeerConnection, ev: Event) => any; + onremovestream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onsignalingstatechange: (this: RTCPeerConnection, ev: Event) => any; + readonly remoteDescription: RTCSessionDescription | null; + readonly signalingState: string; + addIceCandidate(candidate: RTCIceCandidate, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addStream(stream: MediaStream): void; + close(): void; + createAnswer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + createOffer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback, options?: RTCOfferOptions): Promise; + getConfiguration(): RTCConfiguration; + getLocalStreams(): MediaStream[]; + getRemoteStreams(): MediaStream[]; + getStats(selector: MediaStreamTrack | null, successCallback?: RTCStatsCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + getStreamById(streamId: string): MediaStream | null; + removeStream(stream: MediaStream): void; + setLocalDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + setRemoteDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addEventListener(type: K, listener: (this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCPeerConnection: { + prototype: RTCPeerConnection; + new(configuration: RTCConfiguration): RTCPeerConnection; +} + +interface RTCPeerConnectionIceEvent extends Event { + readonly candidate: RTCIceCandidate; +} + +declare var RTCPeerConnectionIceEvent: { + prototype: RTCPeerConnectionIceEvent; + new(type: string, eventInitDict: RTCPeerConnectionIceEventInit): RTCPeerConnectionIceEvent; +} + interface RTCRtpReceiverEventMap { - "error": ErrorEvent; + "error": Event; } interface RTCRtpReceiver extends RTCStatsProvider { - onerror: ((this: RTCRtpReceiver, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCRtpReceiver, ev: Event) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack | null; readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; @@ -12665,12 +13363,12 @@ declare var RTCRtpReceiver: { } interface RTCRtpSenderEventMap { - "error": ErrorEvent; + "error": Event; "ssrcconflict": RTCSsrcConflictEvent; } interface RTCRtpSender extends RTCStatsProvider { - onerror: ((this: RTCRtpSender, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCRtpSender, ev: Event) => any) | null; onssrcconflict: ((this: RTCRtpSender, ev: RTCSsrcConflictEvent) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack; @@ -12689,12 +13387,23 @@ declare var RTCRtpSender: { getCapabilities(kind?: string): RTCRtpCapabilities; } +interface RTCSessionDescription { + sdp: string | null; + type: string | null; + toJSON(): any; +} + +declare var RTCSessionDescription: { + prototype: RTCSessionDescription; + new(descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; +} + interface RTCSrtpSdesTransportEventMap { - "error": ErrorEvent; + "error": Event; } interface RTCSrtpSdesTransport extends EventTarget { - onerror: ((this: RTCSrtpSdesTransport, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCSrtpSdesTransport, ev: Event) => any) | null; readonly transport: RTCIceTransport; addEventListener(type: K, listener: (this: RTCSrtpSdesTransport, ev: RTCSrtpSdesTransportEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -12716,8 +13425,8 @@ declare var RTCSsrcConflictEvent: { } interface RTCStatsProvider extends EventTarget { - getStats(): PromiseLike; - msGetStats(): PromiseLike; + getStats(): Promise; + msGetStats(): Promise; } declare var RTCStatsProvider: { @@ -12769,9 +13478,69 @@ declare var Range: { readonly START_TO_START: number; } -interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface ReadableStream { + readonly locked: boolean; + cancel(): Promise; + getReader(): ReadableStreamReader; +} + +declare var ReadableStream: { + prototype: ReadableStream; + new(): ReadableStream; +} + +interface ReadableStreamReader { + cancel(): Promise; + read(): Promise; + releaseLock(): void; +} + +declare var ReadableStreamReader: { + prototype: ReadableStreamReader; + new(): ReadableStreamReader; +} + +interface Request extends Object, Body { + readonly cache: string; + readonly credentials: string; + readonly destination: string; + readonly headers: Headers; + readonly integrity: string; + readonly keepalive: boolean; + readonly method: string; + readonly mode: string; + readonly redirect: string; + readonly referrer: string; + readonly referrerPolicy: string; + readonly type: string; + readonly url: string; + clone(): Request; +} + +declare var Request: { + prototype: Request; + new(input: Request | string, init?: RequestInit): Request; +} + +interface Response extends Object, Body { + readonly body: ReadableStream | null; + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly type: string; + readonly url: string; + clone(): Response; +} + +declare var Response: { + prototype: Response; + new(body?: any, init?: ResponseInit): Response; +} + +interface SVGAElement extends SVGGraphicsElement, SVGURIReference { readonly target: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12924,11 +13693,11 @@ declare var SVGAnimatedTransformList: { new(): SVGAnimatedTransformList; } -interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGCircleElement extends SVGGraphicsElement { readonly cx: SVGAnimatedLength; readonly cy: SVGAnimatedLength; readonly r: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGCircleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12937,9 +13706,9 @@ declare var SVGCircleElement: { new(): SVGCircleElement; } -interface SVGClipPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { +interface SVGClipPathElement extends SVGGraphicsElement, SVGUnitTypes { readonly clipPathUnits: SVGAnimatedEnumeration; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGClipPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12962,7 +13731,7 @@ interface SVGComponentTransferFunctionElement extends SVGElement { readonly SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; readonly SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGComponentTransferFunctionElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12977,8 +13746,8 @@ declare var SVGComponentTransferFunctionElement: { readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; } -interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGDefsElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGDefsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12987,8 +13756,8 @@ declare var SVGDefsElement: { new(): SVGDefsElement; } -interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGDescElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGDescElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13011,6 +13780,7 @@ interface SVGElementEventMap extends ElementEventMap { } interface SVGElement extends Element { + className: any; onclick: (this: SVGElement, ev: MouseEvent) => any; ondblclick: (this: SVGElement, ev: MouseEvent) => any; onfocusin: (this: SVGElement, ev: FocusEvent) => any; @@ -13022,9 +13792,9 @@ interface SVGElement extends Element { onmouseover: (this: SVGElement, ev: MouseEvent) => any; onmouseup: (this: SVGElement, ev: MouseEvent) => any; readonly ownerSVGElement: SVGSVGElement; + readonly style: CSSStyleDeclaration; readonly viewportElement: SVGElement; xmlbase: string; - className: any; addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13060,12 +13830,12 @@ declare var SVGElementInstanceList: { new(): SVGElementInstanceList; } -interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGEllipseElement extends SVGGraphicsElement { readonly cx: SVGAnimatedLength; readonly cy: SVGAnimatedLength; readonly rx: SVGAnimatedLength; readonly ry: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGEllipseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13095,7 +13865,7 @@ interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttrib readonly SVG_FEBLEND_MODE_SCREEN: number; readonly SVG_FEBLEND_MODE_SOFT_LIGHT: number; readonly SVG_FEBLEND_MODE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEBlendElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13130,7 +13900,7 @@ interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandard readonly SVG_FECOLORMATRIX_TYPE_MATRIX: number; readonly SVG_FECOLORMATRIX_TYPE_SATURATE: number; readonly SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEColorMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13146,7 +13916,7 @@ declare var SVGFEColorMatrixElement: { interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEComponentTransferElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13170,7 +13940,7 @@ interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAt readonly SVG_FECOMPOSITE_OPERATOR_OVER: number; readonly SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; readonly SVG_FECOMPOSITE_OPERATOR_XOR: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFECompositeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13203,7 +13973,7 @@ interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStand readonly SVG_EDGEMODE_NONE: number; readonly SVG_EDGEMODE_UNKNOWN: number; readonly SVG_EDGEMODE_WRAP: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEConvolveMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13222,7 +13992,7 @@ interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStan readonly kernelUnitLengthX: SVGAnimatedNumber; readonly kernelUnitLengthY: SVGAnimatedNumber; readonly surfaceScale: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDiffuseLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13242,7 +14012,7 @@ interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStan readonly SVG_CHANNEL_G: number; readonly SVG_CHANNEL_R: number; readonly SVG_CHANNEL_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDisplacementMapElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13259,7 +14029,7 @@ declare var SVGFEDisplacementMapElement: { interface SVGFEDistantLightElement extends SVGElement { readonly azimuth: SVGAnimatedNumber; readonly elevation: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDistantLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13269,7 +14039,7 @@ declare var SVGFEDistantLightElement: { } interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEFloodElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13279,6 +14049,8 @@ declare var SVGFEFloodElement: { } interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncAElement: { @@ -13287,6 +14059,8 @@ declare var SVGFEFuncAElement: { } interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncBElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncBElement: { @@ -13295,6 +14069,8 @@ declare var SVGFEFuncBElement: { } interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncGElement: { @@ -13303,6 +14079,8 @@ declare var SVGFEFuncGElement: { } interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncRElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncRElement: { @@ -13315,7 +14093,7 @@ interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandar readonly stdDeviationX: SVGAnimatedNumber; readonly stdDeviationY: SVGAnimatedNumber; setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEGaussianBlurElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13324,9 +14102,9 @@ declare var SVGFEGaussianBlurElement: { new(): SVGFEGaussianBlurElement; } -interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { +interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGURIReference { readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13336,7 +14114,7 @@ declare var SVGFEImageElement: { } interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMergeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13347,7 +14125,7 @@ declare var SVGFEMergeElement: { interface SVGFEMergeNodeElement extends SVGElement { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMergeNodeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13364,7 +14142,7 @@ interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardA readonly SVG_MORPHOLOGY_OPERATOR_DILATE: number; readonly SVG_MORPHOLOGY_OPERATOR_ERODE: number; readonly SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMorphologyElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13380,7 +14158,7 @@ interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttri readonly dx: SVGAnimatedNumber; readonly dy: SVGAnimatedNumber; readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEOffsetElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13393,7 +14171,7 @@ interface SVGFEPointLightElement extends SVGElement { readonly x: SVGAnimatedNumber; readonly y: SVGAnimatedNumber; readonly z: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEPointLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13409,7 +14187,7 @@ interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveSta readonly specularConstant: SVGAnimatedNumber; readonly specularExponent: SVGAnimatedNumber; readonly surfaceScale: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFESpecularLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13427,7 +14205,7 @@ interface SVGFESpotLightElement extends SVGElement { readonly x: SVGAnimatedNumber; readonly y: SVGAnimatedNumber; readonly z: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFESpotLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13438,7 +14216,7 @@ declare var SVGFESpotLightElement: { interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFETileElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13460,7 +14238,7 @@ interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardA readonly SVG_TURBULENCE_TYPE_FRACTALNOISE: number; readonly SVG_TURBULENCE_TYPE_TURBULENCE: number; readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFETurbulenceElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13475,7 +14253,7 @@ declare var SVGFETurbulenceElement: { readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; } -interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGURIReference { readonly filterResX: SVGAnimatedInteger; readonly filterResY: SVGAnimatedInteger; readonly filterUnits: SVGAnimatedEnumeration; @@ -13485,7 +14263,7 @@ interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLan readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; setFilterRes(filterResX: number, filterResY: number): void; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFilterElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13494,12 +14272,12 @@ declare var SVGFilterElement: { new(): SVGFilterElement; } -interface SVGForeignObjectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGForeignObjectElement extends SVGGraphicsElement { readonly height: SVGAnimatedLength; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGForeignObjectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13508,8 +14286,8 @@ declare var SVGForeignObjectElement: { new(): SVGForeignObjectElement; } -interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGGElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13518,7 +14296,7 @@ declare var SVGGElement: { new(): SVGGElement; } -interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourcesRequired, SVGURIReference, SVGUnitTypes { +interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGURIReference { readonly gradientTransform: SVGAnimatedTransformList; readonly gradientUnits: SVGAnimatedEnumeration; readonly spreadMethod: SVGAnimatedEnumeration; @@ -13526,7 +14304,7 @@ interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourc readonly SVG_SPREADMETHOD_REFLECT: number; readonly SVG_SPREADMETHOD_REPEAT: number; readonly SVG_SPREADMETHOD_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13539,13 +14317,30 @@ declare var SVGGradientElement: { readonly SVG_SPREADMETHOD_UNKNOWN: number; } -interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface SVGGraphicsElement extends SVGElement, SVGTests { + readonly farthestViewportElement: SVGElement; + readonly nearestViewportElement: SVGElement; + readonly transform: SVGAnimatedTransformList; + getBBox(): SVGRect; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; + getTransformToElement(element: SVGElement): SVGMatrix; + addEventListener(type: K, listener: (this: SVGGraphicsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGraphicsElement: { + prototype: SVGGraphicsElement; + new(): SVGGraphicsElement; +} + +interface SVGImageElement extends SVGGraphicsElement, SVGURIReference { readonly height: SVGAnimatedLength; readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13606,12 +14401,12 @@ declare var SVGLengthList: { new(): SVGLengthList; } -interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGLineElement extends SVGGraphicsElement { readonly x1: SVGAnimatedLength; readonly x2: SVGAnimatedLength; readonly y1: SVGAnimatedLength; readonly y2: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGLineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13625,6 +14420,8 @@ interface SVGLinearGradientElement extends SVGGradientElement { readonly x2: SVGAnimatedLength; readonly y1: SVGAnimatedLength; readonly y2: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGLinearGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGLinearGradientElement: { @@ -13632,7 +14429,7 @@ declare var SVGLinearGradientElement: { new(): SVGLinearGradientElement; } -interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { +interface SVGMarkerElement extends SVGElement, SVGFitToViewBox { readonly markerHeight: SVGAnimatedLength; readonly markerUnits: SVGAnimatedEnumeration; readonly markerWidth: SVGAnimatedLength; @@ -13648,7 +14445,7 @@ interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExt readonly SVG_MARKER_ORIENT_ANGLE: number; readonly SVG_MARKER_ORIENT_AUTO: number; readonly SVG_MARKER_ORIENT_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMarkerElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13663,14 +14460,14 @@ declare var SVGMarkerElement: { readonly SVG_MARKER_ORIENT_UNKNOWN: number; } -interface SVGMaskElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { +interface SVGMaskElement extends SVGElement, SVGTests, SVGUnitTypes { readonly height: SVGAnimatedLength; readonly maskContentUnits: SVGAnimatedEnumeration; readonly maskUnits: SVGAnimatedEnumeration; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMaskElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13705,7 +14502,7 @@ declare var SVGMatrix: { } interface SVGMetadataElement extends SVGElement { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMetadataElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13739,7 +14536,8 @@ declare var SVGNumberList: { new(): SVGNumberList; } -interface SVGPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPathData { +interface SVGPathElement extends SVGGraphicsElement { + readonly pathSegList: SVGPathSegList; createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; createSVGPathSegClosePath(): SVGPathSegClosePath; @@ -13762,7 +14560,7 @@ interface SVGPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGT getPathSegAtLength(distance: number): number; getPointAtLength(distance: number): SVGPoint; getTotalLength(): number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14047,7 +14845,7 @@ declare var SVGPathSegMovetoRel: { new(): SVGPathSegMovetoRel; } -interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGURIReference, SVGUnitTypes { +interface SVGPatternElement extends SVGElement, SVGTests, SVGUnitTypes, SVGFitToViewBox, SVGURIReference { readonly height: SVGAnimatedLength; readonly patternContentUnits: SVGAnimatedEnumeration; readonly patternTransform: SVGAnimatedTransformList; @@ -14055,7 +14853,7 @@ interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSp readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGPatternElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14091,8 +14889,8 @@ declare var SVGPointList: { new(): SVGPointList; } -interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGPolygonElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolygonElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14101,8 +14899,8 @@ declare var SVGPolygonElement: { new(): SVGPolygonElement; } -interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGPolylineElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolylineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14155,6 +14953,8 @@ interface SVGRadialGradientElement extends SVGGradientElement { readonly fx: SVGAnimatedLength; readonly fy: SVGAnimatedLength; readonly r: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGRadialGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGRadialGradientElement: { @@ -14174,14 +14974,14 @@ declare var SVGRect: { new(): SVGRect; } -interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGRectElement extends SVGGraphicsElement { readonly height: SVGAnimatedLength; readonly rx: SVGAnimatedLength; readonly ry: SVGAnimatedLength; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGRectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14199,7 +14999,7 @@ interface SVGSVGElementEventMap extends SVGElementEventMap { "SVGZoom": SVGZoomEvent; } -interface SVGSVGElement extends SVGElement, DocumentEvent, SVGLocatable, SVGTests, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { +interface SVGSVGElement extends SVGGraphicsElement, DocumentEvent, SVGFitToViewBox, SVGZoomAndPan { contentScriptType: string; contentStyleType: string; currentScale: number; @@ -14251,9 +15051,9 @@ declare var SVGSVGElement: { new(): SVGSVGElement; } -interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { +interface SVGScriptElement extends SVGElement, SVGURIReference { type: string; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGScriptElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14262,9 +15062,9 @@ declare var SVGScriptElement: { new(): SVGScriptElement; } -interface SVGStopElement extends SVGElement, SVGStylable { +interface SVGStopElement extends SVGElement { readonly offset: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGStopElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14289,12 +15089,12 @@ declare var SVGStringList: { new(): SVGStringList; } -interface SVGStyleElement extends SVGElement, SVGLangSpace { +interface SVGStyleElement extends SVGElement { disabled: boolean; media: string; title: string; type: string; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGStyleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14303,8 +15103,8 @@ declare var SVGStyleElement: { new(): SVGStyleElement; } -interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGSwitchElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGSwitchElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14313,8 +15113,8 @@ declare var SVGSwitchElement: { new(): SVGSwitchElement; } -interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGSymbolElement extends SVGElement, SVGFitToViewBox { + addEventListener(type: K, listener: (this: SVGSymbolElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14324,6 +15124,8 @@ declare var SVGSymbolElement: { } interface SVGTSpanElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTSpanElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTSpanElement: { @@ -14331,7 +15133,7 @@ declare var SVGTSpanElement: { new(): SVGTSpanElement; } -interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGTextContentElement extends SVGGraphicsElement { readonly lengthAdjust: SVGAnimatedEnumeration; readonly textLength: SVGAnimatedLength; getCharNumAtPosition(point: SVGPoint): number; @@ -14346,7 +15148,7 @@ interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLa readonly LENGTHADJUST_SPACING: number; readonly LENGTHADJUST_SPACINGANDGLYPHS: number; readonly LENGTHADJUST_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGTextContentElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14358,7 +15160,9 @@ declare var SVGTextContentElement: { readonly LENGTHADJUST_UNKNOWN: number; } -interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { +interface SVGTextElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTextElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextElement: { @@ -14376,6 +15180,8 @@ interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { readonly TEXTPATH_SPACINGTYPE_AUTO: number; readonly TEXTPATH_SPACINGTYPE_EXACT: number; readonly TEXTPATH_SPACINGTYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGTextPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextPathElement: { @@ -14395,6 +15201,8 @@ interface SVGTextPositioningElement extends SVGTextContentElement { readonly rotate: SVGAnimatedNumberList; readonly x: SVGAnimatedLengthList; readonly y: SVGAnimatedLengthList; + addEventListener(type: K, listener: (this: SVGTextPositioningElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextPositioningElement: { @@ -14402,8 +15210,8 @@ declare var SVGTextPositioningElement: { new(): SVGTextPositioningElement; } -interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGTitleElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGTitleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14468,14 +15276,14 @@ interface SVGUnitTypes { } declare var SVGUnitTypes: SVGUnitTypes; -interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface SVGUseElement extends SVGGraphicsElement, SVGURIReference { readonly animatedInstanceRoot: SVGElementInstance; readonly height: SVGAnimatedLength; readonly instanceRoot: SVGElementInstance; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGUseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14484,9 +15292,9 @@ declare var SVGUseElement: { new(): SVGUseElement; } -interface SVGViewElement extends SVGElement, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { +interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox { readonly viewTarget: SVGStringList; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGViewElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14518,6 +15326,26 @@ declare var SVGZoomEvent: { new(): SVGZoomEvent; } +interface ScopedCredential { + readonly id: ArrayBuffer; + readonly type: string; +} + +declare var ScopedCredential: { + prototype: ScopedCredential; + new(): ScopedCredential; +} + +interface ScopedCredentialInfo { + readonly credential: ScopedCredential; + readonly publicKey: CryptoKey; +} + +declare var ScopedCredentialInfo: { + prototype: ScopedCredentialInfo; + new(): ScopedCredentialInfo; +} + interface ScreenEventMap { "MSOrientationChange": Event; } @@ -14579,6 +15407,10 @@ declare var ScriptProcessorNode: { interface Selection { readonly anchorNode: Node; readonly anchorOffset: number; + readonly baseNode: Node; + readonly baseOffset: number; + readonly extentNode: Node; + readonly extentOffset: number; readonly focusNode: Node; readonly focusOffset: number; readonly isCollapsed: boolean; @@ -14597,6 +15429,7 @@ interface Selection { removeRange(range: Range): void; selectAllChildren(parentNode: Node): void; setBaseAndExtent(baseNode: Node, baseOffset: number, extentNode: Node, extentOffset: number): void; + setPosition(parentNode: Node, offset: number): void; toString(): string; } @@ -14605,6 +15438,84 @@ declare var Selection: { new(): Selection; } +interface ServiceWorkerEventMap extends AbstractWorkerEventMap { + "statechange": Event; +} + +interface ServiceWorker extends EventTarget, AbstractWorker { + onstatechange: (this: ServiceWorker, ev: Event) => any; + readonly scriptURL: USVString; + readonly state: string; + postMessage(message: any, transfer?: any[]): void; + addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorker: { + prototype: ServiceWorker; + new(): ServiceWorker; +} + +interface ServiceWorkerContainerEventMap { + "controllerchange": Event; + "message": ServiceWorkerMessageEvent; +} + +interface ServiceWorkerContainer extends EventTarget { + readonly controller: ServiceWorker | null; + oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; + onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; + readonly ready: Promise; + getRegistration(clientURL?: USVString): Promise; + getRegistrations(): any; + register(scriptURL: USVString, options?: RegistrationOptions): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerContainer: { + prototype: ServiceWorkerContainer; + new(): ServiceWorkerContainer; +} + +interface ServiceWorkerMessageEvent extends Event { + readonly data: any; + readonly lastEventId: string; + readonly origin: string; + readonly ports: MessagePort[] | null; + readonly source: ServiceWorker | MessagePort | null; +} + +declare var ServiceWorkerMessageEvent: { + prototype: ServiceWorkerMessageEvent; + new(type: string, eventInitDict?: ServiceWorkerMessageEventInit): ServiceWorkerMessageEvent; +} + +interface ServiceWorkerRegistrationEventMap { + "updatefound": Event; +} + +interface ServiceWorkerRegistration extends EventTarget { + readonly active: ServiceWorker | null; + readonly installing: ServiceWorker | null; + onupdatefound: (this: ServiceWorkerRegistration, ev: Event) => any; + readonly pushManager: PushManager; + readonly scope: USVString; + readonly sync: SyncManager; + readonly waiting: ServiceWorker | null; + getNotifications(filter?: GetNotificationOptions): any; + showNotification(title: string, options?: NotificationOptions): Promise; + unregister(): Promise; + update(): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerRegistration: { + prototype: ServiceWorkerRegistration; + new(): ServiceWorkerRegistration; +} + interface SourceBuffer extends EventTarget { appendWindowEnd: number; appendWindowStart: number; @@ -14636,6 +15547,87 @@ declare var SourceBufferList: { new(): SourceBufferList; } +interface SpeechSynthesisEventMap { + "voiceschanged": Event; +} + +interface SpeechSynthesis extends EventTarget { + onvoiceschanged: (this: SpeechSynthesis, ev: Event) => any; + readonly paused: boolean; + readonly pending: boolean; + readonly speaking: boolean; + cancel(): void; + getVoices(): SpeechSynthesisVoice[]; + pause(): void; + resume(): void; + speak(utterance: SpeechSynthesisUtterance): void; + addEventListener(type: K, listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesis: { + prototype: SpeechSynthesis; + new(): SpeechSynthesis; +} + +interface SpeechSynthesisEvent extends Event { + readonly charIndex: number; + readonly elapsedTime: number; + readonly name: string; + readonly utterance: SpeechSynthesisUtterance | null; +} + +declare var SpeechSynthesisEvent: { + prototype: SpeechSynthesisEvent; + new(type: string, eventInitDict?: SpeechSynthesisEventInit): SpeechSynthesisEvent; +} + +interface SpeechSynthesisUtteranceEventMap { + "boundary": Event; + "end": Event; + "error": Event; + "mark": Event; + "pause": Event; + "resume": Event; + "start": Event; +} + +interface SpeechSynthesisUtterance extends EventTarget { + lang: string; + onboundary: (this: SpeechSynthesisUtterance, ev: Event) => any; + onend: (this: SpeechSynthesisUtterance, ev: Event) => any; + onerror: (this: SpeechSynthesisUtterance, ev: Event) => any; + onmark: (this: SpeechSynthesisUtterance, ev: Event) => any; + onpause: (this: SpeechSynthesisUtterance, ev: Event) => any; + onresume: (this: SpeechSynthesisUtterance, ev: Event) => any; + onstart: (this: SpeechSynthesisUtterance, ev: Event) => any; + pitch: number; + rate: number; + text: string; + voice: SpeechSynthesisVoice; + volume: number; + addEventListener(type: K, listener: (this: SpeechSynthesisUtterance, ev: SpeechSynthesisUtteranceEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesisUtterance: { + prototype: SpeechSynthesisUtterance; + new(text?: string): SpeechSynthesisUtterance; +} + +interface SpeechSynthesisVoice { + readonly default: boolean; + readonly lang: string; + readonly localService: boolean; + readonly name: string; + readonly voiceURI: string; +} + +declare var SpeechSynthesisVoice: { + prototype: SpeechSynthesisVoice; + new(): SpeechSynthesisVoice; +} + interface StereoPannerNode extends AudioNode { readonly pan: AudioParam; } @@ -14747,6 +15739,16 @@ declare var SubtleCrypto: { new(): SubtleCrypto; } +interface SyncManager { + getTags(): any; + register(tag: string): Promise; +} + +declare var SyncManager: { + prototype: SyncManager; + new(): SyncManager; +} + interface Text extends CharacterData { readonly wholeText: string; readonly assignedSlot: HTMLSlotElement | null; @@ -14801,7 +15803,7 @@ declare var TextMetrics: { interface TextTrackEventMap { "cuechange": Event; - "error": ErrorEvent; + "error": Event; "load": Event; } @@ -14814,7 +15816,7 @@ interface TextTrack extends EventTarget { readonly language: string; mode: any; oncuechange: (this: TextTrack, ev: Event) => any; - onerror: (this: TextTrack, ev: ErrorEvent) => any; + onerror: (this: TextTrack, ev: Event) => any; onload: (this: TextTrack, ev: Event) => any; readonly readyState: number; addCue(cue: TextTrackCue): void; @@ -14926,11 +15928,14 @@ declare var Touch: { interface TouchEvent extends UIEvent { readonly altKey: boolean; readonly changedTouches: TouchList; + readonly charCode: number; readonly ctrlKey: boolean; + readonly keyCode: number; readonly metaKey: boolean; readonly shiftKey: boolean; readonly targetTouches: TouchList; readonly touches: TouchList; + readonly which: number; } declare var TouchEvent: { @@ -14950,12 +15955,12 @@ declare var TouchList: { } interface TrackEvent extends Event { - readonly track: any; + readonly track: VideoTrack | AudioTrack | TextTrack | null; } declare var TrackEvent: { prototype: TrackEvent; - new(): TrackEvent; + new(typeArg: string, eventInitDict?: TrackEventInit): TrackEvent; } interface TransitionEvent extends Event { @@ -14966,7 +15971,7 @@ interface TransitionEvent extends Event { declare var TransitionEvent: { prototype: TransitionEvent; - new(): TransitionEvent; + new(typeArg: string, eventInitDict?: TransitionEventInit): TransitionEvent; } interface TreeWalker { @@ -14997,7 +16002,7 @@ interface UIEvent extends Event { declare var UIEvent: { prototype: UIEvent; - new(type: string, eventInitDict?: UIEventInit): UIEvent; + new(typeArg: string, eventInitDict?: UIEventInit): UIEvent; } interface URL { @@ -15012,6 +16017,7 @@ interface URL { protocol: string; search: string; username: string; + readonly searchparams: URLSearchParams; toString(): string; } @@ -15148,6 +16154,28 @@ declare var WaveShaperNode: { new(): WaveShaperNode; } +interface WebAuthentication { + getAssertion(assertionChallenge: any, options?: AssertionOptions): Promise; + makeCredential(accountInformation: Account, cryptoParameters: ScopedCredentialParameters[], attestationChallenge: any, options?: ScopedCredentialOptions): Promise; +} + +declare var WebAuthentication: { + prototype: WebAuthentication; + new(): WebAuthentication; +} + +interface WebAuthnAssertion { + readonly authenticatorData: ArrayBuffer; + readonly clientData: ArrayBuffer; + readonly credential: ScopedCredential; + readonly signature: ArrayBuffer; +} + +declare var WebAuthnAssertion: { + prototype: WebAuthnAssertion; + new(): WebAuthnAssertion; +} + interface WebGLActiveInfo { readonly name: string; readonly size: number; @@ -15173,7 +16201,7 @@ interface WebGLContextEvent extends Event { declare var WebGLContextEvent: { prototype: WebGLContextEvent; - new(type: string, eventInitDict?: WebGLContextEventInit): WebGLContextEvent; + new(typeArg: string, eventInitDict?: WebGLContextEventInit): WebGLContextEvent; } interface WebGLFramebuffer extends WebGLObject { @@ -15300,7 +16328,7 @@ interface WebGLRenderingContext { isTexture(texture: WebGLTexture | null): boolean; lineWidth(width: number): void; linkProgram(program: WebGLProgram | null): void; - pixelStorei(pname: number, param: number): void; + pixelStorei(pname: number, param: number | boolean): void; polygonOffset(factor: number, units: number): void; readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): void; renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; @@ -16026,6 +17054,56 @@ declare var WebKitCSSMatrix: { new(text?: string): WebKitCSSMatrix; } +interface WebKitDirectoryEntry extends WebKitEntry { + createReader(): WebKitDirectoryReader; +} + +declare var WebKitDirectoryEntry: { + prototype: WebKitDirectoryEntry; + new(): WebKitDirectoryEntry; +} + +interface WebKitDirectoryReader { + readEntries(successCallback: WebKitEntriesCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitDirectoryReader: { + prototype: WebKitDirectoryReader; + new(): WebKitDirectoryReader; +} + +interface WebKitEntry { + readonly filesystem: WebKitFileSystem; + readonly fullPath: string; + readonly isDirectory: boolean; + readonly isFile: boolean; + readonly name: string; +} + +declare var WebKitEntry: { + prototype: WebKitEntry; + new(): WebKitEntry; +} + +interface WebKitFileEntry extends WebKitEntry { + file(successCallback: WebKitFileCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitFileEntry: { + prototype: WebKitFileEntry; + new(): WebKitFileEntry; +} + +interface WebKitFileSystem { + readonly name: string; + readonly root: WebKitDirectoryEntry; +} + +declare var WebKitFileSystem: { + prototype: WebKitFileSystem; + new(): WebKitFileSystem; +} + interface WebKitPoint { x: number; y: number; @@ -16038,7 +17116,7 @@ declare var WebKitPoint: { interface WebSocketEventMap { "close": CloseEvent; - "error": ErrorEvent; + "error": Event; "message": MessageEvent; "open": Event; } @@ -16048,7 +17126,7 @@ interface WebSocket extends EventTarget { readonly bufferedAmount: number; readonly extensions: string; onclose: (this: WebSocket, ev: CloseEvent) => any; - onerror: (this: WebSocket, ev: ErrorEvent) => any; + onerror: (this: WebSocket, ev: Event) => any; onmessage: (this: WebSocket, ev: MessageEvent) => any; onopen: (this: WebSocket, ev: Event) => any; readonly protocol: string; @@ -16185,8 +17263,9 @@ interface WindowEventMap extends GlobalEventHandlersEventMap { "waiting": Event; } -interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64 { +interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch { readonly applicationCache: ApplicationCache; + readonly caches: CacheStorage; readonly clientInformation: Navigator; readonly closed: boolean; readonly crypto: Crypto; @@ -16201,10 +17280,12 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly history: History; readonly innerHeight: number; readonly innerWidth: number; + readonly isSecureContext: boolean; readonly length: number; readonly location: Location; readonly locationbar: BarProp; readonly menubar: BarProp; + readonly msContentScript: ExtensionScriptApis; readonly msCredentials: MSCredentials; name: string; readonly navigator: Navigator; @@ -16318,6 +17399,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly scrollY: number; readonly scrollbars: BarProp; readonly self: Window; + readonly speechSynthesis: SpeechSynthesis; status: string; readonly statusbar: BarProp; readonly styleMedia: StyleMedia; @@ -16326,12 +17408,14 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly window: Window; URL: typeof URL; Blob: typeof Blob; + customElements: CustomElementRegistry; alert(message?: any): void; blur(): void; cancelAnimationFrame(handle: number): void; captureEvents(): void; close(): void; confirm(message?: string): boolean; + departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; focus(): void; getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -16351,6 +17435,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window scroll(x?: number, y?: number): void; scrollBy(x?: number, y?: number): void; scrollTo(x?: number, y?: number): void; + stop(): void; webkitCancelAnimationFrame(handle: number): void; webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; @@ -16373,7 +17458,7 @@ interface WorkerEventMap extends AbstractWorkerEventMap { interface Worker extends EventTarget, AbstractWorker { onmessage: (this: Worker, ev: MessageEvent) => any; - postMessage(message: any, ports?: any): void; + postMessage(message: any, transfer?: any[]): void; terminate(): void; addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -16385,7 +17470,7 @@ declare var Worker: { } interface XMLDocument extends Document { - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16404,14 +17489,14 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly response: any; readonly responseText: string; responseType: string; - readonly responseXML: any; + readonly responseURL: string; + readonly responseXML: Document | null; readonly status: number; readonly statusText: string; timeout: number; readonly upload: XMLHttpRequestUpload; withCredentials: boolean; msCaching?: string; - readonly responseURL: string; abort(): void; getAllResponseHeaders(): string; getResponseHeader(header: string): string | null; @@ -16439,11 +17524,10 @@ declare var XMLHttpRequest: { readonly LOADING: number; readonly OPENED: number; readonly UNSENT: number; - create(): XMLHttpRequest; } interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { - addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16543,6 +17627,16 @@ declare var XSLTProcessor: { new(): XSLTProcessor; } +interface webkitRTCPeerConnection extends RTCPeerConnection { + addEventListener(type: K, listener: (this: webkitRTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var webkitRTCPeerConnection: { + prototype: webkitRTCPeerConnection; + new(configuration: RTCConfiguration): webkitRTCPeerConnection; +} + interface AbstractWorkerEventMap { "error": ErrorEvent; } @@ -16553,6 +17647,14 @@ interface AbstractWorker { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface Body { + readonly bodyUsed: boolean; + arrayBuffer(): Promise; + blob(): Promise; + json(): Promise; + text(): Promise; +} + interface CanvasPathMethods { arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; @@ -16579,12 +17681,10 @@ interface DOML2DeprecatedSizeProperty { interface DocumentEvent { createEvent(eventInterface:"AnimationEvent"): AnimationEvent; - createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent; createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent; createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent; createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent; createEvent(eventInterface:"CloseEvent"): CloseEvent; - createEvent(eventInterface:"CommandEvent"): CommandEvent; createEvent(eventInterface:"CompositionEvent"): CompositionEvent; createEvent(eventInterface:"CustomEvent"): CustomEvent; createEvent(eventInterface:"DeviceLightEvent"): DeviceLightEvent; @@ -16595,6 +17695,7 @@ interface DocumentEvent { createEvent(eventInterface:"Event"): Event; createEvent(eventInterface:"Events"): Event; createEvent(eventInterface:"FocusEvent"): FocusEvent; + createEvent(eventInterface:"FocusNavigationEvent"): FocusNavigationEvent; createEvent(eventInterface:"GamepadEvent"): GamepadEvent; createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; createEvent(eventInterface:"IDBVersionChangeEvent"): IDBVersionChangeEvent; @@ -16610,6 +17711,7 @@ interface DocumentEvent { createEvent(eventInterface:"MediaEncryptedEvent"): MediaEncryptedEvent; createEvent(eventInterface:"MediaKeyMessageEvent"): MediaKeyMessageEvent; createEvent(eventInterface:"MediaStreamErrorEvent"): MediaStreamErrorEvent; + createEvent(eventInterface:"MediaStreamEvent"): MediaStreamEvent; createEvent(eventInterface:"MediaStreamTrackEvent"): MediaStreamTrackEvent; createEvent(eventInterface:"MessageEvent"): MessageEvent; createEvent(eventInterface:"MouseEvent"): MouseEvent; @@ -16622,6 +17724,7 @@ interface DocumentEvent { createEvent(eventInterface:"OfflineAudioCompletionEvent"): OfflineAudioCompletionEvent; createEvent(eventInterface:"OverflowEvent"): OverflowEvent; createEvent(eventInterface:"PageTransitionEvent"): PageTransitionEvent; + createEvent(eventInterface:"PaymentRequestUpdateEvent"): PaymentRequestUpdateEvent; createEvent(eventInterface:"PermissionRequestedEvent"): PermissionRequestedEvent; createEvent(eventInterface:"PointerEvent"): PointerEvent; createEvent(eventInterface:"PopStateEvent"): PopStateEvent; @@ -16631,10 +17734,13 @@ interface DocumentEvent { createEvent(eventInterface:"RTCIceCandidatePairChangedEvent"): RTCIceCandidatePairChangedEvent; createEvent(eventInterface:"RTCIceGathererEvent"): RTCIceGathererEvent; createEvent(eventInterface:"RTCIceTransportStateChangedEvent"): RTCIceTransportStateChangedEvent; + createEvent(eventInterface:"RTCPeerConnectionIceEvent"): RTCPeerConnectionIceEvent; createEvent(eventInterface:"RTCSsrcConflictEvent"): RTCSsrcConflictEvent; createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; + createEvent(eventInterface:"ServiceWorkerMessageEvent"): ServiceWorkerMessageEvent; + createEvent(eventInterface:"SpeechSynthesisEvent"): SpeechSynthesisEvent; createEvent(eventInterface:"StorageEvent"): StorageEvent; createEvent(eventInterface:"TextEvent"): TextEvent; createEvent(eventInterface:"TouchEvent"): TouchEvent; @@ -16650,10 +17756,10 @@ interface DocumentEvent { interface ElementTraversal { readonly childElementCount: number; - readonly firstElementChild: Element; - readonly lastElementChild: Element; - readonly nextElementSibling: Element; - readonly previousElementSibling: Element; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; + readonly nextElementSibling: Element | null; + readonly previousElementSibling: Element | null; } interface GetSVGDocument { @@ -16686,6 +17792,10 @@ interface GlobalEventHandlers { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface GlobalFetch { + fetch(input: RequestInfo, init?: RequestInit): Promise; +} + interface HTMLTableAlignment { /** * Sets or retrieves a value that you can use to implement your own ch functionality for the object. @@ -16749,6 +17859,14 @@ interface MSNavigatorDoNotTrack { storeWebWideTrackingException(args: StoreExceptionsInformation): void; } +interface NavigatorBeacon { + sendBeacon(url: USVString, data?: BodyInit): boolean; +} + +interface NavigatorConcurrentHardware { + readonly hardwareConcurrency: number; +} + interface NavigatorContentUtils { } @@ -16757,6 +17875,7 @@ interface NavigatorGeolocation { } interface NavigatorID { + readonly appCodeName: string; readonly appName: string; readonly appVersion: string; readonly platform: string; @@ -16790,20 +17909,12 @@ interface RandomSource { getRandomValues(array: ArrayBufferView): ArrayBufferView; } -interface SVGAnimatedPathData { - readonly pathSegList: SVGPathSegList; -} - interface SVGAnimatedPoints { readonly animatedPoints: SVGPointList; readonly points: SVGPointList; } -interface SVGExternalResourcesRequired { - readonly externalResourcesRequired: SVGAnimatedBoolean; -} - -interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { +interface SVGFilterPrimitiveStandardAttributes { readonly height: SVGAnimatedLength; readonly result: SVGAnimatedString; readonly width: SVGAnimatedLength; @@ -16816,25 +17927,6 @@ interface SVGFitToViewBox { readonly viewBox: SVGAnimatedRect; } -interface SVGLangSpace { - xmllang: string; - xmlspace: string; -} - -interface SVGLocatable { - readonly farthestViewportElement: SVGElement; - readonly nearestViewportElement: SVGElement; - getBBox(): SVGRect; - getCTM(): SVGMatrix; - getScreenCTM(): SVGMatrix; - getTransformToElement(element: SVGElement): SVGMatrix; -} - -interface SVGStylable { - className: any; - readonly style: CSSStyleDeclaration; -} - interface SVGTests { readonly requiredExtensions: SVGStringList; readonly requiredFeatures: SVGStringList; @@ -16842,10 +17934,6 @@ interface SVGTests { hasExtension(extension: string): boolean; } -interface SVGTransformable extends SVGLocatable { - readonly transform: SVGAnimatedTransformList; -} - interface SVGURIReference { readonly href: SVGAnimatedString; } @@ -16904,6 +17992,14 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface ErrorEventInit { + message?: string; + filename?: string; + lineno?: number; + conlno?: number; + error?: any; +} + interface StorageEventInit extends EventInit { key?: string; oldValue?: string; @@ -16919,6 +18015,41 @@ interface Canvas2DContextAttributes { [attribute: string]: boolean | string | undefined; } +interface URLSearchParams { + /** + * Appends a specified key/value pair as a new search parameter. + */ + append(name: string, value: string): void; + /** + * Deletes the given search parameter, and its associated value, from the list of all search parameters. + */ + delete(name: string): void; + /** + * Returns the first value associated to the given search parameter. + */ + get(name: string): string | null; + /** + * Returns all the values association with a given search parameter. + */ + getAll(name: string): string[]; + /** + * Returns a Boolean indicating if such a search parameter exists. + */ + has(name: string): boolean; + /** + * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. + */ + set(name: string, value: string): void; +} + +declare var URLSearchParams: { + prototype: URLSearchParams; + /** + * Constructor returning a URLSearchParams object. + */ + new (init?: string | URLSearchParams): URLSearchParams; +} + interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -16928,7 +18059,6 @@ interface NodeListOf extends NodeList { interface HTMLCollectionOf extends HTMLCollection { item(index: number): T; namedItem(name: string): T; - [index: number]: T; } interface BlobPropertyBag { @@ -16945,15 +18075,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -interface MessageEventInit extends EventInit { - data?: any; - origin?: string; - lastEventId?: string; - channel?: string; - source?: any; - ports?: MessagePort[]; -} - interface ProgressEventInit extends EventInit { lengthComputable?: boolean; loaded?: number; @@ -17155,8 +18276,8 @@ interface JsonWebKey { interface ParentNode { readonly children: HTMLCollection; - readonly firstElementChild: Element; - readonly lastElementChild: Element; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; readonly childElementCount: number; } @@ -17187,6 +18308,26 @@ interface AssignedNodesOptions { flatten?: boolean; } +interface ElementDefinitionOptions { + extends: string; +} + +interface CustomElementRegistry { + define(name: string, constructor: Function, options?: ElementDefinitionOptions): void; + get(name: string): any; + whenDefined(name: string): PromiseLike; +} + +interface PromiseRejectionEvent extends Event { + readonly promise: PromiseLike; + readonly reason: any; +} + +interface PromiseRejectionEventInit extends EventInit { + promise: PromiseLike; + reason?: any; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -17222,6 +18363,18 @@ interface DecodeSuccessCallback { interface DecodeErrorCallback { (error: DOMException): void; } +interface VoidFunction { + (): void; +} +interface RTCSessionDescriptionCallback { + (sdp: RTCSessionDescription): void; +} +interface RTCPeerConnectionErrorCallback { + (error: DOMError): void; +} +interface RTCStatsCallback { + (report: RTCStatsReport): void; +} interface FunctionStringCallback { (data: string): void; } @@ -17234,6 +18387,12 @@ interface NavigatorUserMediaErrorCallback { interface ForEachCallback { (keyId: any, status: string): void; } +interface NotificationPermissionCallback { + (permission: string): void; +} +interface IntersectionObserverCallback { + (entries: IntersectionObserverEntry[], observer: IntersectionObserver): void; +} interface HTMLElementTagNameMap { "a": HTMLAnchorElement; "applet": HTMLAppletElement; @@ -17249,6 +18408,7 @@ interface HTMLElementTagNameMap { "caption": HTMLTableCaptionElement; "col": HTMLTableColElement; "colgroup": HTMLTableColElement; + "data": HTMLDataElement; "datalist": HTMLDataListElement; "del": HTMLModElement; "dir": HTMLDirectoryElement; @@ -17289,6 +18449,7 @@ interface HTMLElementTagNameMap { "ol": HTMLOListElement; "optgroup": HTMLOptGroupElement; "option": HTMLOptionElement; + "output": HTMLOutputElement; "p": HTMLParagraphElement; "param": HTMLParamElement; "picture": HTMLPictureElement; @@ -17308,6 +18469,7 @@ interface HTMLElementTagNameMap { "tfoot": HTMLTableSectionElement; "th": HTMLTableHeaderCellElement; "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; "title": HTMLTitleElement; "tr": HTMLTableRowElement; "track": HTMLTrackElement; @@ -17345,6 +18507,7 @@ interface ElementTagNameMap { "code": HTMLElement; "col": HTMLTableColElement; "colgroup": HTMLTableColElement; + "data": HTMLDataElement; "datalist": HTMLDataListElement; "dd": HTMLElement; "defs": SVGDefsElement; @@ -17438,6 +18601,7 @@ interface ElementTagNameMap { "ol": HTMLOListElement; "optgroup": HTMLOptGroupElement; "option": HTMLOptionElement; + "output": HTMLOutputElement; "p": HTMLParagraphElement; "param": HTMLParamElement; "path": SVGPathElement; @@ -17480,6 +18644,7 @@ interface ElementTagNameMap { "tfoot": HTMLTableSectionElement; "th": HTMLTableHeaderCellElement; "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; "title": HTMLTitleElement; "tr": HTMLTableRowElement; "track": HTMLTrackElement; @@ -17524,6 +18689,7 @@ interface ElementListTagNameMap { "code": NodeListOf; "col": NodeListOf; "colgroup": NodeListOf; + "data": NodeListOf; "datalist": NodeListOf; "dd": NodeListOf; "defs": NodeListOf; @@ -17617,6 +18783,7 @@ interface ElementListTagNameMap { "ol": NodeListOf; "optgroup": NodeListOf; "option": NodeListOf; + "output": NodeListOf; "p": NodeListOf; "param": NodeListOf; "path": NodeListOf; @@ -17659,6 +18826,7 @@ interface ElementListTagNameMap { "tfoot": NodeListOf; "th": NodeListOf; "thead": NodeListOf; + "time": NodeListOf; "title": NodeListOf; "tr": NodeListOf; "track": NodeListOf; @@ -17679,6 +18847,7 @@ declare var Audio: {new(src?: string): HTMLAudioElement; }; declare var Image: {new(width?: number, height?: number): HTMLImageElement; }; declare var Option: {new(text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; declare var applicationCache: ApplicationCache; +declare var caches: CacheStorage; declare var clientInformation: Navigator; declare var closed: boolean; declare var crypto: Crypto; @@ -17693,10 +18862,12 @@ declare var frames: Window; declare var history: History; declare var innerHeight: number; declare var innerWidth: number; +declare var isSecureContext: boolean; declare var length: number; declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; +declare var msContentScript: ExtensionScriptApis; declare var msCredentials: MSCredentials; declare const name: never; declare var navigator: Navigator; @@ -17810,18 +18981,21 @@ declare var scrollX: number; declare var scrollY: number; declare var scrollbars: BarProp; declare var self: Window; +declare var speechSynthesis: SpeechSynthesis; declare var status: string; declare var statusbar: BarProp; declare var styleMedia: StyleMedia; declare var toolbar: BarProp; declare var top: Window; declare var window: Window; +declare var customElements: CustomElementRegistry; declare function alert(message?: any): void; declare function blur(): void; declare function cancelAnimationFrame(handle: number): void; declare function captureEvents(): void; declare function close(): void; declare function confirm(message?: string): boolean; +declare function departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; declare function focus(): void; declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; declare function getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -17841,6 +19015,7 @@ declare function resizeTo(x?: number, y?: number): void; declare function scroll(x?: number, y?: number): void; declare function scrollBy(x?: number, y?: number): void; declare function scrollTo(x?: number, y?: number): void; +declare function stop(): void; declare function webkitCancelAnimationFrame(handle: number): void; declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; @@ -17875,10 +19050,13 @@ declare var onwheel: (this: Window, ev: WheelEvent) => any; declare var indexedDB: IDBFactory; declare function atob(encodedString: string): string; declare function btoa(rawString: string): string; +declare function fetch(input: RequestInfo, init?: RequestInit): Promise; declare function addEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; type AAGUID = string; type AlgorithmIdentifier = string | Algorithm; +type BodyInit = any; +type ByteString = string; type ConstrainBoolean = boolean | ConstrainBooleanParameters; type ConstrainDOMString = string | string[] | ConstrainDOMStringParameters; type ConstrainDouble = number | ConstrainDoubleRange; @@ -17898,6 +19076,7 @@ type GLsizeiptr = number; type GLubyte = number; type GLuint = number; type GLushort = number; +type HeadersInit = any; type IDBKeyPath = string; type KeyFormat = string; type KeyType = string; @@ -17905,8 +19084,10 @@ type KeyUsage = string; type MSInboundPayload = MSVideoRecvPayload | MSAudioRecvPayload; type MSLocalClientEvent = MSLocalClientEventBase | MSAudioLocalClientEvent; type MSOutboundPayload = MSVideoSendPayload | MSAudioSendPayload; -type RTCIceGatherCandidate = RTCIceCandidate | RTCIceCandidateComplete; +type RTCIceGatherCandidate = RTCIceCandidateDictionary | RTCIceCandidateComplete; type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport; +type RequestInfo = Request | string; +type USVString = string; type payloadtype = number; type ScrollBehavior = "auto" | "instant" | "smooth"; type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 6ee35cd6589..39a0c3da684 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -23,18 +23,50 @@ and limitations under the License. /// IE DOM APIs ///////////////////////////// +interface Account { + rpDisplayName?: string; + displayName?: string; + id?: string; + name?: string; + imageURL?: string; +} + interface Algorithm { name: string; } -interface AriaRequestEventInit extends EventInit { - attributeName?: string; - attributeValue?: string; +interface AnimationEventInit extends EventInit { + animationName?: string; + elapsedTime?: number; } -interface CommandEventInit extends EventInit { - commandName?: string; - detail?: string; +interface AssertionOptions { + timeoutSeconds?: number; + rpId?: USVString; + allowList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface CacheQueryOptions { + ignoreSearch?: boolean; + ignoreMethod?: boolean; + ignoreVary?: boolean; + cacheName?: string; +} + +interface ClientData { + challenge?: string; + origin?: string; + rpId?: string; + hashAlg?: string | Algorithm; + tokenBinding?: string; + extensions?: WebAuthnExtensions; +} + +interface CloseEventInit extends EventInit { + wasClean?: boolean; + code?: number; + reason?: string; } interface CompositionEventInit extends UIEventInit { @@ -74,6 +106,13 @@ interface CustomEventInit extends EventInit { detail?: any; } +interface DOMRectInit { + x?: any; + y?: any; + width?: any; + height?: any; +} + interface DeviceAccelerationDict { x?: number; y?: number; @@ -84,6 +123,20 @@ interface DeviceLightEventInit extends EventInit { value?: number; } +interface DeviceMotionEventInit extends EventInit { + acceleration?: DeviceAccelerationDict; + accelerationIncludingGravity?: DeviceAccelerationDict; + rotationRate?: DeviceRotationRateDict; + interval?: number; +} + +interface DeviceOrientationEventInit extends EventInit { + alpha?: number; + beta?: number; + gamma?: number; + absolute?: boolean; +} + interface DeviceRotationRateDict { alpha?: number; beta?: number; @@ -95,6 +148,14 @@ interface DoubleRange { min?: number; } +interface ErrorEventInit extends EventInit { + message?: string; + filename?: string; + lineno?: number; + colno?: number; + error?: any; +} + interface EventInit { scoped?: boolean; bubbles?: boolean; @@ -127,6 +188,29 @@ interface FocusEventInit extends UIEventInit { relatedTarget?: EventTarget; } +interface FocusNavigationEventInit extends EventInit { + navigationReason?: string; + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface FocusNavigationOrigin { + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface GamepadEventInit extends EventInit { + gamepad?: Gamepad; +} + +interface GetNotificationOptions { + tag?: string; +} + interface HashChangeEventInit extends EventInit { newURL?: string; oldURL?: string; @@ -142,6 +226,20 @@ interface IDBObjectStoreParameters { keyPath?: IDBKeyPath; } +interface IntersectionObserverEntryInit { + time?: number; + rootBounds?: DOMRectInit; + boundingClientRect?: DOMRectInit; + intersectionRect?: DOMRectInit; + target?: Element; +} + +interface IntersectionObserverInit { + root?: Element; + rootMargin?: string; + threshold?: number | number[]; +} + interface KeyAlgorithm { name?: string; } @@ -344,6 +442,11 @@ interface MSPayloadBase extends RTCStats { payloadDescription?: string; } +interface MSPortRange { + min?: number; + max?: number; +} + interface MSRelayAddress { relayAddress?: string; port?: number; @@ -394,7 +497,7 @@ interface MSUtilization { } interface MSVideoPayload extends MSPayloadBase { - resoluton?: string; + resolution?: string; videoBitRateAvg?: number; videoBitRateMax?: number; videoFrameRateAvg?: number; @@ -477,6 +580,10 @@ interface MediaStreamErrorEventInit extends EventInit { error?: MediaStreamError; } +interface MediaStreamEventInit extends EventInit { + stream?: MediaStream; +} + interface MediaStreamTrackEventInit extends EventInit { track?: MediaStreamTrack; } @@ -541,6 +648,15 @@ interface MediaTrackSupportedConstraints { groupId?: boolean; } +interface MessageEventInit extends EventInit { + lastEventId?: string; + channel?: string; + data?: any; + origin?: string; + source?: Window; + ports?: MessagePort[]; +} + interface MouseEventInit extends EventModifierInit { screenX?: number; screenY?: number; @@ -570,10 +686,68 @@ interface MutationObserverInit { attributeFilter?: string[]; } +interface NotificationOptions { + dir?: string; + lang?: string; + body?: string; + tag?: string; + icon?: string; +} + interface ObjectURLOptions { oneTimeOnly?: boolean; } +interface PaymentCurrencyAmount { + currency?: string; + value?: string; + currencySystem?: string; +} + +interface PaymentDetails { + total?: PaymentItem; + displayItems?: PaymentItem[]; + shippingOptions?: PaymentShippingOption[]; + modifiers?: PaymentDetailsModifier[]; + error?: string; +} + +interface PaymentDetailsModifier { + supportedMethods?: string[]; + total?: PaymentItem; + additionalDisplayItems?: PaymentItem[]; + data?: any; +} + +interface PaymentItem { + label?: string; + amount?: PaymentCurrencyAmount; + pending?: boolean; +} + +interface PaymentMethodData { + supportedMethods?: string[]; + data?: any; +} + +interface PaymentOptions { + requestPayerName?: boolean; + requestPayerEmail?: boolean; + requestPayerPhone?: boolean; + requestShipping?: boolean; + shippingType?: string; +} + +interface PaymentRequestUpdateEventInit extends EventInit { +} + +interface PaymentShippingOption { + id?: string; + label?: string; + amount?: PaymentCurrencyAmount; + selected?: boolean; +} + interface PeriodicWaveConstraints { disableNormalization?: boolean; } @@ -589,12 +763,34 @@ interface PointerEventInit extends MouseEventInit { isPrimary?: boolean; } +interface PopStateEventInit extends EventInit { + state?: any; +} + interface PositionOptions { enableHighAccuracy?: boolean; timeout?: number; maximumAge?: number; } +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + +interface PushSubscriptionOptionsInit { + userVisibleOnly?: boolean; + applicationServerKey?: any; +} + +interface RTCConfiguration { + iceServers?: RTCIceServer[]; + iceTransportPolicy?: string; + bundlePolicy?: string; + peerIdentity?: string; +} + interface RTCDTMFToneChangeEventInit extends EventInit { tone?: string; } @@ -609,18 +805,6 @@ interface RTCDtlsParameters { fingerprints?: RTCDtlsFingerprint[]; } -interface RTCIceCandidate { - foundation?: string; - priority?: number; - ip?: string; - protocol?: string; - port?: number; - type?: string; - tcpType?: string; - relatedAddress?: string; - relatedPort?: number; -} - interface RTCIceCandidateAttributes extends RTCStats { ipAddress?: string; portNumber?: number; @@ -633,9 +817,28 @@ interface RTCIceCandidateAttributes extends RTCStats { interface RTCIceCandidateComplete { } +interface RTCIceCandidateDictionary { + foundation?: string; + priority?: number; + ip?: string; + protocol?: string; + port?: number; + type?: string; + tcpType?: string; + relatedAddress?: string; + relatedPort?: number; + msMTurnSessionId?: string; +} + +interface RTCIceCandidateInit { + candidate?: string; + sdpMid?: string; + sdpMLineIndex?: number; +} + interface RTCIceCandidatePair { - local?: RTCIceCandidate; - remote?: RTCIceCandidate; + local?: RTCIceCandidateDictionary; + remote?: RTCIceCandidateDictionary; } interface RTCIceCandidatePairStats extends RTCStats { @@ -657,11 +860,13 @@ interface RTCIceCandidatePairStats extends RTCStats { interface RTCIceGatherOptions { gatherPolicy?: string; iceservers?: RTCIceServer[]; + portRange?: MSPortRange; } interface RTCIceParameters { usernameFragment?: string; password?: string; + iceLite?: boolean; } interface RTCIceServer { @@ -695,6 +900,13 @@ interface RTCMediaStreamTrackStats extends RTCStats { echoReturnLossEnhancement?: number; } +interface RTCOfferOptions { + offerToReceiveVideo?: number; + offerToReceiveAudio?: number; + voiceActivityDetection?: boolean; + iceRestart?: boolean; +} + interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { packetsSent?: number; bytesSent?: number; @@ -702,6 +914,10 @@ interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { roundTripTime?: number; } +interface RTCPeerConnectionIceEventInit extends EventInit { + candidate?: RTCIceCandidate; +} + interface RTCRTPStreamStats extends RTCStats { ssrc?: string; associateStatsId?: string; @@ -739,6 +955,7 @@ interface RTCRtpCodecCapability { clockRate?: number; preferredPayloadType?: number; maxptime?: number; + ptime?: number; numChannels?: number; rtcpFeedback?: RTCRtcpFeedback[]; parameters?: any; @@ -753,6 +970,7 @@ interface RTCRtpCodecParameters { payloadType?: any; clockRate?: number; maxptime?: number; + ptime?: number; numChannels?: number; rtcpFeedback?: RTCRtcpFeedback[]; parameters?: any; @@ -772,9 +990,9 @@ interface RTCRtpEncodingParameters { priority?: number; maxBitrate?: number; minQuality?: number; - framerateBias?: number; resolutionScale?: number; framerateScale?: number; + maxFramerate?: number; active?: boolean; encodingId?: string; dependencyEncodingIds?: string[]; @@ -805,6 +1023,7 @@ interface RTCRtpParameters { headerExtensions?: RTCRtpHeaderExtensionParameters[]; encodings?: RTCRtpEncodingParameters[]; rtcp?: RTCRtcpParameters; + degradationPreference?: string; } interface RTCRtpRtxParameters { @@ -817,6 +1036,11 @@ interface RTCRtpUnhandled { muxId?: string; } +interface RTCSessionDescriptionInit { + type?: string; + sdp?: string; +} + interface RTCSrtpKeyParam { keyMethod?: string; keySalt?: string; @@ -857,6 +1081,64 @@ interface RTCTransportStats extends RTCStats { remoteCertificateId?: string; } +interface RegistrationOptions { + scope?: string; +} + +interface RequestInit { + method?: string; + headers?: any; + body?: any; + referrer?: string; + referrerPolicy?: string; + mode?: string; + credentials?: string; + cache?: string; + redirect?: string; + integrity?: string; + keepalive?: boolean; + window?: any; +} + +interface ResponseInit { + status?: number; + statusText?: string; + headers?: any; +} + +interface ScopedCredentialDescriptor { + type?: string; + id?: any; + transports?: string[]; +} + +interface ScopedCredentialOptions { + timeoutSeconds?: number; + rpId?: USVString; + excludeList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface ScopedCredentialParameters { + type?: string; + algorithm?: string | Algorithm; +} + +interface ServiceWorkerMessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + source?: ServiceWorker | MessagePort; + ports?: MessagePort[]; +} + +interface SpeechSynthesisEventInit extends EventInit { + utterance?: SpeechSynthesisUtterance; + charIndex?: number; + elapsedTime?: number; + name?: string; +} + interface StoreExceptionsInformation extends ExceptionInformation { siteName?: string; explanationString?: string; @@ -867,11 +1149,23 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat arrayOfDomainStrings?: string[]; } +interface TrackEventInit extends EventInit { + track?: VideoTrack | AudioTrack | TextTrack; +} + +interface TransitionEventInit extends EventInit { + propertyName?: string; + elapsedTime?: number; +} + interface UIEventInit extends EventInit { view?: Window; detail?: number; } +interface WebAuthnExtensions { +} + interface WebGLContextAttributes { failIfMajorPerformanceCaveat?: boolean; alpha?: boolean; @@ -897,6 +1191,18 @@ interface EventListener { (evt: Event): void; } +interface WebKitEntriesCallback { + (evt: Event): void; +} + +interface WebKitErrorCallback { + (evt: Event): void; +} + +interface WebKitFileCallback { + (evt: Event): void; +} + interface ANGLE_instanced_arrays { drawArraysInstancedANGLE(mode: number, first: number, count: number, primcount: number): void; drawElementsInstancedANGLE(mode: number, count: number, type: number, offset: number, primcount: number): void; @@ -935,14 +1241,14 @@ interface AnimationEvent extends Event { declare var AnimationEvent: { prototype: AnimationEvent; - new(): AnimationEvent; + new(typeArg: string, eventInitDict?: AnimationEventInit): AnimationEvent; } interface ApplicationCacheEventMap { "cached": Event; "checking": Event; "downloading": Event; - "error": ErrorEvent; + "error": Event; "noupdate": Event; "obsolete": Event; "progress": ProgressEvent; @@ -953,7 +1259,7 @@ interface ApplicationCache extends EventTarget { oncached: (this: ApplicationCache, ev: Event) => any; onchecking: (this: ApplicationCache, ev: Event) => any; ondownloading: (this: ApplicationCache, ev: Event) => any; - onerror: (this: ApplicationCache, ev: ErrorEvent) => any; + onerror: (this: ApplicationCache, ev: Event) => any; onnoupdate: (this: ApplicationCache, ev: Event) => any; onobsolete: (this: ApplicationCache, ev: Event) => any; onprogress: (this: ApplicationCache, ev: ProgressEvent) => any; @@ -983,16 +1289,6 @@ declare var ApplicationCache: { readonly UPDATEREADY: number; } -interface AriaRequestEvent extends Event { - readonly attributeName: string; - attributeValue: string | null; -} - -declare var AriaRequestEvent: { - prototype: AriaRequestEvent; - new(type: string, eventInitDict?: AriaRequestEventInit): AriaRequestEvent; -} - interface Attr extends Node { readonly name: string; readonly ownerElement: Element; @@ -1044,12 +1340,18 @@ declare var AudioBufferSourceNode: { new(): AudioBufferSourceNode; } -interface AudioContext extends EventTarget { +interface AudioContextEventMap { + "statechange": Event; +} + +interface AudioContextBase extends EventTarget { readonly currentTime: number; readonly destination: AudioDestinationNode; readonly listener: AudioListener; + onstatechange: (this: AudioContext, ev: Event) => any; readonly sampleRate: number; - state: string; + readonly state: string; + close(): Promise; createAnalyser(): AnalyserNode; createBiquadFilter(): BiquadFilterNode; createBuffer(numberOfChannels: number, length: number, sampleRate: number): AudioBuffer; @@ -1060,6 +1362,7 @@ interface AudioContext extends EventTarget { createDelay(maxDelayTime?: number): DelayNode; createDynamicsCompressor(): DynamicsCompressorNode; createGain(): GainNode; + createIIRFilter(feedforward: number[], feedback: number[]): IIRFilterNode; createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createMediaStreamSource(mediaStream: MediaStream): MediaStreamAudioSourceNode; createOscillator(): OscillatorNode; @@ -1068,7 +1371,14 @@ interface AudioContext extends EventTarget { createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; - decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): PromiseLike; + decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): Promise; + resume(): Promise; + addEventListener(type: K, listener: (this: AudioContext, ev: AudioContextEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface AudioContext extends AudioContextBase { + suspend(): Promise; } declare var AudioContext: { @@ -1105,7 +1415,7 @@ interface AudioNode extends EventTarget { readonly context: AudioContext; readonly numberOfInputs: number; readonly numberOfOutputs: number; - connect(destination: AudioNode, output?: number, input?: number): void; + connect(destination: AudioNode, output?: number, input?: number): AudioNode; disconnect(output?: number): void; disconnect(destination: AudioNode, output?: number, input?: number): void; disconnect(destination: AudioParam, output?: number): void; @@ -1119,12 +1429,12 @@ declare var AudioNode: { interface AudioParam { readonly defaultValue: number; value: number; - cancelScheduledValues(startTime: number): void; - exponentialRampToValueAtTime(value: number, endTime: number): void; - linearRampToValueAtTime(value: number, endTime: number): void; - setTargetAtTime(target: number, startTime: number, timeConstant: number): void; - setValueAtTime(value: number, startTime: number): void; - setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; + cancelScheduledValues(startTime: number): AudioParam; + exponentialRampToValueAtTime(value: number, endTime: number): AudioParam; + linearRampToValueAtTime(value: number, endTime: number): AudioParam; + setTargetAtTime(target: number, startTime: number, timeConstant: number): AudioParam; + setValueAtTime(value: number, startTime: number): AudioParam; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): AudioParam; } declare var AudioParam: { @@ -1501,10 +1811,16 @@ interface CSSStyleDeclaration { imeMode: string | null; justifyContent: string | null; kerning: string | null; + layoutGrid: string | null; + layoutGridChar: string | null; + layoutGridLine: string | null; + layoutGridMode: string | null; + layoutGridType: string | null; left: string | null; readonly length: number; letterSpacing: string | null; lightingColor: string | null; + lineBreak: string | null; lineHeight: string | null; listStyle: string | null; listStyleImage: string | null; @@ -1576,6 +1892,7 @@ interface CSSStyleDeclaration { orphans: string | null; outline: string | null; outlineColor: string | null; + outlineOffset: string | null; outlineStyle: string | null; outlineWidth: string | null; overflow: string | null; @@ -1596,9 +1913,11 @@ interface CSSStyleDeclaration { position: string | null; quotes: string | null; right: string | null; + rotate: string | null; rubyAlign: string | null; rubyOverhang: string | null; rubyPosition: string | null; + scale: string | null; stopColor: string | null; stopOpacity: string | null; stroke: string | null; @@ -1632,6 +1951,7 @@ interface CSSStyleDeclaration { transitionDuration: string | null; transitionProperty: string | null; transitionTimingFunction: string | null; + translate: string | null; unicodeBidi: string | null; verticalAlign: string | null; visibility: string | null; @@ -1692,6 +2012,9 @@ interface CSSStyleDeclaration { webkitTapHighlightColor: string | null; webkitTextFillColor: string | null; webkitTextSizeAdjust: any; + webkitTextStroke: string | null; + webkitTextStrokeColor: string | null; + webkitTextStrokeWidth: string | null; webkitTransform: string | null; webkitTransformOrigin: string | null; webkitTransformStyle: string | null; @@ -1713,6 +2036,7 @@ interface CSSStyleDeclaration { zIndex: string | null; zoom: string | null; resize: string | null; + userSelect: string | null; getPropertyPriority(propertyName: string): string; getPropertyValue(propertyName: string): string; item(index: number): string; @@ -1740,7 +2064,6 @@ declare var CSSStyleRule: { interface CSSStyleSheet extends StyleSheet { readonly cssRules: CSSRuleList; cssText: string; - readonly href: string; readonly id: string; readonly imports: StyleSheetList; readonly isAlternate: boolean; @@ -1772,6 +2095,34 @@ declare var CSSSupportsRule: { new(): CSSSupportsRule; } +interface Cache { + add(request: RequestInfo): Promise; + addAll(requests: RequestInfo[]): Promise; + delete(request: RequestInfo, options?: CacheQueryOptions): Promise; + keys(request?: RequestInfo, options?: CacheQueryOptions): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + put(request: RequestInfo, response: Response): Promise; +} + +declare var Cache: { + prototype: Cache; + new(): Cache; +} + +interface CacheStorage { + delete(cacheName: string): Promise; + has(cacheName: string): Promise; + keys(): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + open(cacheName: string): Promise; +} + +declare var CacheStorage: { + prototype: CacheStorage; + new(): CacheStorage; +} + interface CanvasGradient { addColorStop(offset: number, color: string): void; } @@ -1796,13 +2147,13 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { font: string; globalAlpha: number; globalCompositeOperation: string; + imageSmoothingEnabled: boolean; lineCap: string; lineDashOffset: number; lineJoin: string; lineWidth: number; miterLimit: number; msFillRule: string; - msImageSmoothingEnabled: boolean; shadowBlur: number; shadowColor: string; shadowOffsetX: number; @@ -1820,6 +2171,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + drawFocusIfNeeded(element: Element): 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; @@ -1835,7 +2187,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { scale(x: number, y: number): void; setLineDash(segments: number[]): void; setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - stroke(): void; + stroke(path?: Path2D): void; strokeRect(x: number, y: number, w: number, h: number): void; strokeText(text: string, x: number, y: number, maxWidth?: number): void; transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; @@ -1921,17 +2273,7 @@ interface CloseEvent extends Event { declare var CloseEvent: { prototype: CloseEvent; - new(): CloseEvent; -} - -interface CommandEvent extends Event { - readonly commandName: string; - readonly detail: string | null; -} - -declare var CommandEvent: { - prototype: CommandEvent; - new(type: string, eventInitDict?: CommandEventInit): CommandEvent; + new(typeArg: string, eventInitDict?: CloseEventInit): CloseEvent; } interface Comment extends CharacterData { @@ -1958,7 +2300,7 @@ interface Console { assert(test?: boolean, message?: string, ...optionalParams: any[]): void; clear(): void; count(countTitle?: string): void; - debug(message?: string, ...optionalParams: any[]): void; + debug(message?: any, ...optionalParams: any[]): void; dir(value?: any, ...optionalParams: any[]): void; dirxml(value: any): void; error(message?: any, ...optionalParams: any[]): void; @@ -2128,9 +2470,9 @@ declare var DOMException: { interface DOMImplementation { createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType): Document; - createDocumentType(qualifiedName: string, publicId: string | null, systemId: string | null): DocumentType; + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; createHTMLDocument(title: string): Document; - hasFeature(feature: string | null, version: string | null): boolean; + hasFeature(): boolean; } declare var DOMImplementation: { @@ -2169,7 +2511,7 @@ declare var DOMStringList: { } interface DOMStringMap { - [name: string]: string; + [name: string]: string | undefined; } declare var DOMStringMap: { @@ -2195,7 +2537,7 @@ declare var DOMTokenList: { interface DataCue extends TextTrackCue { data: ArrayBuffer; - addEventListener(type: K, listener: (this: TextTrackCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: DataCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -2225,6 +2567,7 @@ interface DataTransferItem { readonly type: string; getAsFile(): File | null; getAsString(_callback: FunctionStringCallback | null): void; + webkitGetAsEntry(): any; } declare var DataTransferItem: { @@ -2285,7 +2628,7 @@ interface DeviceLightEvent extends Event { declare var DeviceLightEvent: { prototype: DeviceLightEvent; - new(type: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; + new(typeArg: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; } interface DeviceMotionEvent extends Event { @@ -2298,7 +2641,7 @@ interface DeviceMotionEvent extends Event { declare var DeviceMotionEvent: { prototype: DeviceMotionEvent; - new(): DeviceMotionEvent; + new(typeArg: string, eventInitDict?: DeviceMotionEventInit): DeviceMotionEvent; } interface DeviceOrientationEvent extends Event { @@ -2311,7 +2654,7 @@ interface DeviceOrientationEvent extends Event { declare var DeviceOrientationEvent: { prototype: DeviceOrientationEvent; - new(): DeviceOrientationEvent; + new(typeArg: string, eventInitDict?: DeviceOrientationEventInit): DeviceOrientationEvent; } interface DeviceRotationRate { @@ -2393,7 +2736,7 @@ interface DocumentEventMap extends GlobalEventHandlersEventMap { "pointerlockerror": Event; "progress": ProgressEvent; "ratechange": Event; - "readystatechange": ProgressEvent; + "readystatechange": Event; "reset": Event; "scroll": UIEvent; "seeked": Event; @@ -2464,10 +2807,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven readonly compatMode: string; cookie: string; readonly currentScript: HTMLScriptElement | SVGScriptElement; - /** - * Gets the default character set from the current regional language settings. - */ - readonly defaultCharset: string; readonly defaultView: Window; /** * Sets or gets a value that indicates whether the document can be edited. @@ -2774,7 +3113,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Fires when the state of the object has changed. * @param ev The event */ - onreadystatechange: (this: Document, ev: ProgressEvent) => any; + onreadystatechange: (this: Document, ev: Event) => any; /** * Fires when the user resets a form. * @param ev The event. @@ -3142,8 +3481,8 @@ interface DocumentType extends Node, ChildNode { readonly internalSubset: string | null; readonly name: string; readonly notations: NamedNodeMap; - readonly publicId: string | null; - readonly systemId: string | null; + readonly publicId: string; + readonly systemId: string; } declare var DocumentType: { @@ -3166,7 +3505,7 @@ interface DynamicsCompressorNode extends AudioNode { readonly attack: AudioParam; readonly knee: AudioParam; readonly ratio: AudioParam; - readonly reduction: AudioParam; + readonly reduction: number; readonly release: AudioParam; readonly threshold: AudioParam; } @@ -3197,8 +3536,8 @@ declare var EXT_texture_filter_anisotropic: { } interface ElementEventMap extends GlobalEventHandlersEventMap { - "ariarequest": AriaRequestEvent; - "command": CommandEvent; + "ariarequest": Event; + "command": Event; "gotpointercapture": PointerEvent; "lostpointercapture": PointerEvent; "MSGestureChange": MSGestureEvent; @@ -3234,10 +3573,11 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec readonly clientTop: number; readonly clientWidth: number; id: string; + innerHTML: string; msContentZoomFactor: number; readonly msRegionOverflow: string; - onariarequest: (this: Element, ev: AriaRequestEvent) => any; - oncommand: (this: Element, ev: CommandEvent) => any; + onariarequest: (this: Element, ev: Event) => any; + oncommand: (this: Element, ev: Event) => any; ongotpointercapture: (this: Element, ev: PointerEvent) => any; onlostpointercapture: (this: Element, ev: PointerEvent) => any; onmsgesturechange: (this: Element, ev: MSGestureEvent) => any; @@ -3263,13 +3603,13 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec ontouchstart: (ev: TouchEvent) => any; onwebkitfullscreenchange: (this: Element, ev: Event) => any; onwebkitfullscreenerror: (this: Element, ev: Event) => any; + outerHTML: string; readonly prefix: string | null; readonly scrollHeight: number; scrollLeft: number; scrollTop: number; readonly scrollWidth: number; readonly tagName: string; - innerHTML: string; readonly assignedSlot: HTMLSlotElement | null; slot: string; readonly shadowRoot: ShadowRoot | null; @@ -3293,7 +3633,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec msSetPointerCapture(pointerId: number): void; msZoomTo(args: MsZoomToOptions): void; releasePointerCapture(pointerId: number): void; - removeAttribute(name?: string): void; + removeAttribute(qualifiedName: string): void; removeAttributeNS(namespaceURI: string, localName: string): void; removeAttributeNode(oldAttr: Attr): Attr; requestFullscreen(): void; @@ -3340,7 +3680,7 @@ interface ErrorEvent extends Event { declare var ErrorEvent: { prototype: ErrorEvent; - new(): ErrorEvent; + new(type: string, errorEventInitDict?: ErrorEventInit): ErrorEvent; } interface Event { @@ -3369,7 +3709,7 @@ interface Event { declare var Event: { prototype: Event; - new(type: string, eventInitDict?: EventInit): Event; + new(typeArg: string, eventInitDict?: EventInit): Event; readonly AT_TARGET: number; readonly BUBBLING_PHASE: number; readonly CAPTURING_PHASE: number; @@ -3386,6 +3726,21 @@ declare var EventTarget: { new(): EventTarget; } +interface ExtensionScriptApis { + extensionIdToShortId(extensionId: string): number; + fireExtensionApiTelemetry(functionName: string, isSucceeded: boolean, isSupported: boolean): void; + genericFunction(routerAddress: any, parameters?: string, callbackId?: number): void; + genericSynchronousFunction(functionId: number, parameters?: string): string; + getExtensionId(): string; + registerGenericFunctionCallbackHandler(callbackHandler: any): void; + registerGenericPersistentCallbackHandler(callbackHandler: any): void; +} + +declare var ExtensionScriptApis: { + prototype: ExtensionScriptApis; + new(): ExtensionScriptApis; +} + interface External { } @@ -3422,7 +3777,7 @@ interface FileReader extends EventTarget, MSBaseReader { readAsBinaryString(blob: Blob): void; readAsDataURL(blob: Blob): void; readAsText(blob: Blob, encoding?: string): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3441,6 +3796,20 @@ declare var FocusEvent: { new(typeArg: string, eventInitDict?: FocusEventInit): FocusEvent; } +interface FocusNavigationEvent extends Event { + readonly navigationReason: string; + readonly originHeight: number; + readonly originLeft: number; + readonly originTop: number; + readonly originWidth: number; + requestFocus(): void; +} + +declare var FocusNavigationEvent: { + prototype: FocusNavigationEvent; + new(type: string, eventInitDict?: FocusNavigationEventInit): FocusNavigationEvent; +} + interface FormData { append(name: any, value: any, blobName?: string): void; } @@ -3490,7 +3859,7 @@ interface GamepadEvent extends Event { declare var GamepadEvent: { prototype: GamepadEvent; - new(): GamepadEvent; + new(typeArg: string, eventInitDict?: GamepadEventInit): GamepadEvent; } interface Geolocation { @@ -3504,8 +3873,11 @@ declare var Geolocation: { new(): Geolocation; } -interface HTMLAllCollection extends HTMLCollection { - namedItem(name: string): Element; +interface HTMLAllCollection { + readonly length: number; + item(nameOrIndex?: string): HTMLCollection | Element | null; + namedItem(name: string): HTMLCollection | Element | null; + [index: number]: Element; } declare var HTMLAllCollection: { @@ -3593,7 +3965,7 @@ interface HTMLAnchorElement extends HTMLElement { * Returns a string representation of an object. */ toString(): string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAnchorElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3667,7 +4039,7 @@ interface HTMLAppletElement extends HTMLElement { useMap: string; vspace: number; width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAppletElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3735,7 +4107,7 @@ interface HTMLAreaElement extends HTMLElement { * Returns a string representation of an object. */ toString(): string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3744,15 +4116,7 @@ declare var HTMLAreaElement: { new(): HTMLAreaElement; } -interface HTMLAreasCollection extends HTMLCollection { - /** - * Adds an element to the areas, controlRange, or options collection. - */ - add(element: HTMLElement, before?: HTMLElement | number): void; - /** - * Removes an element from the collection. - */ - remove(index?: number): void; +interface HTMLAreasCollection extends HTMLCollectionBase { } declare var HTMLAreasCollection: { @@ -3761,7 +4125,7 @@ declare var HTMLAreasCollection: { } interface HTMLAudioElement extends HTMLMediaElement { - addEventListener(type: K, listener: (this: HTMLMediaElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAudioElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3775,7 +4139,7 @@ interface HTMLBRElement extends HTMLElement { * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. */ clear: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3793,7 +4157,7 @@ interface HTMLBaseElement extends HTMLElement { * Sets or retrieves the window or frame at which to target content. */ target: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBaseElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3811,7 +4175,7 @@ interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty * Sets or retrieves the font size of the object. */ size: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBaseFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3837,6 +4201,7 @@ interface HTMLBodyElementEventMap extends HTMLElementEventMap { "pageshow": PageTransitionEvent; "popstate": PopStateEvent; "resize": UIEvent; + "scroll": UIEvent; "storage": StorageEvent; "unload": Event; } @@ -3864,6 +4229,7 @@ interface HTMLBodyElement extends HTMLElement { onpageshow: (this: HTMLBodyElement, ev: PageTransitionEvent) => any; onpopstate: (this: HTMLBodyElement, ev: PopStateEvent) => any; onresize: (this: HTMLBodyElement, ev: UIEvent) => any; + onscroll: (this: HTMLBodyElement, ev: UIEvent) => any; onstorage: (this: HTMLBodyElement, ev: StorageEvent) => any; onunload: (this: HTMLBodyElement, ev: Event) => any; text: any; @@ -3941,7 +4307,7 @@ interface HTMLButtonElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLButtonElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3976,7 +4342,7 @@ interface HTMLCanvasElement extends HTMLElement { */ toDataURL(type?: string, ...args: any[]): string; toBlob(callback: (result: Blob | null) => void, type?: string, ...arguments: any[]): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3985,7 +4351,7 @@ declare var HTMLCanvasElement: { new(): HTMLCanvasElement; } -interface HTMLCollection { +interface HTMLCollectionBase { /** * Sets or retrieves the number of objects in a collection. */ @@ -3994,11 +4360,14 @@ interface HTMLCollection { * Retrieves an object from various collections. */ item(index: number): Element; + [index: number]: Element; +} + +interface HTMLCollection extends HTMLCollectionBase { /** * Retrieves a select object or an object from an options collection. */ - namedItem(name: string): Element; - [index: number]: Element; + namedItem(name: string): Element | null; } declare var HTMLCollection: { @@ -4008,7 +4377,7 @@ declare var HTMLCollection: { interface HTMLDListElement extends HTMLElement { compact: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4017,9 +4386,20 @@ declare var HTMLDListElement: { new(): HTMLDListElement; } +interface HTMLDataElement extends HTMLElement { + value: string; + addEventListener(type: K, listener: (this: HTMLDataElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDataElement: { + prototype: HTMLDataElement; + new(): HTMLDataElement; +} + interface HTMLDataListElement extends HTMLElement { options: HTMLCollectionOf; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDataListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4030,7 +4410,7 @@ declare var HTMLDataListElement: { interface HTMLDirectoryElement extends HTMLElement { compact: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDirectoryElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4048,7 +4428,7 @@ interface HTMLDivElement extends HTMLElement { * Sets or retrieves whether the browser automatically performs wordwrap. */ noWrap: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4058,7 +4438,7 @@ declare var HTMLDivElement: { } interface HTMLDocument extends Document { - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4146,7 +4526,6 @@ interface HTMLElement extends Element { draggable: boolean; hidden: boolean; hideFocus: boolean; - innerHTML: string; innerText: string; readonly isContentEditable: boolean; lang: string; @@ -4222,7 +4601,6 @@ interface HTMLElement extends Element { ontimeupdate: (this: HTMLElement, ev: Event) => any; onvolumechange: (this: HTMLElement, ev: Event) => any; onwaiting: (this: HTMLElement, ev: Event) => any; - outerHTML: string; outerText: string; spellcheck: boolean; readonly style: CSSStyleDeclaration; @@ -4233,7 +4611,6 @@ interface HTMLElement extends Element { dragDrop(): boolean; focus(): void; msGetInputContext(): MSInputMethodContext; - setActive(): void; addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4290,7 +4667,7 @@ interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the width of the object. */ width: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLEmbedElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4309,6 +4686,7 @@ interface HTMLFieldSetElement extends HTMLElement { * Retrieves a reference to the form that the object is embedded in. */ readonly form: HTMLFormElement; + name: string; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. */ @@ -4330,7 +4708,7 @@ interface HTMLFieldSetElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFieldSetElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4344,7 +4722,7 @@ interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOM * Sets or retrieves the current typeface family. */ face: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4353,6 +4731,15 @@ declare var HTMLFontElement: { new(): HTMLFontElement; } +interface HTMLFormControlsCollection extends HTMLCollectionBase { + namedItem(name: string): HTMLCollection | Element | null; +} + +declare var HTMLFormControlsCollection: { + prototype: HTMLFormControlsCollection; + new(): HTMLFormControlsCollection; +} + interface HTMLFormElement extends HTMLElement { /** * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. @@ -4369,7 +4756,7 @@ interface HTMLFormElement extends HTMLElement { /** * Retrieves a collection, in source order, of all controls in a given form. */ - readonly elements: HTMLCollection; + readonly elements: HTMLFormControlsCollection; /** * Sets or retrieves the MIME encoding for the form. */ @@ -4420,7 +4807,7 @@ interface HTMLFormElement extends HTMLElement { * Fires when a FORM is about to be submitted. */ submit(): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFormElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [name: string]: any; } @@ -4509,6 +4896,7 @@ declare var HTMLFrameElement: { } interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { + "afterprint": Event; "beforeprint": Event; "beforeunload": BeforeUnloadEvent; "blur": FocusEvent; @@ -4522,7 +4910,9 @@ interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { "orientationchange": Event; "pagehide": PageTransitionEvent; "pageshow": PageTransitionEvent; + "popstate": PopStateEvent; "resize": UIEvent; + "scroll": UIEvent; "storage": StorageEvent; "unload": Event; } @@ -4566,7 +4956,9 @@ interface HTMLFrameSetElement extends HTMLElement { onorientationchange: (this: HTMLFrameSetElement, ev: Event) => any; onpagehide: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; onpageshow: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; + onpopstate: (this: HTMLFrameSetElement, ev: PopStateEvent) => any; onresize: (this: HTMLFrameSetElement, ev: UIEvent) => any; + onscroll: (this: HTMLFrameSetElement, ev: UIEvent) => any; onstorage: (this: HTMLFrameSetElement, ev: StorageEvent) => any; onunload: (this: HTMLFrameSetElement, ev: Event) => any; /** @@ -4595,7 +4987,7 @@ interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2 * Sets or retrieves the width of the object. */ width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4606,7 +4998,7 @@ declare var HTMLHRElement: { interface HTMLHeadElement extends HTMLElement { profile: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHeadElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4620,7 +5012,7 @@ interface HTMLHeadingElement extends HTMLElement { * Sets or retrieves a value that indicates the table alignment. */ align: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHeadingElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4634,7 +5026,7 @@ interface HTMLHtmlElement extends HTMLElement { * Sets or retrieves the DTD version that governs the current document. */ version: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHtmlElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4653,6 +5045,7 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { */ align: string; allowFullscreen: boolean; + allowPaymentRequest: boolean; /** * Specifies the properties of a border drawn around an object. */ @@ -4748,7 +5141,7 @@ interface HTMLImageElement extends HTMLElement { * Retrieves whether the object is fully loaded. */ readonly complete: boolean; - crossOrigin: string; + crossOrigin: string | null; readonly currentSrc: string; /** * Sets or retrieves the height of the object. @@ -4813,14 +5206,13 @@ interface HTMLImageElement extends HTMLElement { readonly x: number; readonly y: number; msGetAsCastingSource(): any; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLImageElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLImageElement: { prototype: HTMLImageElement; new(): HTMLImageElement; - create(): HTMLImageElement; } interface HTMLInputElement extends HTMLElement { @@ -5026,7 +5418,7 @@ interface HTMLInputElement extends HTMLElement { * @param n Value to increment the value by. */ stepUp(n?: number): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLInputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5041,7 +5433,7 @@ interface HTMLLIElement extends HTMLElement { * Sets or retrieves the value of a list item. */ value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLIElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5059,7 +5451,7 @@ interface HTMLLabelElement extends HTMLElement { * Sets or retrieves the object to which the given label object is assigned. */ htmlFor: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLabelElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5077,7 +5469,7 @@ interface HTMLLegendElement extends HTMLElement { * Retrieves a reference to the form that the object is embedded in. */ readonly form: HTMLFormElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5122,7 +5514,7 @@ interface HTMLLinkElement extends HTMLElement, LinkStyle { type: string; import?: Document; integrity: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLinkElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5140,7 +5532,7 @@ interface HTMLMapElement extends HTMLElement { * Sets or retrieves the name of the object. */ name: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMapElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5203,7 +5595,7 @@ interface HTMLMediaElement extends HTMLElement { * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). */ controls: boolean; - crossOrigin: string; + crossOrigin: string | null; /** * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. */ @@ -5344,7 +5736,7 @@ interface HTMLMediaElement extends HTMLElement { * Loads and starts playback of a media resource. */ play(): void; - setMediaKeys(mediaKeys: MediaKeys | null): PromiseLike; + setMediaKeys(mediaKeys: MediaKeys | null): Promise; readonly HAVE_CURRENT_DATA: number; readonly HAVE_ENOUGH_DATA: number; readonly HAVE_FUTURE_DATA: number; @@ -5375,7 +5767,7 @@ declare var HTMLMediaElement: { interface HTMLMenuElement extends HTMLElement { compact: boolean; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMenuElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5409,7 +5801,7 @@ interface HTMLMetaElement extends HTMLElement { * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. */ url: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMetaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5425,7 +5817,7 @@ interface HTMLMeterElement extends HTMLElement { min: number; optimum: number; value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMeterElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5443,7 +5835,7 @@ interface HTMLModElement extends HTMLElement { * Sets or retrieves the date and time of a modification to the object. */ dateTime: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLModElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5459,7 +5851,7 @@ interface HTMLOListElement extends HTMLElement { */ start: number; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5537,10 +5929,6 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the name of the object. */ name: string; - /** - * Retrieves the contained object. - */ - readonly object: any; readonly readyState: number; /** * Sets or retrieves a message to be displayed while an object is loading. @@ -5580,7 +5968,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLObjectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5619,7 +6007,7 @@ interface HTMLOptGroupElement extends HTMLElement { * Sets or retrieves the value which is returned to the server when the form control is submitted. */ value: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOptGroupElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5658,14 +6046,13 @@ interface HTMLOptionElement extends HTMLElement { * Sets or retrieves the value which is returned to the server when the form control is submitted. */ value: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLOptionElement: { prototype: HTMLOptionElement; new(): HTMLOptionElement; - create(): HTMLOptionElement; } interface HTMLOptionsCollection extends HTMLCollectionOf { @@ -5680,13 +6067,35 @@ declare var HTMLOptionsCollection: { new(): HTMLOptionsCollection; } +interface HTMLOutputElement extends HTMLElement { + defaultValue: string; + readonly form: HTMLFormElement; + readonly htmlFor: DOMSettableTokenList; + name: string; + readonly type: string; + readonly validationMessage: string; + readonly validity: ValidityState; + value: string; + readonly willValidate: boolean; + checkValidity(): boolean; + reportValidity(): boolean; + setCustomValidity(error: string): void; + addEventListener(type: K, listener: (this: HTMLOutputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLOutputElement: { + prototype: HTMLOutputElement; + new(): HTMLOutputElement; +} + interface HTMLParagraphElement extends HTMLElement { /** * Sets or retrieves how the object is aligned with adjacent text. */ align: string; clear: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLParagraphElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5712,7 +6121,7 @@ interface HTMLParamElement extends HTMLElement { * Sets or retrieves the data type of the value attribute. */ valueType: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLParamElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5722,7 +6131,7 @@ declare var HTMLParamElement: { } interface HTMLPictureElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLPictureElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5736,7 +6145,7 @@ interface HTMLPreElement extends HTMLElement { * Sets or gets a value that you can use to implement your own width functionality for the object. */ width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLPreElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5762,7 +6171,7 @@ interface HTMLProgressElement extends HTMLElement { * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. */ value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLProgressElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5776,7 +6185,7 @@ interface HTMLQuoteElement extends HTMLElement { * Sets or retrieves reference information about the object. */ cite: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLQuoteElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5791,6 +6200,7 @@ interface HTMLScriptElement extends HTMLElement { * Sets or retrieves the character set used to encode the object. */ charset: string; + crossOrigin: string | null; /** * Sets or retrieves the status of the script. */ @@ -5816,7 +6226,7 @@ interface HTMLScriptElement extends HTMLElement { */ type: string; integrity: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLScriptElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5912,7 +6322,7 @@ interface HTMLSelectElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSelectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [name: string]: any; } @@ -5938,7 +6348,7 @@ interface HTMLSourceElement extends HTMLElement { * Gets or sets the MIME type of a media resource. */ type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSourceElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5948,7 +6358,7 @@ declare var HTMLSourceElement: { } interface HTMLSpanElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSpanElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5967,7 +6377,7 @@ interface HTMLStyleElement extends HTMLElement, LinkStyle { * Retrieves the CSS language in which the style sheet is written. */ type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLStyleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5985,7 +6395,7 @@ interface HTMLTableCaptionElement extends HTMLElement { * Sets or retrieves whether the caption appears at the top or bottom of the table. */ vAlign: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableCaptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6040,7 +6450,7 @@ interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment { * Sets or retrieves the width of the object. */ width: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6062,7 +6472,7 @@ interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { * Sets or retrieves the width of the object. */ width: any; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableColElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6072,6 +6482,8 @@ declare var HTMLTableColElement: { } interface HTMLTableDataCellElement extends HTMLTableCellElement { + addEventListener(type: K, listener: (this: HTMLTableDataCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLTableDataCellElement: { @@ -6183,7 +6595,7 @@ interface HTMLTableElement extends HTMLElement { * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. */ insertRow(index?: number): HTMLTableRowElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6197,6 +6609,8 @@ interface HTMLTableHeaderCellElement extends HTMLTableCellElement { * Sets or retrieves the group of cells in a table to which the object's information applies. */ scope: string; + addEventListener(type: K, listener: (this: HTMLTableHeaderCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLTableHeaderCellElement: { @@ -6236,7 +6650,7 @@ interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment { * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. */ insertCell(index?: number): HTMLTableDataCellElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableRowElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6264,7 +6678,7 @@ interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment { * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. */ insertRow(index?: number): HTMLTableRowElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableSectionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6275,7 +6689,7 @@ declare var HTMLTableSectionElement: { interface HTMLTemplateElement extends HTMLElement { readonly content: DocumentFragment; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTemplateElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6382,7 +6796,7 @@ interface HTMLTextAreaElement extends HTMLElement { * @param end The offset into the text field for the end of the selection. */ setSelectionRange(start: number, end: number): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTextAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6391,12 +6805,23 @@ declare var HTMLTextAreaElement: { new(): HTMLTextAreaElement; } +interface HTMLTimeElement extends HTMLElement { + dateTime: string; + addEventListener(type: K, listener: (this: HTMLTimeElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTimeElement: { + prototype: HTMLTimeElement; + new(): HTMLTimeElement; +} + interface HTMLTitleElement extends HTMLElement { /** * Retrieves or sets the text of the object as a string. */ text: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTitleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6417,7 +6842,7 @@ interface HTMLTrackElement extends HTMLElement { readonly LOADED: number; readonly LOADING: number; readonly NONE: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTrackElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6433,7 +6858,7 @@ declare var HTMLTrackElement: { interface HTMLUListElement extends HTMLElement { compact: boolean; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLUListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6443,7 +6868,7 @@ declare var HTMLUListElement: { } interface HTMLUnknownElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLUnknownElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6514,7 +6939,21 @@ interface HashChangeEvent extends Event { declare var HashChangeEvent: { prototype: HashChangeEvent; - new(type: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; + new(typeArg: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; +} + +interface Headers { + append(name: string, value: string): void; + delete(name: string): void; + forEach(callback: ForEachCallback): void; + get(name: string): string | null; + has(name: string): boolean; + set(name: string, value: string): void; +} + +declare var Headers: { + prototype: Headers; + new(init?: any): Headers; } interface History { @@ -6568,14 +7007,14 @@ declare var IDBCursorWithValue: { interface IDBDatabaseEventMap { "abort": Event; - "error": ErrorEvent; + "error": Event; } interface IDBDatabase extends EventTarget { readonly name: string; readonly objectStoreNames: DOMStringList; onabort: (this: IDBDatabase, ev: Event) => any; - onerror: (this: IDBDatabase, ev: ErrorEvent) => any; + onerror: (this: IDBDatabase, ev: Event) => any; version: number; onversionchange: (ev: IDBVersionChangeEvent) => any; close(): void; @@ -6678,13 +7117,13 @@ declare var IDBOpenDBRequest: { } interface IDBRequestEventMap { - "error": ErrorEvent; + "error": Event; "success": Event; } interface IDBRequest extends EventTarget { readonly error: DOMError; - onerror: (this: IDBRequest, ev: ErrorEvent) => any; + onerror: (this: IDBRequest, ev: Event) => any; onsuccess: (this: IDBRequest, ev: Event) => any; readonly readyState: string; readonly result: any; @@ -6702,7 +7141,7 @@ declare var IDBRequest: { interface IDBTransactionEventMap { "abort": Event; "complete": Event; - "error": ErrorEvent; + "error": Event; } interface IDBTransaction extends EventTarget { @@ -6711,7 +7150,7 @@ interface IDBTransaction extends EventTarget { readonly mode: string; onabort: (this: IDBTransaction, ev: Event) => any; oncomplete: (this: IDBTransaction, ev: Event) => any; - onerror: (this: IDBTransaction, ev: ErrorEvent) => any; + onerror: (this: IDBTransaction, ev: Event) => any; abort(): void; objectStore(name: string): IDBObjectStore; readonly READ_ONLY: string; @@ -6739,6 +7178,15 @@ declare var IDBVersionChangeEvent: { new(): IDBVersionChangeEvent; } +interface IIRFilterNode extends AudioNode { + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; +} + +declare var IIRFilterNode: { + prototype: IIRFilterNode; + new(): IIRFilterNode; +} + interface ImageData { data: Uint8ClampedArray; readonly height: number; @@ -6751,6 +7199,35 @@ declare var ImageData: { new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +interface IntersectionObserver { + readonly root: Element | null; + readonly rootMargin: string; + readonly thresholds: number[]; + disconnect(): void; + observe(target: Element): void; + takeRecords(): IntersectionObserverEntry[]; + unobserve(target: Element): void; +} + +declare var IntersectionObserver: { + prototype: IntersectionObserver; + new(callback: IntersectionObserverCallback, options?: IntersectionObserverInit): IntersectionObserver; +} + +interface IntersectionObserverEntry { + readonly boundingClientRect: ClientRect; + readonly intersectionRatio: number; + readonly intersectionRect: ClientRect; + readonly rootBounds: ClientRect; + readonly target: Element; + readonly time: number; +} + +declare var IntersectionObserverEntry: { + prototype: IntersectionObserverEntry; + new(intersectionObserverEntryInit: IntersectionObserverEntryInit): IntersectionObserverEntry; +} + interface KeyboardEvent extends UIEvent { readonly altKey: boolean; readonly char: string | null; @@ -6837,7 +7314,7 @@ interface MSApp { execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; getCurrentPriority(): string; - getHtmlPrintDocumentSourceAsync(htmlDoc: any): PromiseLike; + getHtmlPrintDocumentSourceAsync(htmlDoc: any): Promise; getViewId(view: any): any; isTaskScheduledAtPriorityOrHigher(priority: string): boolean; pageHandlesAllApplicationActivations(enabled: boolean): void; @@ -6852,13 +7329,13 @@ declare var MSApp: MSApp; interface MSAppAsyncOperationEventMap { "complete": Event; - "error": ErrorEvent; + "error": Event; } interface MSAppAsyncOperation extends EventTarget { readonly error: DOMError; oncomplete: (this: MSAppAsyncOperation, ev: Event) => any; - onerror: (this: MSAppAsyncOperation, ev: ErrorEvent) => any; + onerror: (this: MSAppAsyncOperation, ev: Event) => any; readonly readyState: number; readonly result: any; start(): void; @@ -6898,8 +7375,8 @@ declare var MSBlobBuilder: { } interface MSCredentials { - getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): PromiseLike; - makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): PromiseLike; + getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): Promise; + makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): Promise; } declare var MSCredentials: { @@ -7015,12 +7492,13 @@ interface MSHTMLWebViewElement extends HTMLElement { goForward(): void; invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; navigate(uri: string): void; + navigateFocus(navigationReason: string, origin: FocusNavigationOrigin): void; navigateToLocalStreamUri(source: string, streamResolver: any): void; navigateToString(contents: string): void; navigateWithHttpRequestMessage(requestMessage: any): void; refresh(): void; stop(): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: MSHTMLWebViewElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7212,7 +7690,7 @@ interface MSStreamReader extends EventTarget, MSBaseReader { readAsBlob(stream: MSStream, size?: number): void; readAsDataURL(stream: MSStream, size?: number): void; readAsText(stream: MSStream, encoding?: string, size?: number): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: MSStreamReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7223,13 +7701,13 @@ declare var MSStreamReader: { interface MSWebViewAsyncOperationEventMap { "complete": Event; - "error": ErrorEvent; + "error": Event; } interface MSWebViewAsyncOperation extends EventTarget { readonly error: DOMError; oncomplete: (this: MSWebViewAsyncOperation, ev: Event) => any; - onerror: (this: MSWebViewAsyncOperation, ev: ErrorEvent) => any; + onerror: (this: MSWebViewAsyncOperation, ev: Event) => any; readonly readyState: number; readonly result: any; readonly target: MSHTMLWebViewElement; @@ -7286,7 +7764,7 @@ interface MediaDevices extends EventTarget { ondevicechange: (this: MediaDevices, ev: Event) => any; enumerateDevices(): any; getSupportedConstraints(): MediaTrackSupportedConstraints; - getUserMedia(constraints: MediaStreamConstraints): PromiseLike; + getUserMedia(constraints: MediaStreamConstraints): Promise; addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7345,15 +7823,15 @@ declare var MediaKeyMessageEvent: { } interface MediaKeySession extends EventTarget { - readonly closed: PromiseLike; + readonly closed: Promise; readonly expiration: number; readonly keyStatuses: MediaKeyStatusMap; readonly sessionId: string; - close(): PromiseLike; - generateRequest(initDataType: string, initData: any): PromiseLike; - load(sessionId: string): PromiseLike; - remove(): PromiseLike; - update(response: any): PromiseLike; + close(): Promise; + generateRequest(initDataType: string, initData: any): Promise; + load(sessionId: string): Promise; + remove(): Promise; + update(response: any): Promise; } declare var MediaKeySession: { @@ -7375,7 +7853,7 @@ declare var MediaKeyStatusMap: { interface MediaKeySystemAccess { readonly keySystem: string; - createMediaKeys(): PromiseLike; + createMediaKeys(): Promise; getConfiguration(): MediaKeySystemConfiguration; } @@ -7386,7 +7864,7 @@ declare var MediaKeySystemAccess: { interface MediaKeys { createSession(sessionType?: string): MediaKeySession; - setServerCertificate(serverCertificate: any): PromiseLike; + setServerCertificate(serverCertificate: any): Promise; } declare var MediaKeys: { @@ -7439,18 +7917,18 @@ declare var MediaSource: { interface MediaStreamEventMap { "active": Event; - "addtrack": TrackEvent; + "addtrack": MediaStreamTrackEvent; "inactive": Event; - "removetrack": TrackEvent; + "removetrack": MediaStreamTrackEvent; } interface MediaStream extends EventTarget { readonly active: boolean; readonly id: string; onactive: (this: MediaStream, ev: Event) => any; - onaddtrack: (this: MediaStream, ev: TrackEvent) => any; + onaddtrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; oninactive: (this: MediaStream, ev: Event) => any; - onremovetrack: (this: MediaStream, ev: TrackEvent) => any; + onremovetrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; addTrack(track: MediaStreamTrack): void; clone(): MediaStream; getAudioTracks(): MediaStreamTrack[]; @@ -7493,7 +7971,16 @@ interface MediaStreamErrorEvent extends Event { declare var MediaStreamErrorEvent: { prototype: MediaStreamErrorEvent; - new(type: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; + new(typeArg: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; +} + +interface MediaStreamEvent extends Event { + readonly stream: MediaStream | null; +} + +declare var MediaStreamEvent: { + prototype: MediaStreamEvent; + new(type: string, eventInitDict: MediaStreamEventInit): MediaStreamEvent; } interface MediaStreamTrackEventMap { @@ -7516,7 +8003,7 @@ interface MediaStreamTrack extends EventTarget { readonly readonly: boolean; readonly readyState: string; readonly remote: boolean; - applyConstraints(constraints: MediaTrackConstraints): PromiseLike; + applyConstraints(constraints: MediaTrackConstraints): Promise; clone(): MediaStreamTrack; getCapabilities(): MediaTrackCapabilities; getConstraints(): MediaTrackConstraints; @@ -7537,7 +8024,7 @@ interface MediaStreamTrackEvent extends Event { declare var MediaStreamTrackEvent: { prototype: MediaStreamTrackEvent; - new(type: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; + new(typeArg: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; } interface MessageChannel { @@ -7570,7 +8057,7 @@ interface MessagePortEventMap { interface MessagePort extends EventTarget { onmessage: (this: MessagePort, ev: MessageEvent) => any; close(): void; - postMessage(message?: any, ports?: any): void; + postMessage(message?: any, transfer?: any[]): void; start(): void; addEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -7732,9 +8219,10 @@ declare var NavigationEventWithReferrer: { new(): NavigationEventWithReferrer; } -interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorUserMedia { - readonly appCodeName: string; +interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia { + readonly authentication: WebAuthentication; readonly cookieEnabled: boolean; + gamepadInputEmulation: string; readonly language: string; readonly maxTouchPoints: number; readonly mimeTypes: MimeTypeArray; @@ -7743,12 +8231,13 @@ interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorConte readonly msPointerEnabled: boolean; readonly plugins: PluginArray; readonly pointerEnabled: boolean; + readonly serviceWorker: ServiceWorkerContainer; readonly webdriver: boolean; readonly hardwareConcurrency: number; getGamepads(): Gamepad[]; javaEnabled(): boolean; msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; - requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): PromiseLike; + requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): Promise; vibrate(pattern: number | number[]): boolean; } @@ -7774,7 +8263,7 @@ interface Node extends EventTarget { readonly parentNode: Node | null; readonly previousSibling: Node | null; textContent: string | null; - appendChild(newChild: Node): Node; + appendChild(newChild: T): T; cloneNode(deep?: boolean): Node; compareDocumentPosition(other: Node): number; contains(child: Node): boolean; @@ -7881,6 +8370,36 @@ declare var NodeList: { new(): NodeList; } +interface NotificationEventMap { + "click": Event; + "close": Event; + "error": Event; + "show": Event; +} + +interface Notification extends EventTarget { + readonly body: string; + readonly dir: string; + readonly icon: string; + readonly lang: string; + onclick: (this: Notification, ev: Event) => any; + onclose: (this: Notification, ev: Event) => any; + onerror: (this: Notification, ev: Event) => any; + onshow: (this: Notification, ev: Event) => any; + readonly permission: string; + readonly tag: string; + readonly title: string; + close(): void; + addEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Notification: { + prototype: Notification; + new(title: string, options?: NotificationOptions): Notification; + requestPermission(callback?: NotificationPermissionCallback): Promise; +} + interface OES_element_index_uint { } @@ -7915,6 +8434,24 @@ declare var OES_texture_float_linear: { new(): OES_texture_float_linear; } +interface OES_texture_half_float { + readonly HALF_FLOAT_OES: number; +} + +declare var OES_texture_half_float: { + prototype: OES_texture_half_float; + new(): OES_texture_half_float; + readonly HALF_FLOAT_OES: number; +} + +interface OES_texture_half_float_linear { +} + +declare var OES_texture_half_float_linear: { + prototype: OES_texture_half_float_linear; + new(): OES_texture_half_float_linear; +} + interface OfflineAudioCompletionEvent extends Event { readonly renderedBuffer: AudioBuffer; } @@ -7924,13 +8461,15 @@ declare var OfflineAudioCompletionEvent: { new(): OfflineAudioCompletionEvent; } -interface OfflineAudioContextEventMap { - "complete": Event; +interface OfflineAudioContextEventMap extends AudioContextEventMap { + "complete": OfflineAudioCompletionEvent; } -interface OfflineAudioContext extends AudioContext { - oncomplete: (this: OfflineAudioContext, ev: Event) => any; - startRendering(): PromiseLike; +interface OfflineAudioContext extends AudioContextBase { + readonly length: number; + oncomplete: (this: OfflineAudioContext, ev: OfflineAudioCompletionEvent) => any; + startRendering(): Promise; + suspend(suspendTime: number): Promise; addEventListener(type: K, listener: (this: OfflineAudioContext, ev: OfflineAudioContextEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8006,6 +8545,82 @@ declare var PannerNode: { new(): PannerNode; } +interface Path2D extends Object, CanvasPathMethods { +} + +declare var Path2D: { + prototype: Path2D; + new(path?: Path2D): Path2D; +} + +interface PaymentAddress { + readonly addressLine: string[]; + readonly city: string; + readonly country: string; + readonly dependentLocality: string; + readonly languageCode: string; + readonly organization: string; + readonly phone: string; + readonly postalCode: string; + readonly recipient: string; + readonly region: string; + readonly sortingCode: string; + toJSON(): any; +} + +declare var PaymentAddress: { + prototype: PaymentAddress; + new(): PaymentAddress; +} + +interface PaymentRequestEventMap { + "shippingaddresschange": Event; + "shippingoptionchange": Event; +} + +interface PaymentRequest extends EventTarget { + onshippingaddresschange: (this: PaymentRequest, ev: Event) => any; + onshippingoptionchange: (this: PaymentRequest, ev: Event) => any; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + readonly shippingType: string | null; + abort(): Promise; + show(): Promise; + addEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var PaymentRequest: { + prototype: PaymentRequest; + new(methodData: PaymentMethodData[], details: PaymentDetails, options?: PaymentOptions): PaymentRequest; +} + +interface PaymentRequestUpdateEvent extends Event { + updateWith(d: Promise): void; +} + +declare var PaymentRequestUpdateEvent: { + prototype: PaymentRequestUpdateEvent; + new(type: string, eventInitDict?: PaymentRequestUpdateEventInit): PaymentRequestUpdateEvent; +} + +interface PaymentResponse { + readonly details: any; + readonly methodName: string; + readonly payerEmail: string | null; + readonly payerName: string | null; + readonly payerPhone: string | null; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + complete(result?: string): Promise; + toJSON(): any; +} + +declare var PaymentResponse: { + prototype: PaymentResponse; + new(): PaymentResponse; +} + interface PerfWidgetExternal { readonly activeNetworkRequestCount: number; readonly averageFrameTime: number; @@ -8271,7 +8886,7 @@ interface PopStateEvent extends Event { declare var PopStateEvent: { prototype: PopStateEvent; - new(): PopStateEvent; + new(typeArg: string, eventInitDict?: PopStateEventInit): PopStateEvent; } interface Position { @@ -8322,23 +8937,57 @@ declare var ProgressEvent: { new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } +interface PushManager { + getSubscription(): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; + subscribe(options?: PushSubscriptionOptionsInit): Promise; +} + +declare var PushManager: { + prototype: PushManager; + new(): PushManager; +} + +interface PushSubscription { + readonly endpoint: USVString; + readonly options: PushSubscriptionOptions; + getKey(name: string): ArrayBuffer | null; + toJSON(): any; + unsubscribe(): Promise; +} + +declare var PushSubscription: { + prototype: PushSubscription; + new(): PushSubscription; +} + +interface PushSubscriptionOptions { + readonly applicationServerKey: ArrayBuffer | null; + readonly userVisibleOnly: boolean; +} + +declare var PushSubscriptionOptions: { + prototype: PushSubscriptionOptions; + new(): PushSubscriptionOptions; +} + interface RTCDTMFToneChangeEvent extends Event { readonly tone: string; } declare var RTCDTMFToneChangeEvent: { prototype: RTCDTMFToneChangeEvent; - new(type: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; + new(typeArg: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; } interface RTCDtlsTransportEventMap { "dtlsstatechange": RTCDtlsTransportStateChangedEvent; - "error": ErrorEvent; + "error": Event; } interface RTCDtlsTransport extends RTCStatsProvider { ondtlsstatechange: ((this: RTCDtlsTransport, ev: RTCDtlsTransportStateChangedEvent) => any) | null; - onerror: ((this: RTCDtlsTransport, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCDtlsTransport, ev: Event) => any) | null; readonly state: string; readonly transport: RTCIceTransport; getLocalParameters(): RTCDtlsParameters; @@ -8385,6 +9034,18 @@ declare var RTCDtmfSender: { new(sender: RTCRtpSender): RTCDtmfSender; } +interface RTCIceCandidate { + candidate: string | null; + sdpMLineIndex: number | null; + sdpMid: string | null; + toJSON(): any; +} + +declare var RTCIceCandidate: { + prototype: RTCIceCandidate; + new(candidateInitDict?: RTCIceCandidateInit): RTCIceCandidate; +} + interface RTCIceCandidatePairChangedEvent extends Event { readonly pair: RTCIceCandidatePair; } @@ -8395,16 +9056,16 @@ declare var RTCIceCandidatePairChangedEvent: { } interface RTCIceGathererEventMap { - "error": ErrorEvent; + "error": Event; "localcandidate": RTCIceGathererEvent; } interface RTCIceGatherer extends RTCStatsProvider { readonly component: string; - onerror: ((this: RTCIceGatherer, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCIceGatherer, ev: Event) => any) | null; onlocalcandidate: ((this: RTCIceGatherer, ev: RTCIceGathererEvent) => any) | null; createAssociatedGatherer(): RTCIceGatherer; - getLocalCandidates(): RTCIceCandidate[]; + getLocalCandidates(): RTCIceCandidateDictionary[]; getLocalParameters(): RTCIceParameters; addEventListener(type: K, listener: (this: RTCIceGatherer, ev: RTCIceGathererEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -8416,7 +9077,7 @@ declare var RTCIceGatherer: { } interface RTCIceGathererEvent extends Event { - readonly candidate: RTCIceCandidate | RTCIceCandidateComplete; + readonly candidate: RTCIceCandidateDictionary | RTCIceCandidateComplete; } declare var RTCIceGathererEvent: { @@ -8436,12 +9097,12 @@ interface RTCIceTransport extends RTCStatsProvider { onicestatechange: ((this: RTCIceTransport, ev: RTCIceTransportStateChangedEvent) => any) | null; readonly role: string; readonly state: string; - addRemoteCandidate(remoteCandidate: RTCIceCandidate | RTCIceCandidateComplete): void; + addRemoteCandidate(remoteCandidate: RTCIceCandidateDictionary | RTCIceCandidateComplete): void; createAssociatedTransport(): RTCIceTransport; getNominatedCandidatePair(): RTCIceCandidatePair | null; - getRemoteCandidates(): RTCIceCandidate[]; + getRemoteCandidates(): RTCIceCandidateDictionary[]; getRemoteParameters(): RTCIceParameters | null; - setRemoteCandidates(remoteCandidates: RTCIceCandidate[]): void; + setRemoteCandidates(remoteCandidates: RTCIceCandidateDictionary[]): void; start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: string): void; stop(): void; addEventListener(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, useCapture?: boolean): void; @@ -8462,12 +9123,67 @@ declare var RTCIceTransportStateChangedEvent: { new(): RTCIceTransportStateChangedEvent; } +interface RTCPeerConnectionEventMap { + "addstream": MediaStreamEvent; + "icecandidate": RTCPeerConnectionIceEvent; + "iceconnectionstatechange": Event; + "icegatheringstatechange": Event; + "negotiationneeded": Event; + "removestream": MediaStreamEvent; + "signalingstatechange": Event; +} + +interface RTCPeerConnection extends EventTarget { + readonly canTrickleIceCandidates: boolean | null; + readonly iceConnectionState: string; + readonly iceGatheringState: string; + readonly localDescription: RTCSessionDescription | null; + onaddstream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onicecandidate: (this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any; + oniceconnectionstatechange: (this: RTCPeerConnection, ev: Event) => any; + onicegatheringstatechange: (this: RTCPeerConnection, ev: Event) => any; + onnegotiationneeded: (this: RTCPeerConnection, ev: Event) => any; + onremovestream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onsignalingstatechange: (this: RTCPeerConnection, ev: Event) => any; + readonly remoteDescription: RTCSessionDescription | null; + readonly signalingState: string; + addIceCandidate(candidate: RTCIceCandidate, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addStream(stream: MediaStream): void; + close(): void; + createAnswer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + createOffer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback, options?: RTCOfferOptions): Promise; + getConfiguration(): RTCConfiguration; + getLocalStreams(): MediaStream[]; + getRemoteStreams(): MediaStream[]; + getStats(selector: MediaStreamTrack | null, successCallback?: RTCStatsCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + getStreamById(streamId: string): MediaStream | null; + removeStream(stream: MediaStream): void; + setLocalDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + setRemoteDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addEventListener(type: K, listener: (this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCPeerConnection: { + prototype: RTCPeerConnection; + new(configuration: RTCConfiguration): RTCPeerConnection; +} + +interface RTCPeerConnectionIceEvent extends Event { + readonly candidate: RTCIceCandidate; +} + +declare var RTCPeerConnectionIceEvent: { + prototype: RTCPeerConnectionIceEvent; + new(type: string, eventInitDict: RTCPeerConnectionIceEventInit): RTCPeerConnectionIceEvent; +} + interface RTCRtpReceiverEventMap { - "error": ErrorEvent; + "error": Event; } interface RTCRtpReceiver extends RTCStatsProvider { - onerror: ((this: RTCRtpReceiver, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCRtpReceiver, ev: Event) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack | null; readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; @@ -8487,12 +9203,12 @@ declare var RTCRtpReceiver: { } interface RTCRtpSenderEventMap { - "error": ErrorEvent; + "error": Event; "ssrcconflict": RTCSsrcConflictEvent; } interface RTCRtpSender extends RTCStatsProvider { - onerror: ((this: RTCRtpSender, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCRtpSender, ev: Event) => any) | null; onssrcconflict: ((this: RTCRtpSender, ev: RTCSsrcConflictEvent) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack; @@ -8511,12 +9227,23 @@ declare var RTCRtpSender: { getCapabilities(kind?: string): RTCRtpCapabilities; } +interface RTCSessionDescription { + sdp: string | null; + type: string | null; + toJSON(): any; +} + +declare var RTCSessionDescription: { + prototype: RTCSessionDescription; + new(descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; +} + interface RTCSrtpSdesTransportEventMap { - "error": ErrorEvent; + "error": Event; } interface RTCSrtpSdesTransport extends EventTarget { - onerror: ((this: RTCSrtpSdesTransport, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCSrtpSdesTransport, ev: Event) => any) | null; readonly transport: RTCIceTransport; addEventListener(type: K, listener: (this: RTCSrtpSdesTransport, ev: RTCSrtpSdesTransportEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -8538,8 +9265,8 @@ declare var RTCSsrcConflictEvent: { } interface RTCStatsProvider extends EventTarget { - getStats(): PromiseLike; - msGetStats(): PromiseLike; + getStats(): Promise; + msGetStats(): Promise; } declare var RTCStatsProvider: { @@ -8591,9 +9318,69 @@ declare var Range: { readonly START_TO_START: number; } -interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface ReadableStream { + readonly locked: boolean; + cancel(): Promise; + getReader(): ReadableStreamReader; +} + +declare var ReadableStream: { + prototype: ReadableStream; + new(): ReadableStream; +} + +interface ReadableStreamReader { + cancel(): Promise; + read(): Promise; + releaseLock(): void; +} + +declare var ReadableStreamReader: { + prototype: ReadableStreamReader; + new(): ReadableStreamReader; +} + +interface Request extends Object, Body { + readonly cache: string; + readonly credentials: string; + readonly destination: string; + readonly headers: Headers; + readonly integrity: string; + readonly keepalive: boolean; + readonly method: string; + readonly mode: string; + readonly redirect: string; + readonly referrer: string; + readonly referrerPolicy: string; + readonly type: string; + readonly url: string; + clone(): Request; +} + +declare var Request: { + prototype: Request; + new(input: Request | string, init?: RequestInit): Request; +} + +interface Response extends Object, Body { + readonly body: ReadableStream | null; + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly type: string; + readonly url: string; + clone(): Response; +} + +declare var Response: { + prototype: Response; + new(body?: any, init?: ResponseInit): Response; +} + +interface SVGAElement extends SVGGraphicsElement, SVGURIReference { readonly target: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8746,11 +9533,11 @@ declare var SVGAnimatedTransformList: { new(): SVGAnimatedTransformList; } -interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGCircleElement extends SVGGraphicsElement { readonly cx: SVGAnimatedLength; readonly cy: SVGAnimatedLength; readonly r: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGCircleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8759,9 +9546,9 @@ declare var SVGCircleElement: { new(): SVGCircleElement; } -interface SVGClipPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { +interface SVGClipPathElement extends SVGGraphicsElement, SVGUnitTypes { readonly clipPathUnits: SVGAnimatedEnumeration; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGClipPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8784,7 +9571,7 @@ interface SVGComponentTransferFunctionElement extends SVGElement { readonly SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; readonly SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGComponentTransferFunctionElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8799,8 +9586,8 @@ declare var SVGComponentTransferFunctionElement: { readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; } -interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGDefsElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGDefsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8809,8 +9596,8 @@ declare var SVGDefsElement: { new(): SVGDefsElement; } -interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGDescElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGDescElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8833,6 +9620,7 @@ interface SVGElementEventMap extends ElementEventMap { } interface SVGElement extends Element { + className: any; onclick: (this: SVGElement, ev: MouseEvent) => any; ondblclick: (this: SVGElement, ev: MouseEvent) => any; onfocusin: (this: SVGElement, ev: FocusEvent) => any; @@ -8844,9 +9632,9 @@ interface SVGElement extends Element { onmouseover: (this: SVGElement, ev: MouseEvent) => any; onmouseup: (this: SVGElement, ev: MouseEvent) => any; readonly ownerSVGElement: SVGSVGElement; + readonly style: CSSStyleDeclaration; readonly viewportElement: SVGElement; xmlbase: string; - className: any; addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8882,12 +9670,12 @@ declare var SVGElementInstanceList: { new(): SVGElementInstanceList; } -interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGEllipseElement extends SVGGraphicsElement { readonly cx: SVGAnimatedLength; readonly cy: SVGAnimatedLength; readonly rx: SVGAnimatedLength; readonly ry: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGEllipseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8917,7 +9705,7 @@ interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttrib readonly SVG_FEBLEND_MODE_SCREEN: number; readonly SVG_FEBLEND_MODE_SOFT_LIGHT: number; readonly SVG_FEBLEND_MODE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEBlendElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8952,7 +9740,7 @@ interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandard readonly SVG_FECOLORMATRIX_TYPE_MATRIX: number; readonly SVG_FECOLORMATRIX_TYPE_SATURATE: number; readonly SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEColorMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8968,7 +9756,7 @@ declare var SVGFEColorMatrixElement: { interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEComponentTransferElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8992,7 +9780,7 @@ interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAt readonly SVG_FECOMPOSITE_OPERATOR_OVER: number; readonly SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; readonly SVG_FECOMPOSITE_OPERATOR_XOR: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFECompositeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9025,7 +9813,7 @@ interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStand readonly SVG_EDGEMODE_NONE: number; readonly SVG_EDGEMODE_UNKNOWN: number; readonly SVG_EDGEMODE_WRAP: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEConvolveMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9044,7 +9832,7 @@ interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStan readonly kernelUnitLengthX: SVGAnimatedNumber; readonly kernelUnitLengthY: SVGAnimatedNumber; readonly surfaceScale: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDiffuseLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9064,7 +9852,7 @@ interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStan readonly SVG_CHANNEL_G: number; readonly SVG_CHANNEL_R: number; readonly SVG_CHANNEL_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDisplacementMapElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9081,7 +9869,7 @@ declare var SVGFEDisplacementMapElement: { interface SVGFEDistantLightElement extends SVGElement { readonly azimuth: SVGAnimatedNumber; readonly elevation: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDistantLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9091,7 +9879,7 @@ declare var SVGFEDistantLightElement: { } interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEFloodElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9101,6 +9889,8 @@ declare var SVGFEFloodElement: { } interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncAElement: { @@ -9109,6 +9899,8 @@ declare var SVGFEFuncAElement: { } interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncBElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncBElement: { @@ -9117,6 +9909,8 @@ declare var SVGFEFuncBElement: { } interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncGElement: { @@ -9125,6 +9919,8 @@ declare var SVGFEFuncGElement: { } interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncRElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncRElement: { @@ -9137,7 +9933,7 @@ interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandar readonly stdDeviationX: SVGAnimatedNumber; readonly stdDeviationY: SVGAnimatedNumber; setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEGaussianBlurElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9146,9 +9942,9 @@ declare var SVGFEGaussianBlurElement: { new(): SVGFEGaussianBlurElement; } -interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { +interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGURIReference { readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9158,7 +9954,7 @@ declare var SVGFEImageElement: { } interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMergeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9169,7 +9965,7 @@ declare var SVGFEMergeElement: { interface SVGFEMergeNodeElement extends SVGElement { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMergeNodeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9186,7 +9982,7 @@ interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardA readonly SVG_MORPHOLOGY_OPERATOR_DILATE: number; readonly SVG_MORPHOLOGY_OPERATOR_ERODE: number; readonly SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMorphologyElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9202,7 +9998,7 @@ interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttri readonly dx: SVGAnimatedNumber; readonly dy: SVGAnimatedNumber; readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEOffsetElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9215,7 +10011,7 @@ interface SVGFEPointLightElement extends SVGElement { readonly x: SVGAnimatedNumber; readonly y: SVGAnimatedNumber; readonly z: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEPointLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9231,7 +10027,7 @@ interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveSta readonly specularConstant: SVGAnimatedNumber; readonly specularExponent: SVGAnimatedNumber; readonly surfaceScale: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFESpecularLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9249,7 +10045,7 @@ interface SVGFESpotLightElement extends SVGElement { readonly x: SVGAnimatedNumber; readonly y: SVGAnimatedNumber; readonly z: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFESpotLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9260,7 +10056,7 @@ declare var SVGFESpotLightElement: { interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFETileElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9282,7 +10078,7 @@ interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardA readonly SVG_TURBULENCE_TYPE_FRACTALNOISE: number; readonly SVG_TURBULENCE_TYPE_TURBULENCE: number; readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFETurbulenceElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9297,7 +10093,7 @@ declare var SVGFETurbulenceElement: { readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; } -interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGURIReference { readonly filterResX: SVGAnimatedInteger; readonly filterResY: SVGAnimatedInteger; readonly filterUnits: SVGAnimatedEnumeration; @@ -9307,7 +10103,7 @@ interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLan readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; setFilterRes(filterResX: number, filterResY: number): void; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFilterElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9316,12 +10112,12 @@ declare var SVGFilterElement: { new(): SVGFilterElement; } -interface SVGForeignObjectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGForeignObjectElement extends SVGGraphicsElement { readonly height: SVGAnimatedLength; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGForeignObjectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9330,8 +10126,8 @@ declare var SVGForeignObjectElement: { new(): SVGForeignObjectElement; } -interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGGElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9340,7 +10136,7 @@ declare var SVGGElement: { new(): SVGGElement; } -interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourcesRequired, SVGURIReference, SVGUnitTypes { +interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGURIReference { readonly gradientTransform: SVGAnimatedTransformList; readonly gradientUnits: SVGAnimatedEnumeration; readonly spreadMethod: SVGAnimatedEnumeration; @@ -9348,7 +10144,7 @@ interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourc readonly SVG_SPREADMETHOD_REFLECT: number; readonly SVG_SPREADMETHOD_REPEAT: number; readonly SVG_SPREADMETHOD_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9361,13 +10157,30 @@ declare var SVGGradientElement: { readonly SVG_SPREADMETHOD_UNKNOWN: number; } -interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface SVGGraphicsElement extends SVGElement, SVGTests { + readonly farthestViewportElement: SVGElement; + readonly nearestViewportElement: SVGElement; + readonly transform: SVGAnimatedTransformList; + getBBox(): SVGRect; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; + getTransformToElement(element: SVGElement): SVGMatrix; + addEventListener(type: K, listener: (this: SVGGraphicsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGraphicsElement: { + prototype: SVGGraphicsElement; + new(): SVGGraphicsElement; +} + +interface SVGImageElement extends SVGGraphicsElement, SVGURIReference { readonly height: SVGAnimatedLength; readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9428,12 +10241,12 @@ declare var SVGLengthList: { new(): SVGLengthList; } -interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGLineElement extends SVGGraphicsElement { readonly x1: SVGAnimatedLength; readonly x2: SVGAnimatedLength; readonly y1: SVGAnimatedLength; readonly y2: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGLineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9447,6 +10260,8 @@ interface SVGLinearGradientElement extends SVGGradientElement { readonly x2: SVGAnimatedLength; readonly y1: SVGAnimatedLength; readonly y2: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGLinearGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGLinearGradientElement: { @@ -9454,7 +10269,7 @@ declare var SVGLinearGradientElement: { new(): SVGLinearGradientElement; } -interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { +interface SVGMarkerElement extends SVGElement, SVGFitToViewBox { readonly markerHeight: SVGAnimatedLength; readonly markerUnits: SVGAnimatedEnumeration; readonly markerWidth: SVGAnimatedLength; @@ -9470,7 +10285,7 @@ interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExt readonly SVG_MARKER_ORIENT_ANGLE: number; readonly SVG_MARKER_ORIENT_AUTO: number; readonly SVG_MARKER_ORIENT_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMarkerElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9485,14 +10300,14 @@ declare var SVGMarkerElement: { readonly SVG_MARKER_ORIENT_UNKNOWN: number; } -interface SVGMaskElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { +interface SVGMaskElement extends SVGElement, SVGTests, SVGUnitTypes { readonly height: SVGAnimatedLength; readonly maskContentUnits: SVGAnimatedEnumeration; readonly maskUnits: SVGAnimatedEnumeration; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMaskElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9527,7 +10342,7 @@ declare var SVGMatrix: { } interface SVGMetadataElement extends SVGElement { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMetadataElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9561,7 +10376,8 @@ declare var SVGNumberList: { new(): SVGNumberList; } -interface SVGPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPathData { +interface SVGPathElement extends SVGGraphicsElement { + readonly pathSegList: SVGPathSegList; createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; createSVGPathSegClosePath(): SVGPathSegClosePath; @@ -9584,7 +10400,7 @@ interface SVGPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGT getPathSegAtLength(distance: number): number; getPointAtLength(distance: number): SVGPoint; getTotalLength(): number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9869,7 +10685,7 @@ declare var SVGPathSegMovetoRel: { new(): SVGPathSegMovetoRel; } -interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGURIReference, SVGUnitTypes { +interface SVGPatternElement extends SVGElement, SVGTests, SVGUnitTypes, SVGFitToViewBox, SVGURIReference { readonly height: SVGAnimatedLength; readonly patternContentUnits: SVGAnimatedEnumeration; readonly patternTransform: SVGAnimatedTransformList; @@ -9877,7 +10693,7 @@ interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSp readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGPatternElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9913,8 +10729,8 @@ declare var SVGPointList: { new(): SVGPointList; } -interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGPolygonElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolygonElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9923,8 +10739,8 @@ declare var SVGPolygonElement: { new(): SVGPolygonElement; } -interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGPolylineElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolylineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9977,6 +10793,8 @@ interface SVGRadialGradientElement extends SVGGradientElement { readonly fx: SVGAnimatedLength; readonly fy: SVGAnimatedLength; readonly r: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGRadialGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGRadialGradientElement: { @@ -9996,14 +10814,14 @@ declare var SVGRect: { new(): SVGRect; } -interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGRectElement extends SVGGraphicsElement { readonly height: SVGAnimatedLength; readonly rx: SVGAnimatedLength; readonly ry: SVGAnimatedLength; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGRectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10021,7 +10839,7 @@ interface SVGSVGElementEventMap extends SVGElementEventMap { "SVGZoom": SVGZoomEvent; } -interface SVGSVGElement extends SVGElement, DocumentEvent, SVGLocatable, SVGTests, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { +interface SVGSVGElement extends SVGGraphicsElement, DocumentEvent, SVGFitToViewBox, SVGZoomAndPan { contentScriptType: string; contentStyleType: string; currentScale: number; @@ -10073,9 +10891,9 @@ declare var SVGSVGElement: { new(): SVGSVGElement; } -interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { +interface SVGScriptElement extends SVGElement, SVGURIReference { type: string; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGScriptElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10084,9 +10902,9 @@ declare var SVGScriptElement: { new(): SVGScriptElement; } -interface SVGStopElement extends SVGElement, SVGStylable { +interface SVGStopElement extends SVGElement { readonly offset: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGStopElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10111,12 +10929,12 @@ declare var SVGStringList: { new(): SVGStringList; } -interface SVGStyleElement extends SVGElement, SVGLangSpace { +interface SVGStyleElement extends SVGElement { disabled: boolean; media: string; title: string; type: string; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGStyleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10125,8 +10943,8 @@ declare var SVGStyleElement: { new(): SVGStyleElement; } -interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGSwitchElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGSwitchElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10135,8 +10953,8 @@ declare var SVGSwitchElement: { new(): SVGSwitchElement; } -interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGSymbolElement extends SVGElement, SVGFitToViewBox { + addEventListener(type: K, listener: (this: SVGSymbolElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10146,6 +10964,8 @@ declare var SVGSymbolElement: { } interface SVGTSpanElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTSpanElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTSpanElement: { @@ -10153,7 +10973,7 @@ declare var SVGTSpanElement: { new(): SVGTSpanElement; } -interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGTextContentElement extends SVGGraphicsElement { readonly lengthAdjust: SVGAnimatedEnumeration; readonly textLength: SVGAnimatedLength; getCharNumAtPosition(point: SVGPoint): number; @@ -10168,7 +10988,7 @@ interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLa readonly LENGTHADJUST_SPACING: number; readonly LENGTHADJUST_SPACINGANDGLYPHS: number; readonly LENGTHADJUST_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGTextContentElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10180,7 +11000,9 @@ declare var SVGTextContentElement: { readonly LENGTHADJUST_UNKNOWN: number; } -interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { +interface SVGTextElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTextElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextElement: { @@ -10198,6 +11020,8 @@ interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { readonly TEXTPATH_SPACINGTYPE_AUTO: number; readonly TEXTPATH_SPACINGTYPE_EXACT: number; readonly TEXTPATH_SPACINGTYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGTextPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextPathElement: { @@ -10217,6 +11041,8 @@ interface SVGTextPositioningElement extends SVGTextContentElement { readonly rotate: SVGAnimatedNumberList; readonly x: SVGAnimatedLengthList; readonly y: SVGAnimatedLengthList; + addEventListener(type: K, listener: (this: SVGTextPositioningElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextPositioningElement: { @@ -10224,8 +11050,8 @@ declare var SVGTextPositioningElement: { new(): SVGTextPositioningElement; } -interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGTitleElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGTitleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10290,14 +11116,14 @@ interface SVGUnitTypes { } declare var SVGUnitTypes: SVGUnitTypes; -interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface SVGUseElement extends SVGGraphicsElement, SVGURIReference { readonly animatedInstanceRoot: SVGElementInstance; readonly height: SVGAnimatedLength; readonly instanceRoot: SVGElementInstance; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGUseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10306,9 +11132,9 @@ declare var SVGUseElement: { new(): SVGUseElement; } -interface SVGViewElement extends SVGElement, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { +interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox { readonly viewTarget: SVGStringList; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGViewElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10340,6 +11166,26 @@ declare var SVGZoomEvent: { new(): SVGZoomEvent; } +interface ScopedCredential { + readonly id: ArrayBuffer; + readonly type: string; +} + +declare var ScopedCredential: { + prototype: ScopedCredential; + new(): ScopedCredential; +} + +interface ScopedCredentialInfo { + readonly credential: ScopedCredential; + readonly publicKey: CryptoKey; +} + +declare var ScopedCredentialInfo: { + prototype: ScopedCredentialInfo; + new(): ScopedCredentialInfo; +} + interface ScreenEventMap { "MSOrientationChange": Event; } @@ -10401,6 +11247,10 @@ declare var ScriptProcessorNode: { interface Selection { readonly anchorNode: Node; readonly anchorOffset: number; + readonly baseNode: Node; + readonly baseOffset: number; + readonly extentNode: Node; + readonly extentOffset: number; readonly focusNode: Node; readonly focusOffset: number; readonly isCollapsed: boolean; @@ -10419,6 +11269,7 @@ interface Selection { removeRange(range: Range): void; selectAllChildren(parentNode: Node): void; setBaseAndExtent(baseNode: Node, baseOffset: number, extentNode: Node, extentOffset: number): void; + setPosition(parentNode: Node, offset: number): void; toString(): string; } @@ -10427,6 +11278,84 @@ declare var Selection: { new(): Selection; } +interface ServiceWorkerEventMap extends AbstractWorkerEventMap { + "statechange": Event; +} + +interface ServiceWorker extends EventTarget, AbstractWorker { + onstatechange: (this: ServiceWorker, ev: Event) => any; + readonly scriptURL: USVString; + readonly state: string; + postMessage(message: any, transfer?: any[]): void; + addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorker: { + prototype: ServiceWorker; + new(): ServiceWorker; +} + +interface ServiceWorkerContainerEventMap { + "controllerchange": Event; + "message": ServiceWorkerMessageEvent; +} + +interface ServiceWorkerContainer extends EventTarget { + readonly controller: ServiceWorker | null; + oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; + onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; + readonly ready: Promise; + getRegistration(clientURL?: USVString): Promise; + getRegistrations(): any; + register(scriptURL: USVString, options?: RegistrationOptions): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerContainer: { + prototype: ServiceWorkerContainer; + new(): ServiceWorkerContainer; +} + +interface ServiceWorkerMessageEvent extends Event { + readonly data: any; + readonly lastEventId: string; + readonly origin: string; + readonly ports: MessagePort[] | null; + readonly source: ServiceWorker | MessagePort | null; +} + +declare var ServiceWorkerMessageEvent: { + prototype: ServiceWorkerMessageEvent; + new(type: string, eventInitDict?: ServiceWorkerMessageEventInit): ServiceWorkerMessageEvent; +} + +interface ServiceWorkerRegistrationEventMap { + "updatefound": Event; +} + +interface ServiceWorkerRegistration extends EventTarget { + readonly active: ServiceWorker | null; + readonly installing: ServiceWorker | null; + onupdatefound: (this: ServiceWorkerRegistration, ev: Event) => any; + readonly pushManager: PushManager; + readonly scope: USVString; + readonly sync: SyncManager; + readonly waiting: ServiceWorker | null; + getNotifications(filter?: GetNotificationOptions): any; + showNotification(title: string, options?: NotificationOptions): Promise; + unregister(): Promise; + update(): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerRegistration: { + prototype: ServiceWorkerRegistration; + new(): ServiceWorkerRegistration; +} + interface SourceBuffer extends EventTarget { appendWindowEnd: number; appendWindowStart: number; @@ -10458,6 +11387,87 @@ declare var SourceBufferList: { new(): SourceBufferList; } +interface SpeechSynthesisEventMap { + "voiceschanged": Event; +} + +interface SpeechSynthesis extends EventTarget { + onvoiceschanged: (this: SpeechSynthesis, ev: Event) => any; + readonly paused: boolean; + readonly pending: boolean; + readonly speaking: boolean; + cancel(): void; + getVoices(): SpeechSynthesisVoice[]; + pause(): void; + resume(): void; + speak(utterance: SpeechSynthesisUtterance): void; + addEventListener(type: K, listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesis: { + prototype: SpeechSynthesis; + new(): SpeechSynthesis; +} + +interface SpeechSynthesisEvent extends Event { + readonly charIndex: number; + readonly elapsedTime: number; + readonly name: string; + readonly utterance: SpeechSynthesisUtterance | null; +} + +declare var SpeechSynthesisEvent: { + prototype: SpeechSynthesisEvent; + new(type: string, eventInitDict?: SpeechSynthesisEventInit): SpeechSynthesisEvent; +} + +interface SpeechSynthesisUtteranceEventMap { + "boundary": Event; + "end": Event; + "error": Event; + "mark": Event; + "pause": Event; + "resume": Event; + "start": Event; +} + +interface SpeechSynthesisUtterance extends EventTarget { + lang: string; + onboundary: (this: SpeechSynthesisUtterance, ev: Event) => any; + onend: (this: SpeechSynthesisUtterance, ev: Event) => any; + onerror: (this: SpeechSynthesisUtterance, ev: Event) => any; + onmark: (this: SpeechSynthesisUtterance, ev: Event) => any; + onpause: (this: SpeechSynthesisUtterance, ev: Event) => any; + onresume: (this: SpeechSynthesisUtterance, ev: Event) => any; + onstart: (this: SpeechSynthesisUtterance, ev: Event) => any; + pitch: number; + rate: number; + text: string; + voice: SpeechSynthesisVoice; + volume: number; + addEventListener(type: K, listener: (this: SpeechSynthesisUtterance, ev: SpeechSynthesisUtteranceEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesisUtterance: { + prototype: SpeechSynthesisUtterance; + new(text?: string): SpeechSynthesisUtterance; +} + +interface SpeechSynthesisVoice { + readonly default: boolean; + readonly lang: string; + readonly localService: boolean; + readonly name: string; + readonly voiceURI: string; +} + +declare var SpeechSynthesisVoice: { + prototype: SpeechSynthesisVoice; + new(): SpeechSynthesisVoice; +} + interface StereoPannerNode extends AudioNode { readonly pan: AudioParam; } @@ -10569,6 +11579,16 @@ declare var SubtleCrypto: { new(): SubtleCrypto; } +interface SyncManager { + getTags(): any; + register(tag: string): Promise; +} + +declare var SyncManager: { + prototype: SyncManager; + new(): SyncManager; +} + interface Text extends CharacterData { readonly wholeText: string; readonly assignedSlot: HTMLSlotElement | null; @@ -10623,7 +11643,7 @@ declare var TextMetrics: { interface TextTrackEventMap { "cuechange": Event; - "error": ErrorEvent; + "error": Event; "load": Event; } @@ -10636,7 +11656,7 @@ interface TextTrack extends EventTarget { readonly language: string; mode: any; oncuechange: (this: TextTrack, ev: Event) => any; - onerror: (this: TextTrack, ev: ErrorEvent) => any; + onerror: (this: TextTrack, ev: Event) => any; onload: (this: TextTrack, ev: Event) => any; readonly readyState: number; addCue(cue: TextTrackCue): void; @@ -10748,11 +11768,14 @@ declare var Touch: { interface TouchEvent extends UIEvent { readonly altKey: boolean; readonly changedTouches: TouchList; + readonly charCode: number; readonly ctrlKey: boolean; + readonly keyCode: number; readonly metaKey: boolean; readonly shiftKey: boolean; readonly targetTouches: TouchList; readonly touches: TouchList; + readonly which: number; } declare var TouchEvent: { @@ -10772,12 +11795,12 @@ declare var TouchList: { } interface TrackEvent extends Event { - readonly track: any; + readonly track: VideoTrack | AudioTrack | TextTrack | null; } declare var TrackEvent: { prototype: TrackEvent; - new(): TrackEvent; + new(typeArg: string, eventInitDict?: TrackEventInit): TrackEvent; } interface TransitionEvent extends Event { @@ -10788,7 +11811,7 @@ interface TransitionEvent extends Event { declare var TransitionEvent: { prototype: TransitionEvent; - new(): TransitionEvent; + new(typeArg: string, eventInitDict?: TransitionEventInit): TransitionEvent; } interface TreeWalker { @@ -10819,7 +11842,7 @@ interface UIEvent extends Event { declare var UIEvent: { prototype: UIEvent; - new(type: string, eventInitDict?: UIEventInit): UIEvent; + new(typeArg: string, eventInitDict?: UIEventInit): UIEvent; } interface URL { @@ -10834,6 +11857,7 @@ interface URL { protocol: string; search: string; username: string; + readonly searchparams: URLSearchParams; toString(): string; } @@ -10970,6 +11994,28 @@ declare var WaveShaperNode: { new(): WaveShaperNode; } +interface WebAuthentication { + getAssertion(assertionChallenge: any, options?: AssertionOptions): Promise; + makeCredential(accountInformation: Account, cryptoParameters: ScopedCredentialParameters[], attestationChallenge: any, options?: ScopedCredentialOptions): Promise; +} + +declare var WebAuthentication: { + prototype: WebAuthentication; + new(): WebAuthentication; +} + +interface WebAuthnAssertion { + readonly authenticatorData: ArrayBuffer; + readonly clientData: ArrayBuffer; + readonly credential: ScopedCredential; + readonly signature: ArrayBuffer; +} + +declare var WebAuthnAssertion: { + prototype: WebAuthnAssertion; + new(): WebAuthnAssertion; +} + interface WebGLActiveInfo { readonly name: string; readonly size: number; @@ -10995,7 +12041,7 @@ interface WebGLContextEvent extends Event { declare var WebGLContextEvent: { prototype: WebGLContextEvent; - new(type: string, eventInitDict?: WebGLContextEventInit): WebGLContextEvent; + new(typeArg: string, eventInitDict?: WebGLContextEventInit): WebGLContextEvent; } interface WebGLFramebuffer extends WebGLObject { @@ -11122,7 +12168,7 @@ interface WebGLRenderingContext { isTexture(texture: WebGLTexture | null): boolean; lineWidth(width: number): void; linkProgram(program: WebGLProgram | null): void; - pixelStorei(pname: number, param: number): void; + pixelStorei(pname: number, param: number | boolean): void; polygonOffset(factor: number, units: number): void; readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): void; renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; @@ -11848,6 +12894,56 @@ declare var WebKitCSSMatrix: { new(text?: string): WebKitCSSMatrix; } +interface WebKitDirectoryEntry extends WebKitEntry { + createReader(): WebKitDirectoryReader; +} + +declare var WebKitDirectoryEntry: { + prototype: WebKitDirectoryEntry; + new(): WebKitDirectoryEntry; +} + +interface WebKitDirectoryReader { + readEntries(successCallback: WebKitEntriesCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitDirectoryReader: { + prototype: WebKitDirectoryReader; + new(): WebKitDirectoryReader; +} + +interface WebKitEntry { + readonly filesystem: WebKitFileSystem; + readonly fullPath: string; + readonly isDirectory: boolean; + readonly isFile: boolean; + readonly name: string; +} + +declare var WebKitEntry: { + prototype: WebKitEntry; + new(): WebKitEntry; +} + +interface WebKitFileEntry extends WebKitEntry { + file(successCallback: WebKitFileCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitFileEntry: { + prototype: WebKitFileEntry; + new(): WebKitFileEntry; +} + +interface WebKitFileSystem { + readonly name: string; + readonly root: WebKitDirectoryEntry; +} + +declare var WebKitFileSystem: { + prototype: WebKitFileSystem; + new(): WebKitFileSystem; +} + interface WebKitPoint { x: number; y: number; @@ -11860,7 +12956,7 @@ declare var WebKitPoint: { interface WebSocketEventMap { "close": CloseEvent; - "error": ErrorEvent; + "error": Event; "message": MessageEvent; "open": Event; } @@ -11870,7 +12966,7 @@ interface WebSocket extends EventTarget { readonly bufferedAmount: number; readonly extensions: string; onclose: (this: WebSocket, ev: CloseEvent) => any; - onerror: (this: WebSocket, ev: ErrorEvent) => any; + onerror: (this: WebSocket, ev: Event) => any; onmessage: (this: WebSocket, ev: MessageEvent) => any; onopen: (this: WebSocket, ev: Event) => any; readonly protocol: string; @@ -12007,8 +13103,9 @@ interface WindowEventMap extends GlobalEventHandlersEventMap { "waiting": Event; } -interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64 { +interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch { readonly applicationCache: ApplicationCache; + readonly caches: CacheStorage; readonly clientInformation: Navigator; readonly closed: boolean; readonly crypto: Crypto; @@ -12023,10 +13120,12 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly history: History; readonly innerHeight: number; readonly innerWidth: number; + readonly isSecureContext: boolean; readonly length: number; readonly location: Location; readonly locationbar: BarProp; readonly menubar: BarProp; + readonly msContentScript: ExtensionScriptApis; readonly msCredentials: MSCredentials; name: string; readonly navigator: Navigator; @@ -12140,6 +13239,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly scrollY: number; readonly scrollbars: BarProp; readonly self: Window; + readonly speechSynthesis: SpeechSynthesis; status: string; readonly statusbar: BarProp; readonly styleMedia: StyleMedia; @@ -12148,12 +13248,14 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly window: Window; URL: typeof URL; Blob: typeof Blob; + customElements: CustomElementRegistry; alert(message?: any): void; blur(): void; cancelAnimationFrame(handle: number): void; captureEvents(): void; close(): void; confirm(message?: string): boolean; + departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; focus(): void; getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -12173,6 +13275,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window scroll(x?: number, y?: number): void; scrollBy(x?: number, y?: number): void; scrollTo(x?: number, y?: number): void; + stop(): void; webkitCancelAnimationFrame(handle: number): void; webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; @@ -12195,7 +13298,7 @@ interface WorkerEventMap extends AbstractWorkerEventMap { interface Worker extends EventTarget, AbstractWorker { onmessage: (this: Worker, ev: MessageEvent) => any; - postMessage(message: any, ports?: any): void; + postMessage(message: any, transfer?: any[]): void; terminate(): void; addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -12207,7 +13310,7 @@ declare var Worker: { } interface XMLDocument extends Document { - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12226,14 +13329,14 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly response: any; readonly responseText: string; responseType: string; - readonly responseXML: any; + readonly responseURL: string; + readonly responseXML: Document | null; readonly status: number; readonly statusText: string; timeout: number; readonly upload: XMLHttpRequestUpload; withCredentials: boolean; msCaching?: string; - readonly responseURL: string; abort(): void; getAllResponseHeaders(): string; getResponseHeader(header: string): string | null; @@ -12261,11 +13364,10 @@ declare var XMLHttpRequest: { readonly LOADING: number; readonly OPENED: number; readonly UNSENT: number; - create(): XMLHttpRequest; } interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { - addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12365,6 +13467,16 @@ declare var XSLTProcessor: { new(): XSLTProcessor; } +interface webkitRTCPeerConnection extends RTCPeerConnection { + addEventListener(type: K, listener: (this: webkitRTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var webkitRTCPeerConnection: { + prototype: webkitRTCPeerConnection; + new(configuration: RTCConfiguration): webkitRTCPeerConnection; +} + interface AbstractWorkerEventMap { "error": ErrorEvent; } @@ -12375,6 +13487,14 @@ interface AbstractWorker { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface Body { + readonly bodyUsed: boolean; + arrayBuffer(): Promise; + blob(): Promise; + json(): Promise; + text(): Promise; +} + interface CanvasPathMethods { arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; @@ -12401,12 +13521,10 @@ interface DOML2DeprecatedSizeProperty { interface DocumentEvent { createEvent(eventInterface:"AnimationEvent"): AnimationEvent; - createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent; createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent; createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent; createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent; createEvent(eventInterface:"CloseEvent"): CloseEvent; - createEvent(eventInterface:"CommandEvent"): CommandEvent; createEvent(eventInterface:"CompositionEvent"): CompositionEvent; createEvent(eventInterface:"CustomEvent"): CustomEvent; createEvent(eventInterface:"DeviceLightEvent"): DeviceLightEvent; @@ -12417,6 +13535,7 @@ interface DocumentEvent { createEvent(eventInterface:"Event"): Event; createEvent(eventInterface:"Events"): Event; createEvent(eventInterface:"FocusEvent"): FocusEvent; + createEvent(eventInterface:"FocusNavigationEvent"): FocusNavigationEvent; createEvent(eventInterface:"GamepadEvent"): GamepadEvent; createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; createEvent(eventInterface:"IDBVersionChangeEvent"): IDBVersionChangeEvent; @@ -12432,6 +13551,7 @@ interface DocumentEvent { createEvent(eventInterface:"MediaEncryptedEvent"): MediaEncryptedEvent; createEvent(eventInterface:"MediaKeyMessageEvent"): MediaKeyMessageEvent; createEvent(eventInterface:"MediaStreamErrorEvent"): MediaStreamErrorEvent; + createEvent(eventInterface:"MediaStreamEvent"): MediaStreamEvent; createEvent(eventInterface:"MediaStreamTrackEvent"): MediaStreamTrackEvent; createEvent(eventInterface:"MessageEvent"): MessageEvent; createEvent(eventInterface:"MouseEvent"): MouseEvent; @@ -12444,6 +13564,7 @@ interface DocumentEvent { createEvent(eventInterface:"OfflineAudioCompletionEvent"): OfflineAudioCompletionEvent; createEvent(eventInterface:"OverflowEvent"): OverflowEvent; createEvent(eventInterface:"PageTransitionEvent"): PageTransitionEvent; + createEvent(eventInterface:"PaymentRequestUpdateEvent"): PaymentRequestUpdateEvent; createEvent(eventInterface:"PermissionRequestedEvent"): PermissionRequestedEvent; createEvent(eventInterface:"PointerEvent"): PointerEvent; createEvent(eventInterface:"PopStateEvent"): PopStateEvent; @@ -12453,10 +13574,13 @@ interface DocumentEvent { createEvent(eventInterface:"RTCIceCandidatePairChangedEvent"): RTCIceCandidatePairChangedEvent; createEvent(eventInterface:"RTCIceGathererEvent"): RTCIceGathererEvent; createEvent(eventInterface:"RTCIceTransportStateChangedEvent"): RTCIceTransportStateChangedEvent; + createEvent(eventInterface:"RTCPeerConnectionIceEvent"): RTCPeerConnectionIceEvent; createEvent(eventInterface:"RTCSsrcConflictEvent"): RTCSsrcConflictEvent; createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; + createEvent(eventInterface:"ServiceWorkerMessageEvent"): ServiceWorkerMessageEvent; + createEvent(eventInterface:"SpeechSynthesisEvent"): SpeechSynthesisEvent; createEvent(eventInterface:"StorageEvent"): StorageEvent; createEvent(eventInterface:"TextEvent"): TextEvent; createEvent(eventInterface:"TouchEvent"): TouchEvent; @@ -12472,10 +13596,10 @@ interface DocumentEvent { interface ElementTraversal { readonly childElementCount: number; - readonly firstElementChild: Element; - readonly lastElementChild: Element; - readonly nextElementSibling: Element; - readonly previousElementSibling: Element; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; + readonly nextElementSibling: Element | null; + readonly previousElementSibling: Element | null; } interface GetSVGDocument { @@ -12508,6 +13632,10 @@ interface GlobalEventHandlers { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface GlobalFetch { + fetch(input: RequestInfo, init?: RequestInit): Promise; +} + interface HTMLTableAlignment { /** * Sets or retrieves a value that you can use to implement your own ch functionality for the object. @@ -12571,6 +13699,14 @@ interface MSNavigatorDoNotTrack { storeWebWideTrackingException(args: StoreExceptionsInformation): void; } +interface NavigatorBeacon { + sendBeacon(url: USVString, data?: BodyInit): boolean; +} + +interface NavigatorConcurrentHardware { + readonly hardwareConcurrency: number; +} + interface NavigatorContentUtils { } @@ -12579,6 +13715,7 @@ interface NavigatorGeolocation { } interface NavigatorID { + readonly appCodeName: string; readonly appName: string; readonly appVersion: string; readonly platform: string; @@ -12612,20 +13749,12 @@ interface RandomSource { getRandomValues(array: ArrayBufferView): ArrayBufferView; } -interface SVGAnimatedPathData { - readonly pathSegList: SVGPathSegList; -} - interface SVGAnimatedPoints { readonly animatedPoints: SVGPointList; readonly points: SVGPointList; } -interface SVGExternalResourcesRequired { - readonly externalResourcesRequired: SVGAnimatedBoolean; -} - -interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { +interface SVGFilterPrimitiveStandardAttributes { readonly height: SVGAnimatedLength; readonly result: SVGAnimatedString; readonly width: SVGAnimatedLength; @@ -12638,25 +13767,6 @@ interface SVGFitToViewBox { readonly viewBox: SVGAnimatedRect; } -interface SVGLangSpace { - xmllang: string; - xmlspace: string; -} - -interface SVGLocatable { - readonly farthestViewportElement: SVGElement; - readonly nearestViewportElement: SVGElement; - getBBox(): SVGRect; - getCTM(): SVGMatrix; - getScreenCTM(): SVGMatrix; - getTransformToElement(element: SVGElement): SVGMatrix; -} - -interface SVGStylable { - className: any; - readonly style: CSSStyleDeclaration; -} - interface SVGTests { readonly requiredExtensions: SVGStringList; readonly requiredFeatures: SVGStringList; @@ -12664,10 +13774,6 @@ interface SVGTests { hasExtension(extension: string): boolean; } -interface SVGTransformable extends SVGLocatable { - readonly transform: SVGAnimatedTransformList; -} - interface SVGURIReference { readonly href: SVGAnimatedString; } @@ -12726,6 +13832,14 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface ErrorEventInit { + message?: string; + filename?: string; + lineno?: number; + conlno?: number; + error?: any; +} + interface StorageEventInit extends EventInit { key?: string; oldValue?: string; @@ -12741,6 +13855,41 @@ interface Canvas2DContextAttributes { [attribute: string]: boolean | string | undefined; } +interface URLSearchParams { + /** + * Appends a specified key/value pair as a new search parameter. + */ + append(name: string, value: string): void; + /** + * Deletes the given search parameter, and its associated value, from the list of all search parameters. + */ + delete(name: string): void; + /** + * Returns the first value associated to the given search parameter. + */ + get(name: string): string | null; + /** + * Returns all the values association with a given search parameter. + */ + getAll(name: string): string[]; + /** + * Returns a Boolean indicating if such a search parameter exists. + */ + has(name: string): boolean; + /** + * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. + */ + set(name: string, value: string): void; +} + +declare var URLSearchParams: { + prototype: URLSearchParams; + /** + * Constructor returning a URLSearchParams object. + */ + new (init?: string | URLSearchParams): URLSearchParams; +} + interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -12750,7 +13899,6 @@ interface NodeListOf extends NodeList { interface HTMLCollectionOf extends HTMLCollection { item(index: number): T; namedItem(name: string): T; - [index: number]: T; } interface BlobPropertyBag { @@ -12767,15 +13915,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -interface MessageEventInit extends EventInit { - data?: any; - origin?: string; - lastEventId?: string; - channel?: string; - source?: any; - ports?: MessagePort[]; -} - interface ProgressEventInit extends EventInit { lengthComputable?: boolean; loaded?: number; @@ -12977,8 +14116,8 @@ interface JsonWebKey { interface ParentNode { readonly children: HTMLCollection; - readonly firstElementChild: Element; - readonly lastElementChild: Element; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; readonly childElementCount: number; } @@ -13009,6 +14148,26 @@ interface AssignedNodesOptions { flatten?: boolean; } +interface ElementDefinitionOptions { + extends: string; +} + +interface CustomElementRegistry { + define(name: string, constructor: Function, options?: ElementDefinitionOptions): void; + get(name: string): any; + whenDefined(name: string): PromiseLike; +} + +interface PromiseRejectionEvent extends Event { + readonly promise: PromiseLike; + readonly reason: any; +} + +interface PromiseRejectionEventInit extends EventInit { + promise: PromiseLike; + reason?: any; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -13044,6 +14203,18 @@ interface DecodeSuccessCallback { interface DecodeErrorCallback { (error: DOMException): void; } +interface VoidFunction { + (): void; +} +interface RTCSessionDescriptionCallback { + (sdp: RTCSessionDescription): void; +} +interface RTCPeerConnectionErrorCallback { + (error: DOMError): void; +} +interface RTCStatsCallback { + (report: RTCStatsReport): void; +} interface FunctionStringCallback { (data: string): void; } @@ -13056,6 +14227,12 @@ interface NavigatorUserMediaErrorCallback { interface ForEachCallback { (keyId: any, status: string): void; } +interface NotificationPermissionCallback { + (permission: string): void; +} +interface IntersectionObserverCallback { + (entries: IntersectionObserverEntry[], observer: IntersectionObserver): void; +} interface HTMLElementTagNameMap { "a": HTMLAnchorElement; "applet": HTMLAppletElement; @@ -13071,6 +14248,7 @@ interface HTMLElementTagNameMap { "caption": HTMLTableCaptionElement; "col": HTMLTableColElement; "colgroup": HTMLTableColElement; + "data": HTMLDataElement; "datalist": HTMLDataListElement; "del": HTMLModElement; "dir": HTMLDirectoryElement; @@ -13111,6 +14289,7 @@ interface HTMLElementTagNameMap { "ol": HTMLOListElement; "optgroup": HTMLOptGroupElement; "option": HTMLOptionElement; + "output": HTMLOutputElement; "p": HTMLParagraphElement; "param": HTMLParamElement; "picture": HTMLPictureElement; @@ -13130,6 +14309,7 @@ interface HTMLElementTagNameMap { "tfoot": HTMLTableSectionElement; "th": HTMLTableHeaderCellElement; "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; "title": HTMLTitleElement; "tr": HTMLTableRowElement; "track": HTMLTrackElement; @@ -13167,6 +14347,7 @@ interface ElementTagNameMap { "code": HTMLElement; "col": HTMLTableColElement; "colgroup": HTMLTableColElement; + "data": HTMLDataElement; "datalist": HTMLDataListElement; "dd": HTMLElement; "defs": SVGDefsElement; @@ -13260,6 +14441,7 @@ interface ElementTagNameMap { "ol": HTMLOListElement; "optgroup": HTMLOptGroupElement; "option": HTMLOptionElement; + "output": HTMLOutputElement; "p": HTMLParagraphElement; "param": HTMLParamElement; "path": SVGPathElement; @@ -13302,6 +14484,7 @@ interface ElementTagNameMap { "tfoot": HTMLTableSectionElement; "th": HTMLTableHeaderCellElement; "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; "title": HTMLTitleElement; "tr": HTMLTableRowElement; "track": HTMLTrackElement; @@ -13346,6 +14529,7 @@ interface ElementListTagNameMap { "code": NodeListOf; "col": NodeListOf; "colgroup": NodeListOf; + "data": NodeListOf; "datalist": NodeListOf; "dd": NodeListOf; "defs": NodeListOf; @@ -13439,6 +14623,7 @@ interface ElementListTagNameMap { "ol": NodeListOf; "optgroup": NodeListOf; "option": NodeListOf; + "output": NodeListOf; "p": NodeListOf; "param": NodeListOf; "path": NodeListOf; @@ -13481,6 +14666,7 @@ interface ElementListTagNameMap { "tfoot": NodeListOf; "th": NodeListOf; "thead": NodeListOf; + "time": NodeListOf; "title": NodeListOf; "tr": NodeListOf; "track": NodeListOf; @@ -13501,6 +14687,7 @@ declare var Audio: {new(src?: string): HTMLAudioElement; }; declare var Image: {new(width?: number, height?: number): HTMLImageElement; }; declare var Option: {new(text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; declare var applicationCache: ApplicationCache; +declare var caches: CacheStorage; declare var clientInformation: Navigator; declare var closed: boolean; declare var crypto: Crypto; @@ -13515,10 +14702,12 @@ declare var frames: Window; declare var history: History; declare var innerHeight: number; declare var innerWidth: number; +declare var isSecureContext: boolean; declare var length: number; declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; +declare var msContentScript: ExtensionScriptApis; declare var msCredentials: MSCredentials; declare const name: never; declare var navigator: Navigator; @@ -13632,18 +14821,21 @@ declare var scrollX: number; declare var scrollY: number; declare var scrollbars: BarProp; declare var self: Window; +declare var speechSynthesis: SpeechSynthesis; declare var status: string; declare var statusbar: BarProp; declare var styleMedia: StyleMedia; declare var toolbar: BarProp; declare var top: Window; declare var window: Window; +declare var customElements: CustomElementRegistry; declare function alert(message?: any): void; declare function blur(): void; declare function cancelAnimationFrame(handle: number): void; declare function captureEvents(): void; declare function close(): void; declare function confirm(message?: string): boolean; +declare function departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; declare function focus(): void; declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; declare function getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -13663,6 +14855,7 @@ declare function resizeTo(x?: number, y?: number): void; declare function scroll(x?: number, y?: number): void; declare function scrollBy(x?: number, y?: number): void; declare function scrollTo(x?: number, y?: number): void; +declare function stop(): void; declare function webkitCancelAnimationFrame(handle: number): void; declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; @@ -13697,10 +14890,13 @@ declare var onwheel: (this: Window, ev: WheelEvent) => any; declare var indexedDB: IDBFactory; declare function atob(encodedString: string): string; declare function btoa(rawString: string): string; +declare function fetch(input: RequestInfo, init?: RequestInit): Promise; declare function addEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; type AAGUID = string; type AlgorithmIdentifier = string | Algorithm; +type BodyInit = any; +type ByteString = string; type ConstrainBoolean = boolean | ConstrainBooleanParameters; type ConstrainDOMString = string | string[] | ConstrainDOMStringParameters; type ConstrainDouble = number | ConstrainDoubleRange; @@ -13720,6 +14916,7 @@ type GLsizeiptr = number; type GLubyte = number; type GLuint = number; type GLushort = number; +type HeadersInit = any; type IDBKeyPath = string; type KeyFormat = string; type KeyType = string; @@ -13727,8 +14924,10 @@ type KeyUsage = string; type MSInboundPayload = MSVideoRecvPayload | MSAudioRecvPayload; type MSLocalClientEvent = MSLocalClientEventBase | MSAudioLocalClientEvent; type MSOutboundPayload = MSVideoSendPayload | MSAudioSendPayload; -type RTCIceGatherCandidate = RTCIceCandidate | RTCIceCandidateComplete; +type RTCIceGatherCandidate = RTCIceCandidateDictionary | RTCIceCandidateComplete; type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport; +type RequestInfo = Request | string; +type USVString = string; type payloadtype = number; type ScrollBehavior = "auto" | "instant" | "smooth"; type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; diff --git a/lib/lib.es2015.collection.d.ts b/lib/lib.es2015.collection.d.ts index 9f4a23f3254..bf36745dcf9 100644 --- a/lib/lib.es2015.collection.d.ts +++ b/lib/lib.es2015.collection.d.ts @@ -24,7 +24,7 @@ interface Map { forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void; get(key: K): V | undefined; has(key: K): boolean; - set(key: K, value?: V): this; + set(key: K, value: V): this; readonly size: number; } @@ -42,16 +42,16 @@ interface ReadonlyMap { readonly size: number; } -interface WeakMap { +interface WeakMap { delete(key: K): boolean; get(key: K): V | undefined; has(key: K): boolean; - set(key: K, value?: V): this; + set(key: K, value: V): this; } interface WeakMapConstructor { new (): WeakMap; - new (entries?: [K, V][]): WeakMap; + new (entries?: [K, V][]): WeakMap; readonly prototype: WeakMap; } declare var WeakMap: WeakMapConstructor; diff --git a/lib/lib.es2015.core.d.ts b/lib/lib.es2015.core.d.ts index 7f03aaec04d..ae633957cd5 100644 --- a/lib/lib.es2015.core.d.ts +++ b/lib/lib.es2015.core.d.ts @@ -345,7 +345,7 @@ interface ObjectConstructor { * @param o The object to change its prototype. * @param proto The value of the new prototype or null. */ - setPrototypeOf(o: any, proto: any): any; + setPrototypeOf(o: any, proto: object | null): any; /** * Gets the own property descriptor of the specified object. diff --git a/lib/lib.es2015.iterable.d.ts b/lib/lib.es2015.iterable.d.ts index 02c72a5ee36..3f9ffc62f3c 100644 --- a/lib/lib.es2015.iterable.d.ts +++ b/lib/lib.es2015.iterable.d.ts @@ -119,10 +119,10 @@ interface MapConstructor { new (iterable: Iterable<[K, V]>): Map; } -interface WeakMap { } +interface WeakMap { } interface WeakMapConstructor { - new (iterable: Iterable<[K, V]>): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; } interface Set { @@ -462,4 +462,4 @@ interface Float64ArrayConstructor { * @param thisArg Value of 'this' used to invoke the mapfn. */ from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; -} \ No newline at end of file +} diff --git a/lib/lib.es2015.promise.d.ts b/lib/lib.es2015.promise.d.ts index 99df9263ea1..b628cb89015 100644 --- a/lib/lib.es2015.promise.d.ts +++ b/lib/lib.es2015.promise.d.ts @@ -18,57 +18,6 @@ and limitations under the License. /// -/** - * Represents the completion of an asynchronous operation - */ -interface Promise { - /** - * 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) => T | PromiseLike) | undefined | null, onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): Promise; - - /** - * 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) => T | PromiseLike) | undefined | null, onrejected: (reason: any) => TResult | PromiseLike): Promise; - - /** - * 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) | undefined | null): Promise; - - /** - * 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) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; - - /** - * Attaches a callback for only the rejection of the Promise. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of the callback. - */ - catch(onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): Promise; - - /** - * Attaches a callback for only the rejection of the Promise. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of the callback. - */ - catch(onrejected: (reason: any) => TResult | PromiseLike): Promise; -} - interface PromiseConstructor { /** * A reference to the prototype. diff --git a/lib/lib.es2015.proxy.d.ts b/lib/lib.es2015.proxy.d.ts index d935cdf9781..3b1d8828575 100644 --- a/lib/lib.es2015.proxy.d.ts +++ b/lib/lib.es2015.proxy.d.ts @@ -19,7 +19,7 @@ and limitations under the License. interface ProxyHandler { - getPrototypeOf? (target: T): {} | null; + getPrototypeOf? (target: T): object | null; setPrototypeOf? (target: T, v: any): boolean; isExtensible? (target: T): boolean; preventExtensions? (target: T): boolean; @@ -32,7 +32,7 @@ interface ProxyHandler { enumerate? (target: T): PropertyKey[]; ownKeys? (target: T): PropertyKey[]; apply? (target: T, thisArg: any, argArray?: any): any; - construct? (target: T, argArray: any, newTarget?: any): {}; + construct? (target: T, argArray: any, newTarget?: any): object } interface ProxyConstructor { diff --git a/lib/lib.es2015.symbol.d.ts b/lib/lib.es2015.symbol.d.ts index 3776a44670d..f1a87d316a0 100644 --- a/lib/lib.es2015.symbol.d.ts +++ b/lib/lib.es2015.symbol.d.ts @@ -23,7 +23,7 @@ interface Symbol { toString(): string; /** Returns the primitive value of the specified object. */ - valueOf(): Object; + valueOf(): symbol; } interface SymbolConstructor { diff --git a/lib/lib.es2015.symbol.wellknown.d.ts b/lib/lib.es2015.symbol.wellknown.d.ts index e95f324131a..4668862af5f 100644 --- a/lib/lib.es2015.symbol.wellknown.d.ts +++ b/lib/lib.es2015.symbol.wellknown.d.ts @@ -130,7 +130,7 @@ interface Map { readonly [Symbol.toStringTag]: "Map"; } -interface WeakMap{ +interface WeakMap{ readonly [Symbol.toStringTag]: "WeakMap"; } @@ -344,4 +344,4 @@ interface Float32Array { */ interface Float64Array { readonly [Symbol.toStringTag]: "Float64Array"; -} \ No newline at end of file +} diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index 2ce9151e289..f0c6e9fb861 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -157,23 +157,17 @@ interface ObjectConstructor { getOwnPropertyNames(o: any): string[]; /** - * Creates an object that has null prototype. - * @param o Object to use as a prototype. May be null + * Creates an object that has the specified prototype or that has null prototype. + * @param o Object to use as a prototype. May be null. */ - create(o: null): any; - - /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - */ - create(o: T): T; + create(o: T | null): T | object; /** * Creates an object that has the specified prototype, and that optionally contains specified properties. * @param o Object to use as a prototype. May be null * @param properties JavaScript object that contains one or more property descriptors. */ - create(o: any, properties: PropertyDescriptorMap): any; + create(o: object | null, properties: PropertyDescriptorMap): any; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -361,14 +355,14 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string that represents the regular expression. + * @param searchValue A string to search for. * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string that represents the regular expression. + * @param searchValue A string to search for. * @param replacer A function that returns the replacement text. */ replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; @@ -1336,39 +1330,27 @@ interface PromiseLike { * @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) => T | PromiseLike) | undefined | null, - onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): PromiseLike; + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): PromiseLike; +} +/** + * Represents the completion of an asynchronous operation + */ +interface Promise { /** * 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) => T | PromiseLike) | undefined | null, - onrejected: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. + * Attaches a callback for only the rejection of the Promise. * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. + * @returns A Promise for the completion of the callback. */ - then( - onfulfilled: (value: T) => TResult | PromiseLike, - onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): 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) => TResult1 | PromiseLike, - onrejected: (reason: any) => TResult2 | PromiseLike): PromiseLike; + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; } interface ArrayLike { diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 1c5224c0cc8..777141c0dba 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -157,23 +157,17 @@ interface ObjectConstructor { getOwnPropertyNames(o: any): string[]; /** - * Creates an object that has null prototype. - * @param o Object to use as a prototype. May be null + * Creates an object that has the specified prototype or that has null prototype. + * @param o Object to use as a prototype. May be null. */ - create(o: null): any; - - /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - */ - create(o: T): T; + create(o: T | null): T | object; /** * Creates an object that has the specified prototype, and that optionally contains specified properties. * @param o Object to use as a prototype. May be null * @param properties JavaScript object that contains one or more property descriptors. */ - create(o: any, properties: PropertyDescriptorMap): any; + create(o: object | null, properties: PropertyDescriptorMap): any; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -361,14 +355,14 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string that represents the regular expression. + * @param searchValue A string to search for. * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string that represents the regular expression. + * @param searchValue A string to search for. * @param replacer A function that returns the replacement text. */ replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; @@ -1336,39 +1330,27 @@ interface PromiseLike { * @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) => T | PromiseLike) | undefined | null, - onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): PromiseLike; + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): PromiseLike; +} +/** + * Represents the completion of an asynchronous operation + */ +interface Promise { /** * 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) => T | PromiseLike) | undefined | null, - onrejected: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. + * Attaches a callback for only the rejection of the Promise. * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. + * @returns A Promise for the completion of the callback. */ - then( - onfulfilled: (value: T) => TResult | PromiseLike, - onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): 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) => TResult1 | PromiseLike, - onrejected: (reason: any) => TResult2 | PromiseLike): PromiseLike; + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; } interface ArrayLike { @@ -4523,7 +4505,7 @@ interface ObjectConstructor { * @param o The object to change its prototype. * @param proto The value of the new prototype or null. */ - setPrototypeOf(o: any, proto: any): any; + setPrototypeOf(o: any, proto: object | null): any; /** * Gets the own property descriptor of the specified object. @@ -4728,7 +4710,7 @@ interface Map { forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void; get(key: K): V | undefined; has(key: K): boolean; - set(key: K, value?: V): this; + set(key: K, value: V): this; readonly size: number; } @@ -4746,16 +4728,16 @@ interface ReadonlyMap { readonly size: number; } -interface WeakMap { +interface WeakMap { delete(key: K): boolean; get(key: K): V | undefined; has(key: K): boolean; - set(key: K, value?: V): this; + set(key: K, value: V): this; } interface WeakMapConstructor { new (): WeakMap; - new (entries?: [K, V][]): WeakMap; + new (entries?: [K, V][]): WeakMap; readonly prototype: WeakMap; } declare var WeakMap: WeakMapConstructor; @@ -4911,10 +4893,10 @@ interface MapConstructor { new (iterable: Iterable<[K, V]>): Map; } -interface WeakMap { } +interface WeakMap { } interface WeakMapConstructor { - new (iterable: Iterable<[K, V]>): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; } interface Set { @@ -5256,56 +5238,6 @@ interface Float64ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -/** - * Represents the completion of an asynchronous operation - */ -interface Promise { - /** - * 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) => T | PromiseLike) | undefined | null, onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): Promise; - - /** - * 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) => T | PromiseLike) | undefined | null, onrejected: (reason: any) => TResult | PromiseLike): Promise; - - /** - * 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) | undefined | null): Promise; - - /** - * 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) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; - - /** - * Attaches a callback for only the rejection of the Promise. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of the callback. - */ - catch(onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): Promise; - - /** - * Attaches a callback for only the rejection of the Promise. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of the callback. - */ - catch(onrejected: (reason: any) => TResult | PromiseLike): Promise; -} interface PromiseConstructor { /** @@ -5512,7 +5444,7 @@ interface PromiseConstructor { declare var Promise: PromiseConstructor; interface ProxyHandler { - getPrototypeOf? (target: T): {} | null; + getPrototypeOf? (target: T): object | null; setPrototypeOf? (target: T, v: any): boolean; isExtensible? (target: T): boolean; preventExtensions? (target: T): boolean; @@ -5525,7 +5457,7 @@ interface ProxyHandler { enumerate? (target: T): PropertyKey[]; ownKeys? (target: T): PropertyKey[]; apply? (target: T, thisArg: any, argArray?: any): any; - construct? (target: T, argArray: any, newTarget?: any): {}; + construct? (target: T, argArray: any, newTarget?: any): object } interface ProxyConstructor { @@ -5556,7 +5488,7 @@ interface Symbol { toString(): string; /** Returns the primitive value of the specified object. */ - valueOf(): Object; + valueOf(): symbol; } interface SymbolConstructor { @@ -5700,7 +5632,7 @@ interface Map { readonly [Symbol.toStringTag]: "Map"; } -interface WeakMap{ +interface WeakMap{ readonly [Symbol.toStringTag]: "WeakMap"; } @@ -5917,22 +5849,55 @@ interface Float64Array { } + ///////////////////////////// /// IE DOM APIs ///////////////////////////// +interface Account { + rpDisplayName?: string; + displayName?: string; + id?: string; + name?: string; + imageURL?: string; +} + interface Algorithm { name: string; } -interface AriaRequestEventInit extends EventInit { - attributeName?: string; - attributeValue?: string; +interface AnimationEventInit extends EventInit { + animationName?: string; + elapsedTime?: number; } -interface CommandEventInit extends EventInit { - commandName?: string; - detail?: string; +interface AssertionOptions { + timeoutSeconds?: number; + rpId?: USVString; + allowList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface CacheQueryOptions { + ignoreSearch?: boolean; + ignoreMethod?: boolean; + ignoreVary?: boolean; + cacheName?: string; +} + +interface ClientData { + challenge?: string; + origin?: string; + rpId?: string; + hashAlg?: string | Algorithm; + tokenBinding?: string; + extensions?: WebAuthnExtensions; +} + +interface CloseEventInit extends EventInit { + wasClean?: boolean; + code?: number; + reason?: string; } interface CompositionEventInit extends UIEventInit { @@ -5972,6 +5937,13 @@ interface CustomEventInit extends EventInit { detail?: any; } +interface DOMRectInit { + x?: any; + y?: any; + width?: any; + height?: any; +} + interface DeviceAccelerationDict { x?: number; y?: number; @@ -5982,6 +5954,20 @@ interface DeviceLightEventInit extends EventInit { value?: number; } +interface DeviceMotionEventInit extends EventInit { + acceleration?: DeviceAccelerationDict; + accelerationIncludingGravity?: DeviceAccelerationDict; + rotationRate?: DeviceRotationRateDict; + interval?: number; +} + +interface DeviceOrientationEventInit extends EventInit { + alpha?: number; + beta?: number; + gamma?: number; + absolute?: boolean; +} + interface DeviceRotationRateDict { alpha?: number; beta?: number; @@ -5993,6 +5979,14 @@ interface DoubleRange { min?: number; } +interface ErrorEventInit extends EventInit { + message?: string; + filename?: string; + lineno?: number; + colno?: number; + error?: any; +} + interface EventInit { scoped?: boolean; bubbles?: boolean; @@ -6025,6 +6019,29 @@ interface FocusEventInit extends UIEventInit { relatedTarget?: EventTarget; } +interface FocusNavigationEventInit extends EventInit { + navigationReason?: string; + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface FocusNavigationOrigin { + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface GamepadEventInit extends EventInit { + gamepad?: Gamepad; +} + +interface GetNotificationOptions { + tag?: string; +} + interface HashChangeEventInit extends EventInit { newURL?: string; oldURL?: string; @@ -6040,6 +6057,20 @@ interface IDBObjectStoreParameters { keyPath?: IDBKeyPath; } +interface IntersectionObserverEntryInit { + time?: number; + rootBounds?: DOMRectInit; + boundingClientRect?: DOMRectInit; + intersectionRect?: DOMRectInit; + target?: Element; +} + +interface IntersectionObserverInit { + root?: Element; + rootMargin?: string; + threshold?: number | number[]; +} + interface KeyAlgorithm { name?: string; } @@ -6242,6 +6273,11 @@ interface MSPayloadBase extends RTCStats { payloadDescription?: string; } +interface MSPortRange { + min?: number; + max?: number; +} + interface MSRelayAddress { relayAddress?: string; port?: number; @@ -6292,7 +6328,7 @@ interface MSUtilization { } interface MSVideoPayload extends MSPayloadBase { - resoluton?: string; + resolution?: string; videoBitRateAvg?: number; videoBitRateMax?: number; videoFrameRateAvg?: number; @@ -6375,6 +6411,10 @@ interface MediaStreamErrorEventInit extends EventInit { error?: MediaStreamError; } +interface MediaStreamEventInit extends EventInit { + stream?: MediaStream; +} + interface MediaStreamTrackEventInit extends EventInit { track?: MediaStreamTrack; } @@ -6439,6 +6479,15 @@ interface MediaTrackSupportedConstraints { groupId?: boolean; } +interface MessageEventInit extends EventInit { + lastEventId?: string; + channel?: string; + data?: any; + origin?: string; + source?: Window; + ports?: MessagePort[]; +} + interface MouseEventInit extends EventModifierInit { screenX?: number; screenY?: number; @@ -6468,10 +6517,68 @@ interface MutationObserverInit { attributeFilter?: string[]; } +interface NotificationOptions { + dir?: string; + lang?: string; + body?: string; + tag?: string; + icon?: string; +} + interface ObjectURLOptions { oneTimeOnly?: boolean; } +interface PaymentCurrencyAmount { + currency?: string; + value?: string; + currencySystem?: string; +} + +interface PaymentDetails { + total?: PaymentItem; + displayItems?: PaymentItem[]; + shippingOptions?: PaymentShippingOption[]; + modifiers?: PaymentDetailsModifier[]; + error?: string; +} + +interface PaymentDetailsModifier { + supportedMethods?: string[]; + total?: PaymentItem; + additionalDisplayItems?: PaymentItem[]; + data?: any; +} + +interface PaymentItem { + label?: string; + amount?: PaymentCurrencyAmount; + pending?: boolean; +} + +interface PaymentMethodData { + supportedMethods?: string[]; + data?: any; +} + +interface PaymentOptions { + requestPayerName?: boolean; + requestPayerEmail?: boolean; + requestPayerPhone?: boolean; + requestShipping?: boolean; + shippingType?: string; +} + +interface PaymentRequestUpdateEventInit extends EventInit { +} + +interface PaymentShippingOption { + id?: string; + label?: string; + amount?: PaymentCurrencyAmount; + selected?: boolean; +} + interface PeriodicWaveConstraints { disableNormalization?: boolean; } @@ -6487,12 +6594,34 @@ interface PointerEventInit extends MouseEventInit { isPrimary?: boolean; } +interface PopStateEventInit extends EventInit { + state?: any; +} + interface PositionOptions { enableHighAccuracy?: boolean; timeout?: number; maximumAge?: number; } +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + +interface PushSubscriptionOptionsInit { + userVisibleOnly?: boolean; + applicationServerKey?: any; +} + +interface RTCConfiguration { + iceServers?: RTCIceServer[]; + iceTransportPolicy?: string; + bundlePolicy?: string; + peerIdentity?: string; +} + interface RTCDTMFToneChangeEventInit extends EventInit { tone?: string; } @@ -6507,18 +6636,6 @@ interface RTCDtlsParameters { fingerprints?: RTCDtlsFingerprint[]; } -interface RTCIceCandidate { - foundation?: string; - priority?: number; - ip?: string; - protocol?: string; - port?: number; - type?: string; - tcpType?: string; - relatedAddress?: string; - relatedPort?: number; -} - interface RTCIceCandidateAttributes extends RTCStats { ipAddress?: string; portNumber?: number; @@ -6531,9 +6648,28 @@ interface RTCIceCandidateAttributes extends RTCStats { interface RTCIceCandidateComplete { } +interface RTCIceCandidateDictionary { + foundation?: string; + priority?: number; + ip?: string; + protocol?: string; + port?: number; + type?: string; + tcpType?: string; + relatedAddress?: string; + relatedPort?: number; + msMTurnSessionId?: string; +} + +interface RTCIceCandidateInit { + candidate?: string; + sdpMid?: string; + sdpMLineIndex?: number; +} + interface RTCIceCandidatePair { - local?: RTCIceCandidate; - remote?: RTCIceCandidate; + local?: RTCIceCandidateDictionary; + remote?: RTCIceCandidateDictionary; } interface RTCIceCandidatePairStats extends RTCStats { @@ -6555,11 +6691,13 @@ interface RTCIceCandidatePairStats extends RTCStats { interface RTCIceGatherOptions { gatherPolicy?: string; iceservers?: RTCIceServer[]; + portRange?: MSPortRange; } interface RTCIceParameters { usernameFragment?: string; password?: string; + iceLite?: boolean; } interface RTCIceServer { @@ -6593,6 +6731,13 @@ interface RTCMediaStreamTrackStats extends RTCStats { echoReturnLossEnhancement?: number; } +interface RTCOfferOptions { + offerToReceiveVideo?: number; + offerToReceiveAudio?: number; + voiceActivityDetection?: boolean; + iceRestart?: boolean; +} + interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { packetsSent?: number; bytesSent?: number; @@ -6600,6 +6745,10 @@ interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { roundTripTime?: number; } +interface RTCPeerConnectionIceEventInit extends EventInit { + candidate?: RTCIceCandidate; +} + interface RTCRTPStreamStats extends RTCStats { ssrc?: string; associateStatsId?: string; @@ -6637,6 +6786,7 @@ interface RTCRtpCodecCapability { clockRate?: number; preferredPayloadType?: number; maxptime?: number; + ptime?: number; numChannels?: number; rtcpFeedback?: RTCRtcpFeedback[]; parameters?: any; @@ -6651,6 +6801,7 @@ interface RTCRtpCodecParameters { payloadType?: any; clockRate?: number; maxptime?: number; + ptime?: number; numChannels?: number; rtcpFeedback?: RTCRtcpFeedback[]; parameters?: any; @@ -6670,9 +6821,9 @@ interface RTCRtpEncodingParameters { priority?: number; maxBitrate?: number; minQuality?: number; - framerateBias?: number; resolutionScale?: number; framerateScale?: number; + maxFramerate?: number; active?: boolean; encodingId?: string; dependencyEncodingIds?: string[]; @@ -6703,6 +6854,7 @@ interface RTCRtpParameters { headerExtensions?: RTCRtpHeaderExtensionParameters[]; encodings?: RTCRtpEncodingParameters[]; rtcp?: RTCRtcpParameters; + degradationPreference?: string; } interface RTCRtpRtxParameters { @@ -6715,6 +6867,11 @@ interface RTCRtpUnhandled { muxId?: string; } +interface RTCSessionDescriptionInit { + type?: string; + sdp?: string; +} + interface RTCSrtpKeyParam { keyMethod?: string; keySalt?: string; @@ -6755,6 +6912,64 @@ interface RTCTransportStats extends RTCStats { remoteCertificateId?: string; } +interface RegistrationOptions { + scope?: string; +} + +interface RequestInit { + method?: string; + headers?: any; + body?: any; + referrer?: string; + referrerPolicy?: string; + mode?: string; + credentials?: string; + cache?: string; + redirect?: string; + integrity?: string; + keepalive?: boolean; + window?: any; +} + +interface ResponseInit { + status?: number; + statusText?: string; + headers?: any; +} + +interface ScopedCredentialDescriptor { + type?: string; + id?: any; + transports?: string[]; +} + +interface ScopedCredentialOptions { + timeoutSeconds?: number; + rpId?: USVString; + excludeList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface ScopedCredentialParameters { + type?: string; + algorithm?: string | Algorithm; +} + +interface ServiceWorkerMessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + source?: ServiceWorker | MessagePort; + ports?: MessagePort[]; +} + +interface SpeechSynthesisEventInit extends EventInit { + utterance?: SpeechSynthesisUtterance; + charIndex?: number; + elapsedTime?: number; + name?: string; +} + interface StoreExceptionsInformation extends ExceptionInformation { siteName?: string; explanationString?: string; @@ -6765,11 +6980,23 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat arrayOfDomainStrings?: string[]; } +interface TrackEventInit extends EventInit { + track?: VideoTrack | AudioTrack | TextTrack; +} + +interface TransitionEventInit extends EventInit { + propertyName?: string; + elapsedTime?: number; +} + interface UIEventInit extends EventInit { view?: Window; detail?: number; } +interface WebAuthnExtensions { +} + interface WebGLContextAttributes { failIfMajorPerformanceCaveat?: boolean; alpha?: boolean; @@ -6795,6 +7022,18 @@ interface EventListener { (evt: Event): void; } +interface WebKitEntriesCallback { + (evt: Event): void; +} + +interface WebKitErrorCallback { + (evt: Event): void; +} + +interface WebKitFileCallback { + (evt: Event): void; +} + interface ANGLE_instanced_arrays { drawArraysInstancedANGLE(mode: number, first: number, count: number, primcount: number): void; drawElementsInstancedANGLE(mode: number, count: number, type: number, offset: number, primcount: number): void; @@ -6833,14 +7072,14 @@ interface AnimationEvent extends Event { declare var AnimationEvent: { prototype: AnimationEvent; - new(): AnimationEvent; + new(typeArg: string, eventInitDict?: AnimationEventInit): AnimationEvent; } interface ApplicationCacheEventMap { "cached": Event; "checking": Event; "downloading": Event; - "error": ErrorEvent; + "error": Event; "noupdate": Event; "obsolete": Event; "progress": ProgressEvent; @@ -6851,7 +7090,7 @@ interface ApplicationCache extends EventTarget { oncached: (this: ApplicationCache, ev: Event) => any; onchecking: (this: ApplicationCache, ev: Event) => any; ondownloading: (this: ApplicationCache, ev: Event) => any; - onerror: (this: ApplicationCache, ev: ErrorEvent) => any; + onerror: (this: ApplicationCache, ev: Event) => any; onnoupdate: (this: ApplicationCache, ev: Event) => any; onobsolete: (this: ApplicationCache, ev: Event) => any; onprogress: (this: ApplicationCache, ev: ProgressEvent) => any; @@ -6881,16 +7120,6 @@ declare var ApplicationCache: { readonly UPDATEREADY: number; } -interface AriaRequestEvent extends Event { - readonly attributeName: string; - attributeValue: string | null; -} - -declare var AriaRequestEvent: { - prototype: AriaRequestEvent; - new(type: string, eventInitDict?: AriaRequestEventInit): AriaRequestEvent; -} - interface Attr extends Node { readonly name: string; readonly ownerElement: Element; @@ -6942,12 +7171,18 @@ declare var AudioBufferSourceNode: { new(): AudioBufferSourceNode; } -interface AudioContext extends EventTarget { +interface AudioContextEventMap { + "statechange": Event; +} + +interface AudioContextBase extends EventTarget { readonly currentTime: number; readonly destination: AudioDestinationNode; readonly listener: AudioListener; + onstatechange: (this: AudioContext, ev: Event) => any; readonly sampleRate: number; - state: string; + readonly state: string; + close(): Promise; createAnalyser(): AnalyserNode; createBiquadFilter(): BiquadFilterNode; createBuffer(numberOfChannels: number, length: number, sampleRate: number): AudioBuffer; @@ -6958,6 +7193,7 @@ interface AudioContext extends EventTarget { createDelay(maxDelayTime?: number): DelayNode; createDynamicsCompressor(): DynamicsCompressorNode; createGain(): GainNode; + createIIRFilter(feedforward: number[], feedback: number[]): IIRFilterNode; createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createMediaStreamSource(mediaStream: MediaStream): MediaStreamAudioSourceNode; createOscillator(): OscillatorNode; @@ -6966,7 +7202,14 @@ interface AudioContext extends EventTarget { createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; - decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): PromiseLike; + decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): Promise; + resume(): Promise; + addEventListener(type: K, listener: (this: AudioContext, ev: AudioContextEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface AudioContext extends AudioContextBase { + suspend(): Promise; } declare var AudioContext: { @@ -7003,7 +7246,7 @@ interface AudioNode extends EventTarget { readonly context: AudioContext; readonly numberOfInputs: number; readonly numberOfOutputs: number; - connect(destination: AudioNode, output?: number, input?: number): void; + connect(destination: AudioNode, output?: number, input?: number): AudioNode; disconnect(output?: number): void; disconnect(destination: AudioNode, output?: number, input?: number): void; disconnect(destination: AudioParam, output?: number): void; @@ -7017,12 +7260,12 @@ declare var AudioNode: { interface AudioParam { readonly defaultValue: number; value: number; - cancelScheduledValues(startTime: number): void; - exponentialRampToValueAtTime(value: number, endTime: number): void; - linearRampToValueAtTime(value: number, endTime: number): void; - setTargetAtTime(target: number, startTime: number, timeConstant: number): void; - setValueAtTime(value: number, startTime: number): void; - setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; + cancelScheduledValues(startTime: number): AudioParam; + exponentialRampToValueAtTime(value: number, endTime: number): AudioParam; + linearRampToValueAtTime(value: number, endTime: number): AudioParam; + setTargetAtTime(target: number, startTime: number, timeConstant: number): AudioParam; + setValueAtTime(value: number, startTime: number): AudioParam; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): AudioParam; } declare var AudioParam: { @@ -7399,10 +7642,16 @@ interface CSSStyleDeclaration { imeMode: string | null; justifyContent: string | null; kerning: string | null; + layoutGrid: string | null; + layoutGridChar: string | null; + layoutGridLine: string | null; + layoutGridMode: string | null; + layoutGridType: string | null; left: string | null; readonly length: number; letterSpacing: string | null; lightingColor: string | null; + lineBreak: string | null; lineHeight: string | null; listStyle: string | null; listStyleImage: string | null; @@ -7474,6 +7723,7 @@ interface CSSStyleDeclaration { orphans: string | null; outline: string | null; outlineColor: string | null; + outlineOffset: string | null; outlineStyle: string | null; outlineWidth: string | null; overflow: string | null; @@ -7494,9 +7744,11 @@ interface CSSStyleDeclaration { position: string | null; quotes: string | null; right: string | null; + rotate: string | null; rubyAlign: string | null; rubyOverhang: string | null; rubyPosition: string | null; + scale: string | null; stopColor: string | null; stopOpacity: string | null; stroke: string | null; @@ -7530,6 +7782,7 @@ interface CSSStyleDeclaration { transitionDuration: string | null; transitionProperty: string | null; transitionTimingFunction: string | null; + translate: string | null; unicodeBidi: string | null; verticalAlign: string | null; visibility: string | null; @@ -7590,6 +7843,9 @@ interface CSSStyleDeclaration { webkitTapHighlightColor: string | null; webkitTextFillColor: string | null; webkitTextSizeAdjust: any; + webkitTextStroke: string | null; + webkitTextStrokeColor: string | null; + webkitTextStrokeWidth: string | null; webkitTransform: string | null; webkitTransformOrigin: string | null; webkitTransformStyle: string | null; @@ -7611,6 +7867,7 @@ interface CSSStyleDeclaration { zIndex: string | null; zoom: string | null; resize: string | null; + userSelect: string | null; getPropertyPriority(propertyName: string): string; getPropertyValue(propertyName: string): string; item(index: number): string; @@ -7638,7 +7895,6 @@ declare var CSSStyleRule: { interface CSSStyleSheet extends StyleSheet { readonly cssRules: CSSRuleList; cssText: string; - readonly href: string; readonly id: string; readonly imports: StyleSheetList; readonly isAlternate: boolean; @@ -7670,6 +7926,34 @@ declare var CSSSupportsRule: { new(): CSSSupportsRule; } +interface Cache { + add(request: RequestInfo): Promise; + addAll(requests: RequestInfo[]): Promise; + delete(request: RequestInfo, options?: CacheQueryOptions): Promise; + keys(request?: RequestInfo, options?: CacheQueryOptions): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + put(request: RequestInfo, response: Response): Promise; +} + +declare var Cache: { + prototype: Cache; + new(): Cache; +} + +interface CacheStorage { + delete(cacheName: string): Promise; + has(cacheName: string): Promise; + keys(): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + open(cacheName: string): Promise; +} + +declare var CacheStorage: { + prototype: CacheStorage; + new(): CacheStorage; +} + interface CanvasGradient { addColorStop(offset: number, color: string): void; } @@ -7694,13 +7978,13 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { font: string; globalAlpha: number; globalCompositeOperation: string; + imageSmoothingEnabled: boolean; lineCap: string; lineDashOffset: number; lineJoin: string; lineWidth: number; miterLimit: number; msFillRule: string; - msImageSmoothingEnabled: boolean; shadowBlur: number; shadowColor: string; shadowOffsetX: number; @@ -7718,6 +8002,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + drawFocusIfNeeded(element: Element): 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; @@ -7733,7 +8018,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { scale(x: number, y: number): void; setLineDash(segments: number[]): void; setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - stroke(): void; + stroke(path?: Path2D): void; strokeRect(x: number, y: number, w: number, h: number): void; strokeText(text: string, x: number, y: number, maxWidth?: number): void; transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; @@ -7819,17 +8104,7 @@ interface CloseEvent extends Event { declare var CloseEvent: { prototype: CloseEvent; - new(): CloseEvent; -} - -interface CommandEvent extends Event { - readonly commandName: string; - readonly detail: string | null; -} - -declare var CommandEvent: { - prototype: CommandEvent; - new(type: string, eventInitDict?: CommandEventInit): CommandEvent; + new(typeArg: string, eventInitDict?: CloseEventInit): CloseEvent; } interface Comment extends CharacterData { @@ -7856,7 +8131,7 @@ interface Console { assert(test?: boolean, message?: string, ...optionalParams: any[]): void; clear(): void; count(countTitle?: string): void; - debug(message?: string, ...optionalParams: any[]): void; + debug(message?: any, ...optionalParams: any[]): void; dir(value?: any, ...optionalParams: any[]): void; dirxml(value: any): void; error(message?: any, ...optionalParams: any[]): void; @@ -8026,9 +8301,9 @@ declare var DOMException: { interface DOMImplementation { createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType): Document; - createDocumentType(qualifiedName: string, publicId: string | null, systemId: string | null): DocumentType; + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; createHTMLDocument(title: string): Document; - hasFeature(feature: string | null, version: string | null): boolean; + hasFeature(): boolean; } declare var DOMImplementation: { @@ -8067,7 +8342,7 @@ declare var DOMStringList: { } interface DOMStringMap { - [name: string]: string; + [name: string]: string | undefined; } declare var DOMStringMap: { @@ -8093,7 +8368,7 @@ declare var DOMTokenList: { interface DataCue extends TextTrackCue { data: ArrayBuffer; - addEventListener(type: K, listener: (this: TextTrackCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: DataCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8123,6 +8398,7 @@ interface DataTransferItem { readonly type: string; getAsFile(): File | null; getAsString(_callback: FunctionStringCallback | null): void; + webkitGetAsEntry(): any; } declare var DataTransferItem: { @@ -8183,7 +8459,7 @@ interface DeviceLightEvent extends Event { declare var DeviceLightEvent: { prototype: DeviceLightEvent; - new(type: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; + new(typeArg: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; } interface DeviceMotionEvent extends Event { @@ -8196,7 +8472,7 @@ interface DeviceMotionEvent extends Event { declare var DeviceMotionEvent: { prototype: DeviceMotionEvent; - new(): DeviceMotionEvent; + new(typeArg: string, eventInitDict?: DeviceMotionEventInit): DeviceMotionEvent; } interface DeviceOrientationEvent extends Event { @@ -8209,7 +8485,7 @@ interface DeviceOrientationEvent extends Event { declare var DeviceOrientationEvent: { prototype: DeviceOrientationEvent; - new(): DeviceOrientationEvent; + new(typeArg: string, eventInitDict?: DeviceOrientationEventInit): DeviceOrientationEvent; } interface DeviceRotationRate { @@ -8291,7 +8567,7 @@ interface DocumentEventMap extends GlobalEventHandlersEventMap { "pointerlockerror": Event; "progress": ProgressEvent; "ratechange": Event; - "readystatechange": ProgressEvent; + "readystatechange": Event; "reset": Event; "scroll": UIEvent; "seeked": Event; @@ -8362,10 +8638,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven readonly compatMode: string; cookie: string; readonly currentScript: HTMLScriptElement | SVGScriptElement; - /** - * Gets the default character set from the current regional language settings. - */ - readonly defaultCharset: string; readonly defaultView: Window; /** * Sets or gets a value that indicates whether the document can be edited. @@ -8672,7 +8944,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Fires when the state of the object has changed. * @param ev The event */ - onreadystatechange: (this: Document, ev: ProgressEvent) => any; + onreadystatechange: (this: Document, ev: Event) => any; /** * Fires when the user resets a form. * @param ev The event. @@ -9040,8 +9312,8 @@ interface DocumentType extends Node, ChildNode { readonly internalSubset: string | null; readonly name: string; readonly notations: NamedNodeMap; - readonly publicId: string | null; - readonly systemId: string | null; + readonly publicId: string; + readonly systemId: string; } declare var DocumentType: { @@ -9064,7 +9336,7 @@ interface DynamicsCompressorNode extends AudioNode { readonly attack: AudioParam; readonly knee: AudioParam; readonly ratio: AudioParam; - readonly reduction: AudioParam; + readonly reduction: number; readonly release: AudioParam; readonly threshold: AudioParam; } @@ -9095,8 +9367,8 @@ declare var EXT_texture_filter_anisotropic: { } interface ElementEventMap extends GlobalEventHandlersEventMap { - "ariarequest": AriaRequestEvent; - "command": CommandEvent; + "ariarequest": Event; + "command": Event; "gotpointercapture": PointerEvent; "lostpointercapture": PointerEvent; "MSGestureChange": MSGestureEvent; @@ -9132,10 +9404,11 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec readonly clientTop: number; readonly clientWidth: number; id: string; + innerHTML: string; msContentZoomFactor: number; readonly msRegionOverflow: string; - onariarequest: (this: Element, ev: AriaRequestEvent) => any; - oncommand: (this: Element, ev: CommandEvent) => any; + onariarequest: (this: Element, ev: Event) => any; + oncommand: (this: Element, ev: Event) => any; ongotpointercapture: (this: Element, ev: PointerEvent) => any; onlostpointercapture: (this: Element, ev: PointerEvent) => any; onmsgesturechange: (this: Element, ev: MSGestureEvent) => any; @@ -9161,13 +9434,13 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec ontouchstart: (ev: TouchEvent) => any; onwebkitfullscreenchange: (this: Element, ev: Event) => any; onwebkitfullscreenerror: (this: Element, ev: Event) => any; + outerHTML: string; readonly prefix: string | null; readonly scrollHeight: number; scrollLeft: number; scrollTop: number; readonly scrollWidth: number; readonly tagName: string; - innerHTML: string; readonly assignedSlot: HTMLSlotElement | null; slot: string; readonly shadowRoot: ShadowRoot | null; @@ -9191,7 +9464,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec msSetPointerCapture(pointerId: number): void; msZoomTo(args: MsZoomToOptions): void; releasePointerCapture(pointerId: number): void; - removeAttribute(name?: string): void; + removeAttribute(qualifiedName: string): void; removeAttributeNS(namespaceURI: string, localName: string): void; removeAttributeNode(oldAttr: Attr): Attr; requestFullscreen(): void; @@ -9238,7 +9511,7 @@ interface ErrorEvent extends Event { declare var ErrorEvent: { prototype: ErrorEvent; - new(): ErrorEvent; + new(type: string, errorEventInitDict?: ErrorEventInit): ErrorEvent; } interface Event { @@ -9267,7 +9540,7 @@ interface Event { declare var Event: { prototype: Event; - new(type: string, eventInitDict?: EventInit): Event; + new(typeArg: string, eventInitDict?: EventInit): Event; readonly AT_TARGET: number; readonly BUBBLING_PHASE: number; readonly CAPTURING_PHASE: number; @@ -9284,6 +9557,21 @@ declare var EventTarget: { new(): EventTarget; } +interface ExtensionScriptApis { + extensionIdToShortId(extensionId: string): number; + fireExtensionApiTelemetry(functionName: string, isSucceeded: boolean, isSupported: boolean): void; + genericFunction(routerAddress: any, parameters?: string, callbackId?: number): void; + genericSynchronousFunction(functionId: number, parameters?: string): string; + getExtensionId(): string; + registerGenericFunctionCallbackHandler(callbackHandler: any): void; + registerGenericPersistentCallbackHandler(callbackHandler: any): void; +} + +declare var ExtensionScriptApis: { + prototype: ExtensionScriptApis; + new(): ExtensionScriptApis; +} + interface External { } @@ -9320,7 +9608,7 @@ interface FileReader extends EventTarget, MSBaseReader { readAsBinaryString(blob: Blob): void; readAsDataURL(blob: Blob): void; readAsText(blob: Blob, encoding?: string): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9339,6 +9627,20 @@ declare var FocusEvent: { new(typeArg: string, eventInitDict?: FocusEventInit): FocusEvent; } +interface FocusNavigationEvent extends Event { + readonly navigationReason: string; + readonly originHeight: number; + readonly originLeft: number; + readonly originTop: number; + readonly originWidth: number; + requestFocus(): void; +} + +declare var FocusNavigationEvent: { + prototype: FocusNavigationEvent; + new(type: string, eventInitDict?: FocusNavigationEventInit): FocusNavigationEvent; +} + interface FormData { append(name: any, value: any, blobName?: string): void; } @@ -9388,7 +9690,7 @@ interface GamepadEvent extends Event { declare var GamepadEvent: { prototype: GamepadEvent; - new(): GamepadEvent; + new(typeArg: string, eventInitDict?: GamepadEventInit): GamepadEvent; } interface Geolocation { @@ -9402,8 +9704,11 @@ declare var Geolocation: { new(): Geolocation; } -interface HTMLAllCollection extends HTMLCollection { - namedItem(name: string): Element; +interface HTMLAllCollection { + readonly length: number; + item(nameOrIndex?: string): HTMLCollection | Element | null; + namedItem(name: string): HTMLCollection | Element | null; + [index: number]: Element; } declare var HTMLAllCollection: { @@ -9491,7 +9796,7 @@ interface HTMLAnchorElement extends HTMLElement { * Returns a string representation of an object. */ toString(): string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAnchorElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9565,7 +9870,7 @@ interface HTMLAppletElement extends HTMLElement { useMap: string; vspace: number; width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAppletElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9633,7 +9938,7 @@ interface HTMLAreaElement extends HTMLElement { * Returns a string representation of an object. */ toString(): string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9642,15 +9947,7 @@ declare var HTMLAreaElement: { new(): HTMLAreaElement; } -interface HTMLAreasCollection extends HTMLCollection { - /** - * Adds an element to the areas, controlRange, or options collection. - */ - add(element: HTMLElement, before?: HTMLElement | number): void; - /** - * Removes an element from the collection. - */ - remove(index?: number): void; +interface HTMLAreasCollection extends HTMLCollectionBase { } declare var HTMLAreasCollection: { @@ -9659,7 +9956,7 @@ declare var HTMLAreasCollection: { } interface HTMLAudioElement extends HTMLMediaElement { - addEventListener(type: K, listener: (this: HTMLMediaElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAudioElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9673,7 +9970,7 @@ interface HTMLBRElement extends HTMLElement { * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. */ clear: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9691,7 +9988,7 @@ interface HTMLBaseElement extends HTMLElement { * Sets or retrieves the window or frame at which to target content. */ target: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBaseElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9709,7 +10006,7 @@ interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty * Sets or retrieves the font size of the object. */ size: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBaseFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9735,6 +10032,7 @@ interface HTMLBodyElementEventMap extends HTMLElementEventMap { "pageshow": PageTransitionEvent; "popstate": PopStateEvent; "resize": UIEvent; + "scroll": UIEvent; "storage": StorageEvent; "unload": Event; } @@ -9762,6 +10060,7 @@ interface HTMLBodyElement extends HTMLElement { onpageshow: (this: HTMLBodyElement, ev: PageTransitionEvent) => any; onpopstate: (this: HTMLBodyElement, ev: PopStateEvent) => any; onresize: (this: HTMLBodyElement, ev: UIEvent) => any; + onscroll: (this: HTMLBodyElement, ev: UIEvent) => any; onstorage: (this: HTMLBodyElement, ev: StorageEvent) => any; onunload: (this: HTMLBodyElement, ev: Event) => any; text: any; @@ -9839,7 +10138,7 @@ interface HTMLButtonElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLButtonElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9874,7 +10173,7 @@ interface HTMLCanvasElement extends HTMLElement { */ toDataURL(type?: string, ...args: any[]): string; toBlob(callback: (result: Blob | null) => void, type?: string, ...arguments: any[]): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9883,7 +10182,7 @@ declare var HTMLCanvasElement: { new(): HTMLCanvasElement; } -interface HTMLCollection { +interface HTMLCollectionBase { /** * Sets or retrieves the number of objects in a collection. */ @@ -9892,11 +10191,14 @@ interface HTMLCollection { * Retrieves an object from various collections. */ item(index: number): Element; + [index: number]: Element; +} + +interface HTMLCollection extends HTMLCollectionBase { /** * Retrieves a select object or an object from an options collection. */ - namedItem(name: string): Element; - [index: number]: Element; + namedItem(name: string): Element | null; } declare var HTMLCollection: { @@ -9906,7 +10208,7 @@ declare var HTMLCollection: { interface HTMLDListElement extends HTMLElement { compact: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9915,9 +10217,20 @@ declare var HTMLDListElement: { new(): HTMLDListElement; } +interface HTMLDataElement extends HTMLElement { + value: string; + addEventListener(type: K, listener: (this: HTMLDataElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDataElement: { + prototype: HTMLDataElement; + new(): HTMLDataElement; +} + interface HTMLDataListElement extends HTMLElement { options: HTMLCollectionOf; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDataListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9928,7 +10241,7 @@ declare var HTMLDataListElement: { interface HTMLDirectoryElement extends HTMLElement { compact: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDirectoryElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9946,7 +10259,7 @@ interface HTMLDivElement extends HTMLElement { * Sets or retrieves whether the browser automatically performs wordwrap. */ noWrap: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9956,7 +10269,7 @@ declare var HTMLDivElement: { } interface HTMLDocument extends Document { - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10044,7 +10357,6 @@ interface HTMLElement extends Element { draggable: boolean; hidden: boolean; hideFocus: boolean; - innerHTML: string; innerText: string; readonly isContentEditable: boolean; lang: string; @@ -10120,7 +10432,6 @@ interface HTMLElement extends Element { ontimeupdate: (this: HTMLElement, ev: Event) => any; onvolumechange: (this: HTMLElement, ev: Event) => any; onwaiting: (this: HTMLElement, ev: Event) => any; - outerHTML: string; outerText: string; spellcheck: boolean; readonly style: CSSStyleDeclaration; @@ -10131,7 +10442,6 @@ interface HTMLElement extends Element { dragDrop(): boolean; focus(): void; msGetInputContext(): MSInputMethodContext; - setActive(): void; addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10188,7 +10498,7 @@ interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the width of the object. */ width: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLEmbedElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10207,6 +10517,7 @@ interface HTMLFieldSetElement extends HTMLElement { * Retrieves a reference to the form that the object is embedded in. */ readonly form: HTMLFormElement; + name: string; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. */ @@ -10228,7 +10539,7 @@ interface HTMLFieldSetElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFieldSetElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10242,7 +10553,7 @@ interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOM * Sets or retrieves the current typeface family. */ face: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10251,6 +10562,15 @@ declare var HTMLFontElement: { new(): HTMLFontElement; } +interface HTMLFormControlsCollection extends HTMLCollectionBase { + namedItem(name: string): HTMLCollection | Element | null; +} + +declare var HTMLFormControlsCollection: { + prototype: HTMLFormControlsCollection; + new(): HTMLFormControlsCollection; +} + interface HTMLFormElement extends HTMLElement { /** * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. @@ -10267,7 +10587,7 @@ interface HTMLFormElement extends HTMLElement { /** * Retrieves a collection, in source order, of all controls in a given form. */ - readonly elements: HTMLCollection; + readonly elements: HTMLFormControlsCollection; /** * Sets or retrieves the MIME encoding for the form. */ @@ -10318,7 +10638,7 @@ interface HTMLFormElement extends HTMLElement { * Fires when a FORM is about to be submitted. */ submit(): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFormElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [name: string]: any; } @@ -10407,6 +10727,7 @@ declare var HTMLFrameElement: { } interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { + "afterprint": Event; "beforeprint": Event; "beforeunload": BeforeUnloadEvent; "blur": FocusEvent; @@ -10420,7 +10741,9 @@ interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { "orientationchange": Event; "pagehide": PageTransitionEvent; "pageshow": PageTransitionEvent; + "popstate": PopStateEvent; "resize": UIEvent; + "scroll": UIEvent; "storage": StorageEvent; "unload": Event; } @@ -10464,7 +10787,9 @@ interface HTMLFrameSetElement extends HTMLElement { onorientationchange: (this: HTMLFrameSetElement, ev: Event) => any; onpagehide: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; onpageshow: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; + onpopstate: (this: HTMLFrameSetElement, ev: PopStateEvent) => any; onresize: (this: HTMLFrameSetElement, ev: UIEvent) => any; + onscroll: (this: HTMLFrameSetElement, ev: UIEvent) => any; onstorage: (this: HTMLFrameSetElement, ev: StorageEvent) => any; onunload: (this: HTMLFrameSetElement, ev: Event) => any; /** @@ -10493,7 +10818,7 @@ interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2 * Sets or retrieves the width of the object. */ width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10504,7 +10829,7 @@ declare var HTMLHRElement: { interface HTMLHeadElement extends HTMLElement { profile: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHeadElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10518,7 +10843,7 @@ interface HTMLHeadingElement extends HTMLElement { * Sets or retrieves a value that indicates the table alignment. */ align: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHeadingElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10532,7 +10857,7 @@ interface HTMLHtmlElement extends HTMLElement { * Sets or retrieves the DTD version that governs the current document. */ version: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHtmlElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10551,6 +10876,7 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { */ align: string; allowFullscreen: boolean; + allowPaymentRequest: boolean; /** * Specifies the properties of a border drawn around an object. */ @@ -10646,7 +10972,7 @@ interface HTMLImageElement extends HTMLElement { * Retrieves whether the object is fully loaded. */ readonly complete: boolean; - crossOrigin: string; + crossOrigin: string | null; readonly currentSrc: string; /** * Sets or retrieves the height of the object. @@ -10711,14 +11037,13 @@ interface HTMLImageElement extends HTMLElement { readonly x: number; readonly y: number; msGetAsCastingSource(): any; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLImageElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLImageElement: { prototype: HTMLImageElement; new(): HTMLImageElement; - create(): HTMLImageElement; } interface HTMLInputElement extends HTMLElement { @@ -10924,7 +11249,7 @@ interface HTMLInputElement extends HTMLElement { * @param n Value to increment the value by. */ stepUp(n?: number): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLInputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10939,7 +11264,7 @@ interface HTMLLIElement extends HTMLElement { * Sets or retrieves the value of a list item. */ value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLIElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10957,7 +11282,7 @@ interface HTMLLabelElement extends HTMLElement { * Sets or retrieves the object to which the given label object is assigned. */ htmlFor: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLabelElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10975,7 +11300,7 @@ interface HTMLLegendElement extends HTMLElement { * Retrieves a reference to the form that the object is embedded in. */ readonly form: HTMLFormElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11020,7 +11345,7 @@ interface HTMLLinkElement extends HTMLElement, LinkStyle { type: string; import?: Document; integrity: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLinkElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11038,7 +11363,7 @@ interface HTMLMapElement extends HTMLElement { * Sets or retrieves the name of the object. */ name: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMapElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11101,7 +11426,7 @@ interface HTMLMediaElement extends HTMLElement { * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). */ controls: boolean; - crossOrigin: string; + crossOrigin: string | null; /** * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. */ @@ -11242,7 +11567,7 @@ interface HTMLMediaElement extends HTMLElement { * Loads and starts playback of a media resource. */ play(): void; - setMediaKeys(mediaKeys: MediaKeys | null): PromiseLike; + setMediaKeys(mediaKeys: MediaKeys | null): Promise; readonly HAVE_CURRENT_DATA: number; readonly HAVE_ENOUGH_DATA: number; readonly HAVE_FUTURE_DATA: number; @@ -11273,7 +11598,7 @@ declare var HTMLMediaElement: { interface HTMLMenuElement extends HTMLElement { compact: boolean; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMenuElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11307,7 +11632,7 @@ interface HTMLMetaElement extends HTMLElement { * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. */ url: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMetaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11323,7 +11648,7 @@ interface HTMLMeterElement extends HTMLElement { min: number; optimum: number; value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMeterElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11341,7 +11666,7 @@ interface HTMLModElement extends HTMLElement { * Sets or retrieves the date and time of a modification to the object. */ dateTime: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLModElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11357,7 +11682,7 @@ interface HTMLOListElement extends HTMLElement { */ start: number; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11435,10 +11760,6 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the name of the object. */ name: string; - /** - * Retrieves the contained object. - */ - readonly object: any; readonly readyState: number; /** * Sets or retrieves a message to be displayed while an object is loading. @@ -11478,7 +11799,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLObjectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11517,7 +11838,7 @@ interface HTMLOptGroupElement extends HTMLElement { * Sets or retrieves the value which is returned to the server when the form control is submitted. */ value: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOptGroupElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11556,14 +11877,13 @@ interface HTMLOptionElement extends HTMLElement { * Sets or retrieves the value which is returned to the server when the form control is submitted. */ value: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLOptionElement: { prototype: HTMLOptionElement; new(): HTMLOptionElement; - create(): HTMLOptionElement; } interface HTMLOptionsCollection extends HTMLCollectionOf { @@ -11578,13 +11898,35 @@ declare var HTMLOptionsCollection: { new(): HTMLOptionsCollection; } +interface HTMLOutputElement extends HTMLElement { + defaultValue: string; + readonly form: HTMLFormElement; + readonly htmlFor: DOMSettableTokenList; + name: string; + readonly type: string; + readonly validationMessage: string; + readonly validity: ValidityState; + value: string; + readonly willValidate: boolean; + checkValidity(): boolean; + reportValidity(): boolean; + setCustomValidity(error: string): void; + addEventListener(type: K, listener: (this: HTMLOutputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLOutputElement: { + prototype: HTMLOutputElement; + new(): HTMLOutputElement; +} + interface HTMLParagraphElement extends HTMLElement { /** * Sets or retrieves how the object is aligned with adjacent text. */ align: string; clear: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLParagraphElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11610,7 +11952,7 @@ interface HTMLParamElement extends HTMLElement { * Sets or retrieves the data type of the value attribute. */ valueType: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLParamElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11620,7 +11962,7 @@ declare var HTMLParamElement: { } interface HTMLPictureElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLPictureElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11634,7 +11976,7 @@ interface HTMLPreElement extends HTMLElement { * Sets or gets a value that you can use to implement your own width functionality for the object. */ width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLPreElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11660,7 +12002,7 @@ interface HTMLProgressElement extends HTMLElement { * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. */ value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLProgressElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11674,7 +12016,7 @@ interface HTMLQuoteElement extends HTMLElement { * Sets or retrieves reference information about the object. */ cite: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLQuoteElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11689,6 +12031,7 @@ interface HTMLScriptElement extends HTMLElement { * Sets or retrieves the character set used to encode the object. */ charset: string; + crossOrigin: string | null; /** * Sets or retrieves the status of the script. */ @@ -11714,7 +12057,7 @@ interface HTMLScriptElement extends HTMLElement { */ type: string; integrity: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLScriptElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11810,7 +12153,7 @@ interface HTMLSelectElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSelectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [name: string]: any; } @@ -11836,7 +12179,7 @@ interface HTMLSourceElement extends HTMLElement { * Gets or sets the MIME type of a media resource. */ type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSourceElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11846,7 +12189,7 @@ declare var HTMLSourceElement: { } interface HTMLSpanElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSpanElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11865,7 +12208,7 @@ interface HTMLStyleElement extends HTMLElement, LinkStyle { * Retrieves the CSS language in which the style sheet is written. */ type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLStyleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11883,7 +12226,7 @@ interface HTMLTableCaptionElement extends HTMLElement { * Sets or retrieves whether the caption appears at the top or bottom of the table. */ vAlign: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableCaptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11938,7 +12281,7 @@ interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment { * Sets or retrieves the width of the object. */ width: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11960,7 +12303,7 @@ interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { * Sets or retrieves the width of the object. */ width: any; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableColElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11970,6 +12313,8 @@ declare var HTMLTableColElement: { } interface HTMLTableDataCellElement extends HTMLTableCellElement { + addEventListener(type: K, listener: (this: HTMLTableDataCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLTableDataCellElement: { @@ -12081,7 +12426,7 @@ interface HTMLTableElement extends HTMLElement { * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. */ insertRow(index?: number): HTMLTableRowElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12095,6 +12440,8 @@ interface HTMLTableHeaderCellElement extends HTMLTableCellElement { * Sets or retrieves the group of cells in a table to which the object's information applies. */ scope: string; + addEventListener(type: K, listener: (this: HTMLTableHeaderCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLTableHeaderCellElement: { @@ -12134,7 +12481,7 @@ interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment { * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. */ insertCell(index?: number): HTMLTableDataCellElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableRowElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12162,7 +12509,7 @@ interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment { * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. */ insertRow(index?: number): HTMLTableRowElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableSectionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12173,7 +12520,7 @@ declare var HTMLTableSectionElement: { interface HTMLTemplateElement extends HTMLElement { readonly content: DocumentFragment; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTemplateElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12280,7 +12627,7 @@ interface HTMLTextAreaElement extends HTMLElement { * @param end The offset into the text field for the end of the selection. */ setSelectionRange(start: number, end: number): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTextAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12289,12 +12636,23 @@ declare var HTMLTextAreaElement: { new(): HTMLTextAreaElement; } +interface HTMLTimeElement extends HTMLElement { + dateTime: string; + addEventListener(type: K, listener: (this: HTMLTimeElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTimeElement: { + prototype: HTMLTimeElement; + new(): HTMLTimeElement; +} + interface HTMLTitleElement extends HTMLElement { /** * Retrieves or sets the text of the object as a string. */ text: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTitleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12315,7 +12673,7 @@ interface HTMLTrackElement extends HTMLElement { readonly LOADED: number; readonly LOADING: number; readonly NONE: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTrackElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12331,7 +12689,7 @@ declare var HTMLTrackElement: { interface HTMLUListElement extends HTMLElement { compact: boolean; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLUListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12341,7 +12699,7 @@ declare var HTMLUListElement: { } interface HTMLUnknownElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLUnknownElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12412,7 +12770,21 @@ interface HashChangeEvent extends Event { declare var HashChangeEvent: { prototype: HashChangeEvent; - new(type: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; + new(typeArg: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; +} + +interface Headers { + append(name: string, value: string): void; + delete(name: string): void; + forEach(callback: ForEachCallback): void; + get(name: string): string | null; + has(name: string): boolean; + set(name: string, value: string): void; +} + +declare var Headers: { + prototype: Headers; + new(init?: any): Headers; } interface History { @@ -12466,14 +12838,14 @@ declare var IDBCursorWithValue: { interface IDBDatabaseEventMap { "abort": Event; - "error": ErrorEvent; + "error": Event; } interface IDBDatabase extends EventTarget { readonly name: string; readonly objectStoreNames: DOMStringList; onabort: (this: IDBDatabase, ev: Event) => any; - onerror: (this: IDBDatabase, ev: ErrorEvent) => any; + onerror: (this: IDBDatabase, ev: Event) => any; version: number; onversionchange: (ev: IDBVersionChangeEvent) => any; close(): void; @@ -12576,13 +12948,13 @@ declare var IDBOpenDBRequest: { } interface IDBRequestEventMap { - "error": ErrorEvent; + "error": Event; "success": Event; } interface IDBRequest extends EventTarget { readonly error: DOMError; - onerror: (this: IDBRequest, ev: ErrorEvent) => any; + onerror: (this: IDBRequest, ev: Event) => any; onsuccess: (this: IDBRequest, ev: Event) => any; readonly readyState: string; readonly result: any; @@ -12600,7 +12972,7 @@ declare var IDBRequest: { interface IDBTransactionEventMap { "abort": Event; "complete": Event; - "error": ErrorEvent; + "error": Event; } interface IDBTransaction extends EventTarget { @@ -12609,7 +12981,7 @@ interface IDBTransaction extends EventTarget { readonly mode: string; onabort: (this: IDBTransaction, ev: Event) => any; oncomplete: (this: IDBTransaction, ev: Event) => any; - onerror: (this: IDBTransaction, ev: ErrorEvent) => any; + onerror: (this: IDBTransaction, ev: Event) => any; abort(): void; objectStore(name: string): IDBObjectStore; readonly READ_ONLY: string; @@ -12637,6 +13009,15 @@ declare var IDBVersionChangeEvent: { new(): IDBVersionChangeEvent; } +interface IIRFilterNode extends AudioNode { + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; +} + +declare var IIRFilterNode: { + prototype: IIRFilterNode; + new(): IIRFilterNode; +} + interface ImageData { data: Uint8ClampedArray; readonly height: number; @@ -12649,6 +13030,35 @@ declare var ImageData: { new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +interface IntersectionObserver { + readonly root: Element | null; + readonly rootMargin: string; + readonly thresholds: number[]; + disconnect(): void; + observe(target: Element): void; + takeRecords(): IntersectionObserverEntry[]; + unobserve(target: Element): void; +} + +declare var IntersectionObserver: { + prototype: IntersectionObserver; + new(callback: IntersectionObserverCallback, options?: IntersectionObserverInit): IntersectionObserver; +} + +interface IntersectionObserverEntry { + readonly boundingClientRect: ClientRect; + readonly intersectionRatio: number; + readonly intersectionRect: ClientRect; + readonly rootBounds: ClientRect; + readonly target: Element; + readonly time: number; +} + +declare var IntersectionObserverEntry: { + prototype: IntersectionObserverEntry; + new(intersectionObserverEntryInit: IntersectionObserverEntryInit): IntersectionObserverEntry; +} + interface KeyboardEvent extends UIEvent { readonly altKey: boolean; readonly char: string | null; @@ -12735,7 +13145,7 @@ interface MSApp { execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; getCurrentPriority(): string; - getHtmlPrintDocumentSourceAsync(htmlDoc: any): PromiseLike; + getHtmlPrintDocumentSourceAsync(htmlDoc: any): Promise; getViewId(view: any): any; isTaskScheduledAtPriorityOrHigher(priority: string): boolean; pageHandlesAllApplicationActivations(enabled: boolean): void; @@ -12750,13 +13160,13 @@ declare var MSApp: MSApp; interface MSAppAsyncOperationEventMap { "complete": Event; - "error": ErrorEvent; + "error": Event; } interface MSAppAsyncOperation extends EventTarget { readonly error: DOMError; oncomplete: (this: MSAppAsyncOperation, ev: Event) => any; - onerror: (this: MSAppAsyncOperation, ev: ErrorEvent) => any; + onerror: (this: MSAppAsyncOperation, ev: Event) => any; readonly readyState: number; readonly result: any; start(): void; @@ -12796,8 +13206,8 @@ declare var MSBlobBuilder: { } interface MSCredentials { - getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): PromiseLike; - makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): PromiseLike; + getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): Promise; + makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): Promise; } declare var MSCredentials: { @@ -12913,12 +13323,13 @@ interface MSHTMLWebViewElement extends HTMLElement { goForward(): void; invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; navigate(uri: string): void; + navigateFocus(navigationReason: string, origin: FocusNavigationOrigin): void; navigateToLocalStreamUri(source: string, streamResolver: any): void; navigateToString(contents: string): void; navigateWithHttpRequestMessage(requestMessage: any): void; refresh(): void; stop(): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: MSHTMLWebViewElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13110,7 +13521,7 @@ interface MSStreamReader extends EventTarget, MSBaseReader { readAsBlob(stream: MSStream, size?: number): void; readAsDataURL(stream: MSStream, size?: number): void; readAsText(stream: MSStream, encoding?: string, size?: number): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: MSStreamReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13121,13 +13532,13 @@ declare var MSStreamReader: { interface MSWebViewAsyncOperationEventMap { "complete": Event; - "error": ErrorEvent; + "error": Event; } interface MSWebViewAsyncOperation extends EventTarget { readonly error: DOMError; oncomplete: (this: MSWebViewAsyncOperation, ev: Event) => any; - onerror: (this: MSWebViewAsyncOperation, ev: ErrorEvent) => any; + onerror: (this: MSWebViewAsyncOperation, ev: Event) => any; readonly readyState: number; readonly result: any; readonly target: MSHTMLWebViewElement; @@ -13184,7 +13595,7 @@ interface MediaDevices extends EventTarget { ondevicechange: (this: MediaDevices, ev: Event) => any; enumerateDevices(): any; getSupportedConstraints(): MediaTrackSupportedConstraints; - getUserMedia(constraints: MediaStreamConstraints): PromiseLike; + getUserMedia(constraints: MediaStreamConstraints): Promise; addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13243,15 +13654,15 @@ declare var MediaKeyMessageEvent: { } interface MediaKeySession extends EventTarget { - readonly closed: PromiseLike; + readonly closed: Promise; readonly expiration: number; readonly keyStatuses: MediaKeyStatusMap; readonly sessionId: string; - close(): PromiseLike; - generateRequest(initDataType: string, initData: any): PromiseLike; - load(sessionId: string): PromiseLike; - remove(): PromiseLike; - update(response: any): PromiseLike; + close(): Promise; + generateRequest(initDataType: string, initData: any): Promise; + load(sessionId: string): Promise; + remove(): Promise; + update(response: any): Promise; } declare var MediaKeySession: { @@ -13273,7 +13684,7 @@ declare var MediaKeyStatusMap: { interface MediaKeySystemAccess { readonly keySystem: string; - createMediaKeys(): PromiseLike; + createMediaKeys(): Promise; getConfiguration(): MediaKeySystemConfiguration; } @@ -13284,7 +13695,7 @@ declare var MediaKeySystemAccess: { interface MediaKeys { createSession(sessionType?: string): MediaKeySession; - setServerCertificate(serverCertificate: any): PromiseLike; + setServerCertificate(serverCertificate: any): Promise; } declare var MediaKeys: { @@ -13337,18 +13748,18 @@ declare var MediaSource: { interface MediaStreamEventMap { "active": Event; - "addtrack": TrackEvent; + "addtrack": MediaStreamTrackEvent; "inactive": Event; - "removetrack": TrackEvent; + "removetrack": MediaStreamTrackEvent; } interface MediaStream extends EventTarget { readonly active: boolean; readonly id: string; onactive: (this: MediaStream, ev: Event) => any; - onaddtrack: (this: MediaStream, ev: TrackEvent) => any; + onaddtrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; oninactive: (this: MediaStream, ev: Event) => any; - onremovetrack: (this: MediaStream, ev: TrackEvent) => any; + onremovetrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; addTrack(track: MediaStreamTrack): void; clone(): MediaStream; getAudioTracks(): MediaStreamTrack[]; @@ -13391,7 +13802,16 @@ interface MediaStreamErrorEvent extends Event { declare var MediaStreamErrorEvent: { prototype: MediaStreamErrorEvent; - new(type: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; + new(typeArg: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; +} + +interface MediaStreamEvent extends Event { + readonly stream: MediaStream | null; +} + +declare var MediaStreamEvent: { + prototype: MediaStreamEvent; + new(type: string, eventInitDict: MediaStreamEventInit): MediaStreamEvent; } interface MediaStreamTrackEventMap { @@ -13414,7 +13834,7 @@ interface MediaStreamTrack extends EventTarget { readonly readonly: boolean; readonly readyState: string; readonly remote: boolean; - applyConstraints(constraints: MediaTrackConstraints): PromiseLike; + applyConstraints(constraints: MediaTrackConstraints): Promise; clone(): MediaStreamTrack; getCapabilities(): MediaTrackCapabilities; getConstraints(): MediaTrackConstraints; @@ -13435,7 +13855,7 @@ interface MediaStreamTrackEvent extends Event { declare var MediaStreamTrackEvent: { prototype: MediaStreamTrackEvent; - new(type: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; + new(typeArg: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; } interface MessageChannel { @@ -13468,7 +13888,7 @@ interface MessagePortEventMap { interface MessagePort extends EventTarget { onmessage: (this: MessagePort, ev: MessageEvent) => any; close(): void; - postMessage(message?: any, ports?: any): void; + postMessage(message?: any, transfer?: any[]): void; start(): void; addEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -13630,9 +14050,10 @@ declare var NavigationEventWithReferrer: { new(): NavigationEventWithReferrer; } -interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorUserMedia { - readonly appCodeName: string; +interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia { + readonly authentication: WebAuthentication; readonly cookieEnabled: boolean; + gamepadInputEmulation: string; readonly language: string; readonly maxTouchPoints: number; readonly mimeTypes: MimeTypeArray; @@ -13641,12 +14062,13 @@ interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorConte readonly msPointerEnabled: boolean; readonly plugins: PluginArray; readonly pointerEnabled: boolean; + readonly serviceWorker: ServiceWorkerContainer; readonly webdriver: boolean; readonly hardwareConcurrency: number; getGamepads(): Gamepad[]; javaEnabled(): boolean; msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; - requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): PromiseLike; + requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): Promise; vibrate(pattern: number | number[]): boolean; } @@ -13672,7 +14094,7 @@ interface Node extends EventTarget { readonly parentNode: Node | null; readonly previousSibling: Node | null; textContent: string | null; - appendChild(newChild: Node): Node; + appendChild(newChild: T): T; cloneNode(deep?: boolean): Node; compareDocumentPosition(other: Node): number; contains(child: Node): boolean; @@ -13779,6 +14201,36 @@ declare var NodeList: { new(): NodeList; } +interface NotificationEventMap { + "click": Event; + "close": Event; + "error": Event; + "show": Event; +} + +interface Notification extends EventTarget { + readonly body: string; + readonly dir: string; + readonly icon: string; + readonly lang: string; + onclick: (this: Notification, ev: Event) => any; + onclose: (this: Notification, ev: Event) => any; + onerror: (this: Notification, ev: Event) => any; + onshow: (this: Notification, ev: Event) => any; + readonly permission: string; + readonly tag: string; + readonly title: string; + close(): void; + addEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Notification: { + prototype: Notification; + new(title: string, options?: NotificationOptions): Notification; + requestPermission(callback?: NotificationPermissionCallback): Promise; +} + interface OES_element_index_uint { } @@ -13813,6 +14265,24 @@ declare var OES_texture_float_linear: { new(): OES_texture_float_linear; } +interface OES_texture_half_float { + readonly HALF_FLOAT_OES: number; +} + +declare var OES_texture_half_float: { + prototype: OES_texture_half_float; + new(): OES_texture_half_float; + readonly HALF_FLOAT_OES: number; +} + +interface OES_texture_half_float_linear { +} + +declare var OES_texture_half_float_linear: { + prototype: OES_texture_half_float_linear; + new(): OES_texture_half_float_linear; +} + interface OfflineAudioCompletionEvent extends Event { readonly renderedBuffer: AudioBuffer; } @@ -13822,13 +14292,15 @@ declare var OfflineAudioCompletionEvent: { new(): OfflineAudioCompletionEvent; } -interface OfflineAudioContextEventMap { - "complete": Event; +interface OfflineAudioContextEventMap extends AudioContextEventMap { + "complete": OfflineAudioCompletionEvent; } -interface OfflineAudioContext extends AudioContext { - oncomplete: (this: OfflineAudioContext, ev: Event) => any; - startRendering(): PromiseLike; +interface OfflineAudioContext extends AudioContextBase { + readonly length: number; + oncomplete: (this: OfflineAudioContext, ev: OfflineAudioCompletionEvent) => any; + startRendering(): Promise; + suspend(suspendTime: number): Promise; addEventListener(type: K, listener: (this: OfflineAudioContext, ev: OfflineAudioContextEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13904,6 +14376,82 @@ declare var PannerNode: { new(): PannerNode; } +interface Path2D extends Object, CanvasPathMethods { +} + +declare var Path2D: { + prototype: Path2D; + new(path?: Path2D): Path2D; +} + +interface PaymentAddress { + readonly addressLine: string[]; + readonly city: string; + readonly country: string; + readonly dependentLocality: string; + readonly languageCode: string; + readonly organization: string; + readonly phone: string; + readonly postalCode: string; + readonly recipient: string; + readonly region: string; + readonly sortingCode: string; + toJSON(): any; +} + +declare var PaymentAddress: { + prototype: PaymentAddress; + new(): PaymentAddress; +} + +interface PaymentRequestEventMap { + "shippingaddresschange": Event; + "shippingoptionchange": Event; +} + +interface PaymentRequest extends EventTarget { + onshippingaddresschange: (this: PaymentRequest, ev: Event) => any; + onshippingoptionchange: (this: PaymentRequest, ev: Event) => any; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + readonly shippingType: string | null; + abort(): Promise; + show(): Promise; + addEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var PaymentRequest: { + prototype: PaymentRequest; + new(methodData: PaymentMethodData[], details: PaymentDetails, options?: PaymentOptions): PaymentRequest; +} + +interface PaymentRequestUpdateEvent extends Event { + updateWith(d: Promise): void; +} + +declare var PaymentRequestUpdateEvent: { + prototype: PaymentRequestUpdateEvent; + new(type: string, eventInitDict?: PaymentRequestUpdateEventInit): PaymentRequestUpdateEvent; +} + +interface PaymentResponse { + readonly details: any; + readonly methodName: string; + readonly payerEmail: string | null; + readonly payerName: string | null; + readonly payerPhone: string | null; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + complete(result?: string): Promise; + toJSON(): any; +} + +declare var PaymentResponse: { + prototype: PaymentResponse; + new(): PaymentResponse; +} + interface PerfWidgetExternal { readonly activeNetworkRequestCount: number; readonly averageFrameTime: number; @@ -14169,7 +14717,7 @@ interface PopStateEvent extends Event { declare var PopStateEvent: { prototype: PopStateEvent; - new(): PopStateEvent; + new(typeArg: string, eventInitDict?: PopStateEventInit): PopStateEvent; } interface Position { @@ -14220,23 +14768,57 @@ declare var ProgressEvent: { new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } +interface PushManager { + getSubscription(): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; + subscribe(options?: PushSubscriptionOptionsInit): Promise; +} + +declare var PushManager: { + prototype: PushManager; + new(): PushManager; +} + +interface PushSubscription { + readonly endpoint: USVString; + readonly options: PushSubscriptionOptions; + getKey(name: string): ArrayBuffer | null; + toJSON(): any; + unsubscribe(): Promise; +} + +declare var PushSubscription: { + prototype: PushSubscription; + new(): PushSubscription; +} + +interface PushSubscriptionOptions { + readonly applicationServerKey: ArrayBuffer | null; + readonly userVisibleOnly: boolean; +} + +declare var PushSubscriptionOptions: { + prototype: PushSubscriptionOptions; + new(): PushSubscriptionOptions; +} + interface RTCDTMFToneChangeEvent extends Event { readonly tone: string; } declare var RTCDTMFToneChangeEvent: { prototype: RTCDTMFToneChangeEvent; - new(type: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; + new(typeArg: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; } interface RTCDtlsTransportEventMap { "dtlsstatechange": RTCDtlsTransportStateChangedEvent; - "error": ErrorEvent; + "error": Event; } interface RTCDtlsTransport extends RTCStatsProvider { ondtlsstatechange: ((this: RTCDtlsTransport, ev: RTCDtlsTransportStateChangedEvent) => any) | null; - onerror: ((this: RTCDtlsTransport, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCDtlsTransport, ev: Event) => any) | null; readonly state: string; readonly transport: RTCIceTransport; getLocalParameters(): RTCDtlsParameters; @@ -14283,6 +14865,18 @@ declare var RTCDtmfSender: { new(sender: RTCRtpSender): RTCDtmfSender; } +interface RTCIceCandidate { + candidate: string | null; + sdpMLineIndex: number | null; + sdpMid: string | null; + toJSON(): any; +} + +declare var RTCIceCandidate: { + prototype: RTCIceCandidate; + new(candidateInitDict?: RTCIceCandidateInit): RTCIceCandidate; +} + interface RTCIceCandidatePairChangedEvent extends Event { readonly pair: RTCIceCandidatePair; } @@ -14293,16 +14887,16 @@ declare var RTCIceCandidatePairChangedEvent: { } interface RTCIceGathererEventMap { - "error": ErrorEvent; + "error": Event; "localcandidate": RTCIceGathererEvent; } interface RTCIceGatherer extends RTCStatsProvider { readonly component: string; - onerror: ((this: RTCIceGatherer, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCIceGatherer, ev: Event) => any) | null; onlocalcandidate: ((this: RTCIceGatherer, ev: RTCIceGathererEvent) => any) | null; createAssociatedGatherer(): RTCIceGatherer; - getLocalCandidates(): RTCIceCandidate[]; + getLocalCandidates(): RTCIceCandidateDictionary[]; getLocalParameters(): RTCIceParameters; addEventListener(type: K, listener: (this: RTCIceGatherer, ev: RTCIceGathererEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -14314,7 +14908,7 @@ declare var RTCIceGatherer: { } interface RTCIceGathererEvent extends Event { - readonly candidate: RTCIceCandidate | RTCIceCandidateComplete; + readonly candidate: RTCIceCandidateDictionary | RTCIceCandidateComplete; } declare var RTCIceGathererEvent: { @@ -14334,12 +14928,12 @@ interface RTCIceTransport extends RTCStatsProvider { onicestatechange: ((this: RTCIceTransport, ev: RTCIceTransportStateChangedEvent) => any) | null; readonly role: string; readonly state: string; - addRemoteCandidate(remoteCandidate: RTCIceCandidate | RTCIceCandidateComplete): void; + addRemoteCandidate(remoteCandidate: RTCIceCandidateDictionary | RTCIceCandidateComplete): void; createAssociatedTransport(): RTCIceTransport; getNominatedCandidatePair(): RTCIceCandidatePair | null; - getRemoteCandidates(): RTCIceCandidate[]; + getRemoteCandidates(): RTCIceCandidateDictionary[]; getRemoteParameters(): RTCIceParameters | null; - setRemoteCandidates(remoteCandidates: RTCIceCandidate[]): void; + setRemoteCandidates(remoteCandidates: RTCIceCandidateDictionary[]): void; start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: string): void; stop(): void; addEventListener(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, useCapture?: boolean): void; @@ -14360,12 +14954,67 @@ declare var RTCIceTransportStateChangedEvent: { new(): RTCIceTransportStateChangedEvent; } +interface RTCPeerConnectionEventMap { + "addstream": MediaStreamEvent; + "icecandidate": RTCPeerConnectionIceEvent; + "iceconnectionstatechange": Event; + "icegatheringstatechange": Event; + "negotiationneeded": Event; + "removestream": MediaStreamEvent; + "signalingstatechange": Event; +} + +interface RTCPeerConnection extends EventTarget { + readonly canTrickleIceCandidates: boolean | null; + readonly iceConnectionState: string; + readonly iceGatheringState: string; + readonly localDescription: RTCSessionDescription | null; + onaddstream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onicecandidate: (this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any; + oniceconnectionstatechange: (this: RTCPeerConnection, ev: Event) => any; + onicegatheringstatechange: (this: RTCPeerConnection, ev: Event) => any; + onnegotiationneeded: (this: RTCPeerConnection, ev: Event) => any; + onremovestream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onsignalingstatechange: (this: RTCPeerConnection, ev: Event) => any; + readonly remoteDescription: RTCSessionDescription | null; + readonly signalingState: string; + addIceCandidate(candidate: RTCIceCandidate, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addStream(stream: MediaStream): void; + close(): void; + createAnswer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + createOffer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback, options?: RTCOfferOptions): Promise; + getConfiguration(): RTCConfiguration; + getLocalStreams(): MediaStream[]; + getRemoteStreams(): MediaStream[]; + getStats(selector: MediaStreamTrack | null, successCallback?: RTCStatsCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + getStreamById(streamId: string): MediaStream | null; + removeStream(stream: MediaStream): void; + setLocalDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + setRemoteDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addEventListener(type: K, listener: (this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCPeerConnection: { + prototype: RTCPeerConnection; + new(configuration: RTCConfiguration): RTCPeerConnection; +} + +interface RTCPeerConnectionIceEvent extends Event { + readonly candidate: RTCIceCandidate; +} + +declare var RTCPeerConnectionIceEvent: { + prototype: RTCPeerConnectionIceEvent; + new(type: string, eventInitDict: RTCPeerConnectionIceEventInit): RTCPeerConnectionIceEvent; +} + interface RTCRtpReceiverEventMap { - "error": ErrorEvent; + "error": Event; } interface RTCRtpReceiver extends RTCStatsProvider { - onerror: ((this: RTCRtpReceiver, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCRtpReceiver, ev: Event) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack | null; readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; @@ -14385,12 +15034,12 @@ declare var RTCRtpReceiver: { } interface RTCRtpSenderEventMap { - "error": ErrorEvent; + "error": Event; "ssrcconflict": RTCSsrcConflictEvent; } interface RTCRtpSender extends RTCStatsProvider { - onerror: ((this: RTCRtpSender, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCRtpSender, ev: Event) => any) | null; onssrcconflict: ((this: RTCRtpSender, ev: RTCSsrcConflictEvent) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack; @@ -14409,12 +15058,23 @@ declare var RTCRtpSender: { getCapabilities(kind?: string): RTCRtpCapabilities; } +interface RTCSessionDescription { + sdp: string | null; + type: string | null; + toJSON(): any; +} + +declare var RTCSessionDescription: { + prototype: RTCSessionDescription; + new(descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; +} + interface RTCSrtpSdesTransportEventMap { - "error": ErrorEvent; + "error": Event; } interface RTCSrtpSdesTransport extends EventTarget { - onerror: ((this: RTCSrtpSdesTransport, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCSrtpSdesTransport, ev: Event) => any) | null; readonly transport: RTCIceTransport; addEventListener(type: K, listener: (this: RTCSrtpSdesTransport, ev: RTCSrtpSdesTransportEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -14436,8 +15096,8 @@ declare var RTCSsrcConflictEvent: { } interface RTCStatsProvider extends EventTarget { - getStats(): PromiseLike; - msGetStats(): PromiseLike; + getStats(): Promise; + msGetStats(): Promise; } declare var RTCStatsProvider: { @@ -14489,9 +15149,69 @@ declare var Range: { readonly START_TO_START: number; } -interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface ReadableStream { + readonly locked: boolean; + cancel(): Promise; + getReader(): ReadableStreamReader; +} + +declare var ReadableStream: { + prototype: ReadableStream; + new(): ReadableStream; +} + +interface ReadableStreamReader { + cancel(): Promise; + read(): Promise; + releaseLock(): void; +} + +declare var ReadableStreamReader: { + prototype: ReadableStreamReader; + new(): ReadableStreamReader; +} + +interface Request extends Object, Body { + readonly cache: string; + readonly credentials: string; + readonly destination: string; + readonly headers: Headers; + readonly integrity: string; + readonly keepalive: boolean; + readonly method: string; + readonly mode: string; + readonly redirect: string; + readonly referrer: string; + readonly referrerPolicy: string; + readonly type: string; + readonly url: string; + clone(): Request; +} + +declare var Request: { + prototype: Request; + new(input: Request | string, init?: RequestInit): Request; +} + +interface Response extends Object, Body { + readonly body: ReadableStream | null; + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly type: string; + readonly url: string; + clone(): Response; +} + +declare var Response: { + prototype: Response; + new(body?: any, init?: ResponseInit): Response; +} + +interface SVGAElement extends SVGGraphicsElement, SVGURIReference { readonly target: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14644,11 +15364,11 @@ declare var SVGAnimatedTransformList: { new(): SVGAnimatedTransformList; } -interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGCircleElement extends SVGGraphicsElement { readonly cx: SVGAnimatedLength; readonly cy: SVGAnimatedLength; readonly r: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGCircleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14657,9 +15377,9 @@ declare var SVGCircleElement: { new(): SVGCircleElement; } -interface SVGClipPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { +interface SVGClipPathElement extends SVGGraphicsElement, SVGUnitTypes { readonly clipPathUnits: SVGAnimatedEnumeration; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGClipPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14682,7 +15402,7 @@ interface SVGComponentTransferFunctionElement extends SVGElement { readonly SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; readonly SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGComponentTransferFunctionElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14697,8 +15417,8 @@ declare var SVGComponentTransferFunctionElement: { readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; } -interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGDefsElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGDefsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14707,8 +15427,8 @@ declare var SVGDefsElement: { new(): SVGDefsElement; } -interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGDescElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGDescElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14731,6 +15451,7 @@ interface SVGElementEventMap extends ElementEventMap { } interface SVGElement extends Element { + className: any; onclick: (this: SVGElement, ev: MouseEvent) => any; ondblclick: (this: SVGElement, ev: MouseEvent) => any; onfocusin: (this: SVGElement, ev: FocusEvent) => any; @@ -14742,9 +15463,9 @@ interface SVGElement extends Element { onmouseover: (this: SVGElement, ev: MouseEvent) => any; onmouseup: (this: SVGElement, ev: MouseEvent) => any; readonly ownerSVGElement: SVGSVGElement; + readonly style: CSSStyleDeclaration; readonly viewportElement: SVGElement; xmlbase: string; - className: any; addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14780,12 +15501,12 @@ declare var SVGElementInstanceList: { new(): SVGElementInstanceList; } -interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGEllipseElement extends SVGGraphicsElement { readonly cx: SVGAnimatedLength; readonly cy: SVGAnimatedLength; readonly rx: SVGAnimatedLength; readonly ry: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGEllipseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14815,7 +15536,7 @@ interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttrib readonly SVG_FEBLEND_MODE_SCREEN: number; readonly SVG_FEBLEND_MODE_SOFT_LIGHT: number; readonly SVG_FEBLEND_MODE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEBlendElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14850,7 +15571,7 @@ interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandard readonly SVG_FECOLORMATRIX_TYPE_MATRIX: number; readonly SVG_FECOLORMATRIX_TYPE_SATURATE: number; readonly SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEColorMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14866,7 +15587,7 @@ declare var SVGFEColorMatrixElement: { interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEComponentTransferElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14890,7 +15611,7 @@ interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAt readonly SVG_FECOMPOSITE_OPERATOR_OVER: number; readonly SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; readonly SVG_FECOMPOSITE_OPERATOR_XOR: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFECompositeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14923,7 +15644,7 @@ interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStand readonly SVG_EDGEMODE_NONE: number; readonly SVG_EDGEMODE_UNKNOWN: number; readonly SVG_EDGEMODE_WRAP: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEConvolveMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14942,7 +15663,7 @@ interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStan readonly kernelUnitLengthX: SVGAnimatedNumber; readonly kernelUnitLengthY: SVGAnimatedNumber; readonly surfaceScale: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDiffuseLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14962,7 +15683,7 @@ interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStan readonly SVG_CHANNEL_G: number; readonly SVG_CHANNEL_R: number; readonly SVG_CHANNEL_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDisplacementMapElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14979,7 +15700,7 @@ declare var SVGFEDisplacementMapElement: { interface SVGFEDistantLightElement extends SVGElement { readonly azimuth: SVGAnimatedNumber; readonly elevation: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDistantLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14989,7 +15710,7 @@ declare var SVGFEDistantLightElement: { } interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEFloodElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14999,6 +15720,8 @@ declare var SVGFEFloodElement: { } interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncAElement: { @@ -15007,6 +15730,8 @@ declare var SVGFEFuncAElement: { } interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncBElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncBElement: { @@ -15015,6 +15740,8 @@ declare var SVGFEFuncBElement: { } interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncGElement: { @@ -15023,6 +15750,8 @@ declare var SVGFEFuncGElement: { } interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncRElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncRElement: { @@ -15035,7 +15764,7 @@ interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandar readonly stdDeviationX: SVGAnimatedNumber; readonly stdDeviationY: SVGAnimatedNumber; setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEGaussianBlurElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15044,9 +15773,9 @@ declare var SVGFEGaussianBlurElement: { new(): SVGFEGaussianBlurElement; } -interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { +interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGURIReference { readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15056,7 +15785,7 @@ declare var SVGFEImageElement: { } interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMergeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15067,7 +15796,7 @@ declare var SVGFEMergeElement: { interface SVGFEMergeNodeElement extends SVGElement { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMergeNodeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15084,7 +15813,7 @@ interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardA readonly SVG_MORPHOLOGY_OPERATOR_DILATE: number; readonly SVG_MORPHOLOGY_OPERATOR_ERODE: number; readonly SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMorphologyElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15100,7 +15829,7 @@ interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttri readonly dx: SVGAnimatedNumber; readonly dy: SVGAnimatedNumber; readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEOffsetElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15113,7 +15842,7 @@ interface SVGFEPointLightElement extends SVGElement { readonly x: SVGAnimatedNumber; readonly y: SVGAnimatedNumber; readonly z: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEPointLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15129,7 +15858,7 @@ interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveSta readonly specularConstant: SVGAnimatedNumber; readonly specularExponent: SVGAnimatedNumber; readonly surfaceScale: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFESpecularLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15147,7 +15876,7 @@ interface SVGFESpotLightElement extends SVGElement { readonly x: SVGAnimatedNumber; readonly y: SVGAnimatedNumber; readonly z: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFESpotLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15158,7 +15887,7 @@ declare var SVGFESpotLightElement: { interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFETileElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15180,7 +15909,7 @@ interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardA readonly SVG_TURBULENCE_TYPE_FRACTALNOISE: number; readonly SVG_TURBULENCE_TYPE_TURBULENCE: number; readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFETurbulenceElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15195,7 +15924,7 @@ declare var SVGFETurbulenceElement: { readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; } -interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGURIReference { readonly filterResX: SVGAnimatedInteger; readonly filterResY: SVGAnimatedInteger; readonly filterUnits: SVGAnimatedEnumeration; @@ -15205,7 +15934,7 @@ interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLan readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; setFilterRes(filterResX: number, filterResY: number): void; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFilterElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15214,12 +15943,12 @@ declare var SVGFilterElement: { new(): SVGFilterElement; } -interface SVGForeignObjectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGForeignObjectElement extends SVGGraphicsElement { readonly height: SVGAnimatedLength; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGForeignObjectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15228,8 +15957,8 @@ declare var SVGForeignObjectElement: { new(): SVGForeignObjectElement; } -interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGGElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15238,7 +15967,7 @@ declare var SVGGElement: { new(): SVGGElement; } -interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourcesRequired, SVGURIReference, SVGUnitTypes { +interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGURIReference { readonly gradientTransform: SVGAnimatedTransformList; readonly gradientUnits: SVGAnimatedEnumeration; readonly spreadMethod: SVGAnimatedEnumeration; @@ -15246,7 +15975,7 @@ interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourc readonly SVG_SPREADMETHOD_REFLECT: number; readonly SVG_SPREADMETHOD_REPEAT: number; readonly SVG_SPREADMETHOD_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15259,13 +15988,30 @@ declare var SVGGradientElement: { readonly SVG_SPREADMETHOD_UNKNOWN: number; } -interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface SVGGraphicsElement extends SVGElement, SVGTests { + readonly farthestViewportElement: SVGElement; + readonly nearestViewportElement: SVGElement; + readonly transform: SVGAnimatedTransformList; + getBBox(): SVGRect; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; + getTransformToElement(element: SVGElement): SVGMatrix; + addEventListener(type: K, listener: (this: SVGGraphicsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGraphicsElement: { + prototype: SVGGraphicsElement; + new(): SVGGraphicsElement; +} + +interface SVGImageElement extends SVGGraphicsElement, SVGURIReference { readonly height: SVGAnimatedLength; readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15326,12 +16072,12 @@ declare var SVGLengthList: { new(): SVGLengthList; } -interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGLineElement extends SVGGraphicsElement { readonly x1: SVGAnimatedLength; readonly x2: SVGAnimatedLength; readonly y1: SVGAnimatedLength; readonly y2: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGLineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15345,6 +16091,8 @@ interface SVGLinearGradientElement extends SVGGradientElement { readonly x2: SVGAnimatedLength; readonly y1: SVGAnimatedLength; readonly y2: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGLinearGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGLinearGradientElement: { @@ -15352,7 +16100,7 @@ declare var SVGLinearGradientElement: { new(): SVGLinearGradientElement; } -interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { +interface SVGMarkerElement extends SVGElement, SVGFitToViewBox { readonly markerHeight: SVGAnimatedLength; readonly markerUnits: SVGAnimatedEnumeration; readonly markerWidth: SVGAnimatedLength; @@ -15368,7 +16116,7 @@ interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExt readonly SVG_MARKER_ORIENT_ANGLE: number; readonly SVG_MARKER_ORIENT_AUTO: number; readonly SVG_MARKER_ORIENT_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMarkerElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15383,14 +16131,14 @@ declare var SVGMarkerElement: { readonly SVG_MARKER_ORIENT_UNKNOWN: number; } -interface SVGMaskElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { +interface SVGMaskElement extends SVGElement, SVGTests, SVGUnitTypes { readonly height: SVGAnimatedLength; readonly maskContentUnits: SVGAnimatedEnumeration; readonly maskUnits: SVGAnimatedEnumeration; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMaskElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15425,7 +16173,7 @@ declare var SVGMatrix: { } interface SVGMetadataElement extends SVGElement { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMetadataElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15459,7 +16207,8 @@ declare var SVGNumberList: { new(): SVGNumberList; } -interface SVGPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPathData { +interface SVGPathElement extends SVGGraphicsElement { + readonly pathSegList: SVGPathSegList; createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; createSVGPathSegClosePath(): SVGPathSegClosePath; @@ -15482,7 +16231,7 @@ interface SVGPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGT getPathSegAtLength(distance: number): number; getPointAtLength(distance: number): SVGPoint; getTotalLength(): number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15767,7 +16516,7 @@ declare var SVGPathSegMovetoRel: { new(): SVGPathSegMovetoRel; } -interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGURIReference, SVGUnitTypes { +interface SVGPatternElement extends SVGElement, SVGTests, SVGUnitTypes, SVGFitToViewBox, SVGURIReference { readonly height: SVGAnimatedLength; readonly patternContentUnits: SVGAnimatedEnumeration; readonly patternTransform: SVGAnimatedTransformList; @@ -15775,7 +16524,7 @@ interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSp readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGPatternElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15811,8 +16560,8 @@ declare var SVGPointList: { new(): SVGPointList; } -interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGPolygonElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolygonElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15821,8 +16570,8 @@ declare var SVGPolygonElement: { new(): SVGPolygonElement; } -interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGPolylineElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolylineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15875,6 +16624,8 @@ interface SVGRadialGradientElement extends SVGGradientElement { readonly fx: SVGAnimatedLength; readonly fy: SVGAnimatedLength; readonly r: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGRadialGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGRadialGradientElement: { @@ -15894,14 +16645,14 @@ declare var SVGRect: { new(): SVGRect; } -interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGRectElement extends SVGGraphicsElement { readonly height: SVGAnimatedLength; readonly rx: SVGAnimatedLength; readonly ry: SVGAnimatedLength; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGRectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15919,7 +16670,7 @@ interface SVGSVGElementEventMap extends SVGElementEventMap { "SVGZoom": SVGZoomEvent; } -interface SVGSVGElement extends SVGElement, DocumentEvent, SVGLocatable, SVGTests, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { +interface SVGSVGElement extends SVGGraphicsElement, DocumentEvent, SVGFitToViewBox, SVGZoomAndPan { contentScriptType: string; contentStyleType: string; currentScale: number; @@ -15971,9 +16722,9 @@ declare var SVGSVGElement: { new(): SVGSVGElement; } -interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { +interface SVGScriptElement extends SVGElement, SVGURIReference { type: string; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGScriptElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15982,9 +16733,9 @@ declare var SVGScriptElement: { new(): SVGScriptElement; } -interface SVGStopElement extends SVGElement, SVGStylable { +interface SVGStopElement extends SVGElement { readonly offset: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGStopElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16009,12 +16760,12 @@ declare var SVGStringList: { new(): SVGStringList; } -interface SVGStyleElement extends SVGElement, SVGLangSpace { +interface SVGStyleElement extends SVGElement { disabled: boolean; media: string; title: string; type: string; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGStyleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16023,8 +16774,8 @@ declare var SVGStyleElement: { new(): SVGStyleElement; } -interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGSwitchElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGSwitchElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16033,8 +16784,8 @@ declare var SVGSwitchElement: { new(): SVGSwitchElement; } -interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGSymbolElement extends SVGElement, SVGFitToViewBox { + addEventListener(type: K, listener: (this: SVGSymbolElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16044,6 +16795,8 @@ declare var SVGSymbolElement: { } interface SVGTSpanElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTSpanElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTSpanElement: { @@ -16051,7 +16804,7 @@ declare var SVGTSpanElement: { new(): SVGTSpanElement; } -interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGTextContentElement extends SVGGraphicsElement { readonly lengthAdjust: SVGAnimatedEnumeration; readonly textLength: SVGAnimatedLength; getCharNumAtPosition(point: SVGPoint): number; @@ -16066,7 +16819,7 @@ interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLa readonly LENGTHADJUST_SPACING: number; readonly LENGTHADJUST_SPACINGANDGLYPHS: number; readonly LENGTHADJUST_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGTextContentElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16078,7 +16831,9 @@ declare var SVGTextContentElement: { readonly LENGTHADJUST_UNKNOWN: number; } -interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { +interface SVGTextElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTextElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextElement: { @@ -16096,6 +16851,8 @@ interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { readonly TEXTPATH_SPACINGTYPE_AUTO: number; readonly TEXTPATH_SPACINGTYPE_EXACT: number; readonly TEXTPATH_SPACINGTYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGTextPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextPathElement: { @@ -16115,6 +16872,8 @@ interface SVGTextPositioningElement extends SVGTextContentElement { readonly rotate: SVGAnimatedNumberList; readonly x: SVGAnimatedLengthList; readonly y: SVGAnimatedLengthList; + addEventListener(type: K, listener: (this: SVGTextPositioningElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextPositioningElement: { @@ -16122,8 +16881,8 @@ declare var SVGTextPositioningElement: { new(): SVGTextPositioningElement; } -interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGTitleElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGTitleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16188,14 +16947,14 @@ interface SVGUnitTypes { } declare var SVGUnitTypes: SVGUnitTypes; -interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface SVGUseElement extends SVGGraphicsElement, SVGURIReference { readonly animatedInstanceRoot: SVGElementInstance; readonly height: SVGAnimatedLength; readonly instanceRoot: SVGElementInstance; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGUseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16204,9 +16963,9 @@ declare var SVGUseElement: { new(): SVGUseElement; } -interface SVGViewElement extends SVGElement, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { +interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox { readonly viewTarget: SVGStringList; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGViewElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16238,6 +16997,26 @@ declare var SVGZoomEvent: { new(): SVGZoomEvent; } +interface ScopedCredential { + readonly id: ArrayBuffer; + readonly type: string; +} + +declare var ScopedCredential: { + prototype: ScopedCredential; + new(): ScopedCredential; +} + +interface ScopedCredentialInfo { + readonly credential: ScopedCredential; + readonly publicKey: CryptoKey; +} + +declare var ScopedCredentialInfo: { + prototype: ScopedCredentialInfo; + new(): ScopedCredentialInfo; +} + interface ScreenEventMap { "MSOrientationChange": Event; } @@ -16299,6 +17078,10 @@ declare var ScriptProcessorNode: { interface Selection { readonly anchorNode: Node; readonly anchorOffset: number; + readonly baseNode: Node; + readonly baseOffset: number; + readonly extentNode: Node; + readonly extentOffset: number; readonly focusNode: Node; readonly focusOffset: number; readonly isCollapsed: boolean; @@ -16317,6 +17100,7 @@ interface Selection { removeRange(range: Range): void; selectAllChildren(parentNode: Node): void; setBaseAndExtent(baseNode: Node, baseOffset: number, extentNode: Node, extentOffset: number): void; + setPosition(parentNode: Node, offset: number): void; toString(): string; } @@ -16325,6 +17109,84 @@ declare var Selection: { new(): Selection; } +interface ServiceWorkerEventMap extends AbstractWorkerEventMap { + "statechange": Event; +} + +interface ServiceWorker extends EventTarget, AbstractWorker { + onstatechange: (this: ServiceWorker, ev: Event) => any; + readonly scriptURL: USVString; + readonly state: string; + postMessage(message: any, transfer?: any[]): void; + addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorker: { + prototype: ServiceWorker; + new(): ServiceWorker; +} + +interface ServiceWorkerContainerEventMap { + "controllerchange": Event; + "message": ServiceWorkerMessageEvent; +} + +interface ServiceWorkerContainer extends EventTarget { + readonly controller: ServiceWorker | null; + oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; + onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; + readonly ready: Promise; + getRegistration(clientURL?: USVString): Promise; + getRegistrations(): any; + register(scriptURL: USVString, options?: RegistrationOptions): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerContainer: { + prototype: ServiceWorkerContainer; + new(): ServiceWorkerContainer; +} + +interface ServiceWorkerMessageEvent extends Event { + readonly data: any; + readonly lastEventId: string; + readonly origin: string; + readonly ports: MessagePort[] | null; + readonly source: ServiceWorker | MessagePort | null; +} + +declare var ServiceWorkerMessageEvent: { + prototype: ServiceWorkerMessageEvent; + new(type: string, eventInitDict?: ServiceWorkerMessageEventInit): ServiceWorkerMessageEvent; +} + +interface ServiceWorkerRegistrationEventMap { + "updatefound": Event; +} + +interface ServiceWorkerRegistration extends EventTarget { + readonly active: ServiceWorker | null; + readonly installing: ServiceWorker | null; + onupdatefound: (this: ServiceWorkerRegistration, ev: Event) => any; + readonly pushManager: PushManager; + readonly scope: USVString; + readonly sync: SyncManager; + readonly waiting: ServiceWorker | null; + getNotifications(filter?: GetNotificationOptions): any; + showNotification(title: string, options?: NotificationOptions): Promise; + unregister(): Promise; + update(): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerRegistration: { + prototype: ServiceWorkerRegistration; + new(): ServiceWorkerRegistration; +} + interface SourceBuffer extends EventTarget { appendWindowEnd: number; appendWindowStart: number; @@ -16356,6 +17218,87 @@ declare var SourceBufferList: { new(): SourceBufferList; } +interface SpeechSynthesisEventMap { + "voiceschanged": Event; +} + +interface SpeechSynthesis extends EventTarget { + onvoiceschanged: (this: SpeechSynthesis, ev: Event) => any; + readonly paused: boolean; + readonly pending: boolean; + readonly speaking: boolean; + cancel(): void; + getVoices(): SpeechSynthesisVoice[]; + pause(): void; + resume(): void; + speak(utterance: SpeechSynthesisUtterance): void; + addEventListener(type: K, listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesis: { + prototype: SpeechSynthesis; + new(): SpeechSynthesis; +} + +interface SpeechSynthesisEvent extends Event { + readonly charIndex: number; + readonly elapsedTime: number; + readonly name: string; + readonly utterance: SpeechSynthesisUtterance | null; +} + +declare var SpeechSynthesisEvent: { + prototype: SpeechSynthesisEvent; + new(type: string, eventInitDict?: SpeechSynthesisEventInit): SpeechSynthesisEvent; +} + +interface SpeechSynthesisUtteranceEventMap { + "boundary": Event; + "end": Event; + "error": Event; + "mark": Event; + "pause": Event; + "resume": Event; + "start": Event; +} + +interface SpeechSynthesisUtterance extends EventTarget { + lang: string; + onboundary: (this: SpeechSynthesisUtterance, ev: Event) => any; + onend: (this: SpeechSynthesisUtterance, ev: Event) => any; + onerror: (this: SpeechSynthesisUtterance, ev: Event) => any; + onmark: (this: SpeechSynthesisUtterance, ev: Event) => any; + onpause: (this: SpeechSynthesisUtterance, ev: Event) => any; + onresume: (this: SpeechSynthesisUtterance, ev: Event) => any; + onstart: (this: SpeechSynthesisUtterance, ev: Event) => any; + pitch: number; + rate: number; + text: string; + voice: SpeechSynthesisVoice; + volume: number; + addEventListener(type: K, listener: (this: SpeechSynthesisUtterance, ev: SpeechSynthesisUtteranceEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesisUtterance: { + prototype: SpeechSynthesisUtterance; + new(text?: string): SpeechSynthesisUtterance; +} + +interface SpeechSynthesisVoice { + readonly default: boolean; + readonly lang: string; + readonly localService: boolean; + readonly name: string; + readonly voiceURI: string; +} + +declare var SpeechSynthesisVoice: { + prototype: SpeechSynthesisVoice; + new(): SpeechSynthesisVoice; +} + interface StereoPannerNode extends AudioNode { readonly pan: AudioParam; } @@ -16467,6 +17410,16 @@ declare var SubtleCrypto: { new(): SubtleCrypto; } +interface SyncManager { + getTags(): any; + register(tag: string): Promise; +} + +declare var SyncManager: { + prototype: SyncManager; + new(): SyncManager; +} + interface Text extends CharacterData { readonly wholeText: string; readonly assignedSlot: HTMLSlotElement | null; @@ -16521,7 +17474,7 @@ declare var TextMetrics: { interface TextTrackEventMap { "cuechange": Event; - "error": ErrorEvent; + "error": Event; "load": Event; } @@ -16534,7 +17487,7 @@ interface TextTrack extends EventTarget { readonly language: string; mode: any; oncuechange: (this: TextTrack, ev: Event) => any; - onerror: (this: TextTrack, ev: ErrorEvent) => any; + onerror: (this: TextTrack, ev: Event) => any; onload: (this: TextTrack, ev: Event) => any; readonly readyState: number; addCue(cue: TextTrackCue): void; @@ -16646,11 +17599,14 @@ declare var Touch: { interface TouchEvent extends UIEvent { readonly altKey: boolean; readonly changedTouches: TouchList; + readonly charCode: number; readonly ctrlKey: boolean; + readonly keyCode: number; readonly metaKey: boolean; readonly shiftKey: boolean; readonly targetTouches: TouchList; readonly touches: TouchList; + readonly which: number; } declare var TouchEvent: { @@ -16670,12 +17626,12 @@ declare var TouchList: { } interface TrackEvent extends Event { - readonly track: any; + readonly track: VideoTrack | AudioTrack | TextTrack | null; } declare var TrackEvent: { prototype: TrackEvent; - new(): TrackEvent; + new(typeArg: string, eventInitDict?: TrackEventInit): TrackEvent; } interface TransitionEvent extends Event { @@ -16686,7 +17642,7 @@ interface TransitionEvent extends Event { declare var TransitionEvent: { prototype: TransitionEvent; - new(): TransitionEvent; + new(typeArg: string, eventInitDict?: TransitionEventInit): TransitionEvent; } interface TreeWalker { @@ -16717,7 +17673,7 @@ interface UIEvent extends Event { declare var UIEvent: { prototype: UIEvent; - new(type: string, eventInitDict?: UIEventInit): UIEvent; + new(typeArg: string, eventInitDict?: UIEventInit): UIEvent; } interface URL { @@ -16732,6 +17688,7 @@ interface URL { protocol: string; search: string; username: string; + readonly searchparams: URLSearchParams; toString(): string; } @@ -16868,6 +17825,28 @@ declare var WaveShaperNode: { new(): WaveShaperNode; } +interface WebAuthentication { + getAssertion(assertionChallenge: any, options?: AssertionOptions): Promise; + makeCredential(accountInformation: Account, cryptoParameters: ScopedCredentialParameters[], attestationChallenge: any, options?: ScopedCredentialOptions): Promise; +} + +declare var WebAuthentication: { + prototype: WebAuthentication; + new(): WebAuthentication; +} + +interface WebAuthnAssertion { + readonly authenticatorData: ArrayBuffer; + readonly clientData: ArrayBuffer; + readonly credential: ScopedCredential; + readonly signature: ArrayBuffer; +} + +declare var WebAuthnAssertion: { + prototype: WebAuthnAssertion; + new(): WebAuthnAssertion; +} + interface WebGLActiveInfo { readonly name: string; readonly size: number; @@ -16893,7 +17872,7 @@ interface WebGLContextEvent extends Event { declare var WebGLContextEvent: { prototype: WebGLContextEvent; - new(type: string, eventInitDict?: WebGLContextEventInit): WebGLContextEvent; + new(typeArg: string, eventInitDict?: WebGLContextEventInit): WebGLContextEvent; } interface WebGLFramebuffer extends WebGLObject { @@ -17020,7 +17999,7 @@ interface WebGLRenderingContext { isTexture(texture: WebGLTexture | null): boolean; lineWidth(width: number): void; linkProgram(program: WebGLProgram | null): void; - pixelStorei(pname: number, param: number): void; + pixelStorei(pname: number, param: number | boolean): void; polygonOffset(factor: number, units: number): void; readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): void; renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; @@ -17746,6 +18725,56 @@ declare var WebKitCSSMatrix: { new(text?: string): WebKitCSSMatrix; } +interface WebKitDirectoryEntry extends WebKitEntry { + createReader(): WebKitDirectoryReader; +} + +declare var WebKitDirectoryEntry: { + prototype: WebKitDirectoryEntry; + new(): WebKitDirectoryEntry; +} + +interface WebKitDirectoryReader { + readEntries(successCallback: WebKitEntriesCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitDirectoryReader: { + prototype: WebKitDirectoryReader; + new(): WebKitDirectoryReader; +} + +interface WebKitEntry { + readonly filesystem: WebKitFileSystem; + readonly fullPath: string; + readonly isDirectory: boolean; + readonly isFile: boolean; + readonly name: string; +} + +declare var WebKitEntry: { + prototype: WebKitEntry; + new(): WebKitEntry; +} + +interface WebKitFileEntry extends WebKitEntry { + file(successCallback: WebKitFileCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitFileEntry: { + prototype: WebKitFileEntry; + new(): WebKitFileEntry; +} + +interface WebKitFileSystem { + readonly name: string; + readonly root: WebKitDirectoryEntry; +} + +declare var WebKitFileSystem: { + prototype: WebKitFileSystem; + new(): WebKitFileSystem; +} + interface WebKitPoint { x: number; y: number; @@ -17758,7 +18787,7 @@ declare var WebKitPoint: { interface WebSocketEventMap { "close": CloseEvent; - "error": ErrorEvent; + "error": Event; "message": MessageEvent; "open": Event; } @@ -17768,7 +18797,7 @@ interface WebSocket extends EventTarget { readonly bufferedAmount: number; readonly extensions: string; onclose: (this: WebSocket, ev: CloseEvent) => any; - onerror: (this: WebSocket, ev: ErrorEvent) => any; + onerror: (this: WebSocket, ev: Event) => any; onmessage: (this: WebSocket, ev: MessageEvent) => any; onopen: (this: WebSocket, ev: Event) => any; readonly protocol: string; @@ -17905,8 +18934,9 @@ interface WindowEventMap extends GlobalEventHandlersEventMap { "waiting": Event; } -interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64 { +interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch { readonly applicationCache: ApplicationCache; + readonly caches: CacheStorage; readonly clientInformation: Navigator; readonly closed: boolean; readonly crypto: Crypto; @@ -17921,10 +18951,12 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly history: History; readonly innerHeight: number; readonly innerWidth: number; + readonly isSecureContext: boolean; readonly length: number; readonly location: Location; readonly locationbar: BarProp; readonly menubar: BarProp; + readonly msContentScript: ExtensionScriptApis; readonly msCredentials: MSCredentials; name: string; readonly navigator: Navigator; @@ -18038,6 +19070,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly scrollY: number; readonly scrollbars: BarProp; readonly self: Window; + readonly speechSynthesis: SpeechSynthesis; status: string; readonly statusbar: BarProp; readonly styleMedia: StyleMedia; @@ -18046,12 +19079,14 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly window: Window; URL: typeof URL; Blob: typeof Blob; + customElements: CustomElementRegistry; alert(message?: any): void; blur(): void; cancelAnimationFrame(handle: number): void; captureEvents(): void; close(): void; confirm(message?: string): boolean; + departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; focus(): void; getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -18071,6 +19106,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window scroll(x?: number, y?: number): void; scrollBy(x?: number, y?: number): void; scrollTo(x?: number, y?: number): void; + stop(): void; webkitCancelAnimationFrame(handle: number): void; webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; @@ -18093,7 +19129,7 @@ interface WorkerEventMap extends AbstractWorkerEventMap { interface Worker extends EventTarget, AbstractWorker { onmessage: (this: Worker, ev: MessageEvent) => any; - postMessage(message: any, ports?: any): void; + postMessage(message: any, transfer?: any[]): void; terminate(): void; addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -18105,7 +19141,7 @@ declare var Worker: { } interface XMLDocument extends Document { - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -18124,14 +19160,14 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly response: any; readonly responseText: string; responseType: string; - readonly responseXML: any; + readonly responseURL: string; + readonly responseXML: Document | null; readonly status: number; readonly statusText: string; timeout: number; readonly upload: XMLHttpRequestUpload; withCredentials: boolean; msCaching?: string; - readonly responseURL: string; abort(): void; getAllResponseHeaders(): string; getResponseHeader(header: string): string | null; @@ -18159,11 +19195,10 @@ declare var XMLHttpRequest: { readonly LOADING: number; readonly OPENED: number; readonly UNSENT: number; - create(): XMLHttpRequest; } interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { - addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -18263,6 +19298,16 @@ declare var XSLTProcessor: { new(): XSLTProcessor; } +interface webkitRTCPeerConnection extends RTCPeerConnection { + addEventListener(type: K, listener: (this: webkitRTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var webkitRTCPeerConnection: { + prototype: webkitRTCPeerConnection; + new(configuration: RTCConfiguration): webkitRTCPeerConnection; +} + interface AbstractWorkerEventMap { "error": ErrorEvent; } @@ -18273,6 +19318,14 @@ interface AbstractWorker { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface Body { + readonly bodyUsed: boolean; + arrayBuffer(): Promise; + blob(): Promise; + json(): Promise; + text(): Promise; +} + interface CanvasPathMethods { arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; @@ -18299,12 +19352,10 @@ interface DOML2DeprecatedSizeProperty { interface DocumentEvent { createEvent(eventInterface:"AnimationEvent"): AnimationEvent; - createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent; createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent; createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent; createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent; createEvent(eventInterface:"CloseEvent"): CloseEvent; - createEvent(eventInterface:"CommandEvent"): CommandEvent; createEvent(eventInterface:"CompositionEvent"): CompositionEvent; createEvent(eventInterface:"CustomEvent"): CustomEvent; createEvent(eventInterface:"DeviceLightEvent"): DeviceLightEvent; @@ -18315,6 +19366,7 @@ interface DocumentEvent { createEvent(eventInterface:"Event"): Event; createEvent(eventInterface:"Events"): Event; createEvent(eventInterface:"FocusEvent"): FocusEvent; + createEvent(eventInterface:"FocusNavigationEvent"): FocusNavigationEvent; createEvent(eventInterface:"GamepadEvent"): GamepadEvent; createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; createEvent(eventInterface:"IDBVersionChangeEvent"): IDBVersionChangeEvent; @@ -18330,6 +19382,7 @@ interface DocumentEvent { createEvent(eventInterface:"MediaEncryptedEvent"): MediaEncryptedEvent; createEvent(eventInterface:"MediaKeyMessageEvent"): MediaKeyMessageEvent; createEvent(eventInterface:"MediaStreamErrorEvent"): MediaStreamErrorEvent; + createEvent(eventInterface:"MediaStreamEvent"): MediaStreamEvent; createEvent(eventInterface:"MediaStreamTrackEvent"): MediaStreamTrackEvent; createEvent(eventInterface:"MessageEvent"): MessageEvent; createEvent(eventInterface:"MouseEvent"): MouseEvent; @@ -18342,6 +19395,7 @@ interface DocumentEvent { createEvent(eventInterface:"OfflineAudioCompletionEvent"): OfflineAudioCompletionEvent; createEvent(eventInterface:"OverflowEvent"): OverflowEvent; createEvent(eventInterface:"PageTransitionEvent"): PageTransitionEvent; + createEvent(eventInterface:"PaymentRequestUpdateEvent"): PaymentRequestUpdateEvent; createEvent(eventInterface:"PermissionRequestedEvent"): PermissionRequestedEvent; createEvent(eventInterface:"PointerEvent"): PointerEvent; createEvent(eventInterface:"PopStateEvent"): PopStateEvent; @@ -18351,10 +19405,13 @@ interface DocumentEvent { createEvent(eventInterface:"RTCIceCandidatePairChangedEvent"): RTCIceCandidatePairChangedEvent; createEvent(eventInterface:"RTCIceGathererEvent"): RTCIceGathererEvent; createEvent(eventInterface:"RTCIceTransportStateChangedEvent"): RTCIceTransportStateChangedEvent; + createEvent(eventInterface:"RTCPeerConnectionIceEvent"): RTCPeerConnectionIceEvent; createEvent(eventInterface:"RTCSsrcConflictEvent"): RTCSsrcConflictEvent; createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; + createEvent(eventInterface:"ServiceWorkerMessageEvent"): ServiceWorkerMessageEvent; + createEvent(eventInterface:"SpeechSynthesisEvent"): SpeechSynthesisEvent; createEvent(eventInterface:"StorageEvent"): StorageEvent; createEvent(eventInterface:"TextEvent"): TextEvent; createEvent(eventInterface:"TouchEvent"): TouchEvent; @@ -18370,10 +19427,10 @@ interface DocumentEvent { interface ElementTraversal { readonly childElementCount: number; - readonly firstElementChild: Element; - readonly lastElementChild: Element; - readonly nextElementSibling: Element; - readonly previousElementSibling: Element; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; + readonly nextElementSibling: Element | null; + readonly previousElementSibling: Element | null; } interface GetSVGDocument { @@ -18406,6 +19463,10 @@ interface GlobalEventHandlers { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface GlobalFetch { + fetch(input: RequestInfo, init?: RequestInit): Promise; +} + interface HTMLTableAlignment { /** * Sets or retrieves a value that you can use to implement your own ch functionality for the object. @@ -18469,6 +19530,14 @@ interface MSNavigatorDoNotTrack { storeWebWideTrackingException(args: StoreExceptionsInformation): void; } +interface NavigatorBeacon { + sendBeacon(url: USVString, data?: BodyInit): boolean; +} + +interface NavigatorConcurrentHardware { + readonly hardwareConcurrency: number; +} + interface NavigatorContentUtils { } @@ -18477,6 +19546,7 @@ interface NavigatorGeolocation { } interface NavigatorID { + readonly appCodeName: string; readonly appName: string; readonly appVersion: string; readonly platform: string; @@ -18510,20 +19580,12 @@ interface RandomSource { getRandomValues(array: ArrayBufferView): ArrayBufferView; } -interface SVGAnimatedPathData { - readonly pathSegList: SVGPathSegList; -} - interface SVGAnimatedPoints { readonly animatedPoints: SVGPointList; readonly points: SVGPointList; } -interface SVGExternalResourcesRequired { - readonly externalResourcesRequired: SVGAnimatedBoolean; -} - -interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { +interface SVGFilterPrimitiveStandardAttributes { readonly height: SVGAnimatedLength; readonly result: SVGAnimatedString; readonly width: SVGAnimatedLength; @@ -18536,25 +19598,6 @@ interface SVGFitToViewBox { readonly viewBox: SVGAnimatedRect; } -interface SVGLangSpace { - xmllang: string; - xmlspace: string; -} - -interface SVGLocatable { - readonly farthestViewportElement: SVGElement; - readonly nearestViewportElement: SVGElement; - getBBox(): SVGRect; - getCTM(): SVGMatrix; - getScreenCTM(): SVGMatrix; - getTransformToElement(element: SVGElement): SVGMatrix; -} - -interface SVGStylable { - className: any; - readonly style: CSSStyleDeclaration; -} - interface SVGTests { readonly requiredExtensions: SVGStringList; readonly requiredFeatures: SVGStringList; @@ -18562,10 +19605,6 @@ interface SVGTests { hasExtension(extension: string): boolean; } -interface SVGTransformable extends SVGLocatable { - readonly transform: SVGAnimatedTransformList; -} - interface SVGURIReference { readonly href: SVGAnimatedString; } @@ -18624,6 +19663,14 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface ErrorEventInit { + message?: string; + filename?: string; + lineno?: number; + conlno?: number; + error?: any; +} + interface StorageEventInit extends EventInit { key?: string; oldValue?: string; @@ -18639,6 +19686,41 @@ interface Canvas2DContextAttributes { [attribute: string]: boolean | string | undefined; } +interface URLSearchParams { + /** + * Appends a specified key/value pair as a new search parameter. + */ + append(name: string, value: string): void; + /** + * Deletes the given search parameter, and its associated value, from the list of all search parameters. + */ + delete(name: string): void; + /** + * Returns the first value associated to the given search parameter. + */ + get(name: string): string | null; + /** + * Returns all the values association with a given search parameter. + */ + getAll(name: string): string[]; + /** + * Returns a Boolean indicating if such a search parameter exists. + */ + has(name: string): boolean; + /** + * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. + */ + set(name: string, value: string): void; +} + +declare var URLSearchParams: { + prototype: URLSearchParams; + /** + * Constructor returning a URLSearchParams object. + */ + new (init?: string | URLSearchParams): URLSearchParams; +} + interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -18648,7 +19730,6 @@ interface NodeListOf extends NodeList { interface HTMLCollectionOf extends HTMLCollection { item(index: number): T; namedItem(name: string): T; - [index: number]: T; } interface BlobPropertyBag { @@ -18665,15 +19746,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -interface MessageEventInit extends EventInit { - data?: any; - origin?: string; - lastEventId?: string; - channel?: string; - source?: any; - ports?: MessagePort[]; -} - interface ProgressEventInit extends EventInit { lengthComputable?: boolean; loaded?: number; @@ -18875,8 +19947,8 @@ interface JsonWebKey { interface ParentNode { readonly children: HTMLCollection; - readonly firstElementChild: Element; - readonly lastElementChild: Element; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; readonly childElementCount: number; } @@ -18907,6 +19979,26 @@ interface AssignedNodesOptions { flatten?: boolean; } +interface ElementDefinitionOptions { + extends: string; +} + +interface CustomElementRegistry { + define(name: string, constructor: Function, options?: ElementDefinitionOptions): void; + get(name: string): any; + whenDefined(name: string): PromiseLike; +} + +interface PromiseRejectionEvent extends Event { + readonly promise: PromiseLike; + readonly reason: any; +} + +interface PromiseRejectionEventInit extends EventInit { + promise: PromiseLike; + reason?: any; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -18942,6 +20034,18 @@ interface DecodeSuccessCallback { interface DecodeErrorCallback { (error: DOMException): void; } +interface VoidFunction { + (): void; +} +interface RTCSessionDescriptionCallback { + (sdp: RTCSessionDescription): void; +} +interface RTCPeerConnectionErrorCallback { + (error: DOMError): void; +} +interface RTCStatsCallback { + (report: RTCStatsReport): void; +} interface FunctionStringCallback { (data: string): void; } @@ -18954,6 +20058,12 @@ interface NavigatorUserMediaErrorCallback { interface ForEachCallback { (keyId: any, status: string): void; } +interface NotificationPermissionCallback { + (permission: string): void; +} +interface IntersectionObserverCallback { + (entries: IntersectionObserverEntry[], observer: IntersectionObserver): void; +} interface HTMLElementTagNameMap { "a": HTMLAnchorElement; "applet": HTMLAppletElement; @@ -18969,6 +20079,7 @@ interface HTMLElementTagNameMap { "caption": HTMLTableCaptionElement; "col": HTMLTableColElement; "colgroup": HTMLTableColElement; + "data": HTMLDataElement; "datalist": HTMLDataListElement; "del": HTMLModElement; "dir": HTMLDirectoryElement; @@ -19009,6 +20120,7 @@ interface HTMLElementTagNameMap { "ol": HTMLOListElement; "optgroup": HTMLOptGroupElement; "option": HTMLOptionElement; + "output": HTMLOutputElement; "p": HTMLParagraphElement; "param": HTMLParamElement; "picture": HTMLPictureElement; @@ -19028,6 +20140,7 @@ interface HTMLElementTagNameMap { "tfoot": HTMLTableSectionElement; "th": HTMLTableHeaderCellElement; "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; "title": HTMLTitleElement; "tr": HTMLTableRowElement; "track": HTMLTrackElement; @@ -19065,6 +20178,7 @@ interface ElementTagNameMap { "code": HTMLElement; "col": HTMLTableColElement; "colgroup": HTMLTableColElement; + "data": HTMLDataElement; "datalist": HTMLDataListElement; "dd": HTMLElement; "defs": SVGDefsElement; @@ -19158,6 +20272,7 @@ interface ElementTagNameMap { "ol": HTMLOListElement; "optgroup": HTMLOptGroupElement; "option": HTMLOptionElement; + "output": HTMLOutputElement; "p": HTMLParagraphElement; "param": HTMLParamElement; "path": SVGPathElement; @@ -19200,6 +20315,7 @@ interface ElementTagNameMap { "tfoot": HTMLTableSectionElement; "th": HTMLTableHeaderCellElement; "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; "title": HTMLTitleElement; "tr": HTMLTableRowElement; "track": HTMLTrackElement; @@ -19244,6 +20360,7 @@ interface ElementListTagNameMap { "code": NodeListOf; "col": NodeListOf; "colgroup": NodeListOf; + "data": NodeListOf; "datalist": NodeListOf; "dd": NodeListOf; "defs": NodeListOf; @@ -19337,6 +20454,7 @@ interface ElementListTagNameMap { "ol": NodeListOf; "optgroup": NodeListOf; "option": NodeListOf; + "output": NodeListOf; "p": NodeListOf; "param": NodeListOf; "path": NodeListOf; @@ -19379,6 +20497,7 @@ interface ElementListTagNameMap { "tfoot": NodeListOf; "th": NodeListOf; "thead": NodeListOf; + "time": NodeListOf; "title": NodeListOf; "tr": NodeListOf; "track": NodeListOf; @@ -19399,6 +20518,7 @@ declare var Audio: {new(src?: string): HTMLAudioElement; }; declare var Image: {new(width?: number, height?: number): HTMLImageElement; }; declare var Option: {new(text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; declare var applicationCache: ApplicationCache; +declare var caches: CacheStorage; declare var clientInformation: Navigator; declare var closed: boolean; declare var crypto: Crypto; @@ -19413,10 +20533,12 @@ declare var frames: Window; declare var history: History; declare var innerHeight: number; declare var innerWidth: number; +declare var isSecureContext: boolean; declare var length: number; declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; +declare var msContentScript: ExtensionScriptApis; declare var msCredentials: MSCredentials; declare const name: never; declare var navigator: Navigator; @@ -19530,18 +20652,21 @@ declare var scrollX: number; declare var scrollY: number; declare var scrollbars: BarProp; declare var self: Window; +declare var speechSynthesis: SpeechSynthesis; declare var status: string; declare var statusbar: BarProp; declare var styleMedia: StyleMedia; declare var toolbar: BarProp; declare var top: Window; declare var window: Window; +declare var customElements: CustomElementRegistry; declare function alert(message?: any): void; declare function blur(): void; declare function cancelAnimationFrame(handle: number): void; declare function captureEvents(): void; declare function close(): void; declare function confirm(message?: string): boolean; +declare function departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; declare function focus(): void; declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; declare function getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -19561,6 +20686,7 @@ declare function resizeTo(x?: number, y?: number): void; declare function scroll(x?: number, y?: number): void; declare function scrollBy(x?: number, y?: number): void; declare function scrollTo(x?: number, y?: number): void; +declare function stop(): void; declare function webkitCancelAnimationFrame(handle: number): void; declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; @@ -19595,10 +20721,13 @@ declare var onwheel: (this: Window, ev: WheelEvent) => any; declare var indexedDB: IDBFactory; declare function atob(encodedString: string): string; declare function btoa(rawString: string): string; +declare function fetch(input: RequestInfo, init?: RequestInit): Promise; declare function addEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; type AAGUID = string; type AlgorithmIdentifier = string | Algorithm; +type BodyInit = any; +type ByteString = string; type ConstrainBoolean = boolean | ConstrainBooleanParameters; type ConstrainDOMString = string | string[] | ConstrainDOMStringParameters; type ConstrainDouble = number | ConstrainDoubleRange; @@ -19618,6 +20747,7 @@ type GLsizeiptr = number; type GLubyte = number; type GLuint = number; type GLushort = number; +type HeadersInit = any; type IDBKeyPath = string; type KeyFormat = string; type KeyType = string; @@ -19625,8 +20755,10 @@ type KeyUsage = string; type MSInboundPayload = MSVideoRecvPayload | MSAudioRecvPayload; type MSLocalClientEvent = MSLocalClientEventBase | MSAudioLocalClientEvent; type MSOutboundPayload = MSVideoSendPayload | MSAudioSendPayload; -type RTCIceGatherCandidate = RTCIceCandidate | RTCIceCandidateComplete; +type RTCIceGatherCandidate = RTCIceCandidateDictionary | RTCIceCandidateComplete; type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport; +type RequestInfo = Request | string; +type USVString = string; type payloadtype = number; type ScrollBehavior = "auto" | "instant" | "smooth"; type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 4ee2566928d..e20455cf59e 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -27,12 +27,29 @@ interface Algorithm { name: string; } +interface CacheQueryOptions { + ignoreSearch?: boolean; + ignoreMethod?: boolean; + ignoreVary?: boolean; + cacheName?: string; +} + +interface CloseEventInit extends EventInit { + wasClean?: boolean; + code?: number; + reason?: string; +} + interface EventInit { scoped?: boolean; bubbles?: boolean; cancelable?: boolean; } +interface GetNotificationOptions { + tag?: string; +} + interface IDBIndexParameters { multiEntry?: boolean; unique?: boolean; @@ -47,10 +64,101 @@ interface KeyAlgorithm { name?: string; } +interface MessageEventInit extends EventInit { + lastEventId?: string; + channel?: string; + data?: any; + origin?: string; + source?: any; + ports?: MessagePort[]; +} + +interface NotificationOptions { + dir?: string; + lang?: string; + body?: string; + tag?: string; + icon?: string; +} + +interface PushSubscriptionOptionsInit { + userVisibleOnly?: boolean; + applicationServerKey?: any; +} + +interface RequestInit { + method?: string; + headers?: any; + body?: any; + referrer?: string; + referrerPolicy?: string; + mode?: string; + credentials?: string; + cache?: string; + redirect?: string; + integrity?: string; + keepalive?: boolean; + window?: any; +} + +interface ResponseInit { + status?: number; + statusText?: string; + headers?: any; +} + +interface ClientQueryOptions { + includeUncontrolled?: boolean; + type?: string; +} + +interface ExtendableEventInit extends EventInit { +} + +interface ExtendableMessageEventInit extends ExtendableEventInit { + data?: any; + origin?: string; + lastEventId?: string; + source?: Client | ServiceWorker | MessagePort; + ports?: MessagePort[]; +} + +interface FetchEventInit extends ExtendableEventInit { + request?: Request; + clientId?: string; + isReload?: boolean; +} + +interface NotificationEventInit extends ExtendableEventInit { + notification?: Notification; + action?: string; +} + +interface PushEventInit extends ExtendableEventInit { + data?: any; +} + +interface SyncEventInit extends ExtendableEventInit { + tag?: string; + lastChance?: boolean; +} + interface EventListener { (evt: Event): void; } +interface WebKitEntriesCallback { + (evt: Event): void; +} + +interface WebKitErrorCallback { + (evt: Event): void; +} + +interface WebKitFileCallback { + (evt: Event): void; +} + interface AudioBuffer { readonly duration: number; readonly length: number; @@ -79,6 +187,34 @@ declare var Blob: { new (blobParts?: any[], options?: BlobPropertyBag): Blob; } +interface Cache { + add(request: RequestInfo): Promise; + addAll(requests: RequestInfo[]): Promise; + delete(request: RequestInfo, options?: CacheQueryOptions): Promise; + keys(request?: RequestInfo, options?: CacheQueryOptions): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + put(request: RequestInfo, response: Response): Promise; +} + +declare var Cache: { + prototype: Cache; + new(): Cache; +} + +interface CacheStorage { + delete(cacheName: string): Promise; + has(cacheName: string): Promise; + keys(): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + open(cacheName: string): Promise; +} + +declare var CacheStorage: { + prototype: CacheStorage; + new(): CacheStorage; +} + interface CloseEvent extends Event { readonly code: number; readonly reason: string; @@ -88,14 +224,14 @@ interface CloseEvent extends Event { declare var CloseEvent: { prototype: CloseEvent; - new(): CloseEvent; + new(typeArg: string, eventInitDict?: CloseEventInit): CloseEvent; } interface Console { assert(test?: boolean, message?: string, ...optionalParams: any[]): void; clear(): void; count(countTitle?: string): void; - debug(message?: string, ...optionalParams: any[]): void; + debug(message?: any, ...optionalParams: any[]): void; dir(value?: any, ...optionalParams: any[]): void; dirxml(value: any): void; error(message?: any, ...optionalParams: any[]): void; @@ -247,7 +383,7 @@ interface ErrorEvent extends Event { declare var ErrorEvent: { prototype: ErrorEvent; - new(): ErrorEvent; + new(type: string, errorEventInitDict?: ErrorEventInit): ErrorEvent; } interface Event { @@ -276,7 +412,7 @@ interface Event { declare var Event: { prototype: Event; - new(type: string, eventInitDict?: EventInit): Event; + new(typeArg: string, eventInitDict?: EventInit): Event; readonly AT_TARGET: number; readonly BUBBLING_PHASE: number; readonly CAPTURING_PHASE: number; @@ -321,7 +457,7 @@ interface FileReader extends EventTarget, MSBaseReader { readAsBinaryString(blob: Blob): void; readAsDataURL(blob: Blob): void; readAsText(blob: Blob, encoding?: string): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -330,6 +466,20 @@ declare var FileReader: { new(): FileReader; } +interface Headers { + append(name: string, value: string): void; + delete(name: string): void; + forEach(callback: ForEachCallback): void; + get(name: string): string | null; + has(name: string): boolean; + set(name: string, value: string): void; +} + +declare var Headers: { + prototype: Headers; + new(init?: any): Headers; +} + interface IDBCursor { readonly direction: string; key: IDBKeyRange | IDBValidKey; @@ -365,14 +515,14 @@ declare var IDBCursorWithValue: { interface IDBDatabaseEventMap { "abort": Event; - "error": ErrorEvent; + "error": Event; } interface IDBDatabase extends EventTarget { readonly name: string; readonly objectStoreNames: DOMStringList; onabort: (this: IDBDatabase, ev: Event) => any; - onerror: (this: IDBDatabase, ev: ErrorEvent) => any; + onerror: (this: IDBDatabase, ev: Event) => any; version: number; onversionchange: (ev: IDBVersionChangeEvent) => any; close(): void; @@ -475,13 +625,13 @@ declare var IDBOpenDBRequest: { } interface IDBRequestEventMap { - "error": ErrorEvent; + "error": Event; "success": Event; } interface IDBRequest extends EventTarget { readonly error: DOMError; - onerror: (this: IDBRequest, ev: ErrorEvent) => any; + onerror: (this: IDBRequest, ev: Event) => any; onsuccess: (this: IDBRequest, ev: Event) => any; readonly readyState: string; readonly result: any; @@ -499,7 +649,7 @@ declare var IDBRequest: { interface IDBTransactionEventMap { "abort": Event; "complete": Event; - "error": ErrorEvent; + "error": Event; } interface IDBTransaction extends EventTarget { @@ -508,7 +658,7 @@ interface IDBTransaction extends EventTarget { readonly mode: string; onabort: (this: IDBTransaction, ev: Event) => any; oncomplete: (this: IDBTransaction, ev: Event) => any; - onerror: (this: IDBTransaction, ev: ErrorEvent) => any; + onerror: (this: IDBTransaction, ev: Event) => any; abort(): void; objectStore(name: string): IDBObjectStore; readonly READ_ONLY: string; @@ -548,105 +698,6 @@ declare var ImageData: { new(array: Uint8ClampedArray, width: number, height: number): ImageData; } -interface MSApp { - clearTemporaryWebDataAsync(): MSAppAsyncOperation; - createBlobFromRandomAccessStream(type: string, seeker: any): Blob; - createDataPackage(object: any): any; - createDataPackageFromSelection(): any; - createFileFromStorageFile(storageFile: any): File; - createStreamFromInputStream(type: string, inputStream: any): MSStream; - execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; - execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; - getCurrentPriority(): string; - getHtmlPrintDocumentSourceAsync(htmlDoc: any): PromiseLike; - getViewId(view: any): any; - isTaskScheduledAtPriorityOrHigher(priority: string): boolean; - pageHandlesAllApplicationActivations(enabled: boolean): void; - suppressSubdownloadCredentialPrompts(suppress: boolean): void; - terminateApp(exceptionObject: any): void; - readonly CURRENT: string; - readonly HIGH: string; - readonly IDLE: string; - readonly NORMAL: string; -} -declare var MSApp: MSApp; - -interface MSAppAsyncOperationEventMap { - "complete": Event; - "error": ErrorEvent; -} - -interface MSAppAsyncOperation extends EventTarget { - readonly error: DOMError; - oncomplete: (this: MSAppAsyncOperation, ev: Event) => any; - onerror: (this: MSAppAsyncOperation, ev: ErrorEvent) => any; - readonly readyState: number; - readonly result: any; - start(): void; - readonly COMPLETED: number; - readonly ERROR: number; - readonly STARTED: number; - addEventListener(type: K, listener: (this: MSAppAsyncOperation, ev: MSAppAsyncOperationEventMap[K]) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var MSAppAsyncOperation: { - prototype: MSAppAsyncOperation; - new(): MSAppAsyncOperation; - readonly COMPLETED: number; - readonly ERROR: number; - readonly STARTED: number; -} - -interface MSBlobBuilder { - append(data: any, endings?: string): void; - getBlob(contentType?: string): Blob; -} - -declare var MSBlobBuilder: { - prototype: MSBlobBuilder; - new(): MSBlobBuilder; -} - -interface MSStream { - readonly type: string; - msClose(): void; - msDetachStream(): any; -} - -declare var MSStream: { - prototype: MSStream; - new(): MSStream; -} - -interface MSStreamReader extends EventTarget, MSBaseReader { - readonly error: DOMError; - readAsArrayBuffer(stream: MSStream, size?: number): void; - readAsBinaryString(stream: MSStream, size?: number): void; - readAsBlob(stream: MSStream, size?: number): void; - readAsDataURL(stream: MSStream, size?: number): void; - readAsText(stream: MSStream, encoding?: string, size?: number): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var MSStreamReader: { - prototype: MSStreamReader; - new(): MSStreamReader; -} - -interface MediaQueryList { - readonly matches: boolean; - readonly media: string; - addListener(listener: MediaQueryListListener): void; - removeListener(listener: MediaQueryListListener): void; -} - -declare var MediaQueryList: { - prototype: MediaQueryList; - new(): MediaQueryList; -} - interface MessageChannel { readonly port1: MessagePort; readonly port2: MessagePort; @@ -677,7 +728,7 @@ interface MessagePortEventMap { interface MessagePort extends EventTarget { onmessage: (this: MessagePort, ev: MessageEvent) => any; close(): void; - postMessage(message?: any, ports?: any): void; + postMessage(message?: any, transfer?: any[]): void; start(): void; addEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -688,6 +739,109 @@ declare var MessagePort: { new(): MessagePort; } +interface NotificationEventMap { + "click": Event; + "close": Event; + "error": Event; + "show": Event; +} + +interface Notification extends EventTarget { + readonly body: string; + readonly dir: string; + readonly icon: string; + readonly lang: string; + onclick: (this: Notification, ev: Event) => any; + onclose: (this: Notification, ev: Event) => any; + onerror: (this: Notification, ev: Event) => any; + onshow: (this: Notification, ev: Event) => any; + readonly permission: string; + readonly tag: string; + readonly title: string; + close(): void; + addEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Notification: { + prototype: Notification; + new(title: string, options?: NotificationOptions): Notification; + requestPermission(callback?: NotificationPermissionCallback): Promise; +} + +interface Performance { + readonly navigation: PerformanceNavigation; + readonly timing: PerformanceTiming; + clearMarks(markName?: string): void; + clearMeasures(measureName?: string): void; + clearResourceTimings(): void; + getEntries(): any; + getEntriesByName(name: string, entryType?: string): any; + getEntriesByType(entryType: string): any; + getMarks(markName?: string): any; + getMeasures(measureName?: string): any; + mark(markName: string): void; + measure(measureName: string, startMarkName?: string, endMarkName?: string): void; + now(): number; + setResourceTimingBufferSize(maxSize: number): void; + toJSON(): any; +} + +declare var Performance: { + prototype: Performance; + new(): Performance; +} + +interface PerformanceNavigation { + readonly redirectCount: number; + readonly type: number; + toJSON(): any; + readonly TYPE_BACK_FORWARD: number; + readonly TYPE_NAVIGATE: number; + readonly TYPE_RELOAD: number; + readonly TYPE_RESERVED: number; +} + +declare var PerformanceNavigation: { + prototype: PerformanceNavigation; + new(): PerformanceNavigation; + readonly TYPE_BACK_FORWARD: number; + readonly TYPE_NAVIGATE: number; + readonly TYPE_RELOAD: number; + readonly TYPE_RESERVED: number; +} + +interface PerformanceTiming { + readonly connectEnd: number; + readonly connectStart: number; + readonly domComplete: number; + readonly domContentLoadedEventEnd: number; + readonly domContentLoadedEventStart: number; + readonly domInteractive: number; + readonly domLoading: number; + readonly domainLookupEnd: number; + readonly domainLookupStart: number; + readonly fetchStart: number; + readonly loadEventEnd: number; + readonly loadEventStart: number; + readonly msFirstPaint: number; + readonly navigationStart: number; + readonly redirectEnd: number; + readonly redirectStart: number; + readonly requestStart: number; + readonly responseEnd: number; + readonly responseStart: number; + readonly unloadEventEnd: number; + readonly unloadEventStart: number; + readonly secureConnectionStart: number; + toJSON(): any; +} + +declare var PerformanceTiming: { + prototype: PerformanceTiming; + new(): PerformanceTiming; +} + interface Position { readonly coords: Coordinates; readonly timestamp: number; @@ -727,9 +881,156 @@ declare var ProgressEvent: { new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } +interface PushManager { + getSubscription(): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; + subscribe(options?: PushSubscriptionOptionsInit): Promise; +} + +declare var PushManager: { + prototype: PushManager; + new(): PushManager; +} + +interface PushSubscription { + readonly endpoint: USVString; + readonly options: PushSubscriptionOptions; + getKey(name: string): ArrayBuffer | null; + toJSON(): any; + unsubscribe(): Promise; +} + +declare var PushSubscription: { + prototype: PushSubscription; + new(): PushSubscription; +} + +interface PushSubscriptionOptions { + readonly applicationServerKey: ArrayBuffer | null; + readonly userVisibleOnly: boolean; +} + +declare var PushSubscriptionOptions: { + prototype: PushSubscriptionOptions; + new(): PushSubscriptionOptions; +} + +interface ReadableStream { + readonly locked: boolean; + cancel(): Promise; + getReader(): ReadableStreamReader; +} + +declare var ReadableStream: { + prototype: ReadableStream; + new(): ReadableStream; +} + +interface ReadableStreamReader { + cancel(): Promise; + read(): Promise; + releaseLock(): void; +} + +declare var ReadableStreamReader: { + prototype: ReadableStreamReader; + new(): ReadableStreamReader; +} + +interface Request extends Object, Body { + readonly cache: string; + readonly credentials: string; + readonly destination: string; + readonly headers: Headers; + readonly integrity: string; + readonly keepalive: boolean; + readonly method: string; + readonly mode: string; + readonly redirect: string; + readonly referrer: string; + readonly referrerPolicy: string; + readonly type: string; + readonly url: string; + clone(): Request; +} + +declare var Request: { + prototype: Request; + new(input: Request | string, init?: RequestInit): Request; +} + +interface Response extends Object, Body { + readonly body: ReadableStream | null; + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly type: string; + readonly url: string; + clone(): Response; +} + +declare var Response: { + prototype: Response; + new(body?: any, init?: ResponseInit): Response; +} + +interface ServiceWorkerEventMap extends AbstractWorkerEventMap { + "statechange": Event; +} + +interface ServiceWorker extends EventTarget, AbstractWorker { + onstatechange: (this: ServiceWorker, ev: Event) => any; + readonly scriptURL: USVString; + readonly state: string; + postMessage(message: any, transfer?: any[]): void; + addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorker: { + prototype: ServiceWorker; + new(): ServiceWorker; +} + +interface ServiceWorkerRegistrationEventMap { + "updatefound": Event; +} + +interface ServiceWorkerRegistration extends EventTarget { + readonly active: ServiceWorker | null; + readonly installing: ServiceWorker | null; + onupdatefound: (this: ServiceWorkerRegistration, ev: Event) => any; + readonly pushManager: PushManager; + readonly scope: USVString; + readonly sync: SyncManager; + readonly waiting: ServiceWorker | null; + getNotifications(filter?: GetNotificationOptions): any; + showNotification(title: string, options?: NotificationOptions): Promise; + unregister(): Promise; + update(): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerRegistration: { + prototype: ServiceWorkerRegistration; + new(): ServiceWorkerRegistration; +} + +interface SyncManager { + getTags(): any; + register(tag: string): Promise; +} + +declare var SyncManager: { + prototype: SyncManager; + new(): SyncManager; +} + interface WebSocketEventMap { "close": CloseEvent; - "error": ErrorEvent; + "error": Event; "message": MessageEvent; "open": Event; } @@ -739,7 +1040,7 @@ interface WebSocket extends EventTarget { readonly bufferedAmount: number; readonly extensions: string; onclose: (this: WebSocket, ev: CloseEvent) => any; - onerror: (this: WebSocket, ev: ErrorEvent) => any; + onerror: (this: WebSocket, ev: Event) => any; onmessage: (this: WebSocket, ev: MessageEvent) => any; onopen: (this: WebSocket, ev: Event) => any; readonly protocol: string; @@ -770,7 +1071,7 @@ interface WorkerEventMap extends AbstractWorkerEventMap { interface Worker extends EventTarget, AbstractWorker { onmessage: (this: Worker, ev: MessageEvent) => any; - postMessage(message: any, ports?: any): void; + postMessage(message: any, transfer?: any[]): void; terminate(): void; addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -791,6 +1092,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly response: any; readonly responseText: string; responseType: string; + readonly responseURL: string; readonly responseXML: any; readonly status: number; readonly statusText: string; @@ -798,7 +1100,6 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly upload: XMLHttpRequestUpload; withCredentials: boolean; msCaching?: string; - readonly responseURL: string; abort(): void; getAllResponseHeaders(): string; getResponseHeader(header: string): string | null; @@ -825,11 +1126,10 @@ declare var XMLHttpRequest: { readonly LOADING: number; readonly OPENED: number; readonly UNSENT: number; - create(): XMLHttpRequest; } interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { - addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -848,6 +1148,18 @@ interface AbstractWorker { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface Body { + readonly bodyUsed: boolean; + arrayBuffer(): Promise; + blob(): Promise; + json(): Promise; + text(): Promise; +} + +interface GlobalFetch { + fetch(input: RequestInfo, init?: RequestInit): Promise; +} + interface MSBaseReaderEventMap { "abort": Event; "error": ErrorEvent; @@ -874,7 +1186,16 @@ interface MSBaseReader { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface NavigatorBeacon { + sendBeacon(url: USVString, data?: BodyInit): boolean; +} + +interface NavigatorConcurrentHardware { + readonly hardwareConcurrency: number; +} + interface NavigatorID { + readonly appCodeName: string; readonly appName: string; readonly appVersion: string; readonly platform: string; @@ -920,6 +1241,81 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface Client { + readonly frameType: string; + readonly id: string; + readonly url: USVString; + postMessage(message: any, transfer?: any[]): void; +} + +declare var Client: { + prototype: Client; + new(): Client; +} + +interface Clients { + claim(): Promise; + get(id: string): Promise; + matchAll(options?: ClientQueryOptions): any; + openWindow(url: USVString): Promise; +} + +declare var Clients: { + prototype: Clients; + new(): Clients; +} + +interface DedicatedWorkerGlobalScopeEventMap extends WorkerGlobalScopeEventMap { + "message": MessageEvent; +} + +interface DedicatedWorkerGlobalScope extends WorkerGlobalScope { + onmessage: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any; + close(): void; + postMessage(message: any, transfer?: any[]): void; + addEventListener(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var DedicatedWorkerGlobalScope: { + prototype: DedicatedWorkerGlobalScope; + new(): DedicatedWorkerGlobalScope; +} + +interface ExtendableEvent extends Event { + waitUntil(f: Promise): void; +} + +declare var ExtendableEvent: { + prototype: ExtendableEvent; + new(type: string, eventInitDict?: ExtendableEventInit): ExtendableEvent; +} + +interface ExtendableMessageEvent extends ExtendableEvent { + readonly data: any; + readonly lastEventId: string; + readonly origin: string; + readonly ports: MessagePort[] | null; + readonly source: Client | ServiceWorker | MessagePort | null; +} + +declare var ExtendableMessageEvent: { + prototype: ExtendableMessageEvent; + new(type: string, eventInitDict?: ExtendableMessageEventInit): ExtendableMessageEvent; +} + +interface FetchEvent extends ExtendableEvent { + readonly clientId: string | null; + readonly isReload: boolean; + readonly request: Request; + respondWith(r: Promise): void; +} + +declare var FetchEvent: { + prototype: FetchEvent; + new(type: string, eventInitDict: FetchEventInit): FetchEvent; +} + interface FileReaderSync { readAsArrayBuffer(blob: Blob): any; readAsBinaryString(blob: Blob): void; @@ -932,17 +1328,105 @@ declare var FileReaderSync: { new(): FileReaderSync; } -interface WorkerGlobalScopeEventMap extends DedicatedWorkerGlobalScopeEventMap { +interface NotificationEvent extends ExtendableEvent { + readonly action: string; + readonly notification: Notification; +} + +declare var NotificationEvent: { + prototype: NotificationEvent; + new(type: string, eventInitDict: NotificationEventInit): NotificationEvent; +} + +interface PushEvent extends ExtendableEvent { + readonly data: PushMessageData | null; +} + +declare var PushEvent: { + prototype: PushEvent; + new(type: string, eventInitDict?: PushEventInit): PushEvent; +} + +interface PushMessageData { + arrayBuffer(): ArrayBuffer; + blob(): Blob; + json(): JSON; + text(): USVString; +} + +declare var PushMessageData: { + prototype: PushMessageData; + new(): PushMessageData; +} + +interface ServiceWorkerGlobalScopeEventMap extends WorkerGlobalScopeEventMap { + "activate": ExtendableEvent; + "fetch": FetchEvent; + "install": ExtendableEvent; + "message": ExtendableMessageEvent; + "notificationclick": NotificationEvent; + "notificationclose": NotificationEvent; + "push": PushEvent; + "pushsubscriptionchange": ExtendableEvent; + "sync": SyncEvent; +} + +interface ServiceWorkerGlobalScope extends WorkerGlobalScope { + readonly clients: Clients; + onactivate: (this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any; + onfetch: (this: ServiceWorkerGlobalScope, ev: FetchEvent) => any; + oninstall: (this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any; + onmessage: (this: ServiceWorkerGlobalScope, ev: ExtendableMessageEvent) => any; + onnotificationclick: (this: ServiceWorkerGlobalScope, ev: NotificationEvent) => any; + onnotificationclose: (this: ServiceWorkerGlobalScope, ev: NotificationEvent) => any; + onpush: (this: ServiceWorkerGlobalScope, ev: PushEvent) => any; + onpushsubscriptionchange: (this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any; + onsync: (this: ServiceWorkerGlobalScope, ev: SyncEvent) => any; + readonly registration: ServiceWorkerRegistration; + skipWaiting(): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerGlobalScope: { + prototype: ServiceWorkerGlobalScope; + new(): ServiceWorkerGlobalScope; +} + +interface SyncEvent extends ExtendableEvent { + readonly lastChance: boolean; + readonly tag: string; +} + +declare var SyncEvent: { + prototype: SyncEvent; + new(type: string, init: SyncEventInit): SyncEvent; +} + +interface WindowClient extends Client { + readonly focused: boolean; + readonly visibilityState: string; + focus(): Promise; + navigate(url: USVString): Promise; +} + +declare var WindowClient: { + prototype: WindowClient; + new(): WindowClient; +} + +interface WorkerGlobalScopeEventMap { "error": ErrorEvent; } -interface WorkerGlobalScope extends EventTarget, WorkerUtils, DedicatedWorkerGlobalScope, WindowConsole { +interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, GlobalFetch { + readonly caches: CacheStorage; + readonly isSecureContext: boolean; readonly location: WorkerLocation; onerror: (this: WorkerGlobalScope, ev: ErrorEvent) => any; + readonly performance: Performance; readonly self: WorkerGlobalScope; - close(): void; msWriteProfilerMark(profilerMarkName: string): void; - toString(): string; addEventListener(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -957,6 +1441,7 @@ interface WorkerLocation { readonly host: string; readonly hostname: string; readonly href: string; + readonly origin: string; readonly pathname: string; readonly port: string; readonly protocol: string; @@ -969,7 +1454,7 @@ declare var WorkerLocation: { new(): WorkerLocation; } -interface WorkerNavigator extends Object, NavigatorID, NavigatorOnLine { +interface WorkerNavigator extends Object, NavigatorID, NavigatorOnLine, NavigatorBeacon, NavigatorConcurrentHardware { readonly hardwareConcurrency: number; } @@ -978,17 +1463,6 @@ declare var WorkerNavigator: { new(): WorkerNavigator; } -interface DedicatedWorkerGlobalScopeEventMap { - "message": MessageEvent; -} - -interface DedicatedWorkerGlobalScope { - onmessage: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any; - postMessage(data: any): void; - addEventListener(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - interface WorkerUtils extends Object, WindowBase64 { readonly indexedDB: IDBFactory; readonly msIndexedDB: IDBFactory; @@ -1005,6 +1479,14 @@ interface WorkerUtils extends Object, WindowBase64 { setTimeout(handler: any, timeout?: any, ...args: any[]): number; } +interface ErrorEventInit { + message?: string; + filename?: string; + lineno?: number; + conlno?: number; + error?: any; +} + interface BlobPropertyBag { type?: string; endings?: string; @@ -1019,15 +1501,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -interface MessageEventInit extends EventInit { - data?: any; - origin?: string; - lastEventId?: string; - channel?: string; - source?: any; - ports?: MessagePort[]; -} - interface ProgressEventInit extends EventInit { lengthComputable?: boolean; loaded?: number; @@ -1219,18 +1692,6 @@ interface PositionCallback { interface PositionErrorCallback { (error: PositionError): void; } -interface MediaQueryListListener { - (mql: MediaQueryList): void; -} -interface MSLaunchUriCallback { - (): void; -} -interface MSUnsafeFunctionCallback { - (): any; -} -interface MSExecAtPriorityFunctionCallback { - (...args: any[]): any; -} interface DecodeSuccessCallback { (decodedData: AudioBuffer): void; } @@ -1240,12 +1701,22 @@ interface DecodeErrorCallback { interface FunctionStringCallback { (data: string): void; } -declare var location: WorkerLocation; -declare var onerror: (this: WorkerGlobalScope, ev: ErrorEvent) => any; -declare var self: WorkerGlobalScope; +interface ForEachCallback { + (keyId: any, status: string): void; +} +interface NotificationPermissionCallback { + (permission: string): void; +} +declare var onmessage: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any; declare function close(): void; +declare function postMessage(message: any, transfer?: any[]): void; +declare var caches: CacheStorage; +declare var isSecureContext: boolean; +declare var location: WorkerLocation; +declare var onerror: (this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any; +declare var performance: Performance; +declare var self: WorkerGlobalScope; declare function msWriteProfilerMark(profilerMarkName: string): void; -declare function toString(): string; declare function dispatchEvent(evt: Event): boolean; declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; declare var indexedDB: IDBFactory; @@ -1263,12 +1734,16 @@ declare function setTimeout(handler: (...args: any[]) => void, timeout: number): declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; declare function atob(encodedString: string): string; declare function btoa(rawString: string): string; -declare var onmessage: (this: WorkerGlobalScope, ev: MessageEvent) => any; -declare function postMessage(data: any): void; declare var console: Console; -declare function addEventListener(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; +declare function fetch(input: RequestInfo, init?: RequestInit): Promise; +declare function dispatchEvent(evt: Event): boolean; +declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function addEventListener(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; type AlgorithmIdentifier = string | Algorithm; +type BodyInit = any; type IDBKeyPath = string; +type RequestInfo = Request | string; +type USVString = string; type IDBValidKey = number | string | Date | IDBArrayKey; type BufferSource = ArrayBuffer | ArrayBufferView; \ No newline at end of file diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index d6c0246af34..2fc15c3a256 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -734,9 +734,9 @@ declare namespace ts.server.protocol { */ formatOptions?: FormatCodeSettings; /** - * The host's additional supported file extensions + * The host's additional supported .js file extensions */ - extraFileExtensions?: FileExtensionInfo[]; + extraFileExtensions?: JsFileExtensionInfo[]; } /** * Configure request; value of command field is "configure". Specifies @@ -905,6 +905,10 @@ declare namespace ts.server.protocol { * List of files names that should be recompiled */ fileNames: string[]; + /** + * true if project uses outFile or out compiler option + */ + projectUsesOutFile: boolean; } /** * Response for CompileOnSaveAffectedFileListRequest request; @@ -1352,6 +1356,17 @@ declare namespace ts.server.protocol { command: CommandTypes.Geterr; arguments: GeterrRequestArgs; } + type RequestCompletedEventName = "requestCompleted"; + /** + * Event that is sent when server have finished processing request with specified id. + */ + interface RequestCompletedEvent extends Event { + event: RequestCompletedEventName; + body: RequestCompletedEventBody; + } + interface RequestCompletedEventBody { + request_seq: number; + } /** * Item of diagnostic information found in a DiagnosticEvent message. */ @@ -1775,6 +1790,7 @@ declare namespace ts.server.protocol { outDir?: string; outFile?: string; paths?: MapLike; + plugins?: PluginImport[]; preserveConstEnums?: boolean; project?: string; reactNamespace?: string; @@ -1798,9 +1814,10 @@ declare namespace ts.server.protocol { namespace JsxEmit { type None = "None"; type Preserve = "Preserve"; + type ReactNative = "ReactNative"; type React = "React"; } - type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; + type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.ReactNative; namespace ModuleKind { type None = "None"; type CommonJS = "CommonJS"; @@ -1856,17 +1873,25 @@ declare namespace ts.server.protocol { [option: string]: string[] | boolean | undefined; } - interface FileExtensionInfo { + interface JsFileExtensionInfo { extension: string; - scriptKind: ScriptKind; isMixedContent: boolean; } + /** + * Type of objects whose values are all of the same type. + * The `in` and `for-in` operators can *not* be safely used, + * since `Object.prototype` may be modified by outside code. + */ interface MapLike { [index: string]: T; } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; + interface PluginImport { + name: string; + } + + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; } declare namespace ts { // these types are empty stubs for types from services and should not be used directly diff --git a/lib/tsc.js b/lib/tsc.js index c1ab6d062f5..be8abfb4a0d 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -88,32 +88,32 @@ var ts; var measures; function mark(markName) { if (enabled) { - marks[markName] = ts.timestamp(); - counts[markName] = (counts[markName] || 0) + 1; + marks.set(markName, ts.timestamp()); + counts.set(markName, (counts.get(markName) || 0) + 1); profilerEvent(markName); } } performance.mark = mark; function measure(measureName, startMarkName, endMarkName) { if (enabled) { - var end = endMarkName && marks[endMarkName] || ts.timestamp(); - var start = startMarkName && marks[startMarkName] || profilerStart; - measures[measureName] = (measures[measureName] || 0) + (end - start); + var end = endMarkName && marks.get(endMarkName) || ts.timestamp(); + var start = startMarkName && marks.get(startMarkName) || profilerStart; + measures.set(measureName, (measures.get(measureName) || 0) + (end - start)); } } performance.measure = measure; function getCount(markName) { - return counts && counts[markName] || 0; + return counts && counts.get(markName) || 0; } performance.getCount = getCount; function getDuration(measureName) { - return measures && measures[measureName] || 0; + return measures && measures.get(measureName) || 0; } performance.getDuration = getDuration; function forEachMeasure(cb) { - for (var key in measures) { - cb(key, measures[key]); - } + measures.forEach(function (measure, key) { + cb(key, measure); + }); } performance.forEachMeasure = forEachMeasure; function enable() { @@ -132,22 +132,96 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.2.0"; + ts.version = "2.3.0"; })(ts || (ts = {})); (function (ts) { - var createObject = Object.create; - ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - function createMap(template) { - var map = createObject(null); + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(undefined, { usage: "sort", sensitivity: "accent" }) : undefined; + ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + function createDictionaryObject() { + var map = Object.create(null); map["__"] = undefined; delete map["__"]; + return map; + } + function createMap() { + return new MapCtr(); + } + ts.createMap = createMap; + function createMapFromTemplate(template) { + var map = new MapCtr(); for (var key in template) if (hasOwnProperty.call(template, key)) { - map[key] = template[key]; + map.set(key, template[key]); } return map; } - ts.createMap = createMap; + ts.createMapFromTemplate = createMapFromTemplate; + var MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); + function shimMap() { + var MapIterator = (function () { + function MapIterator(data, selector) { + this.index = 0; + this.data = data; + this.selector = selector; + this.keys = Object.keys(data); + } + MapIterator.prototype.next = function () { + var index = this.index; + if (index < this.keys.length) { + this.index++; + return { value: this.selector(this.data, this.keys[index]), done: false }; + } + return { value: undefined, done: true }; + }; + return MapIterator; + }()); + return (function () { + function class_1() { + this.data = createDictionaryObject(); + this.size = 0; + } + class_1.prototype.get = function (key) { + return this.data[key]; + }; + class_1.prototype.set = function (key, value) { + if (!this.has(key)) { + this.size++; + } + this.data[key] = value; + return this; + }; + class_1.prototype.has = function (key) { + return key in this.data; + }; + class_1.prototype.delete = function (key) { + if (this.has(key)) { + this.size--; + delete this.data[key]; + return true; + } + return false; + }; + class_1.prototype.clear = function () { + this.data = createDictionaryObject(); + this.size = 0; + }; + class_1.prototype.keys = function () { + return new MapIterator(this.data, function (_data, key) { return key; }); + }; + class_1.prototype.values = function () { + return new MapIterator(this.data, function (data, key) { return data[key]; }); + }; + class_1.prototype.entries = function () { + return new MapIterator(this.data, function (data, key) { return [key, data[key]]; }); + }; + class_1.prototype.forEach = function (action) { + for (var key in this.data) { + action(this.data[key], key); + } + }; + return class_1; + }()); + } function createFileMap(keyMapper) { var files = createMap(); return { @@ -160,32 +234,27 @@ var ts; clear: clear, }; function forEachValueInMap(f) { - for (var key in files) { - f(key, files[key]); - } + files.forEach(function (file, key) { + f(key, file); + }); } function getKeys() { - var keys = []; - for (var key in files) { - keys.push(key); - } - return keys; + return arrayFrom(files.keys()); } function get(path) { - return files[toKey(path)]; + return files.get(toKey(path)); } function set(path, value) { - files[toKey(path)] = value; + files.set(toKey(path), value); } function contains(path) { - return toKey(path) in files; + return files.has(toKey(path)); } function remove(path) { - var key = toKey(path); - delete files[key]; + files.delete(toKey(path)); } function clear() { - files = createMap(); + files.clear(); } function toKey(path) { return keyMapper ? keyMapper(path) : path; @@ -199,6 +268,10 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + function length(array) { + return array ? array.length : 0; + } + ts.length = length; function forEach(array, callback) { if (array) { for (var i = 0; i < array.length; i++) { @@ -239,6 +312,15 @@ var ts; return undefined; } ts.find = find; + function findIndex(array, predicate) { + for (var i = 0; i < array.length; i++) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; + } + ts.findIndex = findIndex; function findMap(array, callback) { for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); @@ -460,21 +542,18 @@ var ts; return result; } ts.spanMap = spanMap; - function mapObject(object, f) { - var result; - if (object) { - result = {}; - for (var _i = 0, _a = getOwnKeys(object); _i < _a.length; _i++) { - var v = _a[_i]; - var _b = f(v, object[v]) || [undefined, undefined], key = _b[0], value = _b[1]; - if (key !== undefined) { - result[key] = value; - } - } + function mapEntries(map, f) { + if (!map) { + return undefined; } + var result = createMap(); + map.forEach(function (value, key) { + var _a = f(key, value), newKey = _a[0], newValue = _a[1]; + result.set(newKey, newValue); + }); return result; } - ts.mapObject = mapObject; + ts.mapEntries = mapEntries; function some(array, predicate) { if (array) { if (predicate) { @@ -758,38 +837,55 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - function forEachProperty(map, callback) { - var result; - for (var key in map) { - if (result = callback(map[key], key)) - break; + function arrayFrom(iterator) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(value); } return result; + var _b; } - ts.forEachProperty = forEachProperty; - function someProperties(map, predicate) { - for (var key in map) { - if (!predicate || predicate(map[key], key)) - return true; + ts.arrayFrom = arrayFrom; + function convertToArray(iterator, f) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(f(value)); } - return false; + return result; + var _b; } - ts.someProperties = someProperties; - function copyProperties(source, target) { - for (var key in source) { - target[key] = source[key]; + ts.convertToArray = convertToArray; + function forEachEntry(map, callback) { + var iterator = map.entries(); + for (var _a = iterator.next(), pair = _a.value, done = _a.done; !done; _b = iterator.next(), pair = _b.value, done = _b.done, _b) { + var key = pair[0], value = pair[1]; + var result = callback(value, key); + if (result) { + return result; + } } + return undefined; + var _b; } - ts.copyProperties = copyProperties; - function appendProperty(map, key, value) { - if (key === undefined || value === undefined) - return map; - if (map === undefined) - map = createMap(); - map[key] = value; - return map; + ts.forEachEntry = forEachEntry; + function forEachKey(map, callback) { + var iterator = map.keys(); + for (var _a = iterator.next(), key = _a.value, done = _a.done; !done; _b = iterator.next(), key = _b.value, done = _b.done, _b) { + var result = callback(key); + if (result) { + return result; + } + } + return undefined; + var _b; } - ts.appendProperty = appendProperty; + ts.forEachKey = forEachKey; + function copyEntries(source, target) { + source.forEach(function (value, key) { + target.set(key, value); + }); + } + ts.copyEntries = copyEntries; function assign(t) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -805,14 +901,6 @@ var ts; return t; } ts.assign = assign; - function reduceProperties(map, callback, initial) { - var result = initial; - for (var key in map) { - result = callback(result, map[key], String(key)); - } - return result; - } - ts.reduceProperties = reduceProperties; function equalOwnProperties(left, right, equalityComparer) { if (left === right) return true; @@ -837,23 +925,14 @@ var ts; var result = createMap(); for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { var value = array_8[_i]; - result[makeKey(value)] = makeValue ? makeValue(value) : value; + result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; } ts.arrayToMap = arrayToMap; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; function cloneMap(map) { var clone = createMap(); - copyProperties(map, clone); + copyEntries(map, clone); return clone; } ts.cloneMap = cloneMap; @@ -880,27 +959,32 @@ var ts; return result; } ts.extend = extend; - function multiMapAdd(map, key, value) { - var values = map[key]; + function createMultiMap() { + var map = createMap(); + map.add = multiMapAdd; + map.remove = multiMapRemove; + return map; + } + ts.createMultiMap = createMultiMap; + function multiMapAdd(key, value) { + var values = this.get(key); if (values) { values.push(value); - return values; } else { - return map[key] = [value]; + this.set(key, values = [value]); } + return values; } - ts.multiMapAdd = multiMapAdd; - function multiMapRemove(map, key, value) { - var values = map[key]; + function multiMapRemove(key, value) { + var values = this.get(key); if (values) { unorderedRemoveItem(values, value); if (!values.length) { - delete map[key]; + this.delete(key); } } } - ts.multiMapRemove = multiMapRemove; function isArray(value) { return Array.isArray ? Array.isArray(value) : value instanceof Array; } @@ -1078,8 +1162,10 @@ var ts; if (b === undefined) return 1; if (ignoreCase) { - if (ts.collator && String.prototype.localeCompare) { - var result = a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); + if (ts.collator) { + var result = ts.localeCompareIsCorrect ? + ts.collator.compare(a, b) : + a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 : result > 0 ? 1 : 0; } a = a.toUpperCase(); @@ -1461,36 +1547,26 @@ var ts; var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; var singleAsteriskRegexFragmentOther = "[^/]*"; function getRegularExpressionForWildcard(specs, basePath, usage) { + var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); + if (!patterns || !patterns.length) { + return undefined; + } + var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; + } + ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + function getRegularExpressionsForWildcards(specs, basePath, usage) { if (specs === undefined || specs.length === 0) { return undefined; } var replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther; var singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther; var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; - var pattern = ""; - var hasWrittenSubpattern = false; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!spec) { - continue; - } - var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); - if (subPattern === undefined) { - continue; - } - if (hasWrittenSubpattern) { - pattern += "|"; - } - pattern += "(" + subPattern + ")"; - hasWrittenSubpattern = true; - } - if (!pattern) { - return undefined; - } - var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return flatMap(specs, function (spec) { + return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + }); } - ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function isImplicitGlob(lastPathComponent) { return !/[.*?]/.test(lastPathComponent); } @@ -1560,6 +1636,7 @@ var ts; currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); return { + includeFilePatterns: map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -1572,34 +1649,48 @@ var ts; currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); - var result = []; + var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; + var comparer = useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive; for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; visitDirectory(basePath, combinePaths(currentDirectory, basePath)); } - return result; + return flatten(results); function visitDirectory(path, absolutePath) { var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; + files = files.slice().sort(comparer); + directories = directories.slice().sort(comparer); + var _loop_1 = function (current) { + var name = combinePaths(path, current); + var absoluteName = combinePaths(absolutePath, current); + if (extensions && !fileExtensionIsAny(name, extensions)) + return "continue"; + if (excludeRegex && excludeRegex.test(absoluteName)) + return "continue"; + if (!includeFileRegexes) { + results[0].push(name); + } + else { + var includeIndex = findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); }); + if (includeIndex !== -1) { + results[includeIndex].push(name); + } + } + }; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var current = files_1[_i]; - var name_1 = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); - if ((!extensions || fileExtensionIsAny(name_1, extensions)) && - (!includeFileRegex || includeFileRegex.test(absoluteName)) && - (!excludeRegex || !excludeRegex.test(absoluteName))) { - result.push(name_1); - } + _loop_1(current); } for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var current = directories_1[_b]; - var name_2 = combinePaths(path, current); + var name = combinePaths(path, current); var absoluteName = combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { - visitDirectory(name_2, absoluteName); + visitDirectory(name, absoluteName); } } } @@ -1615,14 +1706,14 @@ var ts; includeBasePaths.push(getIncludeBasePath(absolute)); } includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); - var _loop_1 = function (includeBasePath) { + var _loop_2 = function (includeBasePath) { if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } }; for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { var includeBasePath = includeBasePaths_1[_a]; - _loop_1(includeBasePath); + _loop_2(includeBasePath); } } return basePaths; @@ -1662,13 +1753,13 @@ var ts; var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions); function getSupportedExtensions(options, extraFileExtensions) { var needAllExtensions = options && options.allowJs; - if (!extraFileExtensions || extraFileExtensions.length === 0) { + if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = (needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions).slice(0); + var extensions = allSupportedExtensions.slice(0); for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { var extInfo = extraFileExtensions_1[_i]; - if (needAllExtensions || extInfo.scriptKind === 3) { + if (extensions.indexOf(extInfo.extension) === -1) { extensions.push(extInfo.extension); } } @@ -1699,30 +1790,30 @@ var ts; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { - return adjustExtensionPriority(i); + return adjustExtensionPriority(i, supportedExtensions); } } return 0; } ts.getExtensionPriority = getExtensionPriority; - function adjustExtensionPriority(extensionPriority) { + function adjustExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2) { return 0; } - else if (extensionPriority < 5) { + else if (extensionPriority < supportedExtensions.length) { return 2; } else { - return 5; + return supportedExtensions.length; } } ts.adjustExtensionPriority = adjustExtensionPriority; - function getNextLowestExtensionPriority(extensionPriority) { + function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2) { return 2; } else { - return 5; + return supportedExtensions.length; } } ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority; @@ -2069,32 +2160,32 @@ var ts; var useNonPollingWatchers = process.env["TSC_NONPOLLING_WATCHER"]; function createWatchedFileSet() { var dirWatchers = ts.createMap(); - var fileWatcherCallbacks = ts.createMap(); + var fileWatcherCallbacks = ts.createMultiMap(); return { addFile: addFile, removeFile: removeFile }; function reduceDirWatcherRefCountForFile(fileName) { var dirName = ts.getDirectoryPath(fileName); - var watcher = dirWatchers[dirName]; + var watcher = dirWatchers.get(dirName); if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); - delete dirWatchers[dirName]; + dirWatchers.delete(dirName); } } } function addDirWatcher(dirPath) { - var watcher = dirWatchers[dirPath]; + var watcher = dirWatchers.get(dirPath); if (watcher) { watcher.referenceCount += 1; return; } watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; - dirWatchers[dirPath] = watcher; + dirWatchers.set(dirPath, watcher); return; } function addFileWatcherCallback(filePath, callback) { - ts.multiMapAdd(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.add(filePath, callback); } function addFile(fileName, callback) { addFileWatcherCallback(fileName, callback); @@ -2106,16 +2197,19 @@ var ts; reduceDirWatcherRefCountForFile(watchedFile.fileName); } function removeFileWatcherCallback(filePath, callback) { - ts.multiMapRemove(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.remove(filePath, callback); } function fileEventHandler(eventName, relativeFileName, baseDirPath) { var fileName = typeof relativeFileName !== "string" ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); - if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { - for (var _i = 0, _a = fileWatcherCallbacks[fileName]; _i < _a.length; _i++) { - var fileCallback = _a[_i]; - fileCallback(fileName); + if ((eventName === "change" || eventName === "rename")) { + var callbacks = fileWatcherCallbacks.get(fileName); + if (callbacks) { + for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) { + var fileCallback = callbacks_1[_i]; + fileCallback(fileName); + } } } } @@ -2180,10 +2274,10 @@ var ts; if (entry === "." || entry === "..") { continue; } - var name_3 = ts.combinePaths(path, entry); + var name = ts.combinePaths(path, entry); var stat = void 0; try { - stat = _fs.statSync(name_3); + stat = _fs.statSync(name); } catch (e) { continue; @@ -2257,7 +2351,7 @@ var ts; }, watchDirectory: function (directoryName, callback, recursive) { var options; - if (!directoryExists(directoryName)) { + if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { @@ -2272,6 +2366,9 @@ var ts; } ; }); + function isUNCPath(s) { + return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47; + } }, resolvePath: function (path) { return _path.resolve(path); @@ -2582,6 +2679,7 @@ var ts; Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", message: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", message: "Invalid use of '{0}'. Modules are automatically in strict mode." }, + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", message: "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export_assignment_is_not_supported_when_module_flag_is_system_1218", message: "Export assignment is not supported when '--module' flag is 'system'." }, Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", message: "Generators are only available when targeting ECMAScript 2015 or higher." }, @@ -2860,6 +2958,8 @@ var ts; Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, + A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, + Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union 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_2601", message: "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_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2870,6 +2970,7 @@ var ts; 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_2607", message: "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_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, + Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -2918,11 +3019,15 @@ var ts; The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: { code: 2699, category: ts.DiagnosticCategory.Error, key: "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", message: "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'." }, Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, + Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, + Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "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_4002", message: "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_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2933,8 +3038,8 @@ var ts; Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4014", message: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_function_has_or_is_using_private_name_1_4016", message: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019", message: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "'extends' clause of exported class '{0}' has or is using private name '{1}'." }, + extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "'extends' clause of exported interface '{0}' has or is using private name '{1}'." }, Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023", message: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024", message: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_private_name_1_4025", message: "Exported variable '{0}' has or is using private name '{1}'." }, @@ -2997,6 +3102,7 @@ var ts; Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced: { code: 4093, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced_4093", message: "'extends' clause of exported class '{0}' refers to a type whose name cannot be referenced." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -3042,7 +3148,7 @@ var ts; Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, - Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_in_the_given_directory_6020", message: "Compile the project in the given directory." }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, @@ -3057,6 +3163,7 @@ var ts; LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, STRATEGY: { code: 6039, category: ts.DiagnosticCategory.Message, key: "STRATEGY_6039", message: "STRATEGY" }, + FILE_OR_DIRECTORY: { code: 6040, category: ts.DiagnosticCategory.Message, key: "FILE_OR_DIRECTORY_6040", message: "FILE OR DIRECTORY" }, Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation_complete_Watching_for_file_changes_6042", message: "Compilation complete. Watching for file changes." }, Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_map_file_6043", message: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_expects_an_argument_6044", message: "Compiler option '{0}' expects an argument." }, @@ -3090,7 +3197,7 @@ var ts; Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, @@ -3110,7 +3217,7 @@ var ts; File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, + package_json_does_not_have_a_0_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_0_field_6100", message: "'package.json' does not have a '{0}' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -3147,7 +3254,6 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, @@ -3200,7 +3306,7 @@ var ts; parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: ts.DiagnosticCategory.Error, key: "parameter_modifiers_can_only_be_used_in_a_ts_file_8012", message: "'parameter modifiers' 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_8015", message: "'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_8016", message: "'type assertion expressions' 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_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause." }, class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "class_expressions_are_not_currently_supported_9003", message: "'class' expressions are not currently supported." }, Language_service_is_disabled: { code: 9004, category: ts.DiagnosticCategory.Error, key: "Language_service_is_disabled_9004", message: "Language service is disabled." }, 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_17000", message: "JSX attributes must only be assigned a non-empty 'expression'." }, @@ -3224,9 +3330,10 @@ var ts; Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, + Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, @@ -3242,7 +3349,7 @@ var ts; return token >= 70; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = ts.createMap({ + var textToToken = ts.createMapFromTemplate({ "abstract": 116, "any": 118, "as": 117, @@ -3266,7 +3373,7 @@ var ts; "false": 85, "finally": 86, "for": 87, - "from": 138, + "from": 139, "function": 88, "get": 124, "if": 89, @@ -3284,27 +3391,28 @@ var ts; "new": 93, "null": 94, "number": 132, + "object": 133, "package": 110, "private": 111, "protected": 112, "public": 113, "readonly": 130, "require": 131, - "global": 139, + "global": 140, "return": 95, - "set": 133, + "set": 134, "static": 114, - "string": 134, + "string": 135, "super": 96, "switch": 97, - "symbol": 135, + "symbol": 136, "this": 98, "throw": 99, "true": 100, "try": 101, - "type": 136, + "type": 137, "typeof": 102, - "undefined": 137, + "undefined": 138, "var": 103, "void": 104, "while": 105, @@ -3312,7 +3420,7 @@ var ts; "yield": 115, "async": 119, "await": 120, - "of": 140, + "of": 141, "{": 16, "}": 17, "(": 18, @@ -3407,9 +3515,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_4 in source) { - result[source[name_4]] = name_4; - } + source.forEach(function (value, name) { + result[value] = name; + }); return result; } var tokenStrings = makeReverseMap(textToToken); @@ -3418,7 +3526,7 @@ var ts; } ts.tokenToString = tokenToString; function stringToToken(s) { - return textToToken[s]; + return textToToken.get(s); } ts.stringToToken = stringToToken; function computeLineStarts(text) { @@ -3478,7 +3586,6 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - var hasOwnProperty = Object.prototype.hasOwnProperty; function isWhiteSpace(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } @@ -4137,8 +4244,11 @@ var ts; var len = tokenValue.length; if (len >= 2 && len <= 11) { var ch = tokenValue.charCodeAt(0); - if (ch >= 97 && ch <= 122 && hasOwnProperty.call(textToToken, tokenValue)) { - return token = textToToken[tokenValue]; + if (ch >= 97 && ch <= 122) { + token = textToToken.get(tokenValue); + if (token !== undefined) { + return token; + } } } return token = 70; @@ -4804,6 +4914,19 @@ var ts; return undefined; } ts.getDeclarationOfKind = getDeclarationOfKind; + function findDeclaration(symbol, predicate) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; + if (predicate(declaration)) { + return declaration; + } + } + } + return undefined; + } + ts.findDeclaration = findDeclaration; var stringWriters = []; function getSingleLineStringWriter() { if (stringWriters.length === 0) { @@ -4824,7 +4947,8 @@ var ts; decreaseIndent: ts.noop, clear: function () { return str_1 = ""; }, trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop }; } return stringWriters.pop(); @@ -4840,25 +4964,25 @@ var ts; } ts.getFullWidth = getFullWidth; function hasResolvedModule(sourceFile, moduleNameText) { - return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText)); } ts.hasResolvedModule = hasResolvedModule; function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules.get(moduleNameText) : undefined; } ts.getResolvedModule = getResolvedModule; function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { if (!sourceFile.resolvedModules) { sourceFile.resolvedModules = ts.createMap(); } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; + sourceFile.resolvedModules.set(moduleNameText, resolvedModule); } ts.setResolvedModule = setResolvedModule; function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { if (!sourceFile.resolvedTypeReferenceDirectiveNames) { sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; + sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective); } ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; function moduleResolutionIsEqualTo(oldResolution, newResolution) { @@ -4877,7 +5001,7 @@ var ts; } for (var i = 0; i < names.length; i++) { var newResolution = newResolutions[i]; - var oldResolution = oldResolutions && oldResolutions[names[i]]; + var oldResolution = oldResolutions && oldResolutions.get(names[i]); var changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) : newResolution; @@ -4904,7 +5028,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 262) { + while (node && node.kind !== 264) { node = node.parent; } return node; @@ -4912,11 +5036,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 205: - case 233: - case 212: + case 206: + case 234: case 213: case 214: + case 215: return true; } return false; @@ -4981,18 +5105,18 @@ var ts; if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 293 && node._children.length > 0) { + if (node.kind === 296 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 263 && node.kind <= 289; + return node.kind >= 266 && node.kind <= 295; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 279 && node.kind <= 292; + return node.kind >= 282 && node.kind <= 295; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -5052,18 +5176,36 @@ var ts; } ts.getLiteralText = getLiteralText; function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 && text.length > 1) { + return node.kind === 8 + && (getNumericLiteralFlags(text, 6) & 6) !== 0; + } + ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + function getNumericLiteralFlags(text, hint) { + if (text.length > 1) { switch (text.charCodeAt(1)) { case 98: case 66: + return 2; case 111: case 79: - return true; + return 4; + case 120: + case 88: + return 1; + } + if (hint & 8) { + for (var i = text.length - 1; i >= 0; i--) { + switch (text.charCodeAt(i)) { + case 101: + case 69: + return 8; + } + } } } - return false; + return 0; } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + ts.getNumericLiteralFlags = getNumericLiteralFlags; function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; } @@ -5071,10 +5213,6 @@ var ts; return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; } ts.escapeIdentifier = escapeIdentifier; - function unescapeIdentifier(identifier) { - return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; - } - ts.unescapeIdentifier = unescapeIdentifier; function makeIdentifierFromModuleName(moduleName) { return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } @@ -5086,11 +5224,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 224 && node.parent.kind === 257; + return node.kind === 225 && node.parent.kind === 259; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 231 && + return node && node.kind === 232 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -5099,11 +5237,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 231 && (!node.body); + return node && node.kind === 232 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 262 || - node.kind === 231 || + return node.kind === 264 || + node.kind === 232 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -5116,9 +5254,9 @@ var ts; return false; } switch (node.parent.kind) { - case 262: + case 264: return ts.isExternalModule(node.parent); - case 232: + case 233: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -5130,22 +5268,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 262: - case 233: - case 257: - case 231: - case 212: + case 264: + case 234: + case 259: + case 232: case 213: case 214: - case 150: - case 149: + case 215: case 151: + case 150: case 152: - case 226: - case 184: + case 153: + case 227: case 185: + case 186: return true; - case 205: + case 206: return parentNode && !isFunctionLike(parentNode); } return false; @@ -5172,7 +5310,7 @@ var ts; case 9: case 8: return name.text; - case 142: + case 143: if (isStringOrNumericLiteral(name.expression)) { return name.expression.text; } @@ -5183,10 +5321,10 @@ var ts; function entityNameToString(name) { switch (name.kind) { case 70: - return getFullWidth(name) === 0 ? unescapeIdentifier(name.text) : getTextOfNode(name); - case 141: + return getFullWidth(name) === 0 ? ts.unescapeIdentifier(name.text) : getTextOfNode(name); + case 142: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 177: + case 178: return entityNameToString(name.expression) + "." + entityNameToString(name.name); } } @@ -5223,7 +5361,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 205) { + if (node.body && node.body.kind === 206) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -5235,29 +5373,29 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 262: + case 264: 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 224: - case 174: - case 227: - case 197: + case 225: + case 175: case 228: - case 231: - case 230: - case 261: - case 226: - case 184: - case 149: - case 151: - case 152: + case 198: case 229: + case 232: + case 231: + case 263: + case 227: + case 185: + case 150: + case 152: + case 153: + case 230: errorNode = node.name; break; - case 185: + case 186: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -5278,7 +5416,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 230 && isConst(node); + return node.kind === 231 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -5291,11 +5429,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 179 && n.expression.kind === 96; + return n.kind === 180 && n.expression.kind === 96; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 208 + return node.kind === 209 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -5308,10 +5446,10 @@ var ts; } ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 144 || - node.kind === 143 || - node.kind === 184 || - node.kind === 185) ? + var commentRanges = (node.kind === 145 || + node.kind === 144 || + node.kind === 185 || + node.kind === 186) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, function (comment) { @@ -5325,69 +5463,69 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (156 <= node.kind && node.kind <= 171) { + if (157 <= node.kind && node.kind <= 172) { return true; } switch (node.kind) { case 118: case 132: - case 134: - case 121: case 135: - case 137: + case 121: + case 136: + case 138: case 129: return true; case 104: - return node.parent.kind !== 188; - case 199: + return node.parent.kind !== 189; + case 200: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 70: - if (node.parent.kind === 141 && node.parent.right === node) { + if (node.parent.kind === 142 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 177 && node.parent.name === node) { + else if (node.parent.kind === 178 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 70 || node.kind === 141 || node.kind === 177, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 141: - case 177: + ts.Debug.assert(node.kind === 70 || node.kind === 142 || node.kind === 178, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 142: + case 178: case 98: - var parent_1 = node.parent; - if (parent_1.kind === 160) { + var parent = node.parent; + if (parent.kind === 161) { return false; } - if (156 <= parent_1.kind && parent_1.kind <= 171) { + if (157 <= parent.kind && parent.kind <= 172) { return true; } - switch (parent_1.kind) { - case 199: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 143: - return node === parent_1.constraint; - case 147: - case 146: + switch (parent.kind) { + case 200: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 144: - case 224: - return node === parent_1.type; - case 226: - case 184: + return node === parent.constraint; + case 148: + case 147: + case 145: + case 225: + return node === parent.type; + case 227: case 185: + case 186: + case 151: case 150: case 149: - case 148: - case 151: case 152: - return node === parent_1.type; case 153: + return node === parent.type; case 154: case 155: - return node === parent_1.type; - case 182: - return node === parent_1.type; - case 179: + case 156: + return node === parent.type; + case 183: + return node === parent.type; case 180: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 181: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 182: return false; } } @@ -5405,30 +5543,30 @@ var ts; } ts.isChildOfNodeWithKind = isChildOfNodeWithKind; function isPrefixUnaryExpression(node) { - return node.kind === 190; + return node.kind === 191; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 217: + case 218: return visitor(node); - case 233: - case 205: - case 209: + case 234: + case 206: case 210: case 211: case 212: case 213: case 214: - case 218: + case 215: case 219: - case 254: - case 255: case 220: - case 222: + case 256: case 257: + case 221: + case 223: + case 259: return ts.forEachChild(node, traverse); } } @@ -5438,24 +5576,24 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 195: + case 196: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 230: - case 228: case 231: case 229: - case 227: - case 197: + case 232: + case 230: + case 228: + case 198: return; default: if (isFunctionLike(node)) { - var name_5 = node.name; - if (name_5 && name_5.kind === 142) { - traverse(name_5.expression); + var name = node.name; + if (name && name.kind === 143) { + traverse(name.expression); return; } } @@ -5467,10 +5605,10 @@ var ts; } ts.forEachYieldExpression = forEachYieldExpression; function getRestParameterElementType(node) { - if (node && node.kind === 162) { + if (node && node.kind === 163) { return node.elementType; } - else if (node && node.kind === 157) { + else if (node && node.kind === 158) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -5481,14 +5619,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 174: - case 261: - case 144: - case 258: + case 175: + case 263: + case 145: + case 260: + case 148: case 147: - case 146: - case 259: - case 224: + case 261: + case 225: return true; } } @@ -5496,11 +5634,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 151 || node.kind === 152); + return node && (node.kind === 152 || node.kind === 153); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 227 || node.kind === 197); + return node && (node.kind === 228 || node.kind === 198); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -5509,19 +5647,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 150: - case 184: - case 226: - case 185: - case 149: - case 148: case 151: + case 185: + case 227: + case 186: + case 150: + case 149: case 152: case 153: case 154: case 155: - case 158: + case 156: case 159: + case 160: return true; } return false; @@ -5529,13 +5667,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 226: - case 184: + case 153: + case 227: + case 185: return true; } return false; @@ -5543,13 +5681,13 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 212: case 213: case 214: - case 210: + case 215: case 211: + case 212: return true; - case 220: + case 221: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -5560,7 +5698,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 220) { + if (node.statement.kind !== 221) { return node.statement; } node = node.statement; @@ -5568,17 +5706,17 @@ var ts; } ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 205 && isFunctionLike(node.parent); + return node && node.kind === 206 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 149 && node.parent.kind === 176; + return node && node.kind === 150 && node.parent.kind === 177; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 149 && - (node.parent.kind === 176 || - node.parent.kind === 197); + return node.kind === 150 && + (node.parent.kind === 177 || + node.parent.kind === 198); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -5614,39 +5752,39 @@ var ts; return undefined; } switch (node.kind) { - case 142: + case 143: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 145: - if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { + case 146: + if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 185: + case 186: if (!includeArrowFunctions) { continue; } - case 226: - case 184: - case 231: - case 147: - case 146: - case 149: + case 227: + case 185: + case 232: case 148: + case 147: case 150: + case 149: case 151: case 152: case 153: case 154: case 155: - case 230: - case 262: + case 156: + case 231: + case 264: return node; } } @@ -5656,9 +5794,9 @@ var ts; var container = getThisContainer(node, false); if (container) { switch (container.kind) { - case 150: - case 226: - case 184: + case 151: + case 227: + case 185: return container; } } @@ -5672,25 +5810,25 @@ var ts; return node; } switch (node.kind) { - case 142: + case 143: node = node.parent; break; - case 226: - case 184: + case 227: case 185: + case 186: if (!stopOnFunctions) { continue; } - case 147: - case 146: - case 149: case 148: + case 147: case 150: + case 149: case 151: case 152: + case 153: return node; - case 145: - if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { + case 146: + if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -5702,36 +5840,36 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 184 || func.kind === 185) { + if (func.kind === 185 || func.kind === 186) { var prev = func; - var parent_2 = func.parent; - while (parent_2.kind === 183) { - prev = parent_2; - parent_2 = parent_2.parent; + var parent = func.parent; + while (parent.kind === 184) { + prev = parent; + parent = parent.parent; } - if (parent_2.kind === 179 && parent_2.expression === prev) { - return parent_2; + if (parent.kind === 180 && parent.expression === prev) { + return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 177 || kind === 178) + return (kind === 178 || kind === 179) && node.expression.kind === 96; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 157: - case 273: + case 158: + case 276: return node.typeName; - case 199: + case 200: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 70: - case 141: + case 142: return node; } return undefined; @@ -5739,10 +5877,12 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 179: + case 250: + case 249: case 180: case 181: - case 145: + case 182: + case 146: return true; default: return false; @@ -5750,29 +5890,32 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 181) { + if (node.kind === 182) { return node.tag; } + else if (isJsxOpeningLikeElement(node)) { + return node.tagName; + } return node.expression; } ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 227: + case 228: return true; - case 147: - return node.parent.kind === 227; - case 151: + case 148: + return node.parent.kind === 228; case 152: - case 149: + case 153: + case 150: return node.body !== undefined - && node.parent.kind === 227; - case 144: + && node.parent.kind === 228; + case 145: return node.parent.body !== undefined - && (node.parent.kind === 150 - || node.parent.kind === 149 - || node.parent.kind === 152) - && node.parent.parent.kind === 227; + && (node.parent.kind === 151 + || node.parent.kind === 150 + || node.parent.kind === 153) + && node.parent.parent.kind === 228; } return false; } @@ -5788,19 +5931,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 227: + case 228: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 149: - case 152: + case 150: + case 153: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 249 || - parent.kind === 248 || - parent.kind === 250) { + if (parent.kind === 250 || + parent.kind === 249 || + parent.kind === 251) { return parent.tagName === node; } return false; @@ -5814,96 +5957,96 @@ var ts; case 100: case 85: case 11: - case 175: case 176: case 177: case 178: case 179: case 180: case 181: - case 200: case 182: case 201: case 183: + case 202: case 184: - case 197: case 185: - case 188: + case 198: case 186: + case 189: case 187: - case 190: + case 188: case 191: case 192: case 193: - case 196: case 194: - case 12: - case 198: - case 247: - case 248: + case 197: case 195: - case 189: - case 202: + case 12: + case 199: + case 248: + case 249: + case 196: + case 190: + case 203: return true; - case 141: - while (node.parent.kind === 141) { + case 142: + while (node.parent.kind === 142) { node = node.parent; } - return node.parent.kind === 160 || isJSXTagName(node); + return node.parent.kind === 161 || isJSXTagName(node); case 70: - if (node.parent.kind === 160 || isJSXTagName(node)) { + if (node.parent.kind === 161 || isJSXTagName(node)) { return true; } case 8: case 9: case 98: - var parent_3 = node.parent; - switch (parent_3.kind) { - case 224: - case 144: + var parent = node.parent; + switch (parent.kind) { + case 225: + case 145: + case 148: case 147: - case 146: - case 261: - case 258: - case 174: - return parent_3.initializer === node; - case 208: + case 263: + case 260: + case 175: + return parent.initializer === node; case 209: case 210: case 211: - case 217: + case 212: case 218: case 219: - case 254: - case 221: - case 219: - return parent_3.expression === node; - case 212: - var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 225) || + case 220: + case 256: + case 222: + case 220: + return parent.expression === node; + case 213: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 226) || forStatement.condition === node || forStatement.incrementor === node; - case 213: case 214: - var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 225) || + case 215: + var forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 226) || forInStatement.expression === node; - case 182: - case 200: - return node === parent_3.expression; - case 203: - return node === parent_3.expression; - case 142: - return node === parent_3.expression; - case 145: - case 253: - case 252: - case 260: + case 183: + case 201: + return node === parent.expression; + case 204: + return node === parent.expression; + case 143: + return node === parent.expression; + case 146: + case 255: + case 254: + case 262: return true; - case 199: - return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); + case 200: + return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: - if (isPartOfExpression(parent_3)) { + if (isPartOfExpression(parent)) { return true; } } @@ -5918,7 +6061,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 235 && node.moduleReference.kind === 246; + return node.kind === 236 && node.moduleReference.kind === 247; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5927,7 +6070,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 235 && node.moduleReference.kind !== 246; + return node.kind === 236 && node.moduleReference.kind !== 247; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -5939,7 +6082,7 @@ var ts; } ts.isInJavaScriptFile = isInJavaScriptFile; function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 179 && + var isRequire = expression.kind === 180 && expression.expression.kind === 70 && expression.expression.text === "require" && expression.arguments.length === 1; @@ -5951,9 +6094,9 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 224) { + if (s.valueDeclaration && s.valueDeclaration.kind === 225) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 184; + return declaration.initializer && declaration.initializer.kind === 185; } return false; } @@ -5962,11 +6105,11 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0; } - if (expression.kind !== 192) { + if (expression.kind !== 193) { return 0; } var expr = expression; - if (expr.operatorToken.kind !== 57 || expr.left.kind !== 177) { + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 178) { return 0; } var lhs = expr.left; @@ -5982,7 +6125,7 @@ var ts; else if (lhs.expression.kind === 98) { return 4; } - else if (lhs.expression.kind === 177) { + else if (lhs.expression.kind === 178) { var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 70) { var innerPropertyAccessIdentifier = innerPropertyAccess.expression; @@ -5998,35 +6141,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 236) { + if (node.kind === 237) { return node.moduleSpecifier; } - if (node.kind === 235) { + if (node.kind === 236) { var reference = node.moduleReference; - if (reference.kind === 246) { + if (reference.kind === 247) { return reference.expression; } } - if (node.kind === 242) { + if (node.kind === 243) { return node.moduleSpecifier; } - if (node.kind === 231 && node.name.kind === 9) { + if (node.kind === 232 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 235) { + if (node.kind === 236) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 238) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 239) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 236 + return node.kind === 237 && node.importClause && !!node.importClause.name; } @@ -6034,13 +6177,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 144: + case 145: + case 150: case 149: + case 261: + case 260: case 148: - case 259: - case 258: case 147: - case 146: return node.questionToken !== undefined; } } @@ -6048,22 +6191,27 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 275 && + return node.kind === 278 && node.parameters.length > 0 && - node.parameters[0].type.kind === 277; + node.parameters[0].type.kind === 280; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { return ts.map(getJSDocs(node), function (doc) { return doc.comment; }); } ts.getCommentsFromJSDoc = getCommentsFromJSDoc; + function hasJSDocParameterTags(node) { + var parameterTags = getJSDocTags(node, 285); + return parameterTags && parameterTags.length > 0; + } + ts.hasJSDocParameterTags = hasJSDocParameterTags; function getJSDocTags(node, kind) { var docs = getJSDocs(node); if (docs) { var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 282) { + if (doc.kind === 285) { if (doc.kind === kind) { result.push(doc); } @@ -6089,9 +6237,9 @@ var ts; var parent = node.parent; var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 206; + parent.parent.parent.kind === 207; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 206; + parent.parent.kind === 207; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -6099,19 +6247,19 @@ var ts; getJSDocsWorker(variableStatementNode); } var isSourceOfAssignmentExpressionStatement = parent && parent.parent && - parent.kind === 192 && + parent.kind === 193 && parent.operatorToken.kind === 57 && - parent.parent.kind === 208; + parent.parent.kind === 209; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 231 && - parent && parent.kind === 231; - var isPropertyAssignmentExpression = parent && parent.kind === 258; + var isModuleDeclaration = node.kind === 232 && + parent && parent.kind === 232; + var isPropertyAssignmentExpression = parent && parent.kind === 260; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } - if (node.kind === 144) { + if (node.kind === 145) { cache = ts.concatenate(cache, getJSDocParameterTags(node)); } if (isVariableLike(node) && node.initializer) { @@ -6125,17 +6273,17 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 282); + var tags = getJSDocTags(func, 285); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 282; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 285; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70) { - var name_6 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 282 && tag.parameterName.text === name_6; }); + var name_1 = param.name.text; + return ts.filter(tags, function (tag) { return tag.kind === 285 && tag.parameterName.text === name_1; }); } else { return undefined; @@ -6143,8 +6291,8 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 284); - if (!tag && node.kind === 144) { + var tag = getFirstJSDocTag(node, 287); + if (!tag && node.kind === 145) { var paramTags = getJSDocParameterTags(node); if (paramTags) { tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); @@ -6154,15 +6302,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 281); + return getFirstJSDocTag(node, 284); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 283); + return getFirstJSDocTag(node, 286); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 285); + return getFirstJSDocTag(node, 288); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -6175,8 +6323,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536)) { - if (node.type && node.type.kind === 276 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 276; })) { + if (node.type && node.type.kind === 279 || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 279; })) { return true; } } @@ -6191,28 +6339,33 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 192: + case 193: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 57 ? 1 : 2 : 0; - case 190: case 191: + case 192: var unaryOperator = parent.operator; return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; - case 213: case 214: + case 215: return parent.initializer === node ? 1 : 0; - case 183: - case 175: - case 196: + case 184: + case 176: + case 197: node = parent; break; - case 259: + case 261: if (parent.name !== node) { return 0; } - case 258: + node = parent.parent; + break; + case 260: + if (parent.name === node) { + return 0; + } node = parent.parent; break; default: @@ -6227,14 +6380,14 @@ var ts; } ts.isAssignmentTarget = isAssignmentTarget; function isDeleteTarget(node) { - if (node.kind !== 177 && node.kind !== 178) { + if (node.kind !== 178 && node.kind !== 179) { return false; } node = node.parent; - while (node && node.kind === 183) { + while (node && node.kind === 184) { node = node.parent; } - return node && node.kind === 186; + return node && node.kind === 187; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -6248,7 +6401,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2) || (node.kind === 262 && node.isDeclarationFile)) { + if (hasModifier(node, 2) || (node.kind === 264 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -6261,7 +6414,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 240 || parent.kind === 244) { + if (parent.kind === 241 || parent.kind === 245) { if (parent.propertyName) { return true; } @@ -6274,48 +6427,48 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 142 && + node.parent.kind === 143 && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 147: - case 146: - case 149: case 148: - case 151: + case 147: + case 150: + case 149: case 152: - case 261: - case 258: - case 177: + case 153: + case 263: + case 260: + case 178: return parent.name === node; - case 141: + case 142: if (parent.right === node) { - while (parent.kind === 141) { + while (parent.kind === 142) { parent = parent.parent; } - return parent.kind === 160; + return parent.kind === 161; } return false; - case 174: - case 240: + case 175: + case 241: return parent.propertyName === node; - case 244: + case 245: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 235 || - node.kind === 234 || - node.kind === 237 && !!node.name || - node.kind === 238 || - node.kind === 240 || - node.kind === 244 || - node.kind === 241 && exportAssignmentIsAlias(node); + return node.kind === 236 || + node.kind === 235 || + node.kind === 238 && !!node.name || + node.kind === 239 || + node.kind === 241 || + node.kind === 245 || + node.kind === 242 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -6401,7 +6554,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 <= token && token <= 140; + return 71 <= token && token <= 141; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -6423,7 +6576,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 142 && + return name.kind === 143 && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -6433,10 +6586,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 144) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 145) { return name.text; } - if (name.kind === 142) { + if (name.kind === 143) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6481,11 +6634,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 144; + return root.kind === 145; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 174) { + while (node.kind === 175) { node = node.parent.parent; } return node; @@ -6493,15 +6646,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 150 - || kind === 184 - || kind === 226 + return kind === 151 || kind === 185 - || kind === 149 - || kind === 151 + || kind === 227 + || kind === 186 + || kind === 150 || kind === 152 - || kind === 231 - || kind === 262; + || kind === 153 + || kind === 232 + || kind === 264; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -6509,66 +6662,44 @@ var ts; || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node, nodeTest) { - if (node) { - while (node.original !== undefined) { - node = node.original; - } + function getOriginalSourceFileOrBundle(sourceFileOrBundle) { + if (sourceFileOrBundle.kind === 265) { + return ts.updateBundle(sourceFileOrBundle, ts.sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile)); } - return !nodeTest || nodeTest(node) ? node : undefined; + return getOriginalSourceFile(sourceFileOrBundle); } - ts.getOriginalNode = getOriginalNode; - function isParseTreeNode(node) { - return (node.flags & 8) === 0; + ts.getOriginalSourceFileOrBundle = getOriginalSourceFileOrBundle; + function getOriginalSourceFile(sourceFile) { + return ts.getParseTreeNode(sourceFile, isSourceFile) || sourceFile; } - ts.isParseTreeNode = isParseTreeNode; - function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { - return node; - } - node = getOriginalNode(node); - if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { - return node; - } - return undefined; - } - ts.getParseTreeNode = getParseTreeNode; function getOriginalSourceFiles(sourceFiles) { - var originalSourceFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); - if (originalSourceFile) { - originalSourceFiles.push(originalSourceFile); - } - } - return originalSourceFiles; + return ts.sameMap(sourceFiles, getOriginalSourceFile); } ts.getOriginalSourceFiles = getOriginalSourceFiles; function getOriginalNodeId(node) { - node = getOriginalNode(node); + node = ts.getOriginalNode(node); return node ? ts.getNodeId(node) : 0; } ts.getOriginalNodeId = getOriginalNodeId; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 180 && expression.arguments !== undefined; + var hasArguments = expression.kind === 181 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 180: + case 181: return hasArguments ? 0 : 1; - case 190: - case 187: + case 191: case 188: - case 186: case 189: - case 193: - case 195: + case 187: + case 190: + case 194: + case 196: return 1; - case 192: + case 193: switch (operator) { case 39: case 57: @@ -6592,15 +6723,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 180 && expression.arguments !== undefined; + var hasArguments = expression.kind === 181 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 192) { + if (expression.kind === 193) { return expression.operatorToken.kind; } - else if (expression.kind === 190 || expression.kind === 191) { + else if (expression.kind === 191 || expression.kind === 192) { return expression.operator; } else { @@ -6618,36 +6749,36 @@ var ts; case 85: case 8: case 9: - case 175: case 176: - case 184: + case 177: case 185: - case 197: - case 247: + case 186: + case 198: case 248: + case 249: case 11: case 12: - case 194: - case 183: - case 198: + case 195: + case 184: + case 199: return 19; - case 181: - case 177: + case 182: case 178: - return 18; - case 180: - return hasArguments ? 18 : 17; case 179: + return 18; + case 181: + return hasArguments ? 18 : 17; + case 180: return 17; - case 191: - return 16; - case 190: - case 187: - case 188: - case 186: - case 189: - return 15; case 192: + return 16; + case 191: + case 188: + case 189: + case 187: + case 190: + return 15; + case 193: switch (operatorKind) { case 50: case 51: @@ -6705,11 +6836,11 @@ var ts; default: return -1; } - case 193: + case 194: return 4; - case 195: - return 2; case 196: + return 2; + case 197: return 1; default: return -1; @@ -6732,21 +6863,15 @@ var ts; return modificationCount; } function reattachFileDiagnostics(newFile) { - if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { - var diagnostic = _a[_i]; - diagnostic.file = newFile; - } + ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } function add(diagnostic) { var diagnostics; if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); if (!diagnostics) { diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; + fileDiagnostics.set(diagnostic.file.fileName, diagnostics); } } else { @@ -6763,16 +6888,16 @@ var ts; function getDiagnostics(fileName) { sortAndDeduplicate(); if (fileName) { - return fileDiagnostics[fileName] || []; + return fileDiagnostics.get(fileName) || []; } var allDiagnostics = []; function pushDiagnostic(d) { allDiagnostics.push(d); } ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } + fileDiagnostics.forEach(function (diagnostics) { + ts.forEach(diagnostics, pushDiagnostic); + }); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function sortAndDeduplicate() { @@ -6781,14 +6906,14 @@ var ts; } diagnosticsModified = false; nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } + fileDiagnostics.forEach(function (diagnostics, key) { + fileDiagnostics.set(key, ts.sortAndDeduplicateDiagnostics(diagnostics)); + }); } } ts.createDiagnosticCollection = createDiagnosticCollection; var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = ts.createMap({ + var escapedCharsMap = ts.createMapFromTemplate({ "\0": "\\0", "\t": "\\t", "\v": "\\v", @@ -6807,7 +6932,7 @@ var ts; } ts.escapeString = escapeString; function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); @@ -6951,129 +7076,62 @@ var ts; ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); + var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); }; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); - var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = getAllEmittableSourceFiles(); - return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); + var moduleEmitEnabled_1 = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; + return ts.filter(host.getSourceFiles(), function (sourceFile) { + return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); + }); } else { - var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; - return filterSourceFilesInDirectory(sourceFiles, function (file) { return host.isSourceFileFromExternalLibrary(file); }); - } - function getAllEmittableSourceFiles() { - return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); + var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); }); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; - function filterSourceFilesInDirectory(sourceFiles, isSourceFileFromExternalLibrary) { - return ts.filter(sourceFiles, function (file) { return shouldEmitInDirectory(file, isSourceFileFromExternalLibrary); }); + function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) { + return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !isDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); } - ts.filterSourceFilesInDirectory = filterSourceFilesInDirectory; - function isNonDeclarationFile(sourceFile) { - return !isDeclarationFile(sourceFile); - } - function shouldEmitInDirectory(sourceFile, isSourceFileFromExternalLibrary) { - return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); - } - function isBundleEmitNonExternalModule(sourceFile) { - return isNonDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); - } - function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { + ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { - onBundledEmit(sourceFiles); - } - else { - for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { - var sourceFile = sourceFiles_2[_i]; - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } - } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); - } - function onBundledEmit(sourceFiles) { if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, true); + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); + } + } + else { + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, sourceFile, emitOnlyDtsFiles); } } } - ts.forEachTransformedEmitFile = forEachTransformedEmitFile; + ts.forEachEmittedFile = forEachEmittedFile; function getSourceMapFilePath(jsFilePath, options) { return options.sourceMap ? jsFilePath + ".map" : undefined; } - function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - onBundledEmit(host); - } - else { - var sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; - if (shouldEmitInDirectory(sourceFile, function (file) { return host.isSourceFileFromExternalLibrary(file); })) { - onSingleFileEmit(host, sourceFile); + function getOutputExtension(sourceFile, options) { + if (options.jsx === 1) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + return ".jsx"; } } - } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: declarationFilePath - }; - action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); - } - function onBundledEmit(host) { - var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (!ts.isExternalModule(sourceFile) || - !!ts.getEmitModuleKind(options)); }); - if (bundledSources.length) { - var jsFilePath = options.outFile || options.out; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined - }; - action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); + else if (sourceFile.languageVariant === 1) { + return ".jsx"; } } + return ".js"; } - ts.forEachExpectedEmitFile = forEachExpectedEmitFile; function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); var commonSourceDirectory = host.getCommonSourceDirectory(); @@ -7098,7 +7156,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 150 && nodeIsPresent(member.body)) { + if (member.kind === 151 && nodeIsPresent(member.body)) { return member; } }); @@ -7139,10 +7197,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 151) { + if (accessor.kind === 152) { getAccessor = accessor; } - else if (accessor.kind === 152) { + else if (accessor.kind === 153) { setAccessor = accessor; } else { @@ -7151,7 +7209,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 151 || member.kind === 152) + if ((member.kind === 152 || member.kind === 153) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -7162,10 +7220,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 151 && !getAccessor) { + if (member.kind === 152 && !getAccessor) { getAccessor = member; } - if (member.kind === 152 && !setAccessor) { + if (member.kind === 153 && !setAccessor) { setAccessor = member; } } @@ -7383,7 +7441,7 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 199 && + if (node.kind === 200 && node.parent.token === 84 && isClassLike(node.parent.parent)) { return node.parent.parent; @@ -7401,8 +7459,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 176 - || kind === 175; + return kind === 177 + || kind === 176; } return false; } @@ -7428,29 +7486,33 @@ var ts; ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { return node.kind === 70 || - node.kind === 177 && isEntityNameExpression(node.expression); + node.kind === 178 && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 141 && node.parent.right === node) || - (node.parent.kind === 177 && node.parent.name === node); + return (node.parent.kind === 142 && node.parent.right === node) || + (node.parent.kind === 178 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 176) { + if (kind === 177) { return expression.properties.length === 0; } - if (kind === 175) { + if (kind === 176) { return expression.elements.length === 0; } return false; } ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; + return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function isExportDefaultSymbol(symbol) { + return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512); + } + ts.isExportDefaultSymbol = isExportDefaultSymbol; function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); } @@ -7542,39 +7604,39 @@ var ts; || kind === 94) { return true; } - else if (kind === 177) { + else if (kind === 178) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 178) { + else if (kind === 179) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 190 - || kind === 191) { + else if (kind === 191 + || kind === 192) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 192) { + else if (kind === 193) { return node.operatorToken.kind !== 39 && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 193) { + else if (kind === 194) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 188 - || kind === 187 - || kind === 186) { + else if (kind === 189 + || kind === 188 + || kind === 187) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 175) { + else if (kind === 176) { return node.elements.length === 0; } - else if (kind === 176) { + else if (kind === 177) { return node.properties.length === 0; } - else if (kind === 179) { + else if (kind === 180) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -7589,16 +7651,19 @@ var ts; } return false; } - var syntaxKindCache = ts.createMap(); + var syntaxKindCache = []; function formatSyntaxKind(kind) { var syntaxKindEnum = ts.SyntaxKind; if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; + var cached = syntaxKindCache[kind]; + if (cached !== undefined) { + return cached; } - for (var name_7 in syntaxKindEnum) { - if (syntaxKindEnum[name_7] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_7 + ")"; + for (var name in syntaxKindEnum) { + if (syntaxKindEnum[name] === kind) { + var result = kind + " (" + name + ")"; + syntaxKindCache[kind] = result; + return result; } } } @@ -7607,6 +7672,14 @@ var ts; } } ts.formatSyntaxKind = formatSyntaxKind; + function getRangePos(range) { + return range ? range.pos : -1; + } + ts.getRangePos = getRangePos; + function getRangeEnd(range) { + return range ? range.end : -1; + } + ts.getRangeEnd = getRangeEnd; function movePos(pos, value) { return ts.positionIsSynthesized(pos) ? -1 : pos + value; } @@ -7681,11 +7754,11 @@ var ts; } ts.getStartPositionOfRange = getStartPositionOfRange; function isDeclarationNameOfEnumOrNamespace(node) { - var parseNode = getParseTreeNode(node); + var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 230: case 231: + case 232: return parseNode === parseNode.parent.name; } } @@ -7703,7 +7776,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 && declaration !== node) { + if (declaration.kind === 228 && declaration !== node) { return true; } } @@ -7755,7 +7828,7 @@ var ts; } ts.isIdentifier = isIdentifier; function isVoidExpression(node) { - return node.kind === 188; + return node.kind === 189; } ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { @@ -7767,16 +7840,16 @@ var ts; } ts.isModifier = isModifier; function isQualifiedName(node) { - return node.kind === 141; + return node.kind === 142; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 142; + return node.kind === 143; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 141 + return kind === 142 || kind === 70; } ts.isEntityName = isEntityName; @@ -7785,7 +7858,7 @@ var ts; return kind === 70 || kind === 9 || kind === 8 - || kind === 142; + || kind === 143; } ts.isPropertyName = isPropertyName; function isModuleName(node) { @@ -7797,101 +7870,101 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 70 - || kind === 172 - || kind === 173; + || kind === 173 + || kind === 174; } ts.isBindingName = isBindingName; function isTypeParameter(node) { - return node.kind === 143; + return node.kind === 144; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 144; + return node.kind === 145; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 145; + return node.kind === 146; } ts.isDecorator = isDecorator; function isMethodDeclaration(node) { - return node.kind === 149; + return node.kind === 150; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 150 - || kind === 147 - || kind === 149 - || kind === 151 + return kind === 151 + || kind === 148 + || kind === 150 || kind === 152 - || kind === 155 - || kind === 204; + || kind === 153 + || kind === 156 + || kind === 205; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 258 - || kind === 259 - || kind === 260 - || kind === 149 - || kind === 151 + return kind === 260 + || kind === 261 + || kind === 262 + || kind === 150 || kind === 152 - || kind === 245; + || kind === 153 + || kind === 246; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 156 && kind <= 171) + return (kind >= 157 && kind <= 172) || kind === 118 || kind === 132 || kind === 121 - || kind === 134 || kind === 135 + || kind === 136 || kind === 104 || kind === 129 - || kind === 199; + || kind === 200; } function isTypeNode(node) { return isTypeNodeKind(node.kind); } ts.isTypeNode = isTypeNode; function isArrayBindingPattern(node) { - return node.kind === 173; + return node.kind === 174; } ts.isArrayBindingPattern = isArrayBindingPattern; function isObjectBindingPattern(node) { - return node.kind === 172; + return node.kind === 173; } ts.isObjectBindingPattern = isObjectBindingPattern; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 173 - || kind === 172; + return kind === 174 + || kind === 173; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 175 - || kind === 176; + return kind === 176 + || kind === 177; } ts.isAssignmentPattern = isAssignmentPattern; function isBindingElement(node) { - return node.kind === 174; + return node.kind === 175; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 174 - || kind === 198; + return kind === 175 + || kind === 199; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 224: - case 144: - case 174: + case 225: + case 145: + case 175: return true; } return false; @@ -7904,8 +7977,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 172: - case 176: + case 173: + case 177: return true; } return false; @@ -7913,94 +7986,94 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 173: - case 175: + case 174: + case 176: return true; } return false; } ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isArrayLiteralExpression(node) { - return node.kind === 175; + return node.kind === 176; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 176; + return node.kind === 177; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 177; + return node.kind === 178; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 178; + return node.kind === 179; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 192; + return node.kind === 193; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 193; + return node.kind === 194; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 179; + return node.kind === 180; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 194 + return kind === 195 || kind === 12; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadExpression(node) { - return node.kind === 196; + return node.kind === 197; } ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 199; + return node.kind === 200; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 177 - || kind === 178 - || kind === 180 + return kind === 178 || kind === 179 - || kind === 247 - || kind === 248 || kind === 181 - || kind === 175 - || kind === 183 + || kind === 180 + || kind === 248 + || kind === 249 + || kind === 182 || kind === 176 - || kind === 197 || kind === 184 + || kind === 177 + || kind === 198 + || kind === 185 || kind === 70 || kind === 11 || kind === 8 || kind === 9 || kind === 12 - || kind === 194 + || kind === 195 || kind === 85 || kind === 94 || kind === 98 || kind === 100 || kind === 96 - || kind === 201 - || kind === 202; + || kind === 202 + || kind === 203; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 190 - || kind === 191 - || kind === 186 + return kind === 191 + || kind === 192 || kind === 187 || kind === 188 || kind === 189 - || kind === 182 + || kind === 190 + || kind === 183 || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -8008,13 +8081,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 193 - || kind === 195 - || kind === 185 - || kind === 192 + return kind === 194 || kind === 196 - || kind === 200 - || kind === 198 + || kind === 186 + || kind === 193 + || kind === 197 + || kind === 201 + || kind === 199 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -8023,16 +8096,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 182 - || kind === 200; + return kind === 183 + || kind === 201; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 295; + return node.kind === 298; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 294; + return node.kind === 297; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -8041,15 +8114,15 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 198; + return node.kind === 199; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 203; + return node.kind === 204; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 205; + return node.kind === 206; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -8067,121 +8140,135 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 224; + return node.kind === 225; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 225; + return node.kind === 226; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 233; + return node.kind === 234; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 232 - || kind === 231; + return kind === 233 + || kind === 232 + || kind === 70; } ts.isModuleBody = isModuleBody; + function isNamespaceBody(node) { + var kind = node.kind; + return kind === 233 + || kind === 232; + } + ts.isNamespaceBody = isNamespaceBody; + function isJSDocNamespaceBody(node) { + var kind = node.kind; + return kind === 70 + || kind === 232; + } + ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isImportEqualsDeclaration(node) { - return node.kind === 235; + return node.kind === 236; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 237; + return node.kind === 238; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 239 - || kind === 238; + return kind === 240 + || kind === 239; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 240; + return node.kind === 241; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 243; + return node.kind === 244; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 244; + return node.kind === 245; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 231 || node.kind === 230; + return node.kind === 232 || node.kind === 231; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 185 - || kind === 174 - || kind === 227 - || kind === 197 - || kind === 150 - || kind === 230 - || kind === 261 - || kind === 244 - || kind === 226 - || kind === 184 - || kind === 151 - || kind === 237 - || kind === 235 - || kind === 240 + return kind === 186 + || kind === 175 || kind === 228 - || kind === 149 - || kind === 148 + || kind === 198 + || kind === 151 || kind === 231 - || kind === 234 - || kind === 238 - || kind === 144 - || kind === 258 - || kind === 147 - || kind === 146 - || kind === 152 - || kind === 259 - || kind === 229 - || kind === 143 - || kind === 224 - || kind === 286; - } - function isDeclarationStatementKind(kind) { - return kind === 226 + || kind === 263 || kind === 245 || kind === 227 + || kind === 185 + || kind === 152 + || kind === 238 + || kind === 236 + || kind === 241 + || kind === 229 + || kind === 252 + || kind === 150 + || kind === 149 + || kind === 232 + || kind === 235 + || kind === 239 + || kind === 145 + || kind === 260 + || kind === 148 + || kind === 147 + || kind === 153 + || kind === 261 + || kind === 230 + || kind === 144 + || kind === 225 + || kind === 289; + } + function isDeclarationStatementKind(kind) { + return kind === 227 + || kind === 246 || kind === 228 || kind === 229 || kind === 230 || kind === 231 + || kind === 232 + || kind === 237 || kind === 236 - || kind === 235 + || kind === 243 || kind === 242 - || kind === 241 - || kind === 234; + || kind === 235; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 216 - || kind === 215 - || kind === 223 - || kind === 210 - || kind === 208 - || kind === 207 - || kind === 213 - || kind === 214 - || kind === 212 - || kind === 209 - || kind === 220 - || kind === 217 - || kind === 219 - || kind === 221 - || kind === 222 - || kind === 206 + return kind === 217 + || kind === 216 + || kind === 224 || kind === 211 + || kind === 209 + || kind === 208 + || kind === 214 + || kind === 215 + || kind === 213 + || kind === 210 + || kind === 221 || kind === 218 - || kind === 294 + || kind === 220 + || kind === 222 + || kind === 223 + || kind === 207 + || kind === 212 + || kind === 219 || kind === 297 - || kind === 296; + || kind === 300 + || kind === 299; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -8199,87 +8286,96 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 205; + || kind === 206; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 246 - || kind === 141 + return kind === 247 + || kind === 142 || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 249; + return node.kind === 250; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 250; + return node.kind === 251; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; return kind === 98 || kind === 70 - || kind === 177; + || kind === 178; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 247 - || kind === 253 - || kind === 248 + return kind === 248 + || kind === 255 + || kind === 249 || kind === 10; } ts.isJsxChild = isJsxChild; + function isJsxAttributes(node) { + var kind = node.kind; + return kind === 253; + } + ts.isJsxAttributes = isJsxAttributes; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 251 - || kind === 252; + return kind === 252 + || kind === 254; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 252; + return node.kind === 254; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 251; + return node.kind === 252; } ts.isJsxAttribute = isJsxAttribute; + function isJsxOpeningLikeElement(node) { + return node.kind === 250 || node.kind === 249; + } + ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 253; + || kind === 255; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 254 - || kind === 255; + return kind === 256 + || kind === 257; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 256; + return node.kind === 258; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 257; + return node.kind === 259; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 258; + return node.kind === 260; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 259; + return node.kind === 261; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 261; + return node.kind === 263; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 262; + return node.kind === 264; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -8418,9 +8514,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 143) { + if (d && d.kind === 144) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 228) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 229) { return current; } } @@ -8428,11 +8524,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 150 && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92) && node.parent.kind === 151 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 174 || ts.isBindingPattern(node))) { + while (node && (node.kind === 175 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -8440,14 +8536,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 224) { + if (node.kind === 225) { node = node.parent; } - if (node && node.kind === 225) { + if (node && node.kind === 226) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 206) { + if (node && node.kind === 207) { flags |= ts.getModifierFlags(node); } return flags; @@ -8456,14 +8552,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 224) { + if (node.kind === 225) { node = node.parent; } - if (node && node.kind === 225) { + if (node && node.kind === 226) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 206) { + if (node && node.kind === 207) { flags |= node.flags; } return flags; @@ -8516,24 +8612,46 @@ var ts; } } ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage; + function getOriginalNode(node, nodeTest) { + if (node) { + while (node.original !== undefined) { + node = node.original; + } + } + return !nodeTest || nodeTest(node) ? node : undefined; + } + ts.getOriginalNode = getOriginalNode; + function isParseTreeNode(node) { + return (node.flags & 8) === 0; + } + ts.isParseTreeNode = isParseTreeNode; + function getParseTreeNode(node, nodeTest) { + if (isParseTreeNode(node)) { + return node; + } + node = getOriginalNode(node); + if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { + return node; + } + return undefined; + } + ts.getParseTreeNode = getParseTreeNode; + function unescapeIdentifier(identifier) { + return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; + } + ts.unescapeIdentifier = unescapeIdentifier; })(ts || (ts = {})); var ts; (function (ts) { - var NodeConstructor; - var SourceFileConstructor; - function createNode(kind, location, flags) { - var ConstructorForKind = kind === 262 - ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) - : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); - var node = location - ? new ConstructorForKind(kind, location.pos, location.end) - : new ConstructorForKind(kind, -1, -1); - node.flags = flags | 8; + function createSynthesizedNode(kind) { + var node = ts.createNode(kind, -1, -1); + node.flags |= 8; return node; } function updateNode(updated, original) { if (updated !== original) { setOriginalNode(updated, original); + setTextRange(updated, original); if (original.startsOnNewLine) { updated.startsOnNewLine = true; } @@ -8542,7 +8660,7 @@ var ts; return updated; } ts.updateNode = updateNode; - function createNodeArray(elements, location, hasTrailingComma) { + function createNodeArray(elements, hasTrailingComma) { if (elements) { if (ts.isNodeArray(elements)) { return elements; @@ -8552,32 +8670,15 @@ var ts; elements = []; } var array = elements; - if (location) { - array.pos = location.pos; - array.end = location.end; - } - else { - array.pos = -1; - array.end = -1; - } - if (hasTrailingComma) { - array.hasTrailingComma = true; - } + array.pos = -1; + array.end = -1; + array.hasTrailingComma = hasTrailingComma; return array; } ts.createNodeArray = createNodeArray; - function createSynthesizedNode(kind, startsOnNewLine) { - var node = createNode(kind, undefined); - node.startsOnNewLine = startsOnNewLine; - return node; - } - ts.createSynthesizedNode = createSynthesizedNode; - function createSynthesizedNodeArray(elements) { - return createNodeArray(elements, undefined); - } - ts.createSynthesizedNodeArray = createSynthesizedNodeArray; function getSynthesizedClone(node) { - var clone = createNode(node.kind, undefined, node.flags); + var clone = createSynthesizedNode(node.kind); + clone.flags |= node.flags; setOriginalNode(clone, node); for (var key in node) { if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { @@ -8588,50 +8689,47 @@ var ts; return clone; } ts.getSynthesizedClone = getSynthesizedClone; - function getMutableClone(node) { - var clone = getSynthesizedClone(node); - clone.pos = node.pos; - clone.end = node.end; - clone.parent = node.parent; - return clone; - } - ts.getMutableClone = getMutableClone; - function createLiteral(value, location) { + function createLiteral(value) { if (typeof value === "number") { - var node = createNode(8, location, undefined); - node.text = value.toString(); - return node; + return createNumericLiteral(value + ""); } - else if (typeof value === "boolean") { - return createNode(value ? 100 : 85, location, undefined); + if (typeof value === "boolean") { + return value ? createTrue() : createFalse(); } - else if (typeof value === "string") { - var node = createNode(9, location, undefined); - node.text = value; - return node; - } - else if (value) { - var node = createNode(9, location, undefined); - node.textSourceNode = value; - node.text = value.text; - return node; + if (typeof value === "string") { + return createStringLiteral(value); } + return createLiteralFromNode(value); } ts.createLiteral = createLiteral; - var nextAutoGenerateId = 0; - function createIdentifier(text, location) { - var node = createNode(70, location); + function createNumericLiteral(value) { + var node = createSynthesizedNode(8); + node.text = value; + return node; + } + ts.createNumericLiteral = createNumericLiteral; + function createStringLiteral(text) { + var node = createSynthesizedNode(9); + node.text = text; + return node; + } + function createLiteralFromNode(sourceNode) { + var node = createStringLiteral(sourceNode.text); + node.textSourceNode = sourceNode; + return node; + } + function createIdentifier(text) { + var node = createSynthesizedNode(70); node.text = ts.escapeIdentifier(text); - node.originalKeywordKind = ts.stringToToken(text); + node.originalKeywordKind = text ? ts.stringToToken(text) : 0; node.autoGenerateKind = 0; node.autoGenerateId = 0; return node; } ts.createIdentifier = createIdentifier; - function createTempVariable(recordTempVariable, location) { - var name = createNode(70, location); - name.text = ""; - name.originalKeywordKind = 0; + var nextAutoGenerateId = 0; + function createTempVariable(recordTempVariable) { + var name = createIdentifier(""); name.autoGenerateKind = 1; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; @@ -8641,93 +8739,121 @@ var ts; return name; } ts.createTempVariable = createTempVariable; - function createLoopVariable(location) { - var name = createNode(70, location); - name.text = ""; - name.originalKeywordKind = 0; + function createLoopVariable() { + var name = createIdentifier(""); name.autoGenerateKind = 2; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createLoopVariable = createLoopVariable; - function createUniqueName(text, location) { - var name = createNode(70, location); - name.text = text; - name.originalKeywordKind = 0; + function createUniqueName(text) { + var name = createIdentifier(text); name.autoGenerateKind = 3; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createUniqueName = createUniqueName; - function getGeneratedNameForNode(node, location) { - var name = createNode(70, location); - name.original = node; - name.text = ""; - name.originalKeywordKind = 0; + function getGeneratedNameForNode(node) { + var name = createIdentifier(""); name.autoGenerateKind = 4; name.autoGenerateId = nextAutoGenerateId; + name.original = node; nextAutoGenerateId++; return name; } ts.getGeneratedNameForNode = getGeneratedNameForNode; function createToken(token) { - return createNode(token); + return createSynthesizedNode(token); } ts.createToken = createToken; function createSuper() { - var node = createNode(96); - return node; + return createSynthesizedNode(96); } ts.createSuper = createSuper; - function createThis(location) { - var node = createNode(98, location); - return node; + function createThis() { + return createSynthesizedNode(98); } ts.createThis = createThis; function createNull() { - var node = createNode(94); - return node; + return createSynthesizedNode(94); } ts.createNull = createNull; - function createComputedPropertyName(expression, location) { - var node = createNode(142, location); + function createTrue() { + return createSynthesizedNode(100); + } + ts.createTrue = createTrue; + function createFalse() { + return createSynthesizedNode(85); + } + ts.createFalse = createFalse; + function createQualifiedName(left, right) { + var node = createSynthesizedNode(142); + node.left = left; + node.right = asName(right); + return node; + } + ts.createQualifiedName = createQualifiedName; + function updateQualifiedName(node, left, right) { + return node.left !== left + || node.right !== right + ? updateNode(createQualifiedName(left, right), node) + : node; + } + ts.updateQualifiedName = updateQualifiedName; + function createComputedPropertyName(expression) { + var node = createSynthesizedNode(143); node.expression = expression; return node; } ts.createComputedPropertyName = createComputedPropertyName; function updateComputedPropertyName(node, expression) { - if (node.expression !== expression) { - return updateNode(createComputedPropertyName(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createComputedPropertyName(expression), node) + : node; } ts.updateComputedPropertyName = updateComputedPropertyName; - function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(144, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { + var node = createSynthesizedNode(145); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.questionToken = questionToken; node.type = type; - node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createParameter = createParameter; function updateParameter(node, decorators, modifiers, dotDotDotToken, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + : node; } ts.updateParameter = updateParameter; - function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(147, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createDecorator(expression) { + var node = createSynthesizedNode(146); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createDecorator = createDecorator; + function updateDecorator(node, expression) { + return node.expression !== expression + ? updateNode(createDecorator(expression), node) + : node; + } + ts.updateDecorator = updateDecorator; + function createProperty(decorators, modifiers, name, questionToken, type, initializer) { + var node = createSynthesizedNode(148); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.questionToken = questionToken; node.type = type; node.initializer = initializer; @@ -8735,19 +8861,22 @@ var ts; } ts.createProperty = createProperty; function updateProperty(node, decorators, modifiers, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer), node) + : node; } ts.updateProperty = updateProperty; - function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(149, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(150); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -8755,16 +8884,21 @@ var ts; } ts.createMethod = createMethod; function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateMethod = updateMethod; - function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(150, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createConstructor(decorators, modifiers, parameters, body) { + var node = createSynthesizedNode(151); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = undefined; @@ -8773,17 +8907,19 @@ var ts; } ts.createConstructor = createConstructor; function updateConstructor(node, decorators, modifiers, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.parameters !== parameters || node.body !== body) { - return updateNode(createConstructor(decorators, modifiers, parameters, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.parameters !== parameters + || node.body !== body + ? updateNode(createConstructor(decorators, modifiers, parameters, body), node) + : node; } ts.updateConstructor = updateConstructor; - function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(151, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createGetAccessor(decorators, modifiers, name, parameters, type, body) { + var node = createSynthesizedNode(152); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = type; @@ -8792,17 +8928,21 @@ var ts; } ts.createGetAccessor = createGetAccessor; function updateGetAccessor(node, decorators, modifiers, name, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body), node) + : node; } ts.updateGetAccessor = updateGetAccessor; - function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(152, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createSetAccessor(decorators, modifiers, name, parameters, body) { + var node = createSynthesizedNode(153); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.body = body; @@ -8810,57 +8950,60 @@ var ts; } ts.createSetAccessor = createSetAccessor; function updateSetAccessor(node, decorators, modifiers, name, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.body !== body) { - return updateNode(createSetAccessor(decorators, modifiers, name, parameters, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.body !== body + ? updateNode(createSetAccessor(decorators, modifiers, name, parameters, body), node) + : node; } ts.updateSetAccessor = updateSetAccessor; - function createObjectBindingPattern(elements, location) { - var node = createNode(172, location); + function createObjectBindingPattern(elements) { + var node = createSynthesizedNode(173); node.elements = createNodeArray(elements); return node; } ts.createObjectBindingPattern = createObjectBindingPattern; function updateObjectBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createObjectBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createObjectBindingPattern(elements), node) + : node; } ts.updateObjectBindingPattern = updateObjectBindingPattern; - function createArrayBindingPattern(elements, location) { - var node = createNode(173, location); + function createArrayBindingPattern(elements) { + var node = createSynthesizedNode(174); node.elements = createNodeArray(elements); return node; } ts.createArrayBindingPattern = createArrayBindingPattern; function updateArrayBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayBindingPattern(elements), node) + : node; } ts.updateArrayBindingPattern = updateArrayBindingPattern; - function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(174, location); - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createBindingElement(propertyName, dotDotDotToken, name, initializer) { + var node = createSynthesizedNode(175); + node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.initializer = initializer; return node; } ts.createBindingElement = createBindingElement; function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) { - if (node.propertyName !== propertyName || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer) { - return updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer, node), node); - } - return node; + return node.propertyName !== propertyName + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.initializer !== initializer + ? updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer), node) + : node; } ts.updateBindingElement = updateBindingElement; - function createArrayLiteral(elements, location, multiLine) { - var node = createNode(175, location); - node.elements = parenthesizeListElements(createNodeArray(elements)); + function createArrayLiteral(elements, multiLine) { + var node = createSynthesizedNode(176); + node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; } @@ -8868,14 +9011,13 @@ var ts; } ts.createArrayLiteral = createArrayLiteral; function updateArrayLiteral(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayLiteral(elements, node, node.multiLine), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayLiteral(elements, node.multiLine), node) + : node; } ts.updateArrayLiteral = updateArrayLiteral; - function createObjectLiteral(properties, location, multiLine) { - var node = createNode(176, location); + function createObjectLiteral(properties, multiLine) { + var node = createSynthesizedNode(177); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -8884,108 +9026,118 @@ var ts; } ts.createObjectLiteral = createObjectLiteral; function updateObjectLiteral(node, properties) { - if (node.properties !== properties) { - return updateNode(createObjectLiteral(properties, node, node.multiLine), node); - } - return node; + return node.properties !== properties + ? updateNode(createObjectLiteral(properties, node.multiLine), node) + : node; } ts.updateObjectLiteral = updateObjectLiteral; - function createPropertyAccess(expression, name, location, flags) { - var node = createNode(177, location, flags); - node.expression = parenthesizeForAccess(expression); - (node.emitNode || (node.emitNode = {})).flags |= 65536; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAccess(expression, name) { + var node = createSynthesizedNode(178); + node.expression = ts.parenthesizeForAccess(expression); + node.name = asName(name); + setEmitFlags(node, 65536); return node; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { - if (node.expression !== expression || node.name !== name) { - var propertyAccess = createPropertyAccess(expression, name, node, node.flags); - (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); - return updateNode(propertyAccess, node); - } - return node; + return node.expression !== expression + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccess(expression, name), getEmitFlags(node)), node) + : node; } ts.updatePropertyAccess = updatePropertyAccess; - function createElementAccess(expression, index, location) { - var node = createNode(178, location); - node.expression = parenthesizeForAccess(expression); - node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; + function createElementAccess(expression, index) { + var node = createSynthesizedNode(179); + node.expression = ts.parenthesizeForAccess(expression); + node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { - if (node.expression !== expression || node.argumentExpression !== argumentExpression) { - return updateNode(createElementAccess(expression, argumentExpression, node), node); - } - return node; + return node.expression !== expression + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccess(expression, argumentExpression), node) + : node; } ts.updateElementAccess = updateElementAccess; - function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(179, location, flags); - node.expression = parenthesizeForAccess(expression); - if (typeArguments) { - node.typeArguments = createNodeArray(typeArguments); - } - node.arguments = parenthesizeListElements(createNodeArray(argumentsArray)); + function createCall(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(180); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); return node; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { - if (expression !== node.expression || typeArguments !== node.typeArguments || argumentsArray !== node.arguments) { - return updateNode(createCall(expression, typeArguments, argumentsArray, node, node.flags), node); - } - return node; + return expression !== node.expression + || typeArguments !== node.typeArguments + || argumentsArray !== node.arguments + ? updateNode(createCall(expression, typeArguments, argumentsArray), node) + : node; } ts.updateCall = updateCall; - function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(180, location, flags); - node.expression = parenthesizeForNew(expression); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; + function createNew(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(181); + node.expression = ts.parenthesizeForNew(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; return node; } ts.createNew = createNew; function updateNew(node, expression, typeArguments, argumentsArray) { - if (node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray) { - return updateNode(createNew(expression, typeArguments, argumentsArray, node, node.flags), node); - } - return node; + return node.expression !== expression + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createNew(expression, typeArguments, argumentsArray), node) + : node; } ts.updateNew = updateNew; - function createTaggedTemplate(tag, template, location) { - var node = createNode(181, location); - node.tag = parenthesizeForAccess(tag); + function createTaggedTemplate(tag, template) { + var node = createSynthesizedNode(182); + node.tag = ts.parenthesizeForAccess(tag); node.template = template; return node; } ts.createTaggedTemplate = createTaggedTemplate; function updateTaggedTemplate(node, tag, template) { - if (node.tag !== tag || node.template !== template) { - return updateNode(createTaggedTemplate(tag, template, node), node); - } - return node; + return node.tag !== tag + || node.template !== template + ? updateNode(createTaggedTemplate(tag, template), node) + : node; } ts.updateTaggedTemplate = updateTaggedTemplate; - function createParen(expression, location) { - var node = createNode(183, location); + function createTypeAssertion(type, expression) { + var node = createSynthesizedNode(183); + node.type = type; + node.expression = ts.parenthesizePrefixOperand(expression); + return node; + } + ts.createTypeAssertion = createTypeAssertion; + function updateTypeAssertion(node, type, expression) { + return node.type !== type + || node.expression !== expression + ? updateNode(createTypeAssertion(type, expression), node) + : node; + } + ts.updateTypeAssertion = updateTypeAssertion; + function createParen(expression) { + var node = createSynthesizedNode(184); node.expression = expression; return node; } ts.createParen = createParen; function updateParen(node, expression) { - if (node.expression !== expression) { - return updateNode(createParen(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createParen(expression), node) + : node; } ts.updateParen = updateParen; - function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(184, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(185); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -8993,322 +9145,340 @@ var ts; } ts.createFunctionExpression = createFunctionExpression; function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.name !== name + || node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionExpression = updateFunctionExpression; - function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(185, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { + var node = createSynthesizedNode(186); + node.modifiers = asNodeArray(modifiers); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35); - node.body = parenthesizeConciseBody(body); + node.body = ts.parenthesizeConciseBody(body); return node; } ts.createArrowFunction = createArrowFunction; function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { - if (node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body, node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + : node; } ts.updateArrowFunction = updateArrowFunction; - function createDelete(expression, location) { - var node = createNode(186, location); - node.expression = parenthesizePrefixOperand(expression); + function createDelete(expression) { + var node = createSynthesizedNode(187); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createDelete = createDelete; function updateDelete(node, expression) { - if (node.expression !== expression) { - return updateNode(createDelete(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createDelete(expression), node) + : node; } ts.updateDelete = updateDelete; - function createTypeOf(expression, location) { - var node = createNode(187, location); - node.expression = parenthesizePrefixOperand(expression); + function createTypeOf(expression) { + var node = createSynthesizedNode(188); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createTypeOf = createTypeOf; function updateTypeOf(node, expression) { - if (node.expression !== expression) { - return updateNode(createTypeOf(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createTypeOf(expression), node) + : node; } ts.updateTypeOf = updateTypeOf; - function createVoid(expression, location) { - var node = createNode(188, location); - node.expression = parenthesizePrefixOperand(expression); + function createVoid(expression) { + var node = createSynthesizedNode(189); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createVoid = createVoid; function updateVoid(node, expression) { - if (node.expression !== expression) { - return updateNode(createVoid(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createVoid(expression), node) + : node; } ts.updateVoid = updateVoid; - function createAwait(expression, location) { - var node = createNode(189, location); - node.expression = parenthesizePrefixOperand(expression); + function createAwait(expression) { + var node = createSynthesizedNode(190); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createAwait = createAwait; function updateAwait(node, expression) { - if (node.expression !== expression) { - return updateNode(createAwait(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createAwait(expression), node) + : node; } ts.updateAwait = updateAwait; - function createPrefix(operator, operand, location) { - var node = createNode(190, location); + function createPrefix(operator, operand) { + var node = createSynthesizedNode(191); node.operator = operator; - node.operand = parenthesizePrefixOperand(operand); + node.operand = ts.parenthesizePrefixOperand(operand); return node; } ts.createPrefix = createPrefix; function updatePrefix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPrefix(node.operator, operand, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPrefix(node.operator, operand), node) + : node; } ts.updatePrefix = updatePrefix; - function createPostfix(operand, operator, location) { - var node = createNode(191, location); - node.operand = parenthesizePostfixOperand(operand); + function createPostfix(operand, operator) { + var node = createSynthesizedNode(192); + node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; } ts.createPostfix = createPostfix; function updatePostfix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPostfix(operand, node.operator, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPostfix(operand, node.operator), node) + : node; } ts.updatePostfix = updatePostfix; - function createBinary(left, operator, right, location) { - var operatorToken = typeof operator === "number" ? createToken(operator) : operator; + function createBinary(left, operator, right) { + var node = createSynthesizedNode(193); + var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; - var node = createNode(192, location); - node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); + node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; - node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); + node.right = ts.parenthesizeBinaryOperand(operatorKind, right, false, node.left); return node; } ts.createBinary = createBinary; function updateBinary(node, left, right) { - if (node.left !== left || node.right !== right) { - return updateNode(createBinary(left, node.operatorToken, right, node), node); - } - return node; + return node.left !== left + || node.right !== right + ? updateNode(createBinary(left, node.operatorToken, right), node) + : node; } ts.updateBinary = updateBinary; - function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonTokenOrLocation, whenFalse, location) { - var node = createNode(193, whenFalse ? location : colonTokenOrLocation); - node.condition = parenthesizeForConditionalHead(condition); - if (whenFalse) { - node.questionToken = questionTokenOrWhenTrue; - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - node.colonToken = colonTokenOrLocation; - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenFalse); - } - else { - node.questionToken = createToken(54); - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(questionTokenOrWhenTrue); - node.colonToken = createToken(55); - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - } + function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { + var node = createSynthesizedNode(194); + node.condition = ts.parenthesizeForConditionalHead(condition); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(54); + node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); + node.colonToken = whenFalse ? colonToken : createToken(55); + node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } ts.createConditional = createConditional; function updateConditional(node, condition, whenTrue, whenFalse) { - if (node.condition !== condition || node.whenTrue !== whenTrue || node.whenFalse !== whenFalse) { - return updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse, node), node); - } - return node; + return node.condition !== condition + || node.whenTrue !== whenTrue + || node.whenFalse !== whenFalse + ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + : node; } ts.updateConditional = updateConditional; - function createTemplateExpression(head, templateSpans, location) { - var node = createNode(194, location); + function createTemplateExpression(head, templateSpans) { + var node = createSynthesizedNode(195); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; } ts.createTemplateExpression = createTemplateExpression; function updateTemplateExpression(node, head, templateSpans) { - if (node.head !== head || node.templateSpans !== templateSpans) { - return updateNode(createTemplateExpression(head, templateSpans, node), node); - } - return node; + return node.head !== head + || node.templateSpans !== templateSpans + ? updateNode(createTemplateExpression(head, templateSpans), node) + : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createYield(asteriskToken, expression, location) { - var node = createNode(195, location); - node.asteriskToken = asteriskToken; - node.expression = expression; + function createYield(asteriskTokenOrExpression, expression) { + var node = createSynthesizedNode(196); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 38 ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 38 ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; function updateYield(node, expression) { - if (node.expression !== expression) { - return updateNode(createYield(node.asteriskToken, expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createYield(node.asteriskToken, expression), node) + : node; } ts.updateYield = updateYield; - function createSpread(expression, location) { - var node = createNode(196, location); - node.expression = parenthesizeExpressionForList(expression); + function createSpread(expression) { + var node = createSynthesizedNode(197); + node.expression = ts.parenthesizeExpressionForList(expression); return node; } ts.createSpread = createSpread; function updateSpread(node, expression) { - if (node.expression !== expression) { - return updateNode(createSpread(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createSpread(expression), node) + : node; } ts.updateSpread = updateSpread; - function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(197, location); + function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(198); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassExpression = createClassExpression; function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) { - if (node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassExpression = updateClassExpression; - function createOmittedExpression(location) { - var node = createNode(198, location); - return node; + function createOmittedExpression() { + return createSynthesizedNode(199); } ts.createOmittedExpression = createOmittedExpression; - function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(199, location); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.expression = parenthesizeForAccess(expression); + function createExpressionWithTypeArguments(typeArguments, expression) { + var node = createSynthesizedNode(200); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); return node; } ts.createExpressionWithTypeArguments = createExpressionWithTypeArguments; function updateExpressionWithTypeArguments(node, typeArguments, expression) { - if (node.typeArguments !== typeArguments || node.expression !== expression) { - return updateNode(createExpressionWithTypeArguments(typeArguments, expression, node), node); - } - return node; + return node.typeArguments !== typeArguments + || node.expression !== expression + ? updateNode(createExpressionWithTypeArguments(typeArguments, expression), node) + : node; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; - function createTemplateSpan(expression, literal, location) { - var node = createNode(203, location); + function createAsExpression(expression, type) { + var node = createSynthesizedNode(201); + node.expression = expression; + node.type = type; + return node; + } + ts.createAsExpression = createAsExpression; + function updateAsExpression(node, expression, type) { + return node.expression !== expression + || node.type !== type + ? updateNode(createAsExpression(expression, type), node) + : node; + } + ts.updateAsExpression = updateAsExpression; + function createNonNullExpression(expression) { + var node = createSynthesizedNode(202); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createNonNullExpression = createNonNullExpression; + function updateNonNullExpression(node, expression) { + return node.expression !== expression + ? updateNode(createNonNullExpression(expression), node) + : node; + } + ts.updateNonNullExpression = updateNonNullExpression; + function createTemplateSpan(expression, literal) { + var node = createSynthesizedNode(204); node.expression = expression; node.literal = literal; return node; } ts.createTemplateSpan = createTemplateSpan; function updateTemplateSpan(node, expression, literal) { - if (node.expression !== expression || node.literal !== literal) { - return updateNode(createTemplateSpan(expression, literal, node), node); - } - return node; + return node.expression !== expression + || node.literal !== literal + ? updateNode(createTemplateSpan(expression, literal), node) + : node; } ts.updateTemplateSpan = updateTemplateSpan; - function createBlock(statements, location, multiLine, flags) { - var block = createNode(205, location, flags); + function createBlock(statements, multiLine) { + var block = createSynthesizedNode(206); block.statements = createNodeArray(statements); - if (multiLine) { - block.multiLine = true; - } + if (multiLine) + block.multiLine = multiLine; return block; } ts.createBlock = createBlock; function updateBlock(node, statements) { - if (statements !== node.statements) { - return updateNode(createBlock(statements, node, node.multiLine, node.flags), node); - } - return node; + return statements !== node.statements + ? updateNode(createBlock(statements, node.multiLine), node) + : node; } ts.updateBlock = updateBlock; - function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(206, location, flags); + function createVariableStatement(modifiers, declarationList) { + var node = createSynthesizedNode(207); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; return node; } ts.createVariableStatement = createVariableStatement; function updateVariableStatement(node, modifiers, declarationList) { - if (node.modifiers !== modifiers || node.declarationList !== declarationList) { - return updateNode(createVariableStatement(modifiers, declarationList, node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.declarationList !== declarationList + ? updateNode(createVariableStatement(modifiers, declarationList), node) + : node; } ts.updateVariableStatement = updateVariableStatement; - function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(225, location, flags); + function createVariableDeclarationList(declarations, flags) { + var node = createSynthesizedNode(226); + node.flags |= flags; node.declarations = createNodeArray(declarations); return node; } ts.createVariableDeclarationList = createVariableDeclarationList; function updateVariableDeclarationList(node, declarations) { - if (node.declarations !== declarations) { - return updateNode(createVariableDeclarationList(declarations, node, node.flags), node); - } - return node; + return node.declarations !== declarations + ? updateNode(createVariableDeclarationList(declarations, node.flags), node) + : node; } ts.updateVariableDeclarationList = updateVariableDeclarationList; - function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(224, location, flags); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createVariableDeclaration(name, type, initializer) { + var node = createSynthesizedNode(225); + node.name = asName(name); node.type = type; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createVariableDeclaration = createVariableDeclaration; function updateVariableDeclaration(node, name, type, initializer) { - if (node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createVariableDeclaration(name, type, initializer, node, node.flags), node); - } - return node; + return node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createVariableDeclaration(name, type, initializer), node) + : node; } ts.updateVariableDeclaration = updateVariableDeclaration; - function createEmptyStatement(location) { - return createNode(207, location); + function createEmptyStatement() { + return createSynthesizedNode(208); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression, location, flags) { - var node = createNode(208, location, flags); - node.expression = parenthesizeExpressionForExpressionStatement(expression); + function createStatement(expression) { + var node = createSynthesizedNode(209); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } ts.createStatement = createStatement; function updateStatement(node, expression) { - if (node.expression !== expression) { - return updateNode(createStatement(expression, node, node.flags), node); - } - return node; + return node.expression !== expression + ? updateNode(createStatement(expression), node) + : node; } ts.updateStatement = updateStatement; - function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(209, location); + function createIf(expression, thenStatement, elseStatement) { + var node = createSynthesizedNode(210); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -9316,42 +9486,43 @@ var ts; } ts.createIf = createIf; function updateIf(node, expression, thenStatement, elseStatement) { - if (node.expression !== expression || node.thenStatement !== thenStatement || node.elseStatement !== elseStatement) { - return updateNode(createIf(expression, thenStatement, elseStatement, node), node); - } - return node; + return node.expression !== expression + || node.thenStatement !== thenStatement + || node.elseStatement !== elseStatement + ? updateNode(createIf(expression, thenStatement, elseStatement), node) + : node; } ts.updateIf = updateIf; - function createDo(statement, expression, location) { - var node = createNode(210, location); + function createDo(statement, expression) { + var node = createSynthesizedNode(211); node.statement = statement; node.expression = expression; return node; } ts.createDo = createDo; function updateDo(node, statement, expression) { - if (node.statement !== statement || node.expression !== expression) { - return updateNode(createDo(statement, expression, node), node); - } - return node; + return node.statement !== statement + || node.expression !== expression + ? updateNode(createDo(statement, expression), node) + : node; } ts.updateDo = updateDo; - function createWhile(expression, statement, location) { - var node = createNode(211, location); + function createWhile(expression, statement) { + var node = createSynthesizedNode(212); node.expression = expression; node.statement = statement; return node; } ts.createWhile = createWhile; function updateWhile(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWhile(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWhile(expression, statement), node) + : node; } ts.updateWhile = updateWhile; - function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(212, location, undefined); + function createFor(initializer, condition, incrementor, statement) { + var node = createSynthesizedNode(213); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -9360,14 +9531,16 @@ var ts; } ts.createFor = createFor; function updateFor(node, initializer, condition, incrementor, statement) { - if (node.initializer !== initializer || node.condition !== condition || node.incrementor !== incrementor || node.statement !== statement) { - return updateNode(createFor(initializer, condition, incrementor, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.condition !== condition + || node.incrementor !== incrementor + || node.statement !== statement + ? updateNode(createFor(initializer, condition, incrementor, statement), node) + : node; } ts.updateFor = updateFor; - function createForIn(initializer, expression, statement, location) { - var node = createNode(213, location); + function createForIn(initializer, expression, statement) { + var node = createSynthesizedNode(214); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -9375,14 +9548,15 @@ var ts; } ts.createForIn = createForIn; function updateForIn(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForIn(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForIn(initializer, expression, statement), node) + : node; } ts.updateForIn = updateForIn; - function createForOf(initializer, expression, statement, location) { - var node = createNode(214, location); + function createForOf(initializer, expression, statement) { + var node = createSynthesizedNode(215); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -9390,112 +9564,105 @@ var ts; } ts.createForOf = createForOf; function updateForOf(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForOf(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForOf(initializer, expression, statement), node) + : node; } ts.updateForOf = updateForOf; - function createContinue(label, location) { - var node = createNode(215, location); - if (label) { - node.label = label; - } + function createContinue(label) { + var node = createSynthesizedNode(216); + node.label = asName(label); return node; } ts.createContinue = createContinue; function updateContinue(node, label) { - if (node.label !== label) { - return updateNode(createContinue(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createContinue(label), node) + : node; } ts.updateContinue = updateContinue; - function createBreak(label, location) { - var node = createNode(216, location); - if (label) { - node.label = label; - } + function createBreak(label) { + var node = createSynthesizedNode(217); + node.label = asName(label); return node; } ts.createBreak = createBreak; function updateBreak(node, label) { - if (node.label !== label) { - return updateNode(createBreak(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createBreak(label), node) + : node; } ts.updateBreak = updateBreak; - function createReturn(expression, location) { - var node = createNode(217, location); + function createReturn(expression) { + var node = createSynthesizedNode(218); node.expression = expression; return node; } ts.createReturn = createReturn; function updateReturn(node, expression) { - if (node.expression !== expression) { - return updateNode(createReturn(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createReturn(expression), node) + : node; } ts.updateReturn = updateReturn; - function createWith(expression, statement, location) { - var node = createNode(218, location); + function createWith(expression, statement) { + var node = createSynthesizedNode(219); node.expression = expression; node.statement = statement; return node; } ts.createWith = createWith; function updateWith(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWith(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWith(expression, statement), node) + : node; } ts.updateWith = updateWith; - function createSwitch(expression, caseBlock, location) { - var node = createNode(219, location); - node.expression = parenthesizeExpressionForList(expression); + function createSwitch(expression, caseBlock) { + var node = createSynthesizedNode(220); + node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; } ts.createSwitch = createSwitch; function updateSwitch(node, expression, caseBlock) { - if (node.expression !== expression || node.caseBlock !== caseBlock) { - return updateNode(createSwitch(expression, caseBlock, node), node); - } - return node; + return node.expression !== expression + || node.caseBlock !== caseBlock + ? updateNode(createSwitch(expression, caseBlock), node) + : node; } ts.updateSwitch = updateSwitch; - function createLabel(label, statement, location) { - var node = createNode(220, location); - node.label = typeof label === "string" ? createIdentifier(label) : label; + function createLabel(label, statement) { + var node = createSynthesizedNode(221); + node.label = asName(label); node.statement = statement; return node; } ts.createLabel = createLabel; function updateLabel(node, label, statement) { - if (node.label !== label || node.statement !== statement) { - return updateNode(createLabel(label, statement, node), node); - } - return node; + return node.label !== label + || node.statement !== statement + ? updateNode(createLabel(label, statement), node) + : node; } ts.updateLabel = updateLabel; - function createThrow(expression, location) { - var node = createNode(221, location); + function createThrow(expression) { + var node = createSynthesizedNode(222); node.expression = expression; return node; } ts.createThrow = createThrow; function updateThrow(node, expression) { - if (node.expression !== expression) { - return updateNode(createThrow(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createThrow(expression), node) + : node; } ts.updateThrow = updateThrow; - function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(222, location); + function createTry(tryBlock, catchClause, finallyBlock) { + var node = createSynthesizedNode(223); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -9503,32 +9670,20 @@ var ts; } ts.createTry = createTry; function updateTry(node, tryBlock, catchClause, finallyBlock) { - if (node.tryBlock !== tryBlock || node.catchClause !== catchClause || node.finallyBlock !== finallyBlock) { - return updateNode(createTry(tryBlock, catchClause, finallyBlock, node), node); - } - return node; + return node.tryBlock !== tryBlock + || node.catchClause !== catchClause + || node.finallyBlock !== finallyBlock + ? updateNode(createTry(tryBlock, catchClause, finallyBlock), node) + : node; } ts.updateTry = updateTry; - function createCaseBlock(clauses, location) { - var node = createNode(233, location); - node.clauses = createNodeArray(clauses); - return node; - } - ts.createCaseBlock = createCaseBlock; - function updateCaseBlock(node, clauses) { - if (node.clauses !== clauses) { - return updateNode(createCaseBlock(clauses, node), node); - } - return node; - } - ts.updateCaseBlock = updateCaseBlock; - function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(226, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(227); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -9536,161 +9691,261 @@ var ts; } ts.createFunctionDeclaration = createFunctionDeclaration; function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionDeclaration = updateFunctionDeclaration; - function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(227, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(228); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassDeclaration = createClassDeclaration; function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassDeclaration = updateClassDeclaration; - function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(236, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createEnumDeclaration(decorators, modifiers, name, members) { + var node = createSynthesizedNode(231); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.members = createNodeArray(members); + return node; + } + ts.createEnumDeclaration = createEnumDeclaration; + function updateEnumDeclaration(node, decorators, modifiers, name, members) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.members !== members + ? updateNode(createEnumDeclaration(decorators, modifiers, name, members), node) + : node; + } + ts.updateEnumDeclaration = updateEnumDeclaration; + function createModuleDeclaration(decorators, modifiers, name, body, flags) { + var node = createSynthesizedNode(232); + node.flags |= flags; + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = name; + node.body = body; + return node; + } + ts.createModuleDeclaration = createModuleDeclaration; + function updateModuleDeclaration(node, decorators, modifiers, name, body) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.body !== body + ? updateNode(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node) + : node; + } + ts.updateModuleDeclaration = updateModuleDeclaration; + function createModuleBlock(statements) { + var node = createSynthesizedNode(234); + node.statements = createNodeArray(statements); + return node; + } + ts.createModuleBlock = createModuleBlock; + function updateModuleBlock(node, statements) { + return node.statements !== statements + ? updateNode(createModuleBlock(statements), node) + : node; + } + ts.updateModuleBlock = updateModuleBlock; + function createCaseBlock(clauses) { + var node = createSynthesizedNode(234); + node.clauses = createNodeArray(clauses); + return node; + } + ts.createCaseBlock = createCaseBlock; + function updateCaseBlock(node, clauses) { + return node.clauses !== clauses + ? updateNode(createCaseBlock(clauses), node) + : node; + } + ts.updateCaseBlock = updateCaseBlock; + function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { + var node = createSynthesizedNode(236); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.moduleReference = moduleReference; + return node; + } + ts.createImportEqualsDeclaration = createImportEqualsDeclaration; + function updateImportEqualsDeclaration(node, decorators, modifiers, name, moduleReference) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.moduleReference !== moduleReference + ? updateNode(createImportEqualsDeclaration(decorators, modifiers, name, moduleReference), node) + : node; + } + ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; + function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { + var node = createSynthesizedNode(237); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createImportDeclaration = createImportDeclaration; function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node) + : node; } ts.updateImportDeclaration = updateImportDeclaration; - function createImportClause(name, namedBindings, location) { - var node = createNode(237, location); + function createImportClause(name, namedBindings) { + var node = createSynthesizedNode(238); node.name = name; node.namedBindings = namedBindings; return node; } ts.createImportClause = createImportClause; function updateImportClause(node, name, namedBindings) { - if (node.name !== name || node.namedBindings !== namedBindings) { - return updateNode(createImportClause(name, namedBindings, node), node); - } - return node; + return node.name !== name + || node.namedBindings !== namedBindings + ? updateNode(createImportClause(name, namedBindings), node) + : node; } ts.updateImportClause = updateImportClause; - function createNamespaceImport(name, location) { - var node = createNode(238, location); + function createNamespaceImport(name) { + var node = createSynthesizedNode(239); node.name = name; return node; } ts.createNamespaceImport = createNamespaceImport; function updateNamespaceImport(node, name) { - if (node.name !== name) { - return updateNode(createNamespaceImport(name, node), node); - } - return node; + return node.name !== name + ? updateNode(createNamespaceImport(name), node) + : node; } ts.updateNamespaceImport = updateNamespaceImport; - function createNamedImports(elements, location) { - var node = createNode(239, location); + function createNamedImports(elements) { + var node = createSynthesizedNode(240); node.elements = createNodeArray(elements); return node; } ts.createNamedImports = createNamedImports; function updateNamedImports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedImports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedImports(elements), node) + : node; } ts.updateNamedImports = updateNamedImports; - function createImportSpecifier(propertyName, name, location) { - var node = createNode(240, location); + function createImportSpecifier(propertyName, name) { + var node = createSynthesizedNode(241); node.propertyName = propertyName; node.name = name; return node; } ts.createImportSpecifier = createImportSpecifier; function updateImportSpecifier(node, propertyName, name) { - if (node.propertyName !== propertyName || node.name !== name) { - return updateNode(createImportSpecifier(propertyName, name, node), node); - } - return node; + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createImportSpecifier(propertyName, name), node) + : node; } ts.updateImportSpecifier = updateImportSpecifier; - function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(241, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportAssignment(decorators, modifiers, isExportEquals, expression) { + var node = createSynthesizedNode(242); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = expression; return node; } ts.createExportAssignment = createExportAssignment; function updateExportAssignment(node, decorators, modifiers, expression) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.expression !== expression) { - return updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.expression !== expression + ? updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node) + : node; } ts.updateExportAssignment = updateExportAssignment; - function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(242, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { + var node = createSynthesizedNode(243); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createExportDeclaration = createExportDeclaration; function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.exportClause !== exportClause + || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier), node) + : node; } ts.updateExportDeclaration = updateExportDeclaration; - function createNamedExports(elements, location) { - var node = createNode(243, location); + function createNamedExports(elements) { + var node = createSynthesizedNode(244); node.elements = createNodeArray(elements); return node; } ts.createNamedExports = createNamedExports; function updateNamedExports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedExports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedExports(elements), node) + : node; } ts.updateNamedExports = updateNamedExports; - function createExportSpecifier(name, propertyName, location) { - var node = createNode(244, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createExportSpecifier(name, propertyName) { + var node = createSynthesizedNode(245); + node.name = asName(name); + node.propertyName = asName(propertyName); return node; } ts.createExportSpecifier = createExportSpecifier; function updateExportSpecifier(node, name, propertyName) { - if (node.name !== name || node.propertyName !== propertyName) { - return updateNode(createExportSpecifier(name, propertyName, node), node); - } - return node; + return node.name !== name || node.propertyName !== propertyName + ? updateNode(createExportSpecifier(name, propertyName), node) + : node; } ts.updateExportSpecifier = updateExportSpecifier; - function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(247, location); + function createExternalModuleReference(expression) { + var node = createSynthesizedNode(247); + node.expression = expression; + return node; + } + ts.createExternalModuleReference = createExternalModuleReference; + function updateExternalModuleReference(node, expression) { + return node.expression !== expression + ? updateNode(createExternalModuleReference(expression), node) + : node; + } + ts.updateExternalModuleReference = updateExternalModuleReference; + function createJsxElement(openingElement, children, closingElement) { + var node = createSynthesizedNode(248); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -9698,96 +9953,107 @@ var ts; } ts.createJsxElement = createJsxElement; function updateJsxElement(node, openingElement, children, closingElement) { - if (node.openingElement !== openingElement || node.children !== children || node.closingElement !== closingElement) { - return updateNode(createJsxElement(openingElement, children, closingElement, node), node); - } - return node; + return node.openingElement !== openingElement + || node.children !== children + || node.closingElement !== closingElement + ? updateNode(createJsxElement(openingElement, children, closingElement), node) + : node; } ts.updateJsxElement = updateJsxElement; - function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(248, location); + function createJsxSelfClosingElement(tagName, attributes) { + var node = createSynthesizedNode(249); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxSelfClosingElement = createJsxSelfClosingElement; function updateJsxSelfClosingElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxSelfClosingElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxSelfClosingElement(tagName, attributes), node) + : node; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; - function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(249, location); + function createJsxOpeningElement(tagName, attributes) { + var node = createSynthesizedNode(250); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxOpeningElement = createJsxOpeningElement; function updateJsxOpeningElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxOpeningElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxOpeningElement(tagName, attributes), node) + : node; } ts.updateJsxOpeningElement = updateJsxOpeningElement; - function createJsxClosingElement(tagName, location) { - var node = createNode(250, location); + function createJsxClosingElement(tagName) { + var node = createSynthesizedNode(251); node.tagName = tagName; return node; } ts.createJsxClosingElement = createJsxClosingElement; function updateJsxClosingElement(node, tagName) { - if (node.tagName !== tagName) { - return updateNode(createJsxClosingElement(tagName, node), node); - } - return node; + return node.tagName !== tagName + ? updateNode(createJsxClosingElement(tagName), node) + : node; } ts.updateJsxClosingElement = updateJsxClosingElement; - function createJsxAttribute(name, initializer, location) { - var node = createNode(251, location); + function createJsxAttributes(properties) { + var jsxAttributes = createSynthesizedNode(253); + jsxAttributes.properties = createNodeArray(properties); + return jsxAttributes; + } + ts.createJsxAttributes = createJsxAttributes; + function updateJsxAttributes(jsxAttributes, properties) { + if (jsxAttributes.properties !== properties) { + return updateNode(createJsxAttributes(properties), jsxAttributes); + } + return jsxAttributes; + } + ts.updateJsxAttributes = updateJsxAttributes; + function createJsxAttribute(name, initializer) { + var node = createSynthesizedNode(252); node.name = name; node.initializer = initializer; return node; } ts.createJsxAttribute = createJsxAttribute; function updateJsxAttribute(node, name, initializer) { - if (node.name !== name || node.initializer !== initializer) { - return updateNode(createJsxAttribute(name, initializer, node), node); - } - return node; + return node.name !== name + || node.initializer !== initializer + ? updateNode(createJsxAttribute(name, initializer), node) + : node; } ts.updateJsxAttribute = updateJsxAttribute; - function createJsxSpreadAttribute(expression, location) { - var node = createNode(252, location); + function createJsxSpreadAttribute(expression) { + var node = createSynthesizedNode(254); node.expression = expression; return node; } ts.createJsxSpreadAttribute = createJsxSpreadAttribute; function updateJsxSpreadAttribute(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxSpreadAttribute(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxSpreadAttribute(expression), node) + : node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, dotDotDotToken, location) { - var node = createNode(253, location); + function createJsxExpression(expression, dotDotDotToken) { + var node = createSynthesizedNode(255); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxExpression(expression, node.dotDotDotToken), node) + : node; } ts.updateJsxExpression = updateJsxExpression; - function createHeritageClause(token, types, location) { - var node = createNode(256, location); + function createHeritageClause(token, types) { + var node = createSynthesizedNode(258); node.token = token; node.types = createNodeArray(types); return node; @@ -9795,40 +10061,40 @@ var ts; ts.createHeritageClause = createHeritageClause; function updateHeritageClause(node, types) { if (node.types !== types) { - return updateNode(createHeritageClause(node.token, types, node), node); + return updateNode(createHeritageClause(node.token, types), node); } return node; } ts.updateHeritageClause = updateHeritageClause; - function createCaseClause(expression, statements, location) { - var node = createNode(254, location); - node.expression = parenthesizeExpressionForList(expression); + function createCaseClause(expression, statements) { + var node = createSynthesizedNode(256); + node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; } ts.createCaseClause = createCaseClause; function updateCaseClause(node, expression, statements) { if (node.expression !== expression || node.statements !== statements) { - return updateNode(createCaseClause(expression, statements, node), node); + return updateNode(createCaseClause(expression, statements), node); } return node; } ts.updateCaseClause = updateCaseClause; - function createDefaultClause(statements, location) { - var node = createNode(255, location); + function createDefaultClause(statements) { + var node = createSynthesizedNode(257); node.statements = createNodeArray(statements); return node; } ts.createDefaultClause = createDefaultClause; function updateDefaultClause(node, statements) { if (node.statements !== statements) { - return updateNode(createDefaultClause(statements, node), node); + return updateNode(createDefaultClause(statements), node); } return node; } ts.updateDefaultClause = updateDefaultClause; - function createCatchClause(variableDeclaration, block, location) { - var node = createNode(257, location); + function createCatchClause(variableDeclaration, block) { + var node = createSynthesizedNode(259); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -9836,56 +10102,71 @@ var ts; ts.createCatchClause = createCatchClause; function updateCatchClause(node, variableDeclaration, block) { if (node.variableDeclaration !== variableDeclaration || node.block !== block) { - return updateNode(createCatchClause(variableDeclaration, block, node), node); + return updateNode(createCatchClause(variableDeclaration, block), node); } return node; } ts.updateCatchClause = updateCatchClause; - function createPropertyAssignment(name, initializer, location) { - var node = createNode(258, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAssignment(name, initializer) { + var node = createSynthesizedNode(260); + node.name = asName(name); node.questionToken = undefined; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createPropertyAssignment = createPropertyAssignment; function updatePropertyAssignment(node, name, initializer) { if (node.name !== name || node.initializer !== initializer) { - return updateNode(createPropertyAssignment(name, initializer, node), node); + return updateNode(createPropertyAssignment(name, initializer), node); } return node; } ts.updatePropertyAssignment = updatePropertyAssignment; - function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(259, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; + function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { + var node = createSynthesizedNode(261); + node.name = asName(name); + node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; - function createSpreadAssignment(expression, location) { - var node = createNode(260, location); - node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; + function createSpreadAssignment(expression) { + var node = createSynthesizedNode(262); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; return node; } ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { - return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); + return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); } return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function updateSpreadAssignment(node, expression) { if (node.expression !== expression) { - return updateNode(createSpreadAssignment(expression, node), node); + return updateNode(createSpreadAssignment(expression), node); } return node; } ts.updateSpreadAssignment = updateSpreadAssignment; + function createEnumMember(name, initializer) { + var node = createSynthesizedNode(263); + node.name = asName(name); + node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); + return node; + } + ts.createEnumMember = createEnumMember; + function updateEnumMember(node, name, initializer) { + return node.name !== name + || node.initializer !== initializer + ? updateNode(createEnumMember(name, initializer), node) + : node; + } + ts.updateEnumMember = updateEnumMember; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(262, node, node.flags); + var updated = createSynthesizedNode(264); + updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -9944,50 +10225,73 @@ var ts; return node; } ts.updateSourceFileNode = updateSourceFileNode; + function getMutableClone(node) { + var clone = getSynthesizedClone(node); + clone.pos = node.pos; + clone.end = node.end; + clone.parent = node.parent; + return clone; + } + ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createNode(294, original); + var node = createSynthesizedNode(297); node.original = original; + setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createNode(297); + var node = createSynthesizedNode(300); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createNode(296); + var node = createSynthesizedNode(299); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; - function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(295, location || original); + function createPartiallyEmittedExpression(expression, original) { + var node = createSynthesizedNode(298); node.expression = expression; node.original = original; + setTextRange(node, original); return node; } ts.createPartiallyEmittedExpression = createPartiallyEmittedExpression; function updatePartiallyEmittedExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createPartiallyEmittedExpression(expression, node.original, node), node); + return updateNode(createPartiallyEmittedExpression(expression, node.original), node); } return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; + function createBundle(sourceFiles) { + var node = ts.createNode(265); + node.sourceFiles = sourceFiles; + return node; + } + ts.createBundle = createBundle; + function updateBundle(node, sourceFiles) { + if (node.sourceFiles !== sourceFiles) { + return createBundle(sourceFiles); + } + return node; + } + ts.updateBundle = updateBundle; function createComma(left, right) { return createBinary(left, 25, right); } ts.createComma = createComma; - function createLessThan(left, right, location) { - return createBinary(left, 26, right, location); + function createLessThan(left, right) { + return createBinary(left, 26, right); } ts.createLessThan = createLessThan; - function createAssignment(left, right, location) { - return createBinary(left, 57, right, location); + function createAssignment(left, right) { + return createBinary(left, 57, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { @@ -10006,8 +10310,8 @@ var ts; return createBinary(left, 37, right); } ts.createSubtract = createSubtract; - function createPostfixIncrement(operand, location) { - return createPostfix(operand, 42, location); + function createPostfixIncrement(operand) { + return createPostfix(operand, 42); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { @@ -10026,97 +10330,6 @@ var ts; return createVoid(createLiteral(0)); } ts.createVoidZero = createVoidZero; - function createTypeCheck(value, tag) { - return tag === "undefined" - ? createStrictEquality(value, createVoidZero()) - : createStrictEquality(createTypeOf(value), createLiteral(tag)); - } - ts.createTypeCheck = createTypeCheck; - function createMemberAccessForPropertyName(target, memberName, location) { - if (ts.isComputedPropertyName(memberName)) { - return createElementAccess(target, memberName.expression, location); - } - else { - var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - (expression.emitNode || (expression.emitNode = {})).flags |= 64; - return expression; - } - } - ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; - function createFunctionCall(func, thisArg, argumentsList, location) { - return createCall(createPropertyAccess(func, "call"), undefined, [ - thisArg - ].concat(argumentsList), location); - } - ts.createFunctionCall = createFunctionCall; - function createFunctionApply(func, thisArg, argumentsExpression, location) { - return createCall(createPropertyAccess(func, "apply"), undefined, [ - thisArg, - argumentsExpression - ], location); - } - ts.createFunctionApply = createFunctionApply; - function createArraySlice(array, start) { - var argumentsList = []; - if (start !== undefined) { - argumentsList.push(typeof start === "number" ? createLiteral(start) : start); - } - return createCall(createPropertyAccess(array, "slice"), undefined, argumentsList); - } - ts.createArraySlice = createArraySlice; - function createArrayConcat(array, values) { - return createCall(createPropertyAccess(array, "concat"), undefined, values); - } - ts.createArrayConcat = createArrayConcat; - function createMathPow(left, right, location) { - return createCall(createPropertyAccess(createIdentifier("Math"), "pow"), undefined, [left, right], location); - } - ts.createMathPow = createMathPow; - function createReactNamespace(reactNamespace, parent) { - var react = createIdentifier(reactNamespace || "React"); - react.flags &= ~8; - react.parent = ts.getParseTreeNode(parent); - return react; - } - function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { - if (ts.isQualifiedName(jsxFactory)) { - var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); - var right = createSynthesizedNode(70); - right.text = jsxFactory.right.text; - return createPropertyAccess(left, right); - } - else { - return createReactNamespace(jsxFactory.text, parent); - } - } - function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { - return jsxFactoryEntity ? - createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : - createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); - } - function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { - var argumentsList = [tagName]; - if (props) { - argumentsList.push(props); - } - if (children && children.length > 0) { - if (!props) { - argumentsList.push(createNull()); - } - if (children.length > 1) { - for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { - var child = children_1[_i]; - child.startsOnNewLine = true; - argumentsList.push(child); - } - } - else { - argumentsList.push(children[0]); - } - } - return createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList, location); - } - ts.createExpressionForJsxElement = createExpressionForJsxElement; function createExportDefault(expression) { return createExportAssignment(undefined, undefined, false, expression); } @@ -10125,586 +10338,17 @@ var ts; return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(exportName)])); } ts.createExternalModuleExport = createExternalModuleExport; - function createLetStatement(name, initializer, location) { - return createVariableStatement(undefined, createLetDeclarationList([createVariableDeclaration(name, undefined, initializer)]), location); + function asName(name) { + return typeof name === "string" ? createIdentifier(name) : name; } - ts.createLetStatement = createLetStatement; - function createLetDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 1); + function asExpression(value) { + return typeof value === "string" || typeof value === "number" ? createLiteral(value) : value; } - ts.createLetDeclarationList = createLetDeclarationList; - function createConstDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 2); + function asNodeArray(array) { + return array ? createNodeArray(array) : undefined; } - ts.createConstDeclarationList = createConstDeclarationList; - function getHelperName(name) { - return setEmitFlags(createIdentifier(name), 4096 | 2); - } - ts.getHelperName = getHelperName; - function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { - if (!outermostLabeledStatement) { - return node; - } - var updated = updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 220 - ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) - : node); - if (afterRestoreLabelCallback) { - afterRestoreLabelCallback(outermostLabeledStatement); - } - return updated; - } - ts.restoreEnclosingLabel = restoreEnclosingLabel; - function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { - var target = skipParentheses(node); - switch (target.kind) { - case 70: - return cacheIdentifiers; - case 98: - case 8: - case 9: - return false; - case 175: - var elements = target.elements; - if (elements.length === 0) { - return false; - } - return true; - case 176: - return target.properties.length > 0; - default: - return true; - } - } - function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { - var callee = skipOuterExpressions(expression, 7); - var thisArg; - var target; - if (ts.isSuperProperty(callee)) { - thisArg = createThis(); - target = callee; - } - else if (callee.kind === 96) { - thisArg = createThis(); - target = languageVersion < 2 ? createIdentifier("_super", callee) : callee; - } - else { - switch (callee.kind) { - case 177: { - if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { - thisArg = createTempVariable(recordTempVariable); - target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); - } - else { - thisArg = callee.expression; - target = callee; - } - break; - } - case 178: { - if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { - thisArg = createTempVariable(recordTempVariable); - target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); - } - else { - thisArg = callee.expression; - target = callee; - } - break; - } - default: { - thisArg = createVoidZero(); - target = parenthesizeForAccess(expression); - break; - } - } - } - return { target: target, thisArg: thisArg }; - } - ts.createCallBinding = createCallBinding; - function inlineExpressions(expressions) { - return ts.reduceLeft(expressions, createComma); - } - ts.inlineExpressions = inlineExpressions; - function createExpressionFromEntityName(node) { - if (ts.isQualifiedName(node)) { - var left = createExpressionFromEntityName(node.left); - var right = getMutableClone(node.right); - return createPropertyAccess(left, right, node); - } - else { - return getMutableClone(node); - } - } - ts.createExpressionFromEntityName = createExpressionFromEntityName; - function createExpressionForPropertyName(memberName) { - if (ts.isIdentifier(memberName)) { - return createLiteral(memberName, undefined); - } - else if (ts.isComputedPropertyName(memberName)) { - return getMutableClone(memberName.expression); - } - else { - return getMutableClone(memberName); - } - } - ts.createExpressionForPropertyName = createExpressionForPropertyName; - function createExpressionForObjectLiteralElementLike(node, property, receiver) { - switch (property.kind) { - case 151: - case 152: - return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 258: - return createExpressionForPropertyAssignment(property, receiver); - case 259: - return createExpressionForShorthandPropertyAssignment(property, receiver); - case 149: - return createExpressionForMethodDeclaration(property, receiver); - } - } - ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike; - function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { - var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; - if (property === firstAccessor) { - var properties_1 = []; - if (getAccessor) { - var getterFunction = createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); - setOriginalNode(getterFunction, getAccessor); - var getter = createPropertyAssignment("get", getterFunction); - properties_1.push(getter); - } - if (setAccessor) { - var setterFunction = createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); - setOriginalNode(setterFunction, setAccessor); - var setter = createPropertyAssignment("set", setterFunction); - properties_1.push(setter); - } - properties_1.push(createPropertyAssignment("enumerable", createLiteral(true))); - properties_1.push(createPropertyAssignment("configurable", createLiteral(true))); - var expression = createCall(createPropertyAccess(createIdentifier("Object"), "defineProperty"), undefined, [ - receiver, - createExpressionForPropertyName(property.name), - createObjectLiteral(properties_1, undefined, multiLine) - ], firstAccessor); - return ts.aggregateTransformFlags(expression); - } - return undefined; - } - function createExpressionForPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer, property), property)); - } - function createExpressionForShorthandPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), getSynthesizedClone(property.name), property), property)); - } - function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); - } - function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384); - } - ts.getLocalName = getLocalName; - function isLocalName(node) { - return (getEmitFlags(node) & 16384) !== 0; - } - ts.isLocalName = isLocalName; - function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 8192); - } - ts.getExportName = getExportName; - function isExportName(node) { - return (getEmitFlags(node) & 8192) !== 0; - } - ts.isExportName = isExportName; - function getDeclarationName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps); - } - ts.getDeclarationName = getDeclarationName; - function getName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { - var name_8 = getMutableClone(node.name); - emitFlags |= getEmitFlags(node.name); - if (!allowSourceMaps) - emitFlags |= 48; - if (!allowComments) - emitFlags |= 1536; - if (emitFlags) - setEmitFlags(name_8, emitFlags); - return name_8; - } - return getGeneratedNameForNode(node); - } - function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && ts.hasModifier(node, 1)) { - return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); - } - return getExportName(node, allowComments, allowSourceMaps); - } - ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; - function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { - var qualifiedName = createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : getSynthesizedClone(name), name); - var emitFlags; - if (!allowSourceMaps) - emitFlags |= 48; - if (!allowComments) - emitFlags |= 1536; - if (emitFlags) - setEmitFlags(qualifiedName, emitFlags); - return qualifiedName; - } - ts.getNamespaceMemberName = getNamespaceMemberName; - function convertToFunctionBody(node, multiLine) { - return ts.isBlock(node) ? node : createBlock([createReturn(node, node)], node, multiLine); - } - ts.convertToFunctionBody = convertToFunctionBody; - function isUseStrictPrologue(node) { - return node.expression.text === "use strict"; - } - function addPrologueDirectives(target, source, ensureUseStrict, visitor) { - ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); - var foundUseStrict = false; - var statementOffset = 0; - var numStatements = source.length; - while (statementOffset < numStatements) { - var statement = source[statementOffset]; - if (ts.isPrologueDirective(statement)) { - if (isUseStrictPrologue(statement)) { - foundUseStrict = true; - } - target.push(statement); - } - else { - break; - } - statementOffset++; - } - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - } - while (statementOffset < numStatements) { - var statement = source[statementOffset]; - if (getEmitFlags(statement) & 524288) { - target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); - } - else { - break; - } - statementOffset++; - } - return statementOffset; - } - ts.addPrologueDirectives = addPrologueDirectives; - function startsWithUseStrict(statements) { - var firstStatement = ts.firstOrUndefined(statements); - return firstStatement !== undefined - && ts.isPrologueDirective(firstStatement) - && isUseStrictPrologue(firstStatement); - } - ts.startsWithUseStrict = startsWithUseStrict; - function ensureUseStrict(statements) { - var foundUseStrict = false; - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; - if (ts.isPrologueDirective(statement)) { - if (isUseStrictPrologue(statement)) { - foundUseStrict = true; - break; - } - } - else { - break; - } - } - if (!foundUseStrict) { - return createNodeArray([ - startOnNewLine(createStatement(createLiteral("use strict"))) - ].concat(statements), statements); - } - return statements; - } - ts.ensureUseStrict = ensureUseStrict; - function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 183) { - return operand; - } - return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) - ? createParen(operand) - : operand; - } - ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; - function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(192, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(192, binaryOperator); - var emittedOperand = skipPartiallyEmittedExpressions(operand); - var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); - switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1: - if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 - && operand.kind === 195) { - return false; - } - return true; - case 1: - return false; - case 0: - if (isLeftSideOfBinary) { - return binaryOperatorAssociativity === 1; - } - else { - if (ts.isBinaryExpression(emittedOperand) - && emittedOperand.operatorToken.kind === binaryOperator) { - if (operatorHasAssociativeProperty(binaryOperator)) { - return false; - } - if (binaryOperator === 36) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; - if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { - return false; - } - } - } - var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0; - } - } - } - function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 38 - || binaryOperator === 48 - || binaryOperator === 47 - || binaryOperator === 49; - } - function getLiteralKindOfBinaryPlusOperand(node) { - node = skipPartiallyEmittedExpressions(node); - if (ts.isLiteralKind(node.kind)) { - return node.kind; - } - if (node.kind === 192 && node.operatorToken.kind === 36) { - if (node.cachedLiteralKind !== undefined) { - return node.cachedLiteralKind; - } - var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0; - node.cachedLiteralKind = literalKind; - return literalKind; - } - return 0; - } - function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(193, 54); - var emittedCondition = skipPartiallyEmittedExpressions(condition); - var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { - return createParen(condition); - } - return condition; - } - ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; - function parenthesizeSubexpressionOfConditionalExpression(e) { - return e.kind === 192 && e.operatorToken.kind === 25 - ? createParen(e) - : e; - } - function parenthesizeForNew(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - switch (emittedExpression.kind) { - case 179: - return createParen(expression); - case 180: - return emittedExpression.arguments - ? expression - : createParen(expression); - } - return parenthesizeForAccess(expression); - } - ts.parenthesizeForNew = parenthesizeForNew; - function parenthesizeForAccess(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 180 || emittedExpression.arguments) - && emittedExpression.kind !== 8) { - return expression; - } - return createParen(expression, expression); - } - ts.parenthesizeForAccess = parenthesizeForAccess; - function parenthesizePostfixOperand(operand) { - return ts.isLeftHandSideExpression(operand) - ? operand - : createParen(operand, operand); - } - ts.parenthesizePostfixOperand = parenthesizePostfixOperand; - function parenthesizePrefixOperand(operand) { - return ts.isUnaryExpression(operand) - ? operand - : createParen(operand, operand); - } - ts.parenthesizePrefixOperand = parenthesizePrefixOperand; - function parenthesizeListElements(elements) { - var result; - for (var i = 0; i < elements.length; i++) { - var element = parenthesizeExpressionForList(elements[i]); - if (result !== undefined || element !== elements[i]) { - if (result === undefined) { - result = elements.slice(0, i); - } - result.push(element); - } - } - if (result !== undefined) { - return createNodeArray(result, elements, elements.hasTrailingComma); - } - return elements; - } - function parenthesizeExpressionForList(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(192, 25); - return expressionPrecedence > commaPrecedence - ? expression - : createParen(expression, expression); - } - ts.parenthesizeExpressionForList = parenthesizeExpressionForList; - function parenthesizeExpressionForExpressionStatement(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - if (ts.isCallExpression(emittedExpression)) { - var callee = emittedExpression.expression; - var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 184 || kind === 185) { - var mutableCall = getMutableClone(emittedExpression); - mutableCall.expression = createParen(callee, callee); - return recreatePartiallyEmittedExpressions(expression, mutableCall); - } - } - else { - var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 176 || leftmostExpressionKind === 184) { - return createParen(expression, expression); - } - } - return expression; - } - ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; - function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { - if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { - var clone_1 = getMutableClone(originalOuterExpression); - clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); - return clone_1; - } - return newInnerExpression; - } - function getLeftmostExpression(node) { - while (true) { - switch (node.kind) { - case 191: - node = node.operand; - continue; - case 192: - node = node.left; - continue; - case 193: - node = node.condition; - continue; - case 179: - case 178: - case 177: - node = node.expression; - continue; - case 295: - node = node.expression; - continue; - } - return node; - } - } - function parenthesizeConciseBody(body) { - var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 176) { - return createParen(body, body); - } - return body; - } - ts.parenthesizeConciseBody = parenthesizeConciseBody; - function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 7; } - var previousNode; - do { - previousNode = node; - if (kinds & 1) { - node = skipParentheses(node); - } - if (kinds & 2) { - node = skipAssertions(node); - } - if (kinds & 4) { - node = skipPartiallyEmittedExpressions(node); - } - } while (previousNode !== node); - return node; - } - ts.skipOuterExpressions = skipOuterExpressions; - function skipParentheses(node) { - while (node.kind === 183) { - node = node.expression; - } - return node; - } - ts.skipParentheses = skipParentheses; - function skipAssertions(node) { - while (ts.isAssertionExpression(node)) { - node = node.expression; - } - return node; - } - ts.skipAssertions = skipAssertions; - function skipPartiallyEmittedExpressions(node) { - while (node.kind === 295) { - node = node.expression; - } - return node; - } - ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; - function startOnNewLine(node) { - node.startsOnNewLine = true; - return node; - } - ts.startOnNewLine = startOnNewLine; - function setOriginalNode(node, original) { - node.original = original; - if (original) { - var emitNode = original.emitNode; - if (emitNode) - node.emitNode = mergeEmitNode(emitNode, node.emitNode); - } - return node; - } - ts.setOriginalNode = setOriginalNode; - function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; - if (!destEmitNode) - destEmitNode = {}; - if (flags) - destEmitNode.flags = flags; - if (commentRange) - destEmitNode.commentRange = commentRange; - if (sourceMapRange) - destEmitNode.sourceMapRange = sourceMapRange; - if (tokenSourceMapRanges) - destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); - if (constantValue !== undefined) - destEmitNode.constantValue = constantValue; - if (helpers) - destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); - return destEmitNode; - } - function mergeTokenSourceMapRanges(sourceRanges, destRanges) { - if (!destRanges) - destRanges = ts.createMap(); - ts.copyProperties(sourceRanges, destRanges); - return destRanges; + function asToken(value) { + return typeof value === "number" ? createToken(value) : value; } function disposeEmitNodes(sourceFile) { sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); @@ -10721,7 +10365,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 262) { + if (node.kind === 264) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -10732,6 +10376,14 @@ var ts; return node.emitNode; } ts.getOrCreateEmitNode = getOrCreateEmitNode; + function setTextRange(range, location) { + if (location) { + range.pos = location.pos; + range.end = location.end; + } + return range; + } + ts.setTextRange = setTextRange; function getEmitFlags(node) { var emitNode = node.emitNode; return emitNode && emitNode.flags; @@ -10760,7 +10412,7 @@ var ts; ts.getTokenSourceMapRange = getTokenSourceMapRange; function setTokenSourceMapRange(node, token, range) { var emitNode = getOrCreateEmitNode(node); - var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); + var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []); tokenSourceMapRanges[token] = range; return node; } @@ -10786,32 +10438,6 @@ var ts; return node; } ts.setConstantValue = setConstantValue; - function getExternalHelpersModuleName(node) { - var parseNode = ts.getOriginalNode(node, ts.isSourceFile); - var emitNode = parseNode && parseNode.emitNode; - return emitNode && emitNode.externalHelpersModuleName; - } - ts.getExternalHelpersModuleName = getExternalHelpersModuleName; - function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions) { - if (compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { - var externalHelpersModuleName = getExternalHelpersModuleName(node); - if (externalHelpersModuleName) { - return externalHelpersModuleName; - } - var helpers = getEmitHelpers(node); - if (helpers) { - for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { - var helper = helpers_1[_i]; - if (!helper.scoped) { - var parseNode = ts.getOriginalNode(node, ts.isSourceFile); - var emitNode = getOrCreateEmitNode(parseNode); - return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = createUniqueName(ts.externalHelpersModuleNameText)); - } - } - } - } - } - ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; function addEmitHelper(node, helper) { var emitNode = getOrCreateEmitNode(node); emitNode.helpers = ts.append(emitNode.helpers, helper); @@ -10821,8 +10447,8 @@ var ts; function addEmitHelpers(node, helpers) { if (ts.some(helpers)) { var emitNode = getOrCreateEmitNode(node); - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { + var helper = helpers_1[_i]; if (!ts.contains(emitNode.helpers, helper)) { emitNode.helpers = ts.append(emitNode.helpers, helper); } @@ -10883,40 +10509,718 @@ var ts; return ts.compareValues(x.priority, y.priority); } ts.compareEmitHelpers = compareEmitHelpers; - function setTextRange(node, location) { - if (location) { - node.pos = location.pos; - node.end = location.end; + function setOriginalNode(node, original) { + node.original = original; + if (original) { + var emitNode = original.emitNode; + if (emitNode) + node.emitNode = mergeEmitNode(emitNode, node.emitNode); } return node; } - ts.setTextRange = setTextRange; - function setNodeFlags(node, flags) { - node.flags = flags; + ts.setOriginalNode = setOriginalNode; + function mergeEmitNode(sourceEmitNode, destEmitNode) { + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; + if (!destEmitNode) + destEmitNode = {}; + if (flags) + destEmitNode.flags = flags; + if (commentRange) + destEmitNode.commentRange = commentRange; + if (sourceMapRange) + destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + if (constantValue !== undefined) + destEmitNode.constantValue = constantValue; + if (helpers) + destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); + return destEmitNode; + } + function mergeTokenSourceMapRanges(sourceRanges, destRanges) { + if (!destRanges) + destRanges = []; + for (var key in sourceRanges) { + destRanges[key] = sourceRanges[key]; + } + return destRanges; + } +})(ts || (ts = {})); +(function (ts) { + function createTypeCheck(value, tag) { + return tag === "undefined" + ? ts.createStrictEquality(value, ts.createVoidZero()) + : ts.createStrictEquality(ts.createTypeOf(value), ts.createLiteral(tag)); + } + ts.createTypeCheck = createTypeCheck; + function createMemberAccessForPropertyName(target, memberName, location) { + if (ts.isComputedPropertyName(memberName)) { + return ts.setTextRange(ts.createElementAccess(target, memberName.expression), location); + } + else { + var expression = ts.setTextRange(ts.isIdentifier(memberName) + ? ts.createPropertyAccess(target, memberName) + : ts.createElementAccess(target, memberName), memberName); + ts.getOrCreateEmitNode(expression).flags |= 64; + return expression; + } + } + ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; + function createFunctionCall(func, thisArg, argumentsList, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), undefined, [ + thisArg + ].concat(argumentsList)), location); + } + ts.createFunctionCall = createFunctionCall; + function createFunctionApply(func, thisArg, argumentsExpression, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "apply"), undefined, [ + thisArg, + argumentsExpression + ]), location); + } + ts.createFunctionApply = createFunctionApply; + function createArraySlice(array, start) { + var argumentsList = []; + if (start !== undefined) { + argumentsList.push(typeof start === "number" ? ts.createLiteral(start) : start); + } + return ts.createCall(ts.createPropertyAccess(array, "slice"), undefined, argumentsList); + } + ts.createArraySlice = createArraySlice; + function createArrayConcat(array, values) { + return ts.createCall(ts.createPropertyAccess(array, "concat"), undefined, values); + } + ts.createArrayConcat = createArrayConcat; + function createMathPow(left, right, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Math"), "pow"), undefined, [left, right]), location); + } + ts.createMathPow = createMathPow; + function createReactNamespace(reactNamespace, parent) { + var react = ts.createIdentifier(reactNamespace || "React"); + react.flags &= ~8; + react.parent = ts.getParseTreeNode(parent); + return react; + } + function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { + if (ts.isQualifiedName(jsxFactory)) { + var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); + var right = ts.createIdentifier(jsxFactory.right.text); + right.text = jsxFactory.right.text; + return ts.createPropertyAccess(left, right); + } + else { + return createReactNamespace(jsxFactory.text, parent); + } + } + function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { + return jsxFactoryEntity ? + createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : + ts.createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); + } + function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { + var argumentsList = [tagName]; + if (props) { + argumentsList.push(props); + } + if (children && children.length > 0) { + if (!props) { + argumentsList.push(ts.createNull()); + } + if (children.length > 1) { + for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { + var child = children_1[_i]; + child.startsOnNewLine = true; + argumentsList.push(child); + } + } + else { + argumentsList.push(children[0]); + } + } + return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location); + } + ts.createExpressionForJsxElement = createExpressionForJsxElement; + function getHelperName(name) { + return ts.setEmitFlags(ts.createIdentifier(name), 4096 | 2); + } + ts.getHelperName = getHelperName; + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 221 + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; + function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { + var target = skipParentheses(node); + switch (target.kind) { + case 70: + return cacheIdentifiers; + case 98: + case 8: + case 9: + return false; + case 176: + var elements = target.elements; + if (elements.length === 0) { + return false; + } + return true; + case 177: + return target.properties.length > 0; + default: + return true; + } + } + function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { + var callee = skipOuterExpressions(expression, 7); + var thisArg; + var target; + if (ts.isSuperProperty(callee)) { + thisArg = ts.createThis(); + target = callee; + } + else if (callee.kind === 96) { + thisArg = ts.createThis(); + target = languageVersion < 2 + ? ts.setTextRange(ts.createIdentifier("_super"), callee) + : callee; + } + else { + switch (callee.kind) { + case 178: { + if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); + ts.setTextRange(target, callee); + } + else { + thisArg = callee.expression; + target = callee; + } + break; + } + case 179: { + if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); + ts.setTextRange(target, callee); + } + else { + thisArg = callee.expression; + target = callee; + } + break; + } + default: { + thisArg = ts.createVoidZero(); + target = parenthesizeForAccess(expression); + break; + } + } + } + return { target: target, thisArg: thisArg }; + } + ts.createCallBinding = createCallBinding; + function inlineExpressions(expressions) { + return ts.reduceLeft(expressions, ts.createComma); + } + ts.inlineExpressions = inlineExpressions; + function createExpressionFromEntityName(node) { + if (ts.isQualifiedName(node)) { + var left = createExpressionFromEntityName(node.left); + var right = ts.getMutableClone(node.right); + return ts.setTextRange(ts.createPropertyAccess(left, right), node); + } + else { + return ts.getMutableClone(node); + } + } + ts.createExpressionFromEntityName = createExpressionFromEntityName; + function createExpressionForPropertyName(memberName) { + if (ts.isIdentifier(memberName)) { + return ts.createLiteral(memberName); + } + else if (ts.isComputedPropertyName(memberName)) { + return ts.getMutableClone(memberName.expression); + } + else { + return ts.getMutableClone(memberName); + } + } + ts.createExpressionForPropertyName = createExpressionForPropertyName; + function createExpressionForObjectLiteralElementLike(node, property, receiver) { + switch (property.kind) { + case 152: + case 153: + return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); + case 260: + return createExpressionForPropertyAssignment(property, receiver); + case 261: + return createExpressionForShorthandPropertyAssignment(property, receiver); + case 150: + return createExpressionForMethodDeclaration(property, receiver); + } + } + ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike; + function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { + var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + if (property === firstAccessor) { + var properties_1 = []; + if (getAccessor) { + var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body); + ts.setTextRange(getterFunction, getAccessor); + ts.setOriginalNode(getterFunction, getAccessor); + var getter = ts.createPropertyAssignment("get", getterFunction); + properties_1.push(getter); + } + if (setAccessor) { + var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body); + ts.setTextRange(setterFunction, setAccessor); + ts.setOriginalNode(setterFunction, setAccessor); + var setter = ts.createPropertyAssignment("set", setterFunction); + properties_1.push(setter); + } + properties_1.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_1.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + receiver, + createExpressionForPropertyName(property.name), + ts.createObjectLiteral(properties_1, multiLine) + ]), firstAccessor); + return ts.aggregateTransformFlags(expression); + } + return undefined; + } + function createExpressionForPropertyAssignment(property, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer), property), property)); + } + function createExpressionForShorthandPropertyAssignment(property, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), ts.getSynthesizedClone(property.name)), property), property)); + } + function createExpressionForMethodDeclaration(method, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body), method), method)), method), method)); + } + function getLocalName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 16384); + } + ts.getLocalName = getLocalName; + function isLocalName(node) { + return (ts.getEmitFlags(node) & 16384) !== 0; + } + ts.isLocalName = isLocalName; + function getExportName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 8192); + } + ts.getExportName = getExportName; + function isExportName(node) { + return (ts.getEmitFlags(node) & 8192) !== 0; + } + ts.isExportName = isExportName; + function getDeclarationName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps); + } + ts.getDeclarationName = getDeclarationName; + function getName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { + var name = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); + if (!allowSourceMaps) + emitFlags |= 48; + if (!allowComments) + emitFlags |= 1536; + if (emitFlags) + ts.setEmitFlags(name, emitFlags); + return name; + } + return ts.getGeneratedNameForNode(node); + } + function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { + if (ns && ts.hasModifier(node, 1)) { + return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); + } + return getExportName(node, allowComments, allowSourceMaps); + } + ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; + function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { + var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name)); + ts.setTextRange(qualifiedName, name); + var emitFlags; + if (!allowSourceMaps) + emitFlags |= 48; + if (!allowComments) + emitFlags |= 1536; + if (emitFlags) + ts.setEmitFlags(qualifiedName, emitFlags); + return qualifiedName; + } + ts.getNamespaceMemberName = getNamespaceMemberName; + function convertToFunctionBody(node, multiLine) { + return ts.isBlock(node) ? node : ts.setTextRange(ts.createBlock([ts.setTextRange(ts.createReturn(node), node)], multiLine), node); + } + ts.convertToFunctionBody = convertToFunctionBody; + function isUseStrictPrologue(node) { + return node.expression.text === "use strict"; + } + function addPrologueDirectives(target, source, ensureUseStrict, visitor) { + ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); + var foundUseStrict = false; + var statementOffset = 0; + var numStatements = source.length; + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + } + target.push(statement); + } + else { + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (ts.getEmitFlags(statement) & 524288) { + target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); + } + else { + break; + } + statementOffset++; + } + return statementOffset; + } + ts.addPrologueDirectives = addPrologueDirectives; + function startsWithUseStrict(statements) { + var firstStatement = ts.firstOrUndefined(statements); + return firstStatement !== undefined + && ts.isPrologueDirective(firstStatement) + && isUseStrictPrologue(firstStatement); + } + ts.startsWithUseStrict = startsWithUseStrict; + function ensureUseStrict(statements) { + var foundUseStrict = false; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + break; + } + } + else { + break; + } + } + if (!foundUseStrict) { + return ts.setTextRange(ts.createNodeArray([ + startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) + ].concat(statements)), statements); + } + return statements; + } + ts.ensureUseStrict = ensureUseStrict; + function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { + var skipped = skipPartiallyEmittedExpressions(operand); + if (skipped.kind === 184) { + return operand; + } + return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) + ? ts.createParen(operand) + : operand; + } + ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; + function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { + var binaryOperatorPrecedence = ts.getOperatorPrecedence(193, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(193, binaryOperator); + var emittedOperand = skipPartiallyEmittedExpressions(operand); + var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); + switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { + case -1: + if (!isLeftSideOfBinary + && binaryOperatorAssociativity === 1 + && operand.kind === 196) { + return false; + } + return true; + case 1: + return false; + case 0: + if (isLeftSideOfBinary) { + return binaryOperatorAssociativity === 1; + } + else { + if (ts.isBinaryExpression(emittedOperand) + && emittedOperand.operatorToken.kind === binaryOperator) { + if (operatorHasAssociativeProperty(binaryOperator)) { + return false; + } + if (binaryOperator === 36) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; + if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { + return false; + } + } + } + var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); + return operandAssociativity === 0; + } + } + } + function operatorHasAssociativeProperty(binaryOperator) { + return binaryOperator === 38 + || binaryOperator === 48 + || binaryOperator === 47 + || binaryOperator === 49; + } + function getLiteralKindOfBinaryPlusOperand(node) { + node = skipPartiallyEmittedExpressions(node); + if (ts.isLiteralKind(node.kind)) { + return node.kind; + } + if (node.kind === 193 && node.operatorToken.kind === 36) { + if (node.cachedLiteralKind !== undefined) { + return node.cachedLiteralKind; + } + var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); + var literalKind = ts.isLiteralKind(leftKind) + && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) + ? leftKind + : 0; + node.cachedLiteralKind = literalKind; + return literalKind; + } + return 0; + } + function parenthesizeForConditionalHead(condition) { + var conditionalPrecedence = ts.getOperatorPrecedence(194, 54); + var emittedCondition = skipPartiallyEmittedExpressions(condition); + var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { + return ts.createParen(condition); + } + return condition; + } + ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; + function parenthesizeSubexpressionOfConditionalExpression(e) { + return e.kind === 193 && e.operatorToken.kind === 25 + ? ts.createParen(e) + : e; + } + ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression; + function parenthesizeForNew(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + switch (emittedExpression.kind) { + case 180: + return ts.createParen(expression); + case 181: + return emittedExpression.arguments + ? expression + : ts.createParen(expression); + } + return parenthesizeForAccess(expression); + } + ts.parenthesizeForNew = parenthesizeForNew; + function parenthesizeForAccess(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + if (ts.isLeftHandSideExpression(emittedExpression) + && (emittedExpression.kind !== 181 || emittedExpression.arguments) + && emittedExpression.kind !== 8) { + return expression; + } + return ts.setTextRange(ts.createParen(expression), expression); + } + ts.parenthesizeForAccess = parenthesizeForAccess; + function parenthesizePostfixOperand(operand) { + return ts.isLeftHandSideExpression(operand) + ? operand + : ts.setTextRange(ts.createParen(operand), operand); + } + ts.parenthesizePostfixOperand = parenthesizePostfixOperand; + function parenthesizePrefixOperand(operand) { + return ts.isUnaryExpression(operand) + ? operand + : ts.setTextRange(ts.createParen(operand), operand); + } + ts.parenthesizePrefixOperand = parenthesizePrefixOperand; + function parenthesizeListElements(elements) { + var result; + for (var i = 0; i < elements.length; i++) { + var element = parenthesizeExpressionForList(elements[i]); + if (result !== undefined || element !== elements[i]) { + if (result === undefined) { + result = elements.slice(0, i); + } + result.push(element); + } + } + if (result !== undefined) { + return ts.setTextRange(ts.createNodeArray(result, elements.hasTrailingComma), elements); + } + return elements; + } + ts.parenthesizeListElements = parenthesizeListElements; + function parenthesizeExpressionForList(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); + var commaPrecedence = ts.getOperatorPrecedence(193, 25); + return expressionPrecedence > commaPrecedence + ? expression + : ts.setTextRange(ts.createParen(expression), expression); + } + ts.parenthesizeExpressionForList = parenthesizeExpressionForList; + function parenthesizeExpressionForExpressionStatement(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + if (ts.isCallExpression(emittedExpression)) { + var callee = emittedExpression.expression; + var kind = skipPartiallyEmittedExpressions(callee).kind; + if (kind === 185 || kind === 186) { + var mutableCall = ts.getMutableClone(emittedExpression); + mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); + return recreatePartiallyEmittedExpressions(expression, mutableCall); + } + } + else { + var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; + if (leftmostExpressionKind === 177 || leftmostExpressionKind === 185) { + return ts.setTextRange(ts.createParen(expression), expression); + } + } + return expression; + } + ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; + function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { + if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { + var clone_1 = ts.getMutableClone(originalOuterExpression); + clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); + return clone_1; + } + return newInnerExpression; + } + function getLeftmostExpression(node) { + while (true) { + switch (node.kind) { + case 192: + node = node.operand; + continue; + case 193: + node = node.left; + continue; + case 194: + node = node.condition; + continue; + case 180: + case 179: + case 178: + node = node.expression; + continue; + case 298: + node = node.expression; + continue; + } + return node; + } + } + function parenthesizeConciseBody(body) { + var emittedBody = skipPartiallyEmittedExpressions(body); + if (emittedBody.kind === 177) { + return ts.setTextRange(ts.createParen(body), body); + } + return body; + } + ts.parenthesizeConciseBody = parenthesizeConciseBody; + function skipOuterExpressions(node, kinds) { + if (kinds === void 0) { kinds = 7; } + var previousNode; + do { + previousNode = node; + if (kinds & 1) { + node = skipParentheses(node); + } + if (kinds & 2) { + node = skipAssertions(node); + } + if (kinds & 4) { + node = skipPartiallyEmittedExpressions(node); + } + } while (previousNode !== node); return node; } - ts.setNodeFlags = setNodeFlags; - function setMultiLine(node, multiLine) { - node.multiLine = multiLine; + ts.skipOuterExpressions = skipOuterExpressions; + function skipParentheses(node) { + while (node.kind === 184) { + node = node.expression; + } return node; } - ts.setMultiLine = setMultiLine; - function setHasTrailingComma(nodes, hasTrailingComma) { - nodes.hasTrailingComma = hasTrailingComma; - return nodes; + ts.skipParentheses = skipParentheses; + function skipAssertions(node) { + while (ts.isAssertionExpression(node)) { + node = node.expression; + } + return node; } - ts.setHasTrailingComma = setHasTrailingComma; + ts.skipAssertions = skipAssertions; + function skipPartiallyEmittedExpressions(node) { + while (node.kind === 298) { + node = node.expression; + } + return node; + } + ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; + function startOnNewLine(node) { + node.startsOnNewLine = true; + return node; + } + ts.startOnNewLine = startOnNewLine; + function getExternalHelpersModuleName(node) { + var parseNode = ts.getOriginalNode(node, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return emitNode && emitNode.externalHelpersModuleName; + } + ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions) { + if (compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { + var externalHelpersModuleName = getExternalHelpersModuleName(node); + if (externalHelpersModuleName) { + return externalHelpersModuleName; + } + var helpers = ts.getEmitHelpers(node); + if (helpers) { + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var parseNode = ts.getOriginalNode(node, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = ts.createUniqueName(ts.externalHelpersModuleNameText)); + } + } + } + } + } + ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_9 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 236 && node.importClause) { - return getGeneratedNameForNode(node); + if (node.kind === 237 && node.importClause) { + return ts.getGeneratedNameForNode(node); } - if (node.kind === 242 && node.moduleSpecifier) { - return getGeneratedNameForNode(node); + if (node.kind === 243 && node.moduleSpecifier) { + return ts.getGeneratedNameForNode(node); } return undefined; } @@ -10926,26 +11230,24 @@ var ts; if (moduleName.kind === 9) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) - || getSynthesizedClone(moduleName); + || ts.getSynthesizedClone(moduleName); } return undefined; } ts.getExternalModuleNameLiteral = getExternalModuleNameLiteral; function tryRenameExternalModule(moduleName, sourceFile) { - if (sourceFile.renamedDependencies && ts.hasProperty(sourceFile.renamedDependencies, moduleName.text)) { - return createLiteral(sourceFile.renamedDependencies[moduleName.text]); - } - return undefined; + var rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text); + return rename && ts.createLiteral(rename); } function tryGetModuleNameFromFile(file, host, options) { if (!file) { return undefined; } if (file.moduleName) { - return createLiteral(file.moduleName); + return ts.createLiteral(file.moduleName); } if (!ts.isDeclarationFile(file) && (options.out || options.outFile)) { - return createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); + return ts.createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); } return undefined; } @@ -10979,11 +11281,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 258: - return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 259: - return bindingElement.name; case 260: + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); + case 261: + return bindingElement.name; + case 262: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -10999,11 +11301,11 @@ var ts; ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 144: - case 174: + case 145: + case 175: return bindingElement.dotDotDotToken; - case 196: - case 260: + case 197: + case 262: return bindingElement; } return undefined; @@ -11011,7 +11313,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 174: + case 175: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -11019,7 +11321,7 @@ var ts; : propertyName; } break; - case 258: + case 260: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -11027,7 +11329,7 @@ var ts; : propertyName; } break; - case 260: + case 262: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -11041,11 +11343,11 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 172: case 173: - case 175: - return name.elements; + case 174: case 176: + return name.elements; + case 177: return name.properties; } } @@ -11054,10 +11356,12 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpread(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpread(element.name), element), element); } var expression = convertToAssignmentElementTarget(element.name); - return element.initializer ? setOriginalNode(createAssignment(expression, element.initializer, element), element) : expression; + return element.initializer + ? ts.setOriginalNode(ts.setTextRange(ts.createAssignment(expression, element.initializer), element), element) + : expression; } ts.Debug.assertNode(element, ts.isExpression); return element; @@ -11067,14 +11371,14 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpreadAssignment(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpreadAssignment(element.name), element), element); } if (element.propertyName) { var expression = convertToAssignmentElementTarget(element.name); - return setOriginalNode(createPropertyAssignment(element.propertyName, element.initializer ? createAssignment(expression, element.initializer) : expression, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createPropertyAssignment(element.propertyName, element.initializer ? ts.createAssignment(expression, element.initializer) : expression), element), element); } ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createShorthandPropertyAssignment(element.name, element.initializer, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createShorthandPropertyAssignment(element.name, element.initializer), element), element); } ts.Debug.assertNode(element, ts.isObjectLiteralElementLike); return element; @@ -11082,18 +11386,18 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 173: - case 175: - return convertToArrayAssignmentPattern(node); - case 172: + case 174: case 176: + return convertToArrayAssignmentPattern(node); + case 173: + case 177: return convertToObjectAssignmentPattern(node); } } ts.convertToAssignmentPattern = convertToAssignmentPattern; function convertToObjectAssignmentPattern(node) { if (ts.isObjectBindingPattern(node)) { - return setOriginalNode(createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isObjectLiteralExpression); return node; @@ -11101,7 +11405,7 @@ var ts; ts.convertToObjectAssignmentPattern = convertToObjectAssignmentPattern; function convertToArrayAssignmentPattern(node) { if (ts.isArrayBindingPattern(node)) { - return setOriginalNode(createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isArrayLiteralExpression); return node; @@ -11117,30 +11421,30 @@ var ts; ts.convertToAssignmentElementTarget = convertToAssignmentElementTarget; function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) { var externalImports = []; - var exportSpecifiers = ts.createMap(); - var exportedBindings = ts.createMap(); + var exportSpecifiers = ts.createMultiMap(); + var exportedBindings = []; var uniqueExports = ts.createMap(); var exportedNames; var hasExportDefault = false; var exportEquals = undefined; var hasExportStarsToExportValues = false; var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions); - var externalHelpersImportDeclaration = externalHelpersModuleName && createImportDeclaration(undefined, undefined, createImportClause(undefined, createNamespaceImport(externalHelpersModuleName)), createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); if (externalHelpersImportDeclaration) { externalImports.push(externalHelpersImportDeclaration); } for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 236: + case 237: externalImports.push(node); break; - case 235: - if (node.moduleReference.kind === 246) { + case 236: + if (node.moduleReference.kind === 247) { externalImports.push(node); } break; - case 242: + case 243: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -11153,26 +11457,26 @@ var ts; else { for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - if (!uniqueExports[specifier.name.text]) { - var name_10 = specifier.propertyName || specifier.name; - ts.multiMapAdd(exportSpecifiers, name_10.text, specifier); - var decl = resolver.getReferencedImportDeclaration(name_10) - || resolver.getReferencedValueDeclaration(name_10); + if (!uniqueExports.get(specifier.name.text)) { + var name = specifier.propertyName || specifier.name; + exportSpecifiers.add(name.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); if (decl) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); } - uniqueExports[specifier.name.text] = true; + uniqueExports.set(specifier.name.text, true); exportedNames = ts.append(exportedNames, specifier.name); } } } break; - case 241: + case 242: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 206: + case 207: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -11180,38 +11484,38 @@ var ts; } } break; - case 226: - if (ts.hasModifier(node, 1)) { - if (ts.hasModifier(node, 512)) { - if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); - hasExportDefault = true; - } - } - else { - var name_11 = node.name; - if (!uniqueExports[name_11.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_11); - uniqueExports[name_11.text] = true; - exportedNames = ts.append(exportedNames, name_11); - } - } - } - break; case 227: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { - var name_12 = node.name; - if (!uniqueExports[name_12.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_12); - uniqueExports[name_12.text] = true; - exportedNames = ts.append(exportedNames, name_12); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); + } + } + } + break; + case 228: + if (ts.hasModifier(node, 1)) { + if (ts.hasModifier(node, 512)) { + if (!hasExportDefault) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + hasExportDefault = true; + } + } + else { + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } @@ -11231,13 +11535,23 @@ var ts; } } else if (!ts.isGeneratedIdentifier(decl.name)) { - if (!uniqueExports[decl.name.text]) { - uniqueExports[decl.name.text] = true; + if (!uniqueExports.get(decl.name.text)) { + uniqueExports.set(decl.name.text, true); exportedNames = ts.append(exportedNames, decl.name); } } return exportedNames; } + function multiMapSparseArrayAdd(map, key, value) { + var values = map[key]; + if (values) { + values.push(value); + } + else { + map[key] = values = [value]; + } + return values; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -11246,13 +11560,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 262) { + if (kind === 264) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 141) { + else if (kind < 142) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -11288,28 +11602,29 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 141: + case 142: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 143: + case 144: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || + visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 259: + case 261: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 260: + case 262: return visitNode(cbNode, node.expression); - case 144: + case 145: + case 148: case 147: - case 146: - case 258: - case 224: - case 174: + case 260: + case 225: + case 175: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -11318,24 +11633,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 158: case 159: - case 153: + case 160: case 154: case 155: + case 156: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 184: - case 226: + case 153: case 185: + case 227: + case 186: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -11346,174 +11661,167 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 157: + case 158: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 156: + case 157: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 160: - return visitNode(cbNode, node.exprName); case 161: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 162: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 163: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 164: + return visitNodes(cbNodes, node.elementTypes); case 165: - return visitNodes(cbNodes, node.types); case 166: - case 168: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); + case 167: case 169: + return visitNode(cbNode, node.type); + case 170: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 170: + case 171: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 171: - return visitNode(cbNode, node.literal); case 172: + return visitNode(cbNode, node.literal); case 173: - return visitNodes(cbNodes, node.elements); - case 175: + case 174: return visitNodes(cbNodes, node.elements); case 176: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 177: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.name); + return visitNodes(cbNodes, node.properties); case 178: return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); + visitNode(cbNode, node.name); case 179: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); case 180: + case 181: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 181: + case 182: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 182: + case 183: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 183: - return visitNode(cbNode, node.expression); - case 186: + case 184: return visitNode(cbNode, node.expression); case 187: return visitNode(cbNode, node.expression); case 188: return visitNode(cbNode, node.expression); - case 190: - return visitNode(cbNode, node.operand); - case 195: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 189: return visitNode(cbNode, node.expression); case 191: return visitNode(cbNode, node.operand); + case 196: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 190: + return visitNode(cbNode, node.expression); case 192: + return visitNode(cbNode, node.operand); + case 193: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 200: + case 201: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 201: - return visitNode(cbNode, node.expression); case 202: + return visitNode(cbNode, node.expression); + case 203: return visitNode(cbNode, node.name); - case 193: + case 194: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 196: + case 197: return visitNode(cbNode, node.expression); - case 205: - case 232: + case 206: + case 233: return visitNodes(cbNodes, node.statements); - case 262: + case 264: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 206: + case 207: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 225: + case 226: return visitNodes(cbNodes, node.declarations); - case 208: - return visitNode(cbNode, node.expression); case 209: + return visitNode(cbNode, node.expression); + case 210: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 210: + case 211: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 211: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 212: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 213: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 214: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 215: - case 216: - return visitNode(cbNode, node.label); - case 217: - return visitNode(cbNode, node.expression); - case 218: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 216: + case 217: + return visitNode(cbNode, node.label); + case 218: + return visitNode(cbNode, node.expression); case 219: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 220: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 233: + case 234: return visitNodes(cbNodes, node.clauses); - case 254: + case 256: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 255: + case 257: return visitNodes(cbNodes, node.statements); - case 220: + case 221: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 221: - return visitNode(cbNode, node.expression); case 222: + return visitNode(cbNode, node.expression); + case 223: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 257: + case 259: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 145: + case 146: return visitNode(cbNode, node.expression); - case 227: - case 197: - 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 228: + case 198: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -11525,144 +11833,153 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 230: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 261: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 231: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 263: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 232: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 235: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 236: + case 237: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 237: + case 238: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 234: - return visitNode(cbNode, node.name); - case 238: + case 235: return visitNode(cbNode, node.name); case 239: - case 243: + return visitNode(cbNode, node.name); + case 240: + case 244: return visitNodes(cbNodes, node.elements); - case 242: + case 243: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 240: - case 244: + case 241: + case 245: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 241: + case 242: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 194: + case 195: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 203: + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 142: + case 143: return visitNode(cbNode, node.expression); - case 256: + case 258: return visitNodes(cbNodes, node.types); - case 199: + case 200: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 246: - return visitNode(cbNode, node.expression); - case 245: - return visitNodes(cbNodes, node.decorators); case 247: + return visitNode(cbNode, node.expression); + case 246: + return visitNodes(cbNodes, node.decorators); + case 248: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 248: case 249: + case 250: return visitNode(cbNode, node.tagName) || - visitNodes(cbNodes, node.attributes); - case 251: + visitNode(cbNode, node.attributes); + case 253: + return visitNodes(cbNodes, node.properties); + case 252: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 252: + case 254: return visitNode(cbNode, node.expression); - case 253: + case 255: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 250: + case 251: return visitNode(cbNode, node.tagName); - case 263: - return visitNode(cbNode, node.type); - case 267: - return visitNodes(cbNodes, node.types); - case 268: - return visitNodes(cbNodes, node.types); case 266: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.type); case 270: - return visitNode(cbNode, node.type); - case 269: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); case 271: - return visitNode(cbNode, node.literal); + return visitNodes(cbNodes, node.types); + case 269: + return visitNode(cbNode, node.elementType); case 273: + return visitNode(cbNode, node.type); + case 272: + return visitNode(cbNode, node.type); + case 274: + return visitNode(cbNode, node.literal); + case 276: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 274: - return visitNode(cbNode, node.type); - case 275: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 276: - return visitNode(cbNode, node.type); case 277: return visitNode(cbNode, node.type); case 278: - return visitNode(cbNode, node.type); - case 272: - return visitNode(cbNode, node.name) || + return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); case 279: - return visitNodes(cbNodes, node.tags); + return visitNode(cbNode, node.type); + case 280: + return visitNode(cbNode, node.type); + case 281: + return visitNode(cbNode, node.type); + case 275: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.type); case 282: + return visitNodes(cbNodes, node.tags); + case 285: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 283: + case 286: + return visitNode(cbNode, node.typeExpression); + case 287: return visitNode(cbNode, node.typeExpression); case 284: return visitNode(cbNode, node.typeExpression); - case 281: - return visitNode(cbNode, node.typeExpression); - case 285: + case 288: return visitNodes(cbNodes, node.typeParameters); - case 286: + case 289: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 288: + case 291: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 287: + case 290: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 295: + case 298: return visitNode(cbNode, node.expression); - case 289: + case 292: return visitNode(cbNode, node.literal); } } @@ -11826,7 +12143,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(262, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(264, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -12053,7 +12370,7 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 141 ? new NodeConstructor(kind, pos, pos) : + return kind >= 142 ? new NodeConstructor(kind, pos, pos) : kind === 70 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } @@ -12090,7 +12407,11 @@ var ts; } function internIdentifier(text) { text = ts.escapeIdentifier(text); - return identifiers[text] || (identifiers[text] = text); + var identifier = identifiers.get(text); + if (identifier === undefined) { + identifiers.set(text, identifier = text); + } + return identifier; } function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; @@ -12135,7 +12456,7 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(142); + var node = createNode(143); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); @@ -12440,14 +12761,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 150: - case 155: case 151: + case 156: case 152: - case 147: - case 204: + case 153: + case 148: + case 205: return true; - case 149: + case 150: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 70 && methodDeclaration.name.originalKeywordKind === 122; @@ -12459,8 +12780,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 254: - case 255: + case 256: + case 257: return true; } } @@ -12469,65 +12790,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 226: + case 227: + case 207: case 206: - case 205: + case 210: case 209: - case 208: - case 221: + case 222: + case 218: + case 220: case 217: - case 219: case 216: + case 214: case 215: case 213: - case 214: case 212: - case 211: - case 218: - case 207: - case 222: - case 220: - case 210: + case 219: + case 208: case 223: + case 221: + case 211: + case 224: + case 237: case 236: - case 235: + case 243: case 242: - case 241: - case 231: - case 227: + case 232: case 228: - case 230: case 229: + case 231: + case 230: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 261; + return node.kind === 263; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 154: - case 148: case 155: - case 146: - case 153: + case 149: + case 156: + case 147: + case 154: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 224) { + if (node.kind !== 225) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 144) { + if (node.kind !== 145) { return false; } var parameter = node; @@ -12623,7 +12944,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(22)) { - var node = createNode(141, entity.pos); + var node = createNode(142, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -12640,7 +12961,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(194); + var template = createNode(195); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -12652,7 +12973,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(203); + var span = createNode(204); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -12700,7 +13021,7 @@ var ts; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(157, typeName.pos); + var node = createNode(158, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token() === 26) { node.typeArguments = parseBracketedList(19, parseType, 26, 28); @@ -12709,24 +13030,24 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(156, lhs.pos); + var node = createNode(157, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(167); + var node = createNode(168); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(160); + var node = createNode(161); parseExpected(102); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(143); + var node = createNode(144); node.name = parseIdentifier(); if (parseOptional(84)) { if (isStartOfType() || !isStartOfExpression()) { @@ -12736,6 +13057,9 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } + if (parseOptional(57)) { + node.default = parseType(); + } return finishNode(node); } function parseTypeParameters() { @@ -12753,7 +13077,7 @@ var ts; return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; } function parseParameter() { - var node = createNode(144); + var node = createNode(145); if (token() === 98) { node.name = createIdentifier(true, undefined); node.type = parseParameterType(); @@ -12813,7 +13137,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 154) { + if (kind === 155) { parseExpected(93); } fillSignature(55, false, false, false, node); @@ -12853,7 +13177,7 @@ var ts; return token() === 55 || token() === 25 || token() === 21; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(155, fullStart); + var node = createNode(156, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.parameters = parseBracketedList(16, parseParameter, 20, 21); @@ -12865,7 +13189,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(54); if (token() === 18 || token() === 26) { - var method = createNode(148, fullStart); + var method = createNode(149, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; @@ -12874,7 +13198,7 @@ var ts; return addJSDocComment(finishNode(method)); } else { - var property = createNode(146, fullStart); + var property = createNode(147, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; @@ -12914,10 +13238,10 @@ var ts; } function parseTypeMember() { if (token() === 18 || token() === 26) { - return parseSignatureMember(153); + return parseSignatureMember(154); } if (token() === 93 && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(154); + return parseSignatureMember(155); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -12931,7 +13255,7 @@ var ts; return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(161); + var node = createNode(162); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -12954,14 +13278,14 @@ var ts; return token() === 20 && nextTokenIsIdentifier() && nextToken() === 91; } function parseMappedTypeParameter() { - var node = createNode(143); + var node = createNode(144); node.name = parseIdentifier(); parseExpected(91); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(170); + var node = createNode(171); parseExpected(16); node.readonlyToken = parseOptionalToken(130); parseExpected(20); @@ -12974,12 +13298,12 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(163); + var node = createNode(164); node.elementTypes = parseBracketedList(20, parseType, 20, 21); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(166); + var node = createNode(167); parseExpected(18); node.type = parseType(); parseExpected(19); @@ -12987,7 +13311,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 159) { + if (kind === 160) { parseExpected(93); } fillSignature(35, false, false, false, node); @@ -12998,7 +13322,7 @@ var ts; return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(171); + var node = createNode(172); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -13009,12 +13333,13 @@ var ts; function parseNonArrayType() { switch (token()) { case 118: - case 134: + case 135: case 132: case 121: - case 135: - case 137: + case 136: + case 138: case 129: + case 133: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: @@ -13051,12 +13376,12 @@ var ts; function isStartOfType() { switch (token()) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: case 104: - case 137: + case 138: case 94: case 98: case 102: @@ -13071,6 +13396,7 @@ var ts; case 8: case 100: case 85: + case 133: return true; case 37: return lookAhead(nextTokenIsNumericLiteral); @@ -13088,14 +13414,14 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { if (isStartOfType()) { - var node = createNode(169, type.pos); + var node = createNode(170, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(21); type = finishNode(node); } else { - var node = createNode(162, type.pos); + var node = createNode(163, type.pos); node.elementType = type; parseExpected(21); type = finishNode(node); @@ -13104,7 +13430,7 @@ var ts; return type; } function parseTypeOperator(operator) { - var node = createNode(168); + var node = createNode(169); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); @@ -13133,10 +13459,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(165, parseTypeOperatorOrHigher, 47); + return parseUnionOrIntersectionType(166, parseTypeOperatorOrHigher, 47); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(164, parseIntersectionTypeOrHigher, 48); + return parseUnionOrIntersectionType(165, parseIntersectionTypeOrHigher, 48); } function isStartOfFunctionType() { if (token() === 26) { @@ -13182,7 +13508,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(156, typePredicateVariable.pos); + var node = createNode(157, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -13203,10 +13529,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(158); + return parseFunctionOrConstructorType(159); } if (token() === 93) { - return parseFunctionOrConstructorType(159); + return parseFunctionOrConstructorType(160); } return parseUnionTypeOrHigher(); } @@ -13325,7 +13651,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(195); + var node = createNode(196); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 38 || isStartOfExpression())) { @@ -13341,13 +13667,13 @@ var ts; ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(185, asyncModifier.pos); + node = createNode(186, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(185, identifier.pos); + node = createNode(186, identifier.pos); } - var parameter = createNode(144, identifier.pos); + var parameter = createNode(145, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); @@ -13481,7 +13807,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(185); + var node = createNode(186); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); fillSignature(55, false, isAsync, !allowAmbiguity, node); @@ -13513,7 +13839,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(193, leftOperand.pos); + var node = createNode(194, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -13526,7 +13852,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 || t === 140; + return t === 91 || t === 141; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -13604,43 +13930,43 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(192, left.pos); + var node = createNode(193, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(200, left.pos); + var node = createNode(201, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(190); + var node = createNode(191); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(186); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(187); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(188); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(189); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { if (token() === 120) { if (inAwaitContext()) { @@ -13651,7 +13977,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(189); + var node = createNode(190); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -13667,7 +13993,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 182) { + if (simpleUnaryExpression.kind === 183) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -13720,7 +14046,7 @@ var ts; } function parseIncrementExpression() { if (token() === 42 || token() === 43) { - var node = createNode(190); + var node = createNode(191); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -13732,7 +14058,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(191, expression.pos); + var node = createNode(192, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -13755,7 +14081,7 @@ var ts; if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(177, expression.pos); + var node = createNode(178, expression.pos); node.expression = expression; parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -13777,8 +14103,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 249) { - var node = createNode(247, opening.pos); + if (opening.kind === 250) { + var node = createNode(248, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -13788,14 +14114,14 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 248); + ts.Debug.assert(opening.kind === 249); result = opening; } if (inExpressionContext && token() === 26) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(192, result.pos); + var badNode = createNode(193, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -13841,14 +14167,19 @@ var ts; parsingContext = saveParsingContext; return result; } + function parseJsxAttributes() { + var jsxAttributes = createNode(253); + jsxAttributes.properties = parseList(13, parseJsxAttribute); + return finishNode(jsxAttributes); + } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); parseExpected(26); var tagName = parseJsxElementName(); - var attributes = parseList(13, parseJsxAttribute); + var attributes = parseJsxAttributes(); var node; if (token() === 28) { - node = createNode(249, fullStart); + node = createNode(250, fullStart); scanJsxText(); } else { @@ -13860,7 +14191,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(248, fullStart); + node = createNode(249, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -13871,7 +14202,7 @@ var ts; var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22)) { - var propertyAccess = createNode(177, expression.pos); + var propertyAccess = createNode(178, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -13879,7 +14210,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(253); + var node = createNode(255); parseExpected(16); if (token() !== 17) { node.dotDotDotToken = parseOptionalToken(23); @@ -13899,7 +14230,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(251); + var node = createNode(252); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -13914,7 +14245,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(252); + var node = createNode(254); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -13922,7 +14253,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(250); + var node = createNode(251); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -13935,7 +14266,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(182); + var node = createNode(183); parseExpected(26); node.type = parseType(); parseExpected(28); @@ -13946,7 +14277,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(177, expression.pos); + var propertyAccess = createNode(178, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -13954,13 +14285,13 @@ var ts; } if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(201, expression.pos); + var nonNullExpression = createNode(202, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(20)) { - var indexedAccess = createNode(178, expression.pos); + var indexedAccess = createNode(179, expression.pos); indexedAccess.expression = expression; if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -13974,7 +14305,7 @@ var ts; continue; } if (token() === 12 || token() === 13) { - var tagExpression = createNode(181, expression.pos); + var tagExpression = createNode(182, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 ? parseLiteralNode() @@ -13993,7 +14324,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(179, expression.pos); + var callExpr = createNode(180, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -14001,7 +14332,7 @@ var ts; continue; } else if (token() === 18) { - var callExpr = createNode(179, expression.pos); + var callExpr = createNode(180, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -14096,28 +14427,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(183); + var node = createNode(184); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(196); + var node = createNode(197); parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 ? parseSpreadElement() : - token() === 25 ? createNode(198) : + token() === 25 ? createNode(199) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(175); + var node = createNode(176); parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14128,18 +14459,18 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(124)) { - return parseAccessorDeclaration(151, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(133)) { return parseAccessorDeclaration(152, fullStart, decorators, modifiers); } + else if (parseContextualModifier(134)) { + return parseAccessorDeclaration(153, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23); if (dotDotDotToken) { - var spreadElement = createNode(260, fullStart); + var spreadElement = createNode(262, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -14158,7 +14489,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(259, fullStart); + var shorthandDeclaration = createNode(261, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -14169,7 +14500,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(258, fullStart); + var propertyAssignment = createNode(260, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -14179,7 +14510,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(176); + var node = createNode(177); parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14193,7 +14524,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(184); + var node = createNode(185); node.modifiers = parseModifiers(); parseExpected(88); node.asteriskToken = parseOptionalToken(38); @@ -14218,12 +14549,12 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(93); if (parseOptional(22)) { - var node_1 = createNode(202, fullStart); + var node_1 = createNode(203, fullStart); node_1.keywordToken = 93; node_1.name = parseIdentifierName(); return finishNode(node_1); } - var node = createNode(180, fullStart); + var node = createNode(181, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18) { @@ -14232,7 +14563,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(205); + var node = createNode(206); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14263,12 +14594,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(207); + var node = createNode(208); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(209); + var node = createNode(210); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14278,7 +14609,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(210); + var node = createNode(211); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -14289,7 +14620,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(211); + var node = createNode(212); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14312,21 +14643,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(213, pos); + var forInStatement = createNode(214, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(140)) { - var forOfStatement = createNode(214, pos); + else if (parseOptional(141)) { + var forOfStatement = createNode(215, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(212, pos); + var forStatement = createNode(213, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -14344,7 +14675,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 216 ? 71 : 76); + parseExpected(kind === 217 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -14352,7 +14683,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(217); + var node = createNode(218); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -14361,7 +14692,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(218); + var node = createNode(219); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14370,7 +14701,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(254); + var node = createNode(256); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -14378,7 +14709,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(255); + var node = createNode(257); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -14388,12 +14719,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(219); + var node = createNode(220); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(233, scanner.getStartPos()); + var caseBlock = createNode(234, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -14401,14 +14732,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(221); + var node = createNode(222); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(222); + var node = createNode(223); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -14419,7 +14750,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(257); + var result = createNode(259); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -14429,7 +14760,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(223); + var node = createNode(224); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -14438,13 +14769,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(220, fullStart); + var labeledStatement = createNode(221, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(208, fullStart); + var expressionStatement = createNode(209, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -14473,7 +14804,7 @@ var ts; case 82: return true; case 108: - case 136: + case 137: return nextTokenIsIdentifierOnSameLine(); case 127: case 128: @@ -14490,7 +14821,7 @@ var ts; return false; } continue; - case 139: + case 140: nextToken(); return token() === 16 || token() === 70 || token() === 83; case 90: @@ -14550,8 +14881,8 @@ var ts; case 108: case 127: case 128: - case 136: - case 139: + case 137: + case 140: return true; case 113: case 111: @@ -14596,9 +14927,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(215); - case 71: return parseBreakOrContinueStatement(216); + case 71: + return parseBreakOrContinueStatement(217); case 95: return parseReturnStatement(); case 106: @@ -14617,7 +14948,7 @@ var ts; return parseDeclaration(); case 119: case 108: - case 136: + case 137: case 127: case 128: case 123: @@ -14631,7 +14962,7 @@ var ts; case 116: case 114: case 130: - case 139: + case 140: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -14654,11 +14985,11 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 108: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 136: + case 137: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 82: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 139: + case 140: case 127: case 128: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -14677,7 +15008,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(245, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(246, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -14698,16 +15029,16 @@ var ts; } function parseArrayBindingElement() { if (token() === 25) { - return createNode(198); + return createNode(199); } - var node = createNode(174); + var node = createNode(175); node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(174); + var node = createNode(175); node.dotDotDotToken = parseOptionalToken(23); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -14723,14 +15054,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(172); + var node = createNode(173); parseExpected(16); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(173); + var node = createNode(174); parseExpected(20); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(21); @@ -14749,7 +15080,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(224); + var node = createNode(225); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -14758,7 +15089,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(225); + var node = createNode(226); switch (token()) { case 103: break; @@ -14772,7 +15103,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token() === 140 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 141 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -14787,7 +15118,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(206, fullStart); + var node = createNode(207, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -14795,7 +15126,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -14808,7 +15139,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(150, pos); + var node = createNode(151, pos); node.decorators = decorators; node.modifiers = modifiers; parseExpected(122); @@ -14817,7 +15148,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(149, fullStart); + var method = createNode(150, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -14830,7 +15161,7 @@ var ts; return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(147, fullStart); + var property = createNode(148, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -14900,7 +15231,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 133 || idToken === 124) { + if (!ts.isKeyword(idToken) || idToken === 134 || idToken === 124) { return true; } switch (token()) { @@ -14923,7 +15254,7 @@ var ts; if (!parseOptional(56)) { break; } - var decorator = createNode(145, decoratorStart); + var decorator = createNode(146, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -14980,7 +15311,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(204); + var result = createNode(205); nextToken(); return finishNode(result); } @@ -15005,16 +15336,16 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_13 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_13, undefined); + var name = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 197); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 198); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 227); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 228); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -15049,7 +15380,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 || token() === 107) { - var node = createNode(256); + var node = createNode(258); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -15058,7 +15389,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(199); + var node = createNode(200); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26) { node.typeArguments = parseBracketedList(19, parseType, 26, 28); @@ -15072,7 +15403,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228, fullStart); + var node = createNode(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -15083,10 +15414,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(136); + parseExpected(137); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57); @@ -15095,13 +15426,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(261, scanner.getStartPos()); + var node = createNode(263, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -15116,7 +15447,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(232, scanner.getStartPos()); + var node = createNode(233, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -15127,7 +15458,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(231, fullStart); + var node = createNode(232, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -15139,10 +15470,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(231, fullStart); + var node = createNode(232, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 139) { + if (token() === 140) { node.name = parseIdentifier(); node.flags |= 512; } @@ -15159,7 +15490,7 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 139) { + if (token() === 140) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } else if (parseOptional(128)) { @@ -15184,7 +15515,7 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(234, fullStart); + var exportDeclaration = createNode(235, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); @@ -15199,8 +15530,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 && token() !== 138) { - var importEqualsDeclaration = createNode(235, fullStart); + if (token() !== 25 && token() !== 139) { + var importEqualsDeclaration = createNode(236, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -15210,27 +15541,27 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(236, fullStart); + var importDeclaration = createNode(237, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || token() === 38 || token() === 16) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(138); + parseExpected(139); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(237, fullStart); + var importClause = createNode(238, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(239); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(240); } return finishNode(importClause); } @@ -15240,7 +15571,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(246); + var node = createNode(247); parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); @@ -15258,7 +15589,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(238); + var namespaceImport = createNode(239); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -15266,14 +15597,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 239 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 240 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(244); + return parseImportOrExportSpecifier(245); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(240); + return parseImportOrExportSpecifier(241); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -15292,23 +15623,23 @@ var ts; else { node.name = identifierName; } - if (kind === 240 && checkIdentifierIsKeyword) { + if (kind === 241 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(242, fullStart); + var node = createNode(243, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38)) { - parseExpected(138); + parseExpected(139); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(243); - if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(138); + node.exportClause = parseNamedImportsOrExports(244); + if (token() === 139 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(139); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -15316,7 +15647,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(241, fullStart); + var node = createNode(242, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -15395,10 +15726,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 235 && node.moduleReference.kind === 246 - || node.kind === 236 - || node.kind === 241 + || node.kind === 236 && node.moduleReference.kind === 247 + || node.kind === 237 || node.kind === 242 + || node.kind === 243 ? node : undefined; }); @@ -15434,7 +15765,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(263, scanner.getTokenPos()); + var result = createNode(266, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -15445,12 +15776,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(267, type.pos); + var unionType = createNode(270, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(274, type.pos); + var optionalType = createNode(277, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -15461,20 +15792,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(266, type.pos); + var arrayType = createNode(269, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(269, type.pos); + var nullableType = createNode(272, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(270, type.pos); + var nonNullableType = createNode(273, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -15508,14 +15839,15 @@ var ts; case 98: return parseJSDocThisType(); case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: case 104: case 94: - case 137: + case 138: case 129: + case 133: return parseTokenNode(); case 9: case 8: @@ -15526,27 +15858,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(278); + var result = createNode(281); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(277); + var result = createNode(280); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(276); + var result = createNode(279); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(275); + var result = createNode(278); nextToken(); parseExpected(18); result.parameters = parseDelimitedList(23, parseJSDocParameter); @@ -15559,7 +15891,7 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(144); + var parameter = createNode(145); parameter.type = parseJSDocType(); if (parseOptional(57)) { parameter.questionToken = createNode(57); @@ -15567,7 +15899,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(273); + var result = createNode(276); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -15601,24 +15933,24 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(141, left.pos); + var result = createNode(142, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(271); + var result = createNode(274); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(270); + var result = createNode(273); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(268); + var result = createNode(271); nextToken(); result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); @@ -15632,7 +15964,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(267); + var result = createNode(270); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -15648,12 +15980,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(264); + var result = createNode(267); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(289); + var result = createNode(292); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -15666,11 +15998,11 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(265, pos); + var result = createNode(268, pos); return finishNode(result); } else { - var result = createNode(269, pos); + var result = createNode(272, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -15814,7 +16146,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(279, start); + var result = createNode(282, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -15924,7 +16256,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(280, atToken.pos); + var result = createNode(283, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -15979,7 +16311,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(282, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -15990,20 +16322,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283; })) { + if (ts.forEach(tags, function (t) { return t.kind === 286; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283, atToken.pos); + var result = createNode(286, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284; })) { + if (ts.forEach(tags, function (t) { return t.kind === 287; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(284, atToken.pos); + var result = createNode(287, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -16018,7 +16350,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(287, atToken.pos); + var result = createNode(290, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -16027,7 +16359,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(281, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -16036,25 +16368,28 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(286, atToken.pos); + var typedefTag = createNode(289, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); if (typedefTag.fullName) { var rightNode = typedefTag.fullName; - while (rightNode.kind !== 70) { + while (true) { + if (rightNode.kind === 70 || !rightNode.body) { + typedefTag.name = rightNode.kind === 70 ? rightNode : rightNode.name; + break; + } rightNode = rightNode.body; } - typedefTag.name = rightNode; } typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 273) { + if (typeExpression.type.kind === 276) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { - var name_14 = jsDocTypeReference.name; - if (name_14.text === "Object") { + var name = jsDocTypeReference.name; + if (name.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -16068,7 +16403,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(288, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(291, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -16109,7 +16444,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(231, pos); + var jsDocNamespaceNode = createNode(232, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -16153,19 +16488,19 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 285; })) { + if (ts.forEach(tags, function (t) { return t.kind === 288; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); while (true) { - var name_15 = parseJSDocIdentifierName(); + var name = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_15) { + if (!name) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(143, name_15.pos); - typeParameter.name = name_15; + var typeParameter = createNode(144, name.pos); + typeParameter.name = name; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25) { @@ -16176,7 +16511,7 @@ var ts; break; } } - var result = createNode(285, atToken.pos); + var result = createNode(288, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -16495,16 +16830,16 @@ var ts; var ts; (function (ts) { function getModuleInstanceState(node) { - if (node.kind === 228 || node.kind === 229) { + if (node.kind === 229 || node.kind === 230) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 236 || node.kind === 235) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 237 || node.kind === 236) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 232) { + else if (node.kind === 233) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -16520,7 +16855,7 @@ var ts; }); return state_1; } - else if (node.kind === 231) { + else if (node.kind === 232) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -16629,7 +16964,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 231)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 232)) { symbol.valueDeclaration = node; } } @@ -16639,7 +16974,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 142) { + if (node.name.kind === 143) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression)) { return nameExpression.text; @@ -16650,21 +16985,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 150: + case 151: return "__constructor"; - case 158: - case 153: - return "__call"; case 159: case 154: - return "__new"; + return "__call"; + case 160: case 155: + return "__new"; + case 156: return "__index"; - case 242: + case 243: return "__export"; - case 241: + case 242: return node.isExportEquals ? "export=" : "default"; - case 192: + case 193: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -16676,20 +17011,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 226: case 227: + case 228: return ts.hasModifier(node, 512) ? "default" : undefined; - case 275: + case 278: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 144: - ts.Debug.assert(node.parent.kind === 275); + case 145: + ts.Debug.assert(node.parent.kind === 278); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 286: + case 289: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 206) { + if (parentNode && parentNode.kind === 207) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -16712,13 +17047,16 @@ var ts; symbol = createSymbol(0, "__missing"); } else { - symbol = symbolTable[name] || (symbolTable[name] = createSymbol(0, name)); + symbol = symbolTable.get(name); + if (!symbol) { + symbolTable.set(name, symbol = createSymbol(0, name)); + } if (name && (includes & 788448)) { - classifiableNames[name] = name; + classifiableNames.set(name, name); } if (symbol.flags & excludes) { if (symbol.isReplaceableByMethod) { - symbol = symbolTable[name] = createSymbol(0, name); + symbolTable.set(name, symbol = createSymbol(0, name)); } else { if (node.name) { @@ -16733,7 +17071,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 241 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 242 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -16753,7 +17091,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 244 || (node.kind === 235 && hasExportModifier)) { + if (node.kind === 245 || (node.kind === 236 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -16761,7 +17099,7 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 286 && + var isJSDocTypedefInJSDocNamespace = node.kind === 289 && node.name && node.name.kind === 70 && node.name.isInJSDocNamespace; @@ -16822,7 +17160,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 262) { + if (node.kind === 264) { node.flags |= emitFlags; } if (isIIFE) { @@ -16898,64 +17236,64 @@ var ts; return; } switch (node.kind) { - case 211: + case 212: bindWhileStatement(node); break; - case 210: + case 211: bindDoStatement(node); break; - case 212: + case 213: bindForStatement(node); break; - case 213: case 214: + case 215: bindForInOrForOfStatement(node); break; - case 209: + case 210: bindIfStatement(node); break; - case 217: - case 221: + case 218: + case 222: bindReturnOrThrow(node); break; + case 217: case 216: - case 215: bindBreakOrContinueStatement(node); break; - case 222: + case 223: bindTryStatement(node); break; - case 219: + case 220: bindSwitchStatement(node); break; - case 233: + case 234: bindCaseBlock(node); break; - case 254: + case 256: bindCaseClause(node); break; - case 220: + case 221: bindLabeledStatement(node); break; - case 190: + case 191: bindPrefixUnaryExpressionFlow(node); break; - case 191: + case 192: bindPostfixUnaryExpressionFlow(node); break; - case 192: + case 193: bindBinaryExpressionFlow(node); break; - case 186: + case 187: bindDeleteExpressionFlow(node); break; - case 193: + case 194: bindConditionalExpressionFlow(node); break; - case 224: + case 225: bindVariableDeclarationFlow(node); break; - case 179: + case 180: bindCallExpressionFlow(node); break; default: @@ -16967,15 +17305,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 177: + case 178: return isNarrowableReference(expr); - case 179: + case 180: return hasNarrowableArgument(expr); - case 183: + case 184: return isNarrowingExpression(expr.expression); - case 192: + case 193: return isNarrowingBinaryExpression(expr); - case 190: + case 191: return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; @@ -16983,7 +17321,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 || expr.kind === 98 || - expr.kind === 177 && isNarrowableReference(expr.expression); + expr.kind === 178 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -16994,14 +17332,14 @@ var ts; } } } - if (expr.expression.kind === 177 && + if (expr.expression.kind === 178 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 187 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 188 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -17022,9 +17360,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 183: + case 184: return isNarrowableOperand(expr.expression); - case 192: + case 193: switch (expr.operatorToken.kind) { case 57: return isNarrowableOperand(expr.left); @@ -17118,33 +17456,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 209: - case 211: case 210: - return parent.expression === node; case 212: - case 193: + case 211: + return parent.expression === node; + case 213: + case 194: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 183) { + if (node.kind === 184) { node = node.expression; } - else if (node.kind === 190 && node.operator === 50) { + else if (node.kind === 191 && node.operator === 50) { node = node.operand; } else { - return node.kind === 192 && (node.operatorToken.kind === 52 || + return node.kind === 193 && (node.operatorToken.kind === 52 || node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 183 || - node.parent.kind === 190 && + while (node.parent.kind === 184 || + node.parent.kind === 191 && node.parent.operator === 50) { node = node.parent; } @@ -17186,7 +17524,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 220 + var enclosingLabeledStatement = node.parent.kind === 221 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -17221,7 +17559,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 225) { + if (node.initializer.kind !== 226) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -17243,7 +17581,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 217) { + if (node.kind === 218) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -17263,7 +17601,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 216 ? breakTarget : continueTarget; + var flowLabel = node.kind === 217 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -17296,7 +17634,8 @@ var ts; flowAfterCatch = currentFlow; } if (node.finallyBlock) { - addAntecedent(preFinallyLabel, preTryFlow); + var preFinallyFlow = { flags: 2048, antecedent: preTryFlow, lock: {} }; + addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); if (!(currentFlow.flags & 1)) { @@ -17306,6 +17645,11 @@ var ts; : unreachableFlow; } } + if (!(currentFlow.flags & 1)) { + var afterFinallyFlow = { flags: 4096, antecedent: currentFlow }; + preFinallyFlow.lock = afterFinallyFlow; + currentFlow = afterFinallyFlow; + } } else { currentFlow = finishFlowLabel(preFinallyLabel); @@ -17320,7 +17664,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 255; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 257; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -17385,13 +17729,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 210) { + if (!node.statement || node.statement.kind !== 211) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 192 && node.operatorToken.kind === 57) { + if (node.kind === 193 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -17402,10 +17746,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 175) { + else if (node.kind === 176) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 196) { + if (e.kind === 197) { bindAssignmentTargetFlow(e.expression); } else { @@ -17413,16 +17757,16 @@ var ts; } } } - else if (node.kind === 176) { + else if (node.kind === 177) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 258) { + if (p.kind === 260) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 259) { + else if (p.kind === 261) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 260) { + else if (p.kind === 262) { bindAssignmentTargetFlow(p.expression); } } @@ -17478,7 +17822,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 57 && node.left.kind === 178) { + if (operator === 57 && node.left.kind === 179) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -17489,7 +17833,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 177) { + if (node.expression.kind === 178) { bindAssignmentTargetFlow(node.expression); } } @@ -17522,16 +17866,16 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 213 || node.parent.parent.kind === 214) { + if (node.initializer || node.parent.parent.kind === 214 || node.parent.parent.kind === 215) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 183) { + while (expr.kind === 184) { expr = expr.expression; } - if (expr.kind === 184 || expr.kind === 185) { + if (expr.kind === 185 || expr.kind === 186) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -17539,7 +17883,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 177) { + if (node.expression.kind === 178) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -17548,52 +17892,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 197: - case 227: - case 230: - case 176: - case 161: - case 288: - case 271: - return 1; + case 198: case 228: - return 1 | 64; - case 275: case 231: + case 177: + case 162: + case 291: + case 274: + case 253: + return 1; case 229: - case 170: + return 1 | 64; + case 278: + case 232: + case 230: + case 171: return 1 | 32; - case 262: + case 264: return 1 | 4 | 32; - case 149: + case 150: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 150: - case 226: - case 148: case 151: + case 227: + case 149: case 152: case 153: case 154: case 155: - case 158: + case 156: case 159: + case 160: return 1 | 4 | 32 | 8; - case 184: case 185: + case 186: return 1 | 4 | 32 | 8 | 16; - case 232: + case 233: return 4; - case 147: + case 148: return node.initializer ? 4 : 0; - case 257: - case 212: + case 259: case 213: case 214: - case 233: + case 215: + case 234: return 2; - case 205: + case 206: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -17609,37 +17954,38 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 231: + case 232: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 262: + case 264: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 197: - case 227: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 230: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 161: - case 176: + case 198: case 228: - case 271: - case 288: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 231: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 162: + case 177: + case 229: + case 274: + case 291: + case 253: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 158: case 159: - case 153: + case 160: case 154: case 155: - case 149: - case 148: + case 156: case 150: + case 149: case 151: case 152: - case 226: - case 184: + case 153: + case 227: case 185: - case 275: - case 229: - case 170: + case 186: + case 278: + case 230: + case 171: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -17654,11 +18000,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 262 ? node : node.body; - if (body && (body.kind === 262 || body.kind === 232)) { + var body = node.kind === 264 ? node : node.body; + if (body && (body.kind === 264 || body.kind === 233)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 242 || stat.kind === 241) { + if (stat.kind === 243 || stat.kind === 242) { return true; } } @@ -17680,7 +18026,7 @@ var ts; errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isExternalModuleAugmentation(node)) { - declareSymbolAndAddToSymbolTable(node, 1024, 0); + declareModuleSymbol(node); } else { var pattern = void 0; @@ -17700,12 +18046,8 @@ var ts; } } else { - var state = getModuleInstanceState(node); - if (state === 0) { - declareSymbolAndAddToSymbolTable(node, 1024, 0); - } - else { - declareSymbolAndAddToSymbolTable(node, 512, 106639); + var state = declareModuleSymbol(node); + if (state !== 0) { if (node.symbol.flags & (16 | 32 | 256)) { node.symbol.constEnumOnlyModule = false; } @@ -17721,29 +18063,35 @@ var ts; } } } + function declareModuleSymbol(node) { + var state = getModuleInstanceState(node); + var instantiated = state !== 0; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 : 1024, instantiated ? 106639 : 0); + return state; + } function bindFunctionOrConstructorType(node) { var symbol = createSymbol(131072, getDeclarationName(node)); addDeclarationToSymbol(symbol, node, 131072); var typeLiteralSymbol = createSymbol(2048, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048); typeLiteralSymbol.members = ts.createMap(); - typeLiteralSymbol.members[symbol.name] = symbol; + typeLiteralSymbol.members.set(symbol.name, symbol); } function bindObjectLiteralExpression(node) { if (inStrictMode) { var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 260 || prop.name.kind !== 70) { + if (prop.kind === 262 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 258 || prop.kind === 259 || prop.kind === 149 + var currentKind = prop.kind === 260 || prop.kind === 261 || prop.kind === 150 ? 1 : 2; - var existingKind = seen[identifier.text]; + var existingKind = seen.get(identifier.text); if (!existingKind) { - seen[identifier.text] = currentKind; + seen.set(identifier.text, currentKind); continue; } if (currentKind === 1 && existingKind === 1) { @@ -17754,16 +18102,22 @@ var ts; } return bindAnonymousDeclaration(node, 4096, "__object"); } + function bindJsxAttributes(node) { + return bindAnonymousDeclaration(node, 4096, "__jsxAttributes"); + } + function bindJsxAttribute(node, symbolFlags, symbolExcludes) { + return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 231: + case 232: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 262: + case 264: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -17853,8 +18207,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 262 && - blockScopeContainer.kind !== 231 && + if (blockScopeContainer.kind !== 264 && + blockScopeContainer.kind !== 232 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -17897,7 +18251,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 140) { + if (node.kind > 141) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -17937,23 +18291,23 @@ var ts; case 70: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 286) { + while (parentNode && parentNode.kind !== 289) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 259)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 261)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 177: + case 178: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 192: + case 193: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -17976,48 +18330,48 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 257: + case 259: return checkStrictModeCatchClause(node); - case 186: + case 187: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 191: + case 192: return checkStrictModePostfixUnaryExpression(node); - case 190: + case 191: return checkStrictModePrefixUnaryExpression(node); - case 218: + case 219: return checkStrictModeWithStatement(node); - case 167: + case 168: seenThisKeyword = true; return; - case 156: + case 157: return checkTypePredicate(node); - case 143: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 144: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 145: return bindParameter(node); - case 224: - case 174: + case 225: + case 175: return bindVariableDeclarationOrBindingElement(node); + case 148: case 147: - case 146: - case 272: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 287: + case 275: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 67108864 : 0), 0); + case 290: return bindJSDocProperty(node); - case 258: - case 259: - return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 261: - return bindPropertyOrMethodOrAccessor(node, 8, 900095); case 260: - case 252: + case 261: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 263: + return bindPropertyOrMethodOrAccessor(node, 8, 900095); + case 262: + case 254: var root = container; var hasRest = false; while (root.parent) { - if (root.kind === 176 && - root.parent.kind === 192 && + if (root.kind === 177 && + root.parent.kind === 193 && root.parent.operatorToken.kind === 57 && root.parent.left === root) { hasRest = true; @@ -18026,78 +18380,82 @@ var ts; root = root.parent; } return; - case 153: case 154: case 155: + case 156: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 149: - case 148: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 226: - return bindFunctionDeclaration(node); case 150: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 149: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 67108864 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); + case 227: + return bindFunctionDeclaration(node); case 151: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 152: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 153: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 158: case 159: - case 275: + case 160: + case 278: return bindFunctionOrConstructorType(node); - case 161: - case 170: - case 288: - case 271: + case 162: + case 171: + case 291: + case 274: return bindAnonymousDeclaration(node, 2048, "__type"); - case 176: + case 177: return bindObjectLiteralExpression(node); - case 184: case 185: + case 186: return bindFunctionExpression(node); - case 179: + case 180: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 197: - case 227: + case 198: + case 228: inStrictMode = true; return bindClassLikeDeclaration(node); - case 228: + case 229: return bindBlockScopedDeclaration(node, 64, 792968); - case 286: + case 289: if (!node.fullName || node.fullName.kind === 70) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 229: - return bindBlockScopedDeclaration(node, 524288, 793064); case 230: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 231: + return bindEnumDeclaration(node); + case 232: return bindModuleDeclaration(node); - case 235: - case 238: - case 240: - case 244: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 234: - return bindNamespaceExportDeclaration(node); - case 237: - return bindImportClause(node); - case 242: - return bindExportDeclaration(node); + case 253: + return bindJsxAttributes(node); + case 252: + return bindJsxAttribute(node, 4, 0); + case 236: + case 239: case 241: + case 245: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 235: + return bindNamespaceExportDeclaration(node); + case 238: + return bindImportClause(node); + case 243: + return bindExportDeclaration(node); + case 242: return bindExportAssignment(node); - case 262: + case 264: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 205: + case 206: if (!ts.isFunctionLike(node.parent)) { return; } - case 232: + case 233: return updateStrictModeStatementList(node.statements); } } @@ -18106,7 +18464,7 @@ var ts; if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 167) { + if (parameterName && parameterName.kind === 168) { seenThisKeyword = true; } bind(type); @@ -18125,7 +18483,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 241 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 242 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -18135,17 +18493,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 262) { + if (node.parent.kind !== 264) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_4 = node.parent; - if (!ts.isExternalModule(parent_4)) { + var parent_1 = node.parent; + if (!ts.isExternalModule(parent_1)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_4.isDeclarationFile) { + if (!parent_1.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -18155,10 +18513,10 @@ var ts; } function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { - bindAnonymousDeclaration(node, 1073741824, getDeclarationName(node)); + bindAnonymousDeclaration(node, 33554432, getDeclarationName(node)); } else if (!node.exportClause) { - declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); + declareSymbol(container.symbol.exports, container.symbol, node, 33554432, 0); } } function bindImportClause(node) { @@ -18184,11 +18542,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 226 || container.kind === 184) { + if (container.kind === 227 || container.kind === 185) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } - else if (container.kind === 150) { + else if (container.kind === 151) { var saveContainer = container; container = container.parent; var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); @@ -18205,7 +18563,7 @@ var ts; leftSideOfAssignment.parent = node; constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - var funcSymbol = container.locals[constructorFunction.text]; + var funcSymbol = container.locals.get(constructorFunction.text); if (!funcSymbol || !(funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { return; } @@ -18220,25 +18578,26 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 227) { + if (node.kind === 228) { bindBlockScopedDeclaration(node, 32, 899519); } else { var bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, 32, bindingName); if (node.name) { - classifiableNames[node.name.text] = node.name.text; + classifiableNames.set(node.name.text, node.name.text); } } var symbol = node.symbol; - var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); - if (symbol.exports[prototypeSymbol.name]) { + var prototypeSymbol = createSymbol(4 | 16777216, "prototype"); + var symbolExport = symbol.exports.get(prototypeSymbol.name); + if (symbolExport) { if (node.name) { node.name.parent = node; } - file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbolExport.declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; + symbol.exports.set(prototypeSymbol.name, prototypeSymbol); prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { @@ -18274,7 +18633,7 @@ var ts; } if (ts.isParameterPropertyDeclaration(node)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 536870912 : 0), 0); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 67108864 : 0), 0); } } function bindFunctionDeclaration(node) { @@ -18330,15 +18689,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 207) || - node.kind === 227 || - (node.kind === 231 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 230 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 208) || + node.kind === 228 || + (node.kind === 232 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 231 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 206 || + (node.kind !== 207 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -18352,56 +18711,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 179: - return computeCallExpression(node, subtreeFlags); case 180: + return computeCallExpression(node, subtreeFlags); + case 181: return computeNewExpression(node, subtreeFlags); - case 231: + case 232: return computeModuleDeclaration(node, subtreeFlags); - case 183: - return computeParenthesizedExpression(node, subtreeFlags); - case 192: - return computeBinaryExpression(node, subtreeFlags); - case 208: - return computeExpressionStatement(node, subtreeFlags); - case 144: - return computeParameter(node, subtreeFlags); - case 185: - return computeArrowFunction(node, subtreeFlags); case 184: + return computeParenthesizedExpression(node, subtreeFlags); + case 193: + return computeBinaryExpression(node, subtreeFlags); + case 209: + return computeExpressionStatement(node, subtreeFlags); + case 145: + return computeParameter(node, subtreeFlags); + case 186: + return computeArrowFunction(node, subtreeFlags); + case 185: return computeFunctionExpression(node, subtreeFlags); - case 226: - return computeFunctionDeclaration(node, subtreeFlags); - case 224: - return computeVariableDeclaration(node, subtreeFlags); - case 225: - return computeVariableDeclarationList(node, subtreeFlags); - case 206: - return computeVariableStatement(node, subtreeFlags); - case 220: - return computeLabeledStatement(node, subtreeFlags); case 227: + return computeFunctionDeclaration(node, subtreeFlags); + case 225: + return computeVariableDeclaration(node, subtreeFlags); + case 226: + return computeVariableDeclarationList(node, subtreeFlags); + case 207: + return computeVariableStatement(node, subtreeFlags); + case 221: + return computeLabeledStatement(node, subtreeFlags); + case 228: return computeClassDeclaration(node, subtreeFlags); - case 197: + case 198: return computeClassExpression(node, subtreeFlags); - case 256: + case 258: return computeHeritageClause(node, subtreeFlags); - case 257: + case 259: return computeCatchClause(node, subtreeFlags); - case 199: + case 200: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 150: - return computeConstructor(node, subtreeFlags); - case 147: - return computePropertyDeclaration(node, subtreeFlags); - case 149: - return computeMethod(node, subtreeFlags); case 151: + return computeConstructor(node, subtreeFlags); + case 148: + return computePropertyDeclaration(node, subtreeFlags); + case 150: + return computeMethod(node, subtreeFlags); case 152: + case 153: return computeAccessor(node, subtreeFlags); - case 235: + case 236: return computeImportEquals(node, subtreeFlags); - case 177: + case 178: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -18426,8 +18785,8 @@ var ts; switch (kind) { case 96: return true; - case 177: case 178: + case 179: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96; @@ -18449,10 +18808,10 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 && leftKind === 176) { + if (operatorTokenKind === 57 && leftKind === 177) { transformFlags |= 8 | 192 | 3072; } - else if (operatorTokenKind === 57 && leftKind === 175) { + else if (operatorTokenKind === 57 && leftKind === 176) { transformFlags |= 192 | 3072; } else if (operatorTokenKind === 39 @@ -18491,8 +18850,8 @@ var ts; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 200 - || expressionKind === 182) { + if (expressionKind === 201 + || expressionKind === 183) { transformFlags |= 3; } if (expressionTransformFlags & 1024) { @@ -18778,7 +19137,7 @@ var ts; var excludeFlags = 536872257; switch (kind) { case 119: - case 189: + case 190: transformFlags |= 16; break; case 113: @@ -18787,51 +19146,52 @@ var ts; case 116: case 123: case 75: - case 230: - case 261: - case 182: - case 200: + case 231: + case 263: + case 183: case 201: + case 202: case 130: transformFlags |= 3; break; - case 247: case 248: case 249: - case 10: case 250: + case 10: case 251: case 252: case 253: + case 254: + case 255: transformFlags |= 4; break; - case 214: + case 215: transformFlags |= 8; case 12: case 13: case 14: case 15: - case 194: - case 181: - case 259: + case 195: + case 182: + case 261: case 114: - case 202: + case 203: transformFlags |= 192; break; - case 195: + case 196: transformFlags |= 192 | 16777216; break; case 118: case 132: case 129: - case 134: - case 121: + case 133: case 135: + case 121: + case 136: case 104: - case 143: - case 146: - case 148: - case 153: + case 144: + case 147: + case 149: case 154: case 155: case 156: @@ -18845,26 +19205,27 @@ var ts; case 164: case 165: case 166: - case 228: - case 229: case 167: + case 229: + case 230: case 168: case 169: case 170: case 171: + case 172: transformFlags = 3; excludeFlags = -3; break; - case 142: + case 143: transformFlags |= 2097152; if (subtreeFlags & 16384) { transformFlags |= 65536; } break; - case 196: + case 197: transformFlags |= 192 | 524288; break; - case 260: + case 262: transformFlags |= 8 | 1048576; break; case 96: @@ -18873,27 +19234,27 @@ var ts; case 98: transformFlags |= 16384; break; - case 172: + case 173: transformFlags |= 192 | 8388608; if (subtreeFlags & 524288) { transformFlags |= 8 | 1048576; } excludeFlags = 537396545; break; - case 173: + case 174: transformFlags |= 192 | 8388608; excludeFlags = 537396545; break; - case 174: + case 175: transformFlags |= 192; if (node.dotDotDotToken) { transformFlags |= 524288; } break; - case 145: + case 146: transformFlags |= 3 | 4096; break; - case 176: + case 177: excludeFlags = 540087617; if (subtreeFlags & 2097152) { transformFlags |= 192; @@ -18905,29 +19266,29 @@ var ts; transformFlags |= 8; } break; - case 175: - case 180: + case 176: + case 181: excludeFlags = 537396545; if (subtreeFlags & 524288) { transformFlags |= 192; } break; - case 210: case 211: case 212: case 213: + case 214: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 262: + case 264: if (subtreeFlags & 32768) { transformFlags |= 192; } break; - case 217: - case 215: + case 218: case 216: + case 217: transformFlags |= 33554432; break; } @@ -18935,56 +19296,57 @@ var ts; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 156 && kind <= 171) { + if (kind >= 157 && kind <= 172) { return -3; } switch (kind) { - case 179: case 180: - case 175: + case 181: + case 176: return 537396545; - case 231: + case 232: return 574674241; - case 144: + case 145: return 536872257; - case 185: + case 186: return 601249089; - case 184: - case 226: - return 601281857; - case 225: - return 546309441; + case 185: case 227: - case 197: + return 601281857; + case 226: + return 546309441; + case 228: + case 198: return 539358529; - case 150: - return 601015617; - case 149: case 151: + return 601015617; + case 150: case 152: + case 153: return 601015617; case 118: case 132: case 129: - case 134: - case 121: case 135: + case 133: + case 121: + case 136: case 104: - case 143: - case 146: - case 148: - case 153: + case 144: + case 147: + case 149: case 154: case 155: - case 228: + case 156: case 229: + case 230: return -3; - case 176: + case 177: return 540087617; - case 257: + case 259: return 537920833; - case 172: case 173: + case 174: return 537396545; default: return 536872257; @@ -19026,37 +19388,28 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { + function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); - switch (extensions) { - case Extensions.DtsOnly: - case Extensions.TypeScript: - return tryReadFromField("typings") || tryReadFromField("types"); - case Extensions.JavaScript: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; - } + return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); - } - return typesFilePath; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } + if (!ts.hasProperty(jsonContent, fieldName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName); } + return; } + var fileName = jsonContent[fieldName]; + if (typeof fileName !== "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof fileName); + } + return; + } + var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path); + } + return path; } } function readJson(path, host) { @@ -19228,9 +19581,10 @@ var ts; if (!moduleHasNonRelativeName(nonRelativeModuleName)) { return undefined; } - var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); if (!perModuleNameCache) { - moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + perModuleNameCache = createPerModuleNameCache(); + moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); } return perModuleNameCache; } @@ -19250,12 +19604,12 @@ var ts; var commonPrefix = getCommonPrefix(path, resolvedFileName); var current = path; while (true) { - var parent_5 = ts.getDirectoryPath(current); - if (parent_5 === current || directoryPathMap.contains(parent_5)) { + var parent = ts.getDirectoryPath(current); + if (parent === current || directoryPathMap.contains(parent)) { break; } - directoryPathMap.set(parent_5, result); - current = parent_5; + directoryPathMap.set(parent, result); + current = parent; if (current == commonPrefix) { break; } @@ -19286,7 +19640,7 @@ var ts; } var containingDirectory = ts.getDirectoryPath(containingFile); var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); - var result = perFolderCache && perFolderCache[moduleName]; + var result = perFolderCache && perFolderCache.get(moduleName); if (result) { if (traceEnabled) { trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); @@ -19314,7 +19668,7 @@ var ts; break; } if (perFolderCache) { - perFolderCache[moduleName] = result; + perFolderCache.set(moduleName, result); var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); if (perModuleNameCache) { perModuleNameCache.set(containingDirectory, result); @@ -19445,18 +19799,24 @@ var ts; } } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, false); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, jsOnly) { + if (jsOnly === void 0) { jsOnly = false; } var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + var result = jsOnly ? tryResolve(Extensions.JavaScript) : (tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript)); if (result && result.value) { var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { - var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + var loader = function (extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, true); }; + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); if (resolved) { return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } @@ -19469,12 +19829,12 @@ var ts; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state, true); return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } - ts.nodeModuleNameResolver = nodeModuleNameResolver; + ts.nodeModuleNameResolverWorker = nodeModuleNameResolverWorker; function realpath(path, host, traceEnabled) { if (!host.realpath) { return path; @@ -19485,7 +19845,7 @@ var ts; } return real; } - function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } @@ -19513,7 +19873,7 @@ var ts; onlyRecordFailures = true; } } - return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); @@ -19570,45 +19930,48 @@ var ts; failedLookupLocations.push(fileName); return undefined; } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { + if (considerPackageJson === void 0) { considerPackageJson = true; } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); - if (mainOrTypesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); - var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromExactFile) { - var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); - if (resolved_3) { - return resolved_3; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); - } - } - var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); - if (resolved) { - return resolved; + if (considerPackageJson) { + var packageJsonPath = pathToPackageJson(candidate); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; } } else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); + if (directoryExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + failedLookupLocations.push(packageJsonPath); } } - else { - if (directoryExists && state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - failedLookupLocations.push(packageJsonPath); - } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + if (!file) { + return undefined; + } + var onlyRecordFailures = !directoryProbablyExists(ts.getDirectoryPath(file), state.host); + var fromFile = tryFile(file, failedLookupLocations, onlyRecordFailures, state); + if (fromFile) { + var resolved = fromFile && resolvedIfExtensionMatches(extensions, fromFile); + if (resolved) { + return resolved; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile); + } + } + var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; + return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, false); + } function resolvedIfExtensionMatches(extensions, path) { var extension = ts.tryGetExtensionFromPath(path); return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; @@ -19695,7 +20058,7 @@ var ts; } var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { - var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); if (resolutionFromCache) { return resolutionFromCache; @@ -19703,8 +20066,8 @@ var ts; var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); - if (resolved_4) { - return resolved_4; + if (resolved_3) { + return resolved_3; } if (extensions === Extensions.TypeScript) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); @@ -19786,9 +20149,9 @@ var ts; var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; var strictNullChecks = compilerOptions.strictNullChecks; var emitResolver = createResolver(); - var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); + var undefinedSymbol = createSymbol(4, "undefined"); undefinedSymbol.declarations = []; - var argumentsSymbol = createSymbol(4 | 67108864, "arguments"); + var argumentsSymbol = createSymbol(4, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, @@ -19809,6 +20172,7 @@ var ts; getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, getTypeFromTypeNode: getTypeFromTypeNode, + getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -19833,8 +20197,9 @@ var ts; getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getAmbientModules: getAmbientModules, - getJsxElementAttributesType: getJsxElementAttributesType, + getAllAttributesTypeFromJsxOpeningLikeElement: getAllAttributesTypeFromJsxOpeningLikeElement, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, isOptionalParameter: isOptionalParameter, tryGetMemberInModuleExports: tryGetMemberInModuleExports, @@ -19850,8 +20215,8 @@ var ts; var numericLiteralTypes = ts.createMap(); var indexedAccessTypes = ts.createMap(); var evolvingArrayTypes = []; - var unknownSymbol = createSymbol(4 | 67108864, "unknown"); - var resolvingSymbol = createSymbol(67108864, "__resolving__"); + var unknownSymbol = createSymbol(4, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__"); var anyType = createIntrinsicType(1, "any"); var autoType = createIntrinsicType(1, "any"); var unknownType = createIntrinsicType(1, "unknown"); @@ -19868,8 +20233,9 @@ var ts; var voidType = createIntrinsicType(1024, "void"); var neverType = createIntrinsicType(8192, "never"); var silentNeverType = createIntrinsicType(8192, "never"); + var nonPrimitiveType = createIntrinsicType(16777216, "object"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var emptyTypeLiteralSymbol = createSymbol(2048 | 67108864, "__type"); + var emptyTypeLiteralSymbol = createSymbol(2048, "__type"); emptyTypeLiteralSymbol.members = ts.createMap(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -19877,6 +20243,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); anyFunctionType.flags |= 8388608; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); @@ -19938,7 +20305,7 @@ var ts; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - var typeofEQFacts = ts.createMap({ + var typeofEQFacts = ts.createMapFromTemplate({ "string": 1, "number": 2, "boolean": 4, @@ -19947,7 +20314,7 @@ var ts; "object": 16, "function": 32 }); - var typeofNEFacts = ts.createMap({ + var typeofNEFacts = ts.createMapFromTemplate({ "string": 128, "number": 256, "boolean": 512, @@ -19956,13 +20323,14 @@ var ts; "object": 2048, "function": 4096 }); - var typeofTypesByName = ts.createMap({ + var typeofTypesByName = ts.createMapFromTemplate({ "string": stringType, "number": numberType, "boolean": booleanType, "symbol": esSymbolType, "undefined": undefinedType }); + var typeofType = createTypeofType(); var jsxElementType; var _jsxNamespace; var _jsxFactoryEntity; @@ -19983,7 +20351,7 @@ var ts; var enumRelation = ts.createMap(); var _displayBuilder; var builtinGlobals = ts.createMap(); - builtinGlobals[undefinedSymbol.name] = undefinedSymbol; + builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); return checker; function getJsxNamespace() { @@ -20013,7 +20381,9 @@ var ts; } function createSymbol(flags, name) { symbolCount++; - return new Symbol(flags, name); + var symbol = (new Symbol(flags | 134217728, name)); + symbol.checkFlags = 0; + return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; @@ -20059,7 +20429,7 @@ var ts; mergedSymbols[source.mergeId] = target; } function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 33554432, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) @@ -20081,7 +20451,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 231 && source.valueDeclaration.kind !== 231))) { + (target.valueDeclaration.kind === 232 && source.valueDeclaration.kind !== 232))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -20097,6 +20467,9 @@ var ts; } recordMergedSymbol(target, source); } + else if (target.flags & 1024) { + error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + } else { var message_2 = target.flags & 2 || source.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -20109,18 +20482,19 @@ var ts; } } function mergeSymbolTable(target, source) { - for (var id in source) { - var targetSymbol = target[id]; + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); if (!targetSymbol) { - target[id] = source[id]; + target.set(id, sourceSymbol); } else { - if (!(targetSymbol.flags & 33554432)) { - target[id] = targetSymbol = cloneSymbol(targetSymbol); + if (!(targetSymbol.flags & 134217728)) { + targetSymbol = cloneSymbol(targetSymbol); + target.set(id, targetSymbol); } - mergeSymbol(targetSymbol, source[id]); + mergeSymbol(targetSymbol, sourceSymbol); } - } + }); } function mergeModuleAugmentation(moduleName) { var moduleAugmentation = moduleName.parent; @@ -20141,7 +20515,7 @@ var ts; } mainModule = resolveExternalModuleSymbol(mainModule); if (mainModule.flags & 1920) { - mainModule = mainModule.flags & 33554432 ? mainModule : cloneSymbol(mainModule); + mainModule = mainModule.flags & 134217728 ? mainModule : cloneSymbol(mainModule); mergeSymbol(mainModule, moduleAugmentation.symbol); } else { @@ -20150,20 +20524,21 @@ var ts; } } function addToSymbolTable(target, source, message) { - for (var id in source) { - if (target[id]) { - ts.forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); + if (targetSymbol) { + ts.forEach(targetSymbol.declarations, addDeclarationDiagnostic(id, message)); } else { - target[id] = source[id]; + target.set(id, sourceSymbol); } - } + }); function addDeclarationDiagnostic(id, message) { return function (declaration) { return diagnostics.add(ts.createDiagnosticForNode(declaration, message, id)); }; } } function getSymbolLinks(symbol) { - if (symbol.flags & 67108864) + if (symbol.flags & 134217728) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = {}); @@ -20175,14 +20550,17 @@ var ts; function getObjectFlags(type) { return type.flags & 32768 ? type.objectFlags : 0; } + function getCheckFlags(symbol) { + return symbol.flags & 134217728 ? symbol.checkFlags : 0; + } function isGlobalSourceFile(node) { - return node.kind === 262 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 264 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { - var symbol = symbols[name]; + var symbol = symbols.get(name); if (symbol) { - ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } @@ -20213,49 +20591,50 @@ var ts; (!compilerOptions.outFile && !compilerOptions.out)) { return true; } - if (isUsedInFunctionOrNonStaticProperty(usage)) { + if (isUsedInFunctionOrInstanceProperty(usage)) { return true; } var sourceFiles = host.getSourceFiles(); return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - if (declaration.kind === 174) { - var errorBindingElement = ts.getAncestor(usage, 174); + if (declaration.kind === 175) { + var errorBindingElement = ts.getAncestor(usage, 175); if (errorBindingElement) { return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || declaration.pos < errorBindingElement.pos; } - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 224), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 225), usage); } - else if (declaration.kind === 224) { + else if (declaration.kind === 225) { return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return isUsedInFunctionOrNonStaticProperty(usage, container); + var isInstanceProperty = declaration.kind === 148 && !(ts.getModifierFlags(declaration) & 32); + return isUsedInFunctionOrInstanceProperty(usage, isInstanceProperty, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 206: - case 212: - case 214: + case 207: + case 213: + case 215: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 213: case 214: + case 215: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } } return false; } - function isUsedInFunctionOrNonStaticProperty(usage, container) { + function isUsedInFunctionOrInstanceProperty(usage, isDeclarationInstanceProperty, container) { var current = usage; while (current) { if (current === container) { @@ -20264,12 +20643,12 @@ var ts; if (ts.isFunctionLike(current)) { return true; } - var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 147 && + var initializerOfInstanceProperty = current.parent && + current.parent.kind === 148 && (ts.getModifierFlags(current.parent) & 32) === 0 && current.parent.initializer === current; - if (initializerOfNonStaticProperty) { - return true; + if (initializerOfInstanceProperty) { + return !isDeclarationInstanceProperty; } current = current.parent; } @@ -20297,18 +20676,18 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793064 && lastLocation.kind !== 279) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 282) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 144 || - lastLocation.kind === 143 + lastLocation.kind === 145 || + lastLocation.kind === 144 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 144 || + lastLocation.kind === 145 || (lastLocation === location.type && - result.valueDeclaration.kind === 144); + result.valueDeclaration.kind === 145); } } if (useResult) { @@ -20320,23 +20699,24 @@ var ts; } } switch (location.kind) { - case 262: + case 264: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 231: + case 232: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 262 || ts.isAmbientModule(location)) { - if (result = moduleExports["default"]) { + if (location.kind === 264 || ts.isAmbientModule(location)) { + if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } - if (moduleExports[name] && - moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 244)) { + var moduleExport = moduleExports.get(name); + if (moduleExport && + moduleExport.flags === 8388608 && + ts.getDeclarationOfKind(moduleExport, 245)) { break; } } @@ -20344,13 +20724,13 @@ var ts; break loop; } break; - case 230: + case 231: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 148: case 147: - case 146: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -20360,17 +20740,21 @@ var ts; } } break; - case 227: - case 197: case 228: + case 198: + case 229: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { + if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { + result = undefined; + break; + } if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; } break loop; } - if (location.kind === 197 && meaning & 32) { + if (location.kind === 198 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -20378,28 +20762,28 @@ var ts; } } break; - case 142: + case 143: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 228) { + if (ts.isClassLike(grandparent) || grandparent.kind === 229) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 226: - case 185: + case 153: + case 227: + case 186: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 184: + case 185: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -20412,8 +20796,8 @@ var ts; } } break; - case 145: - if (location.parent && location.parent.kind === 144) { + case 146: + if (location.parent && location.parent.kind === 145) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -20456,13 +20840,22 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 234) { + if (decls && decls.length === 1 && decls[0].kind === 235) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } } return result; } + function isTypeParameterSymbolDeclaredInContainer(symbol, container) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 144 && decl.parent === container) { + return true; + } + } + return false; + } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { if ((errorLocation.kind === 70 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; @@ -20503,9 +20896,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70: - case 177: + case 178: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 199: + case 200: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -20553,10 +20946,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 235) { + if (node.kind === 236) { return node; } - while (node && node.kind !== 236) { + while (node && node.kind !== 237) { node = node.parent; } return node; @@ -20566,7 +20959,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 246) { + if (node.moduleReference.kind === 247) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -20574,11 +20967,16 @@ var ts; function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { - var exportDefaultSymbol = ts.isShorthandAmbientModuleSymbol(moduleSymbol) ? - moduleSymbol : - moduleSymbol.exports["export="] ? - getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") : - resolveSymbol(moduleSymbol.exports["default"]); + var exportDefaultSymbol = void 0; + if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { + exportDefaultSymbol = moduleSymbol; + } + else { + var exportValue = moduleSymbol.exports.get("export="); + exportDefaultSymbol = exportValue + ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") + : resolveSymbol(moduleSymbol.exports.get("default")); + } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } @@ -20609,7 +21007,7 @@ var ts; } function getExportOfModule(symbol, name) { if (symbol.flags & 1536) { - var exportedSymbol = getExportsOfSymbol(symbol)[name]; + var exportedSymbol = getExportsOfSymbol(symbol).get(name); if (exportedSymbol) { return resolveSymbol(exportedSymbol); } @@ -20627,28 +21025,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_16 = specifier.propertyName || specifier.name; - if (name_16.text) { + var name = specifier.propertyName || specifier.name; + if (name.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_16.text); + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) { + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_16.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_16.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_16.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_16, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_16)); + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name)); } return symbol; } @@ -20670,19 +21068,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 235: + case 236: return getTargetOfImportEqualsDeclaration(node); - case 237: - return getTargetOfImportClause(node); case 238: + return getTargetOfImportClause(node); + case 239: return getTargetOfNamespaceImport(node); - case 240: - return getTargetOfImportSpecifier(node); - case 244: - return getTargetOfExportSpecifier(node); case 241: + return getTargetOfImportSpecifier(node); + case 245: + return getTargetOfExportSpecifier(node); + case 242: return getTargetOfExportAssignment(node); - case 234: + case 235: return getTargetOfNamespaceExportDeclaration(node); } } @@ -20726,10 +21124,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 241) { + if (node.kind === 242) { checkExpressionCached(node.expression); } - else if (node.kind === 244) { + else if (node.kind === 245) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -20741,11 +21139,11 @@ var ts; if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 70 || entityName.parent.kind === 141) { + if (entityName.kind === 70 || entityName.parent.kind === 142) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 235); + ts.Debug.assert(entityName.parent.kind === 236); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -20764,9 +21162,9 @@ var ts; return undefined; } } - else if (name.kind === 141 || name.kind === 177) { - var left = name.kind === 141 ? name.left : name.expression; - var right = name.kind === 141 ? name.right : name.name; + else if (name.kind === 142 || name.kind === 178) { + var left = name.kind === 142 ? name.left : name.expression; + var right = name.kind === 142 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -20785,7 +21183,7 @@ var ts; else { ts.Debug.fail("Unknown entity name kind."); } - ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); } function resolveExternalModuleName(location, moduleReferenceExpression) { @@ -20856,7 +21254,7 @@ var ts; return undefined; } function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="))) || moduleSymbol; } function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { var symbol = resolveExternalModuleSymbol(moduleSymbol); @@ -20867,15 +21265,23 @@ var ts; return symbol; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="] !== undefined; + return moduleSymbol.exports.get("export=") !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); } + function getExportsAndPropertiesOfModule(moduleSymbol) { + var exports = getExportsOfModuleAsArray(moduleSymbol); + var exportEquals = resolveExternalModuleSymbol(moduleSymbol); + if (exportEquals !== moduleSymbol) { + ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + } + return exports; + } function tryGetMemberInModuleExports(memberName, moduleSymbol) { var symbolTable = getExportsOfModule(moduleSymbol); if (symbolTable) { - return symbolTable[memberName]; + return symbolTable.get(memberName); } } function getExportsOfSymbol(symbol) { @@ -20886,24 +21292,28 @@ var ts; return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol)); } function extendExportSymbols(target, source, lookupTable, exportNode) { - for (var id in source) { - if (id !== "default" && !target[id]) { - target[id] = source[id]; + source && source.forEach(function (sourceSymbol, id) { + if (id === "default") + return; + var targetSymbol = target.get(id); + if (!targetSymbol) { + target.set(id, sourceSymbol); if (lookupTable && exportNode) { - lookupTable[id] = { + lookupTable.set(id, { specifierText: ts.getTextOfNode(exportNode.moduleSpecifier) - }; + }); } } - else if (lookupTable && exportNode && id !== "default" && target[id] && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { - if (!lookupTable[id].exportsWithDuplicate) { - lookupTable[id].exportsWithDuplicate = [exportNode]; + else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) { + var collisionTracker = lookupTable.get(id); + if (!collisionTracker.exportsWithDuplicate) { + collisionTracker.exportsWithDuplicate = [exportNode]; } else { - lookupTable[id].exportsWithDuplicate.push(exportNode); + collisionTracker.exportsWithDuplicate.push(exportNode); } } - } + }); } function getExportsForModule(moduleSymbol) { var visitedSymbols = []; @@ -20915,26 +21325,26 @@ var ts; } visitedSymbols.push(symbol); var symbols = ts.cloneMap(symbol.exports); - var exportStars = symbol.exports["__export"]; + var exportStars = symbol.exports.get("__export"); if (exportStars) { var nestedSymbols = ts.createMap(); - var lookupTable = ts.createMap(); + var lookupTable_1 = ts.createMap(); for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { var node = _a[_i]; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable, node); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); } - for (var id in lookupTable) { - var exportsWithDuplicate = lookupTable[id].exportsWithDuplicate; - if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols[id]) { - continue; + lookupTable_1.forEach(function (_a, id) { + var exportsWithDuplicate = _a.exportsWithDuplicate; + if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) { + return; } - for (var _b = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _b < exportsWithDuplicate_1.length; _b++) { - var node = exportsWithDuplicate_1[_b]; - diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable[id].specifierText, id)); + for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) { + var node = exportsWithDuplicate_1[_i]; + diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable_1.get(id).specifierText, id)); } - } + }); extendExportSymbols(symbols, nestedSymbols); } return symbols; @@ -20956,22 +21366,13 @@ var ts; : symbol; } function symbolIsValue(symbol) { - if (symbol.flags & 16777216) { - return symbolIsValue(getSymbolLinks(symbol).target); - } - if (symbol.flags & 107455) { - return true; - } - if (symbol.flags & 8388608) { - return (resolveAlias(symbol).flags & 107455) !== 0; - } - return false; + return !!(symbol.flags & 107455 || symbol.flags & 8388608 && resolveAlias(symbol).flags & 107455); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 150 && ts.nodeIsPresent(member.body)) { + if (member.kind === 151 && ts.nodeIsPresent(member.body)) { return member; } } @@ -20999,6 +21400,9 @@ var ts; type.symbol = symbol; return type; } + function createTypeofType() { + return getUnionType(ts.convertToArray(typeofEQFacts.keys(), function (s) { return getLiteralTypeForText(32, s); })); + } function isReservedMemberName(name) { return name.charCodeAt(0) === 95 && name.charCodeAt(1) === 95 && @@ -21007,16 +21411,15 @@ var ts; } function getNamedMembers(members) { var result; - for (var id in members) { + members.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { if (!result) result = []; - var symbol = members[id]; if (symbolIsValue(symbol)) { result.push(symbol); } } - } + }); return result || emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -21035,19 +21438,19 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { - if (location_1.locals && !isGlobalSourceFile(location_1)) { - if (result = callback(location_1.locals)) { + for (var location = enclosingDeclaration; location; location = location.parent) { + if (location.locals && !isGlobalSourceFile(location)) { + if (result = callback(location.locals)) { return result; } } - switch (location_1.kind) { - case 262: - if (!ts.isExternalOrCommonJsModule(location_1)) { + switch (location.kind) { + case 264: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 231: - if (result = callback(getSymbolOfNode(location_1).exports)) { + case 232: + if (result = callback(getSymbolOfNode(location).exports)) { return result; } break; @@ -21084,13 +21487,13 @@ var ts; } } function trySymbolTable(symbols) { - if (isAccessible(symbols[symbol.name])) { + if (isAccessible(symbols.get(symbol.name))) { return [symbol]; } - return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { + return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -21115,14 +21518,14 @@ var ts; function needsQualification(symbol, enclosingDeclaration, meaning) { var qualify = false; forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { - var symbolFromSymbolTable = symbolTable[symbol.name]; + var symbolFromSymbolTable = symbolTable.get(symbol.name); if (!symbolFromSymbolTable) { return false; } if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -21136,10 +21539,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 147: - case 149: - case 151: + case 148: + case 150: case 152: + case 153: continue; default: return false; @@ -21195,7 +21598,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 262 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 264 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -21229,11 +21632,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 160 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 161 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 141 || entityName.kind === 177 || - entityName.parent.kind === 235) { + else if (entityName.kind === 142 || entityName.kind === 178 || + entityName.parent.kind === 236) { meaning = 1920; } else { @@ -21325,10 +21728,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 166) { + while (node.kind === 167) { node = node.parent; } - if (node.kind === 229) { + if (node.kind === 230) { return getSymbolOfNode(node); } } @@ -21336,29 +21739,29 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 232 && + node.parent.kind === 233 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { return type.flags & 32 ? "\"" + ts.escapeString(type.text) + "\"" : type.text; } - function getSymbolDisplayBuilder() { - function getNameOfSymbol(symbol) { - if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - if (declaration.name) { - return ts.declarationNameToString(declaration.name); - } - switch (declaration.kind) { - case 197: - return "(Anonymous class)"; - case 184: - case 185: - return "(Anonymous function)"; - } + function getNameOfSymbol(symbol) { + if (symbol.declarations && symbol.declarations.length) { + var declaration = symbol.declarations[0]; + if (declaration.name) { + return ts.declarationNameToString(declaration.name); + } + switch (declaration.kind) { + case 198: + return "(Anonymous class)"; + case 185: + case 186: + return "(Anonymous function)"; } - return symbol.name; } + return symbol.name; + } + function getSymbolDisplayBuilder() { function appendSymbolNameOnly(symbol, writer) { writer.writeSymbol(getNameOfSymbol(symbol), symbol); } @@ -21386,7 +21789,7 @@ var ts; function appendParentTypeArgumentsAndSymbolName(symbol) { if (parentSymbol) { if (flags & 1) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); } else { @@ -21405,9 +21808,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_6) { - walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), false); + var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + walkSymbol(parent, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -21437,7 +21840,7 @@ var ts; return writeType(type, globalFlags); function writeType(type, flags) { var nextFlags = flags & ~512; - if (type.flags & 16015) { + if (type.flags & 16793231) { writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) ? "any" : type.intrinsicName); @@ -21462,7 +21865,7 @@ var ts; else if (!(flags & 512) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { var typeArguments = type.aliasTypeArguments; - writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); + writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, ts.length(typeArguments), nextFlags); } else if (type.flags & 196608) { writeUnionOrIntersectionType(type, nextFlags); @@ -21540,12 +21943,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); + writeSymbolTypeReference(parent, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -21571,7 +21974,8 @@ var ts; function writeAnonymousType(type, flags) { var symbol = type.symbol; if (symbol) { - if (symbol.flags & (32 | 384 | 512)) { + if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (384 | 512)) { writeTypeOfSymbol(type, flags); } else if (shouldWriteTypeOfFunctionSymbol()) { @@ -21604,7 +22008,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 262 || declaration.parent.kind === 232; + return declaration.parent.kind === 264 || declaration.parent.kind === 233; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -21623,7 +22027,7 @@ var ts; writeSpace(writer); } buildSymbolDisplay(prop, writer); - if (prop.flags & 536870912) { + if (prop.flags & 67108864) { writePunctuation(writer, 54); } } @@ -21766,6 +22170,13 @@ var ts; writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } + var defaultType = getDefaultFromTypeParameter(tp); + if (defaultType) { + writeSpace(writer); + writePunctuation(writer, 57); + writeSpace(writer); + buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack); + } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; @@ -21783,15 +22194,19 @@ var ts; } writePunctuation(writer, 55); writeSpace(writer); - buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); + var type = getTypeOfSymbol(p); + if (isRequiredInitializedParameter(parameterNode)) { + type = includeFalsyTypes(type, 2048); + } + buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 172) { + if (bindingPattern.kind === 173) { writePunctuation(writer, 16); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); writePunctuation(writer, 17); } - else if (bindingPattern.kind === 173) { + else if (bindingPattern.kind === 174) { writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -21805,7 +22220,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 174); + ts.Debug.assert(bindingElement.kind === 175); if (bindingElement.propertyName) { writer.writeProperty(ts.getTextOfNode(bindingElement.propertyName)); writePunctuation(writer, 55); @@ -21927,7 +22342,7 @@ var ts; writeKeyword(writer, 132); break; case 0: - writeKeyword(writer, 134); + writeKeyword(writer, 135); break; } writePunctuation(writer, 21); @@ -21963,64 +22378,64 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 174: + case 175: return isDeclarationVisible(node.parent.parent); - case 224: + case 225: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 231: - case 227: + case 232: case 228: case 229: - case 226: case 230: - case 235: + case 227: + case 231: + case 236: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_8 = getDeclarationContainer(node); + var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 235 && parent_8.kind !== 262 && ts.isInAmbientContext(parent_8))) { - return isGlobalSourceFile(parent_8); + !(node.kind !== 236 && parent.kind !== 264 && ts.isInAmbientContext(parent))) { + return isGlobalSourceFile(parent); } - return isDeclarationVisible(parent_8); - case 147: - case 146: - case 151: - case 152: - case 149: + return isDeclarationVisible(parent); case 148: + case 147: + case 152: + case 153: + case 150: + case 149: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 150: - case 154: - case 153: + case 151: case 155: - case 144: - case 232: - case 158: + case 154: + case 156: + case 145: + case 233: case 159: - case 161: - case 157: + case 160: case 162: + case 158: case 163: case 164: case 165: case 166: + case 167: return isDeclarationVisible(node.parent); - case 237: case 238: - case 240: - return false; - case 143: - case 262: - case 234: - return true; + case 239: case 241: return false; + case 144: + case 264: + case 235: + return true; + case 242: + return false; default: return false; } @@ -22028,10 +22443,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 241) { + if (node.parent && node.parent.kind === 242) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 244) { + else if (node.parent.kind === 245) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -22109,12 +22524,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 224: case 225: + case 226: + case 241: case 240: case 239: case 238: - case 237: node = node.parent; break; default: @@ -22138,7 +22553,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } function isComputedNonLiteralName(name) { - return name.kind === 142 && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 143 && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 6144); }); @@ -22151,17 +22566,16 @@ var ts; var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name_17 = properties_2[_i]; - names[ts.getTextOfPropertyName(name_17)] = true; + var name = properties_2[_i]; + names.set(ts.getTextOfPropertyName(name), true); } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - var inNamesToRemove = prop.name in names; + var inNamesToRemove = names.has(prop.name); var isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16); - var isMethod = prop.flags & 8192; var isSetOnlyAccessor = prop.flags & 65536 && !(prop.flags & 32768); - if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { - members[prop.name] = prop; + if (!inNamesToRemove && !isPrivate && !isClassMethod(prop) && !isSetOnlyAccessor) { + members.set(prop.name, prop); } } var stringIndexInfo = getIndexInfoOfType(source, 0); @@ -22181,7 +22595,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 172) { + if (pattern.kind === 173) { if (declaration.dotDotDotToken) { if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -22197,19 +22611,19 @@ var ts; type = getRestType(parentType, literalMembers, declaration.symbol); } else { - var name_18 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_18)) { + var name = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name)) { return anyType; } if (declaration.initializer) { getContextualType(declaration.initializer); } - var text = ts.getTextOfPropertyName(name_18); + var text = ts.getTextOfPropertyName(name); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_18, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_18)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); return unknownType; } } @@ -22242,7 +22656,7 @@ var ts; getUnionType([type, checkExpressionCached(declaration.initializer)], true) : type; } - function getTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); if (jsdocType) { return getTypeFromTypeNode(jsdocType); @@ -22255,33 +22669,42 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 175 && expr.elements.length === 0; + return expr.kind === 176 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } + function removeOptionalityFromAnnotation(annotatedType, declaration) { + var annotationIncludesUndefined = strictNullChecks && + declaration.kind === 145 && + declaration.initializer && + getFalsyFlags(annotatedType) & 2048 && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048); + return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; + } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { if (declaration.flags & 65536) { - var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); + var type = getTypeForDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } } - if (declaration.parent.parent.kind === 213) { + if (declaration.parent.parent.kind === 214) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 | 262144) ? indexType : stringType; } - if (declaration.parent.parent.kind === 214) { + if (declaration.parent.parent.kind === 215) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } if (declaration.type) { - return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); + var declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + return addOptionality(declaredType, declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && - declaration.kind === 224 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 225 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -22290,10 +22713,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 144) { + if (declaration.kind === 145) { var func = declaration.parent; - if (func.kind === 152 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 151); + if (func.kind === 153 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 152); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -22319,7 +22742,10 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 259) { + if (ts.isJsxAttribute(declaration)) { + return trueType; + } + if (declaration.kind === 261) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -22327,6 +22753,21 @@ var ts; } return undefined; } + function getTypeForJSSpecialPropertyDeclaration(declaration) { + var expression = declaration.kind === 193 ? declaration : + declaration.kind === 178 ? ts.getAncestor(declaration, 193) : + undefined; + if (!expression) { + return unknownType; + } + if (expression.flags & 65536) { + var type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + return getWidenedType(type); + } + } + return getWidenedLiteralType(checkExpressionCached(expression.right)); + } function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { return checkDeclarationInitializer(element); @@ -22354,11 +22795,11 @@ var ts; return; } var text = ts.getTextOfPropertyName(name); - var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); + var flags = 4 | (e.initializer ? 67108864 : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; - members[symbol.name] = symbol; + members.set(symbol.name, symbol); }); var result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { @@ -22384,7 +22825,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 172 + return pattern.kind === 173 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -22394,7 +22835,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 258) { + if (declaration.kind === 260) { return type; } return getWidenedType(type); @@ -22409,41 +22850,32 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 144 ? root.parent : root; + var memberDeclaration = root.kind === 145 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.flags & 134217728) { + if (symbol.flags & 16777216) { return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 241) { + if (declaration.kind === 242) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 && declaration.kind === 287 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 290 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = void 0; - if (declaration.kind === 192 || - declaration.kind === 177 && declaration.parent.kind === 192) { - if (declaration.flags & 65536) { - var jsdocType = ts.getJSDocType(declaration.parent); - if (jsdocType) { - return links.type = getTypeFromTypeNode(jsdocType); - } - } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 192 ? - checkExpressionCached(decl.right) : - checkExpressionCached(decl.parent.right); }); - type = getUnionType(declaredTypes, true); + if (declaration.kind === 193 || + declaration.kind === 178 && declaration.parent.kind === 193) { + type = getWidenedType(getUnionType(ts.map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), true)); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -22457,7 +22889,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 151) { + if (accessor.kind === 152) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -22477,10 +22909,10 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 151); - var setter = ts.getDeclarationOfKind(symbol, 152); + var getter = ts.getDeclarationOfKind(symbol, 152); + var setter = ts.getDeclarationOfKind(symbol, 153); if (getter && getter.flags & 65536) { - var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); + var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; } @@ -22519,7 +22951,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 151); + var getter_1 = ts.getDeclarationOfKind(symbol, 152); 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)); } } @@ -22527,6 +22959,10 @@ var ts; } return links.type; } + function getBaseTypeVariableOfClass(symbol) { + var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); + return baseConstructorType.flags & 540672 ? baseConstructorType : undefined; + } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { @@ -22535,8 +22971,13 @@ var ts; } else { var type = createObjectType(16, symbol); - links.type = strictNullChecks && symbol.flags & 536870912 ? - includeFalsyTypes(type, 2048) : type; + if (symbol.flags & 32) { + var baseTypeVariable = getBaseTypeVariableOfClass(symbol); + links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; + } + else { + links.type = strictNullChecks && symbol.flags & 67108864 ? includeFalsyTypes(type, 2048) : type; + } } } return links.type; @@ -22583,7 +23024,7 @@ var ts; return anyType; } function getTypeOfSymbol(symbol) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { return getTypeOfInstantiatedSymbol(symbol); } if (symbol.flags & (3 | 4)) { @@ -22609,13 +23050,18 @@ var ts; function hasBaseType(type, checkBase) { return check(type); function check(type) { - var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); + if (getObjectFlags(type) & (3 | 4)) { + var target = getTargetType(type); + return target === checkBase || ts.forEach(getBaseTypes(target), check); + } + else if (type.flags & 131072) { + return ts.forEach(type.types, check); + } } } function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { - var declaration = declarations_2[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -22632,9 +23078,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 227 || node.kind === 197 || - node.kind === 226 || node.kind === 184 || - node.kind === 149 || node.kind === 185) { + if (node.kind === 228 || node.kind === 198 || + node.kind === 227 || node.kind === 185 || + node.kind === 150 || node.kind === 186) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -22643,15 +23089,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 228); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 229); 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 === 228 || node.kind === 227 || - node.kind === 197 || node.kind === 229) { + if (node.kind === 229 || node.kind === 228 || + node.kind === 198 || node.kind === 230) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -22663,15 +23109,30 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } + function isMixinConstructorType(type) { + var signatures = getSignaturesOfType(type, 1); + if (signatures.length === 1) { + var s = signatures[0]; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + } + return false; + } function isConstructorType(type) { - return type.flags & 32768 && getSignaturesOfType(type, 1).length > 0; + if (isValidBaseType(type) && getSignaturesOfType(type, 1).length > 0) { + return true; + } + if (type.flags & 540672) { + var constraint = getBaseConstraintOfType(type); + return isValidBaseType(constraint) && isMixinConstructorType(constraint); + } + return false; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); } function getConstructorsForTypeArguments(type, typeArgumentNodes) { - var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; - return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + var typeArgCount = ts.length(typeArgumentNodes); + return ts.filter(getSignaturesOfType(type, 1), function (sig) { return typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); @@ -22691,7 +23152,7 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 32768) { + if (baseConstructorType.flags & (32768 | 131072)) { resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { @@ -22727,8 +23188,8 @@ var ts; } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - var baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & 32768)) { + var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); + if (!(baseConstructorType.flags & (32768 | 131072))) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -22756,7 +23217,7 @@ var ts; if (baseType === unknownType) { return; } - if (!(getObjectFlags(getTargetType(baseType)) & 3)) { + if (!isValidBaseType(baseType)) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -22780,16 +23241,20 @@ var ts; } return true; } + function isValidBaseType(type) { + return type.flags & (32768 | 16777216) && !isGenericMappedType(type) || + type.flags & 131072 && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); + } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 228 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 229 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { - if (getObjectFlags(getTargetType(baseType)) & 3) { + if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -22813,7 +23278,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 228) { + if (declaration.kind === 229) { if (declaration.flags & 64) { return false; } @@ -22846,7 +23311,7 @@ var ts; type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384); @@ -22863,7 +23328,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 286); + var declaration = ts.getDeclarationOfKind(symbol, 289); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -22874,7 +23339,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 229); + declaration = ts.getDeclarationOfKind(symbol, 230); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -22882,7 +23347,7 @@ var ts; if (typeParameters) { links.typeParameters = typeParameters; links.instantiations = ts.createMap(); - links.instantiations[getTypeListId(typeParameters)] = type; + links.instantiations.set(getTypeListId(typeParameters), type); } } else { @@ -22899,14 +23364,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 190 && expr.operator === 37 && + expr.kind === 191 && expr.operator === 37 && expr.operand.kind === 8 || - expr.kind === 70 && !!symbol.exports[expr.text]; + expr.kind === 70 && !!symbol.exports.get(expr.text); } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 230) { + if (declaration.kind === 231) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -22931,10 +23396,10 @@ var ts; enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { var memberTypeList = []; - var memberTypes = ts.createMap(); + var memberTypes = []; for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 230) { + if (declaration.kind === 231) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -22951,7 +23416,7 @@ var ts; if (memberTypeList.length > 1) { enumType.flags |= 65536; enumType.types = memberTypeList; - unionTypes[getTypeListId(memberTypeList)] = enumType; + unionTypes.set(getTypeListId(memberTypeList), enumType); } } } @@ -22972,9 +23437,6 @@ var ts; if (!links.declaredType) { var type = createType(16384); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 143).constraint) { - type.constraint = noConstraintType; - } links.declaredType = type; } return links.declaredType; @@ -22987,7 +23449,6 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 16777216) === 0); if (symbol.flags & (32 | 64)) { return getDeclaredTypeOfClassOrInterface(symbol); } @@ -23022,19 +23483,20 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: + case 133: case 104: - case 137: + case 138: case 94: case 129: - case 171: + case 172: return true; - case 162: + case 163: return isIndependentType(node.elementType); - case 157: + case 158: return isIndependentTypeReference(node); } return false; @@ -23043,7 +23505,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 150 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 151 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -23059,12 +23521,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 147: - case 146: - return isIndependentVariableLikeDeclaration(declaration); - case 149: case 148: + case 147: + return isIndependentVariableLikeDeclaration(declaration); case 150: + case 149: + case 151: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -23075,7 +23537,7 @@ var ts; var result = ts.createMap(); for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { var symbol = symbols_1[_i]; - result[symbol.name] = symbol; + result.set(symbol.name, symbol); } return result; } @@ -23083,15 +23545,15 @@ var ts; var result = ts.createMap(); for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { var symbol = symbols_2[_i]; - result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); + result.set(symbol.name, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } function addInheritedMembers(symbols, baseSymbols) { for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { var s = baseSymbols_1[_i]; - if (!symbols[s.name]) { - symbols[s.name] = s; + if (!symbols.has(s.name)) { + symbols.set(s.name, s); } } } @@ -23099,8 +23561,8 @@ var ts; if (!type.declaredProperties) { var symbol = type.symbol; type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members.get("__call")); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members.get("__new")); type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0); type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1); } @@ -23108,7 +23570,14 @@ var ts; } function getTypeWithThisArgument(type, thisArgument) { if (getObjectFlags(type) & 4) { - return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + var target = type.target; + var typeArguments = type.typeArguments; + if (ts.length(target.typeParameters) === ts.length(typeArguments)) { + return createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); + } + } + else if (type.flags & 131072) { + return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument); })); } return type; } @@ -23144,7 +23613,7 @@ var ts; for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) { var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0); @@ -23187,13 +23656,14 @@ var ts; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); - var typeArgCount = typeArguments ? typeArguments.length : 0; + var typeArgCount = ts.length(typeArguments); var result = []; for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { var baseSig = baseSignatures_1[_i]; - var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; - if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); + var typeParamCount = ts.length(baseSig.typeParameters); + if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -23247,7 +23717,7 @@ var ts; s = cloneSignature(signature); if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return getTypeOfSymbol(sig.thisParameter) || anyType; }), true); - s.thisParameter = createTransientSymbol(signature.thisParameter, thisType); + s.thisParameter = createSymbolWithType(signature.thisParameter, thisType); } s.resolvedReturnType = undefined; s.unionSignatures = unionSignatures; @@ -23289,17 +23759,44 @@ var ts; function unionSpreadIndexInfos(info1, info2) { return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); } + function includeMixinType(type, types, index) { + var mixedTypes = []; + for (var i = 0; i < types.length; i++) { + if (i === index) { + mixedTypes.push(type); + } + else if (isMixinConstructorType(types[i])) { + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1)[0])); + } + } + return getIntersectionType(mixedTypes); + } function resolveIntersectionTypeMembers(type) { var callSignatures = emptyArray; var constructSignatures = emptyArray; - var stringIndexInfo = undefined; - var numberIndexInfo = undefined; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + var stringIndexInfo; + var numberIndexInfo; + var types = type.types; + var mixinCount = ts.countWhere(types, isMixinConstructorType); + var _loop_3 = function (i) { + var t = type.types[i]; + if (mixinCount === 0 || mixinCount === types.length && i === 0 || !isMixinConstructorType(t)) { + var signatures = getSignaturesOfType(t, 1); + if (signatures.length && mixinCount > 0) { + signatures = ts.map(signatures, function (s) { + var clone = cloneSignature(s); + clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, i); + return clone; + }); + } + constructSignatures = ts.concatenate(constructSignatures, signatures); + } callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1)); stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1)); + }; + for (var i = 0; i < types.length; i++) { + _loop_3(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } @@ -23315,8 +23812,8 @@ var ts; } else if (symbol.flags & 2048) { var members = symbol.members; - var callSignatures = getSignaturesOfSymbol(members["__call"]); - var constructSignatures = getSignaturesOfSymbol(members["__new"]); + var callSignatures = getSignaturesOfSymbol(members.get("__call")); + var constructSignatures = getSignaturesOfSymbol(members.get("__new")); var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0); var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -23329,14 +23826,14 @@ var ts; } if (symbol.flags & 32) { var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 32768) { + if (baseConstructorType.flags & (32768 | 131072 | 540672)) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); + addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } } var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; @@ -23356,8 +23853,11 @@ var ts; var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); var templateReadonly = !!type.declaration.readonlyToken; var templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === 168) { - forEachType(getLiteralTypeFromPropertyNames(modifiersType), addMemberForKeyType); + if (type.declaration.typeParameter.constraint.kind === 169) { + for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { + var propertySymbol = _a[_i]; + addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); + } if (getIndexInfoOfType(modifiersType, 0)) { addMemberForKeyType(stringType); } @@ -23368,18 +23868,21 @@ var ts; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t) { - var iterationMapper = createUnaryTypeMapper(typeParameter, t); + function addMemberForKeyType(t, propertySymbol) { + var iterationMapper = createTypeMapper([typeParameter], [t]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; var propType = instantiateType(templateType, templateMapper); if (t.flags & 32) { var propName = t.text; var modifiersProp = getPropertyOfType(modifiersType, propName); - var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 536870912); - var prop = createSymbol(4 | 67108864 | (isOptional ? 536870912 : 0), propName); + var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 67108864); + var prop = createSymbol(4 | (isOptional ? 67108864 : 0), propName); + prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 4 : 0; prop.type = propType; - prop.isReadonly = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp); - members[propName] = prop; + if (propertySymbol) { + prop.mappedTypeOrigin = propertySymbol; + } + members.set(propName, prop); } else if (t.flags & 2) { stringIndexInfo = createIndexInfo(propType, templateReadonly); @@ -23403,7 +23906,7 @@ var ts; function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { var constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === 168) { + if (constraintDeclaration.kind === 169) { type.modifiersType = instantiateType(getTypeFromTypeNode(constraintDeclaration.type), type.mapper || identityMapper); } else { @@ -23415,9 +23918,6 @@ var ts; } return type.modifiersType; } - function getErasedTemplateTypeFromMappedType(type) { - return instantiateType(getTemplateTypeFromMappedType(type), createUnaryTypeMapper(getTypeParameterFromMappedType(type), anyType)); - } function isGenericMappedType(type) { if (getObjectFlags(type) & 32) { var constraintType = getConstraintTypeFromMappedType(type); @@ -23459,35 +23959,33 @@ var ts; function getPropertyOfObjectType(type, name) { if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } } } 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]; - getUnionOrIntersectionProperty(type, prop.name); - } - if (type.flags & 65536) { - break; - } - } - var props = type.resolvedProperties; - if (props) { - var result = []; - for (var key in props) { - var prop = props[key]; - if (!(prop.flags & 268435456 && prop.isPartial)) { - result.push(prop); + if (!type.resolvedProperties) { + var members = ts.createMap(); + 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]; + if (!members.has(prop.name)) { + var combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.name); + if (combinedProp) { + members.set(prop.name, combinedProp); + } + } + } + if (type.flags & 65536) { + break; } } - return result; + type.resolvedProperties = getNamedMembers(members); } - return emptyArray; + return type.resolvedProperties; } function getPropertiesOfType(type) { type = getApparentType(type); @@ -23495,36 +23993,110 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } - function getApparentTypeOfTypeVariable(type) { - if (!type.resolvedApparentType) { - var constraintType = getConstraintOfTypeVariable(type); - while (constraintType && constraintType.flags & 16384) { - constraintType = getConstraintOfTypeVariable(constraintType); - } - type.resolvedApparentType = getTypeWithThisArgument(constraintType || emptyObjectType, type); + function getConstraintOfType(type) { + return type.flags & 16384 ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + } + function getConstraintOfTypeParameter(typeParameter) { + return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; + } + function getBaseConstraintOfType(type) { + var constraint = getResolvedBaseConstraint(type); + return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + } + function hasNonCircularBaseConstraint(type) { + return getResolvedBaseConstraint(type) !== circularConstraintType; + } + function getResolvedBaseConstraint(type) { + var typeStack; + var circular; + if (!type.resolvedBaseConstraint) { + typeStack = []; + var constraint = getBaseConstraint(type); + type.resolvedBaseConstraint = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type); } - return type.resolvedApparentType; + return type.resolvedBaseConstraint; + function getBaseConstraint(t) { + if (ts.contains(typeStack, t)) { + circular = true; + return undefined; + } + typeStack.push(t); + var result = computeBaseConstraint(t); + typeStack.pop(); + return result; + } + function computeBaseConstraint(t) { + if (t.flags & 16384) { + var constraint = getConstraintFromTypeParameter(t); + return t.isThisType ? constraint : + constraint ? getBaseConstraint(constraint) : undefined; + } + if (t.flags & 196608) { + var types = t.types; + var baseTypes = []; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var type_1 = types_2[_i]; + var baseType = getBaseConstraint(type_1); + if (baseType) { + baseTypes.push(baseType); + } + } + return t.flags & 65536 && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 131072 && baseTypes.length ? getIntersectionType(baseTypes) : + undefined; + } + if (t.flags & 262144) { + return stringType; + } + if (t.flags & 524288) { + var baseObjectType = getBaseConstraint(t.objectType); + var baseIndexType = getBaseConstraint(t.indexType); + var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; + return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + } + return t; + } + } + function getApparentTypeOfIntersectionType(type) { + return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type)); + } + function getDefaultFromTypeParameter(typeParameter) { + if (!typeParameter.default) { + if (typeParameter.target) { + var targetDefault = getDefaultFromTypeParameter(typeParameter.target); + typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType; + } + else { + var defaultDeclaration = typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameter(decl) && decl.default; }); + typeParameter.default = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType; + } + } + return typeParameter.default === noConstraintType ? undefined : typeParameter.default; } function getApparentType(type) { - var t = type.flags & 540672 ? getApparentTypeOfTypeVariable(type) : type; - return t.flags & 262178 ? globalStringType : - t.flags & 340 ? globalNumberType : - t.flags & 136 ? globalBooleanType : - t.flags & 512 ? getGlobalESSymbolType() : - t; + var t = type.flags & 540672 ? getBaseConstraintOfType(type) || emptyObjectType : type; + return t.flags & 131072 ? getApparentTypeOfIntersectionType(t) : + t.flags & 262178 ? globalStringType : + t.flags & 340 ? globalNumberType : + t.flags & 136 ? globalBooleanType : + t.flags & 512 ? getGlobalESSymbolType() : + t.flags & 16777216 ? emptyObjectType : + t; } function createUnionOrIntersectionProperty(containingType, name) { - var types = containingType.types; var props; - var commonFlags = (containingType.flags & 131072) ? 536870912 : 0; - var isReadonly = false; - var isPartial = false; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var current = types_2[_i]; + var types = containingType.types; + var isUnion = containingType.flags & 65536; + var excludeModifiers = isUnion ? 24 : 0; + var commonFlags = isUnion ? 0 : 67108864; + var checkFlags = 2; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var current = types_3[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16))) { + var modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0; + if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; if (!props) { props = [prop]; @@ -23532,25 +24104,26 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } - if (isReadonlySymbol(prop)) { - isReadonly = true; - } + checkFlags |= (isReadonlySymbol(prop) ? 4 : 0) | + (!(modifiers & 24) ? 32 : 0) | + (modifiers & 16 ? 64 : 0) | + (modifiers & 8 ? 128 : 0) | + (modifiers & 32 ? 256 : 0); } - else if (containingType.flags & 65536) { - isPartial = true; + else if (isUnion) { + checkFlags |= 8; } } } if (!props) { return undefined; } - if (props.length === 1 && !isPartial) { + if (props.length === 1 && !(checkFlags & 8)) { return props[0]; } var propTypes = []; var declarations = []; var commonType = undefined; - var hasNonUniformType = false; for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; if (prop.declarations) { @@ -23561,39 +24134,37 @@ var ts; commonType = type; } else if (type !== commonType) { - hasNonUniformType = true; + checkFlags |= 16; } propTypes.push(type); } - var result = createSymbol(4 | 67108864 | 268435456 | commonFlags, name); + var result = createSymbol(4 | commonFlags, name); + result.checkFlags = checkFlags; result.containingType = containingType; - result.hasNonUniformType = hasNonUniformType; - result.isPartial = isPartial; result.declarations = declarations; - result.isReadonly = isReadonly; - result.type = containingType.flags & 65536 ? getUnionType(propTypes) : getIntersectionType(propTypes); + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } function getUnionOrIntersectionProperty(type, name) { - var properties = type.resolvedProperties || (type.resolvedProperties = ts.createMap()); - var property = properties[name]; + var properties = type.propertyCache || (type.propertyCache = ts.createMap()); + var property = properties.get(name); if (!property) { property = createUnionOrIntersectionProperty(type, name); if (property) { - properties[name] = property; + properties.set(name, property); } } return property; } function getPropertyOfUnionOrIntersectionType(type, name) { var property = getUnionOrIntersectionProperty(type, name); - return property && !(property.flags & 268435456 && property.isPartial) ? property : undefined; + return property && !(getCheckFlags(property) & 8) ? property : undefined; } function getPropertyOfType(type, name) { type = getApparentType(type); if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } @@ -23672,16 +24243,16 @@ var ts; } function symbolsToArray(symbols) { var result = []; - for (var id in symbols) { + symbols.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { - result.push(symbols[id]); + result.push(symbol); } - } + }); return result; } function isJSDocOptionalParameter(node) { if (node.flags & 65536) { - if (node.type && node.type.kind === 274) { + if (node.type && node.type.kind === 277) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -23692,7 +24263,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 274; + return paramTag.typeExpression.type.kind === 277; } } } @@ -23716,6 +24287,12 @@ var ts; ts.Debug.assert(parameterIndex >= 0); return parameterIndex >= signature.minArgumentCount; } + var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); + if (iife) { + return !node.type && + !node.dotDotDotToken && + ts.indexOf(node.parent.parameters, node) >= iife.arguments.length; + } return false; } function createTypePredicateFromTypePredicateNode(node) { @@ -23735,15 +24312,48 @@ var ts; }; } } + function getMinTypeArgumentCount(typeParameters) { + var minTypeArgumentCount = 0; + if (typeParameters) { + for (var i = 0; i < typeParameters.length; i++) { + if (!getDefaultFromTypeParameter(typeParameters[i])) { + minTypeArgumentCount = i + 1; + } + } + } + return minTypeArgumentCount; + } + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount) { + var numTypeParameters = ts.length(typeParameters); + if (numTypeParameters) { + var numTypeArguments = ts.length(typeArguments); + if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + if (!typeArguments) { + typeArguments = []; + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + typeArguments[i] = emptyObjectType; + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + var mapper = createTypeMapper(typeParameters, typeArguments); + var defaultType = getDefaultFromTypeParameter(typeParameters[i]); + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + } + } + } + return typeArguments; + } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; var hasLiteralTypes = false; - var minArgumentCount = -1; + var minArgumentCount = 0; var thisParameter = undefined; var hasThisParameter = void 0; + var iife = ts.getImmediatelyInvokedFunctionExpression(declaration); var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); + var isUntypedSignatureInJSFile = !iife && !isJSConstructSignature && ts.isInJavaScriptFile(declaration) && !ts.hasJSDocParameterTags(declaration); for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; @@ -23758,41 +24368,34 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 171) { + if (param.type && param.type.kind === 172) { hasLiteralTypes = true; } - if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { - if (minArgumentCount < 0) { - minArgumentCount = i - (hasThisParameter ? 1 : 0); - } - } - else { - minArgumentCount = -1; + var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken || + iife && parameters.length > iife.arguments.length && !param.type || + isJSDocOptionalParameter(param) || + isUntypedSignatureInJSFile; + if (!isOptionalParameter_1) { + minArgumentCount = parameters.length; } } - if ((declaration.kind === 151 || declaration.kind === 152) && + if ((declaration.kind === 152 || declaration.kind === 153) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 151 ? 152 : 151; + var otherKind = declaration.kind === 152 ? 153 : 152; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); - } - if (isJSConstructSignature) { - minArgumentCount--; - } - var classType = declaration.kind === 150 ? + var classType = declaration.kind === 151 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 156 ? + var typePredicate = declaration.type && declaration.type.kind === 157 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -23815,8 +24418,8 @@ var ts; return type; } } - if (declaration.kind === 151 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 152); + if (declaration.kind === 152 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 153); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -23830,20 +24433,20 @@ var ts; for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 158: case 159: - case 226: - case 149: - case 148: + case 160: + case 227: case 150: - case 153: + case 149: + case 151: case 154: case 155: - case 151: + case 156: case 152: - case 184: + case 153: case 185: - case 275: + case 186: + case 278: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -23911,9 +24514,14 @@ var ts; return anyType; } function getSignatureInstantiation(signature, typeArguments) { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); - return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + var instantiation = instantiations.get(id); + if (!instantiation) { + instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments)); + } + return instantiation; } function createSignatureInstantiation(signature, typeArguments) { return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); @@ -23928,7 +24536,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 150 || signature.declaration.kind === 154; + var isConstructor = signature.declaration.kind === 151 || signature.declaration.kind === 155; var type = createObjectType(16); type.members = emptySymbols; type.properties = emptyArray; @@ -23939,10 +24547,10 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members["__index"]; + return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 132 : 134; + var syntaxKind = kind === 1 ? 132 : 135; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -23969,21 +24577,9 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 143).constraint; + return ts.getDeclarationOfKind(type.symbol, 144).constraint; } - function hasConstraintReferenceTo(type, target) { - var checked; - while (type && type.flags & 16384 && !(type.isThisType) && !ts.contains(checked, type)) { - if (type === target) { - return true; - } - (checked || (checked = [])).push(type); - var constraintDeclaration = getConstraintDeclaration(type); - type = constraintDeclaration && getTypeFromTypeNode(constraintDeclaration); - } - return false; - } - function getConstraintOfTypeParameter(typeParameter) { + function getConstraintFromTypeParameter(typeParameter) { if (!typeParameter.constraint) { if (typeParameter.target) { var targetConstraint = getConstraintOfTypeParameter(typeParameter.target); @@ -23991,23 +24587,13 @@ var ts; } else { var constraintDeclaration = getConstraintDeclaration(typeParameter); - var constraint = getTypeFromTypeNode(constraintDeclaration); - if (hasConstraintReferenceTo(constraint, typeParameter)) { - error(constraintDeclaration, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); - constraint = unknownType; - } - typeParameter.constraint = constraint; + typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : noConstraintType; } } return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } - function getConstraintOfTypeVariable(type) { - return type.flags & 16384 ? getConstraintOfTypeParameter(type) : - type.flags & 524288 ? type.constraint : - undefined; - } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 143).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 144).parent); } function getTypeListId(types) { var result = ""; @@ -24034,8 +24620,8 @@ var ts; } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var type = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -24044,9 +24630,10 @@ var ts; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); - var type = target.instantiations[id]; + var type = target.instantiations.get(id); if (!type) { - type = target.instantiations[id] = createObjectType(4, target.symbol); + type = createObjectType(4, target.symbol); + target.instantiations.set(id, type); type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0; type.target = target; type.typeArguments = typeArguments; @@ -24062,17 +24649,22 @@ var ts; return type; } function getTypeReferenceArity(type) { - return type.target.typeParameters ? type.target.typeParameters.length : 0; + return ts.length(type.target.typeParameters); } function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), typeParameters.length); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, undefined, 1), minTypeArgumentCount, typeParameters.length); return unknownType; } - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + return createTypeReference(type, typeArguments); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -24085,14 +24677,22 @@ var ts; var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + var instantiation = links.instantiations.get(id); + if (!instantiation) { + links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + } + return instantiation; } function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return unknownType; } var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); @@ -24113,11 +24713,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 157: + case 158: return node.typeName; - case 273: + case 276: return node.name; - case 199: + case 200: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -24141,7 +24741,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 273) { + if (symbol.flags & 107455 && node.kind === 276) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -24151,13 +24751,13 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 273) { + if (node.kind === 276) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { - var typeNameOrExpression = node.kind === 157 + var typeNameOrExpression = node.kind === 158 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -24183,12 +24783,12 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var declaration = declarations_4[_i]; switch (declaration.kind) { - case 227: case 228: - case 230: + case 229: + case 231: return declaration; } } @@ -24201,7 +24801,7 @@ var ts; error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return arity ? emptyGenericType : emptyObjectType; } - if ((type.typeParameters ? type.typeParameters.length : 0) !== arity) { + if (ts.length(type.typeParameters) !== arity) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); return arity ? emptyGenericType : emptyObjectType; } @@ -24256,7 +24856,7 @@ var ts; for (var i = 0; i < arity; i++) { var typeParameter = createType(16384); typeParameters.push(typeParameter); - var property = createSymbol(4 | 67108864, "" + i); + var property = createSymbol(4, "" + i); property.type = typeParameter; properties.push(property); } @@ -24265,7 +24865,7 @@ var ts; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384); @@ -24347,14 +24947,14 @@ var ts; } } function addTypesToUnion(typeSet, types) { - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var t = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var t = types_6[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -24362,8 +24962,8 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } @@ -24442,10 +25042,11 @@ var ts; return types[0]; } var id = getTypeListId(types); - var type = unionTypes[id]; + var type = unionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(types, 6144); - type = unionTypes[id] = createType(65536 | propagatedFlags); + type = createType(65536 | propagatedFlags); + unionTypes.set(id, type); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -24470,12 +25071,15 @@ var ts; if (type.flags & 65536 && typeSet.unionIndex === undefined) { typeSet.unionIndex = typeSet.length; } - typeSet.push(type); + if (!(type.flags & 32768 && type.objectFlags & 16 && + type.symbol && type.symbol.flags & (16 | 8192) && containsIdenticalType(typeSet, type))) { + typeSet.push(type); + } } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; addTypeToIntersection(typeSet, type); } } @@ -24497,10 +25101,11 @@ var ts; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex, t)); }), false, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); - var type = intersectionTypes[id]; + var type = intersectionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, 6144); - type = intersectionTypes[id] = createType(131072 | propagatedFlags); + type = createType(131072 | propagatedFlags); + intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -24550,21 +25155,10 @@ var ts; var type = createType(524288); type.objectType = objectType; type.indexType = indexType; - if (type.objectType.flags & 229376) { - type.constraint = getIndexTypeOfType(type.objectType, 0); - } - else if (type.objectType.flags & 540672) { - var apparentType = getApparentTypeOfTypeVariable(type.objectType); - if (apparentType !== emptyObjectType) { - type.constraint = isTypeOfKind(type.indexType, 262178) ? - getIndexedAccessType(apparentType, type.indexType) : - getIndexTypeOfType(apparentType, 0); - } - } return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 178 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; var propName = indexType.flags & (32 | 64 | 256) ? indexType.text : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? @@ -24612,7 +25206,7 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 178 ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 179 ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (32 | 64)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); } @@ -24626,33 +25220,31 @@ var ts; return unknownType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 178 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; } - var mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); + var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } function getIndexedAccessType(objectType, indexType, accessNode) { if (maybeTypeOfKind(indexType, 540672 | 262144) || - maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 178) || + maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 179) || isGenericMappedType(objectType)) { if (objectType.flags & 1) { return objectType; } - if (accessNode) { - if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { - error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); - return unknownType; - } - } if (isGenericMappedType(objectType)) { return getIndexedAccessForMappedType(objectType, indexType, accessNode); } var id = objectType.id + "," + indexType.id; - return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType)); + var type = indexedAccessTypes.get(id); + if (!type) { + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType)); + } + return type; } var apparentObjectType = getApparentType(objectType); if (indexType.flags & 65536 && !(indexType.flags & 8190)) { @@ -24692,7 +25284,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - if (ts.isEmpty(node.symbol.members) && !aliasSymbol) { + if (node.symbol.members.size === 0 && !aliasSymbol) { links.resolvedType = emptyTypeLiteralType; } else { @@ -24705,13 +25297,13 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 229 ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 230 ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } - function getSpreadType(left, right, isFromObjectLiteral) { + function getSpreadType(left, right) { if (left.flags & 1 || right.flags & 1) { return anyType; } @@ -24724,10 +25316,13 @@ var ts; return left; } if (left.flags & 65536) { - return mapType(left, function (t) { return getSpreadType(t, right, isFromObjectLiteral); }); + return mapType(left, function (t) { return getSpreadType(t, right); }); } if (right.flags & 65536) { - return mapType(right, function (t) { return getSpreadType(left, t, isFromObjectLiteral); }); + return mapType(right, function (t) { return getSpreadType(left, t); }); + } + if (right.flags & 16777216) { + return emptyObjectType; } var members = ts.createMap(); var skippedPrivateMembers = ts.createMap(); @@ -24743,42 +25338,45 @@ var ts; } for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; - var isOwnProperty = !(rightProp.flags & 8192) || isFromObjectLiteral; var isSetterWithoutGetter = rightProp.flags & 65536 && !(rightProp.flags & 32768); if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 | 16)) { - skippedPrivateMembers[rightProp.name] = true; + skippedPrivateMembers.set(rightProp.name, true); } - else if (isOwnProperty && !isSetterWithoutGetter) { - members[rightProp.name] = rightProp; + else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { + members.set(rightProp.name, rightProp); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { var leftProp = _c[_b]; if (leftProp.flags & 65536 && !(leftProp.flags & 32768) - || leftProp.name in skippedPrivateMembers) { + || skippedPrivateMembers.has(leftProp.name) + || isClassMethod(leftProp)) { continue; } - if (leftProp.name in members) { - var rightProp = members[leftProp.name]; + if (members.has(leftProp.name)) { + var rightProp = members.get(leftProp.name); var rightType = getTypeOfSymbol(rightProp); - if (maybeTypeOfKind(rightType, 2048) || rightProp.flags & 536870912) { + if (maybeTypeOfKind(rightType, 2048) || rightProp.flags & 67108864) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 | 67108864 | (leftProp.flags & 536870912); + var flags = 4 | (leftProp.flags & 67108864); var result = createSymbol(flags, leftProp.name); + result.checkFlags = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp) ? 4 : 0; result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; - result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); - members[leftProp.name] = result; + members.set(leftProp.name, result); } } else { - members[leftProp.name] = leftProp; + members.set(leftProp.name, leftProp); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function isClassMethod(prop) { + return prop.flags & 8192 && ts.find(prop.declarations, function (decl) { return ts.isClassLike(decl.parent); }); + } function createLiteralType(flags, text) { var type = createType(flags); type.text = text; @@ -24800,7 +25398,11 @@ var ts; } function getLiteralTypeForText(flags, text) { var map = flags & 32 ? stringLiteralTypes : numericLiteralTypes; - return map[text] || (map[text] = createLiteralType(flags, text)); + var type = map.get(text); + if (!type) { + map.set(text, type = createLiteralType(flags, text)); + } + return type; } function getTypeFromLiteralTypeNode(node) { var links = getNodeLinks(node); @@ -24828,9 +25430,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 228)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 229)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 150 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 151 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -24847,85 +25449,87 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118: - case 264: - case 265: + case 267: + case 268: return anyType; - case 134: + case 135: return stringType; case 132: return numberType; case 121: return booleanType; - case 135: + case 136: return esSymbolType; case 104: return voidType; - case 137: + case 138: return undefinedType; case 94: return nullType; case 129: return neverType; - case 290: + case 133: + return nonPrimitiveType; + case 293: return nullType; - case 291: + case 294: return undefinedType; - case 292: + case 295: return neverType; - case 167: + case 168: case 98: return getTypeFromThisTypeNode(node); - case 171: + case 172: return getTypeFromLiteralTypeNode(node); - case 289: + case 292: return getTypeFromLiteralTypeNode(node.literal); - case 157: - case 273: - return getTypeFromTypeReference(node); - case 156: - return booleanType; - case 199: - return getTypeFromTypeReference(node); - case 160: - return getTypeFromTypeQueryNode(node); - case 162: - case 266: - return getTypeFromArrayTypeNode(node); - case 163: - return getTypeFromTupleTypeNode(node); - case 164: - case 267: - return getTypeFromUnionTypeNode(node); - case 165: - return getTypeFromIntersectionTypeNode(node); - case 166: - case 269: - case 270: - case 277: - case 278: - case 274: - return getTypeFromTypeNode(node.type); - case 271: - return getTypeFromTypeNode(node.literal); case 158: - case 159: + case 276: + return getTypeFromTypeReference(node); + case 157: + return booleanType; + case 200: + return getTypeFromTypeReference(node); case 161: - case 288: - case 275: + return getTypeFromTypeQueryNode(node); + case 163: + case 269: + return getTypeFromArrayTypeNode(node); + case 164: + return getTypeFromTupleTypeNode(node); + case 165: + case 270: + return getTypeFromUnionTypeNode(node); + case 166: + return getTypeFromIntersectionTypeNode(node); + case 167: + case 272: + case 273: + case 280: + case 281: + case 277: + return getTypeFromTypeNode(node.type); + case 274: + return getTypeFromTypeNode(node.literal); + case 159: + case 160: + case 162: + case 291: + case 278: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 168: - return getTypeFromTypeOperatorNode(node); case 169: - return getTypeFromIndexedAccessTypeNode(node); + return getTypeFromTypeOperatorNode(node); case 170: + return getTypeFromIndexedAccessTypeNode(node); + case 171: return getTypeFromMappedTypeNode(node); case 70: - case 141: + case 142: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 268: + case 271: return getTypeFromJSDocTupleType(node); - case 276: + case 279: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -24952,13 +25556,13 @@ var ts; var instantiations = mapper.instantiations || (mapper.instantiations = []); return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); } - function createUnaryTypeMapper(source, target) { + function makeUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } - function createBinaryTypeMapper(source1, target1, source2, target2) { + function makeBinaryTypeMapper(source1, target1, source2, target2) { return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; } - function createArrayTypeMapper(sources, targets) { + function makeArrayTypeMapper(sources, targets) { return function (t) { for (var i = 0; i < sources.length; i++) { if (t === sources[i]) { @@ -24969,16 +25573,20 @@ var ts; }; } function createTypeMapper(sources, targets) { - var count = sources.length; - var mapper = count == 1 ? createUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : - count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - createArrayTypeMapper(sources, targets); + var mapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : + makeArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; return mapper; } function createTypeEraser(sources) { return createTypeMapper(sources, undefined); } + function createBackreferenceMapper(typeParameters, index) { + var mapper = function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; + mapper.mappedTypes = typeParameters; + return mapper; + } function getInferenceMapper(context) { if (!context.mapper) { var mapper = function (t) { @@ -25002,7 +25610,12 @@ var ts; } function combineTypeMappers(mapper1, mapper2) { var mapper = function (t) { return instantiateType(mapper1(t), mapper2); }; - mapper.mappedTypes = mapper1.mappedTypes; + mapper.mappedTypes = ts.concatenate(mapper1.mappedTypes, mapper2.mappedTypes); + return mapper; + } + function createReplacementMapper(source, target, baseMapper) { + var mapper = function (t) { return t === source ? target : baseMapper(t); }; + mapper.mappedTypes = baseMapper.mappedTypes; return mapper; } function cloneTypeParameter(typeParameter) { @@ -25047,12 +25660,13 @@ var ts; return result; } function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { var links = getSymbolLinks(symbol); symbol = links.target; mapper = combineTypeMappers(links.mapper, mapper); } - var result = createSymbol(16777216 | 67108864 | symbol.flags, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); + result.checkFlags = 1; result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -25079,10 +25693,7 @@ var ts; if (typeVariable_1 !== mappedTypeVariable) { return mapType(mappedTypeVariable, function (t) { if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); + return instantiateMappedObjectType(type, createReplacementMapper(typeVariable_1, t, mapper)); } return t; }); @@ -25110,23 +25721,23 @@ var ts; var node = symbol.declarations[0]; while (node) { switch (node.kind) { - case 158: case 159: - case 226: - case 149: - case 148: + case 160: + case 227: case 150: - case 153: + case 149: + case 151: case 154: case 155: - case 151: + case 156: case 152: - case 184: + case 153: case 185: - case 227: - case 197: + case 186: case 228: + case 198: case 229: + case 230: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -25136,14 +25747,19 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 228) { + if (ts.isClassLike(node) || node.kind === 229) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 275: + case 171: + if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { + return true; + } + break; + case 278: var func = node; for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { var p = _c[_b]; @@ -25152,8 +25768,8 @@ var ts; } } break; - case 231: - case 262: + case 232: + case 264: return false; } node = node.parent; @@ -25163,7 +25779,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 262 || parentKind === 232; + return parentKind === 264 || parentKind === 233; } return false; } @@ -25215,28 +25831,34 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 184: case 185: + case 186: return isContextSensitiveFunctionLikeDeclaration(node); - case 176: + case 177: return ts.forEach(node.properties, isContextSensitive); - case 175: + case 176: return ts.forEach(node.elements, isContextSensitive); - case 193: + case 194: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 192: + case 193: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 258: + case 260: return isContextSensitive(node.initializer); + case 150: case 149: - case 148: return isContextSensitiveFunctionLikeDeclaration(node); - case 183: + case 184: return isContextSensitive(node.expression); + case 253: + return ts.forEach(node.properties, isContextSensitive); + case 252: + return node.initializer && isContextSensitive(node.initializer); + case 255: + return node.expression && isContextSensitive(node.expression); } return false; } @@ -25247,7 +25869,7 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !p.type; })) { return true; } - if (node.kind === 185) { + if (node.kind === 186) { return false; } var parameter = ts.firstOrUndefined(node.parameters); @@ -25265,9 +25887,12 @@ var ts; result.properties = resolved.properties; result.callSignatures = emptyArray; result.constructSignatures = emptyArray; - type = result; + return result; } } + else if (type.flags & 131072) { + return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); + } return type; } function isTypeIdenticalTo(source, target) { @@ -25434,13 +26059,15 @@ var ts; return true; } var id = source.id + "," + target.id; - if (enumRelation[id] !== undefined) { - return enumRelation[id]; + var relation = enumRelation.get(id); + if (relation !== undefined) { + return relation; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & 256) || !(target.symbol.flags & 256) || (source.flags & 65536) !== (target.flags & 65536)) { - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } var targetEnumType = getTypeOfSymbol(target.symbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(source.symbol)); _i < _a.length; _i++) { @@ -25451,11 +26078,13 @@ var ts; if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, property.name, typeToString(target, undefined, 128)); } - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } } } - return enumRelation[id] = true; + enumRelation.set(id, true); + return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { if (target.flags & 8192) @@ -25476,6 +26105,8 @@ var ts; return true; if (source.flags & 4096 && (!strictNullChecks || target.flags & 4096)) return true; + if (source.flags & 32768 && target.flags & 16777216) + return true; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & 1) return true; @@ -25507,12 +26138,12 @@ var ts; } if (source.flags & 32768 && target.flags & 32768) { var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { return related === 1; } } - if (source.flags & 507904 || target.flags & 507904) { + if (source.flags & 1032192 || target.flags & 1032192) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -25651,14 +26282,6 @@ var ts; } } } - else { - var constraint = getConstraintOfTypeParameter(target); - if (constraint && constraint.flags & 262144) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - return result; - } - } - } } else if (target.flags & 262144) { if (source.flags & 262144) { @@ -25666,12 +26289,10 @@ var ts; return result; } } - if (target.type.flags & 540672) { - var constraint = getConstraintOfTypeVariable(target.type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } + var constraint = getConstraintOfType(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; } } } @@ -25681,8 +26302,9 @@ var ts; return result; } } - if (target.constraint) { - if (result = isRelatedTo(source, target.constraint, reportErrors)) { + var constraint = getBaseConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -25699,20 +26321,23 @@ var ts; } else { var constraint = getConstraintOfTypeParameter(source); - if (!constraint || constraint.flags & 1) { - constraint = emptyObjectType; - } - constraint = getTypeWithThisArgument(constraint, source); - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; + if (constraint || !(target.flags & 16777216)) { + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + constraint = getTypeWithThisArgument(constraint, source); + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } } else if (source.flags & 524288) { - if (source.constraint) { - if (result = isRelatedTo(source.constraint, target, reportErrors)) { + var constraint = getBaseConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -25764,42 +26389,55 @@ var ts; } return 0; } - function isKnownProperty(type, name) { + function isKnownProperty(type, name, isComparingJsxAttributes) { if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || - resolved.stringIndexInfo || - (resolved.numberIndexInfo && isNumericLiteralName(name)) || - getPropertyOfType(type, name)) { + if ((relation === assignableRelation || relation === comparableRelation) && + (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) { + return true; + } + else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) { + return true; + } + else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) { return true; } } else if (type.flags & 196608) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (isKnownProperty(t, name)) { + if (isKnownProperty(t, name, isComparingJsxAttributes)) { return true; } } } return false; } - function isEmptyObjectType(t) { + function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && !t.stringIndexInfo && !t.numberIndexInfo; } + function isEmptyObjectType(type) { + return type.flags & 32768 && isEmptyResolvedType(resolveStructuredTypeMembers(type)); + } function hasExcessProperties(source, target, reportErrors) { if (maybeTypeOfKind(target, 32768) && !(getObjectFlags(target) & 512)) { + var isComparingJsxAttributes = !!(source.flags & 33554432); for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; - if (!isKnownProperty(target, prop.name)) { + if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { if (reportErrors) { ts.Debug.assert(!!errorNode); - errorNode = prop.valueDeclaration; - reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + if (ts.isJsxAttributes(errorNode)) { + reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); + } + else { + errorNode = prop.valueDeclaration; + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } } return true; } @@ -25825,20 +26463,42 @@ var ts; if (target.flags & 65536 && containsType(targetTypes, source)) { return -1; } - var len = targetTypes.length; - for (var i = 0; i < len; i++) { - var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var type = targetTypes_1[_i]; + var related = isRelatedTo(source, type, false); if (related) { return related; } } + if (reportErrors) { + var discriminantType = findMatchingDiscriminantType(source, target); + isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], true); + } return 0; } + function findMatchingDiscriminantType(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProperty = sourceProperties_1[_i]; + if (isDiscriminantProperty(target, sourceProperty.name)) { + var sourceType = getTypeOfSymbol(sourceProperty); + for (var _a = 0, _b = target.types; _a < _b.length; _a++) { + var type = _b[_a]; + var targetType = getTypeOfPropertyOfType(type, sourceProperty.name); + if (targetType && isRelatedTo(sourceType, targetType)) { + return type; + } + } + } + } + } + } function typeRelatedToEachType(source, target, reportErrors) { var result = -1; var targetTypes = target.types; - for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { - var targetType = targetTypes_1[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var targetType = targetTypes_2[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0; @@ -25896,10 +26556,10 @@ var ts; return 0; } var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2) { - relation[id] = 3; + relation.set(id, 3); } else { return related === 1 ? -1 : 0; @@ -25907,7 +26567,7 @@ var ts; } if (depth > 0) { for (var i = 0; i < depth; i++) { - if (maybeStack[i][id]) { + if (maybeStack[i].get(id)) { return 1; } } @@ -25925,7 +26585,7 @@ var ts; sourceStack[depth] = source; targetStack[depth] = target; maybeStack[depth] = ts.createMap(); - maybeStack[depth][id] = 1; + maybeStack[depth].set(id, 1); depth++; var saveExpandingFlags = expandingFlags; if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) @@ -25959,38 +26619,38 @@ var ts; if (result) { var maybeCache = maybeStack[depth]; var destinationCache = (result === -1 || depth === 0) ? relation : maybeStack[depth - 1]; - ts.copyProperties(maybeCache, destinationCache); + ts.copyEntries(maybeCache, destinationCache); } else { - relation[id] = reportErrors ? 3 : 2; + relation.set(id, reportErrors ? 3 : 2); } return result; } function mappedTypeRelatedTo(source, target, reportErrors) { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { - var result_2; - if (relation === identityRelation) { - var readonlyMatches = !source.declaration.readonlyToken === !target.declaration.readonlyToken; - var optionalMatches = !source.declaration.questionToken === !target.declaration.questionToken; - if (readonlyMatches && optionalMatches) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getErasedTemplateTypeFromMappedType(source), getErasedTemplateTypeFromMappedType(target), reportErrors); - } - } - } - else { - if (relation === comparableRelation || !source.declaration.questionToken || target.declaration.questionToken) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors); - } + var sourceReadonly = !!source.declaration.readonlyToken; + var sourceOptional = !!source.declaration.questionToken; + var targetReadonly = !!target.declaration.readonlyToken; + var targetOptional = !!target.declaration.questionToken; + var modifiersRelated = relation === identityRelation ? + sourceReadonly === targetReadonly && sourceOptional === targetOptional : + relation === comparableRelation || !sourceOptional || targetOptional; + if (modifiersRelated) { + var result_2; + if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { + var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); + return result_2 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } + else if (target.declaration.questionToken && isEmptyObjectType(source)) { + return -1; + } } else if (relation !== identityRelation) { var resolved = resolveStructuredTypeMembers(target); - if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1) { + if (isEmptyResolvedType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1) { return -1; } } @@ -26008,17 +26668,23 @@ var ts; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { - if (!(targetProp.flags & 536870912) || requireOptionalProperties) { + if (!(targetProp.flags & 67108864) || requireOptionalProperties) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); } return 0; } } - else if (!(targetProp.flags & 134217728)) { + else if (!(targetProp.flags & 16777216)) { var sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 || targetPropFlags & 8) { + if (getCheckFlags(sourceProp) & 128) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); + } + return 0; + } if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { if (sourcePropFlags & 8 && targetPropFlags & 8) { @@ -26032,12 +26698,9 @@ var ts; } } else if (targetPropFlags & 16) { - var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(getParentOfSymbol(sourceProp)) : undefined; - var targetClass = getDeclaredTypeOfSymbol(getParentOfSymbol(targetProp)); - if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { + if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); + reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } return 0; } @@ -26056,7 +26719,7 @@ var ts; return 0; } result &= related; - if (relation !== comparableRelation && sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { + if (relation !== comparableRelation && sourceProp.flags & 67108864 && !(targetProp.flags & 67108864)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -26077,8 +26740,8 @@ var ts; return 0; } var result = -1; - for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { - var sourceProp = sourceProperties_1[_i]; + for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { + var sourceProp = sourceProperties_2[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0; @@ -26239,6 +26902,37 @@ var ts; return false; } } + function forEachProperty(prop, callback) { + if (getCheckFlags(prop) & 2) { + for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var p = getPropertyOfType(t, prop.name); + var result = p && forEachProperty(p, callback); + if (result) { + return result; + } + } + return undefined; + } + return callback(prop); + } + function getDeclaringClass(prop) { + return prop.parent && prop.parent.flags & 32 ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + } + function isPropertyInClassDerivedFrom(prop, baseClass) { + return forEachProperty(prop, function (sp) { + var sourceClass = getDeclaringClass(sp); + return sourceClass ? hasBaseType(sourceClass, baseClass) : false; + }); + } + function isValidOverrideOf(sourceProp, targetProp) { + return !forEachProperty(targetProp, function (tp) { return getDeclarationModifierFlagsFromSymbol(tp) & 16 ? + !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); + } + function isClassDerivedFromDeclaringClasses(checkClass, prop) { + return forEachProperty(prop, function (p) { return getDeclarationModifierFlagsFromSymbol(p) & 16 ? + !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; + } function isAbstractConstructorType(type) { if (getObjectFlags(type) & 16) { var symbol = type.symbol; @@ -26284,7 +26978,7 @@ var ts; } } else { - if ((sourceProp.flags & 536870912) !== (targetProp.flags & 536870912)) { + if ((sourceProp.flags & 67108864) !== (targetProp.flags & 67108864)) { return 0; } } @@ -26314,7 +27008,7 @@ var ts; if (!(isMatchingSignature(source, target, partialMatch))) { return 0; } - if ((source.typeParameters ? source.typeParameters.length : 0) !== (target.typeParameters ? target.typeParameters.length : 0)) { + if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { return 0; } source = getErasedSignature(source); @@ -26352,8 +27046,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -26361,8 +27055,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -26453,8 +27147,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getFalsyFlags(t); } return result; @@ -26483,7 +27177,7 @@ var ts; types.push(undefinedType); if (flags & 4096) types.push(nullType); - return getUnionType(types, true); + return getUnionType(types); } function removeDefinitelyFalsyTypes(type) { return getFalsyFlags(type) & 7392 ? @@ -26498,8 +27192,8 @@ var ts; getSignaturesOfType(type, 0).length === 0 && getSignaturesOfType(type, 1).length === 0; } - function createTransientSymbol(source, type) { - var symbol = createSymbol(source.flags | 67108864, source.name); + function createSymbolWithType(source, type) { + var symbol = createSymbol(source.flags, source.name); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -26515,7 +27209,7 @@ var ts; var property = _a[_i]; var original = getTypeOfSymbol(property); var updated = f(original); - members[property.name] = updated === original ? property : createTransientSymbol(property, updated); + members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); } ; return members; @@ -26601,25 +27295,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 148: case 147: - case 146: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 144: + case 145: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 174: + case 175: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 226: + case 227: + case 150: case 149: - case 148: - case 151: case 152: - case 184: + case 153: case 185: + case 186: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -26704,7 +27398,7 @@ var ts; var typeInferencesArray = [typeInferences]; var templateType = getTemplateTypeFromMappedType(target); var readonlyMask = target.declaration.readonlyToken ? false : true; - var optionalMask = target.declaration.questionToken ? 0 : 536870912; + var optionalMask = target.declaration.questionToken ? 0 : 67108864; var members = createSymbolTable(properties); for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var prop = properties_4[_i]; @@ -26712,11 +27406,11 @@ var ts; if (!inferredPropType) { return undefined; } - var inferredProp = createSymbol(4 | 67108864 | prop.flags & optionalMask, prop.name); + var inferredProp = createSymbol(4 | prop.flags & optionalMask, prop.name); + inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 4 : 0; inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; - inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); - members[prop.name] = inferredProp; + members.set(prop.name, inferredProp); } if (indexInfo) { var inferredIndexType = inferTargetType(indexInfo.type); @@ -26826,8 +27520,8 @@ var ts; var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; - for (var _d = 0, targetTypes_2 = targetTypes; _d < targetTypes_2.length; _d++) { - var t = targetTypes_2[_d]; + for (var _d = 0, targetTypes_3 = targetTypes; _d < targetTypes_3.length; _d++) { + var t = targetTypes_3[_d]; if (t.flags & 540672 && ts.contains(typeVariables, t)) { typeVariable = t; typeVariableCount++; @@ -26859,10 +27553,10 @@ var ts; return; } var key = source.id + "," + target.id; - if (visited[key]) { + if (visited.get(key)) { return; } - visited[key] = true; + visited.set(key, true); if (depth === 0) { sourceStack = []; targetStack = []; @@ -26954,8 +27648,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -26996,7 +27690,13 @@ var ts; inferenceSucceeded = !!unionOrSuperType; } else { - inferredType = emptyObjectType; + var defaultType = getDefaultFromTypeParameter(context.signature.typeParameters[index]); + if (defaultType) { + inferredType = instantiateType(defaultType, combineTypeMappers(createBackreferenceMapper(context.signature.typeParameters, index), getInferenceMapper(context))); + } + else { + inferredType = emptyObjectType; + } inferenceSucceeded = true; } context.inferredTypes[index] = inferredType; @@ -27031,10 +27731,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 160: + case 161: return true; case 70: - case 141: + case 142: node = node.parent; continue; default: @@ -27051,7 +27751,7 @@ var ts; if (node.kind === 98) { return "0"; } - if (node.kind === 177) { + if (node.kind === 178) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -27062,7 +27762,7 @@ var ts; case 70: case 98: return node; - case 177: + case 178: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -27071,19 +27771,19 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 224 || target.kind === 174) && + (target.kind === 225 || target.kind === 175) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; - case 177: - return target.kind === 177 && + case 178: + return target.kind === 178 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 177) { + while (source.kind === 178) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -27092,7 +27792,7 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 177 && + return target.kind === 178 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -27100,7 +27800,7 @@ var ts; if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 177) { + if (expr.kind === 178) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -27109,9 +27809,9 @@ var ts; function isDiscriminantProperty(type, name) { if (type && type.flags & 65536) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && prop.flags & 268435456) { + if (prop && getCheckFlags(prop) & 2) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.hasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.checkFlags & 16 && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -27130,7 +27830,7 @@ var ts; } } } - if (callExpression.expression.kind === 177 && + if (callExpression.expression.kind === 178 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -27169,8 +27869,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -27178,7 +27878,7 @@ var ts; function isFunctionObjectType(type) { var resolved = resolveStructuredTypeMembers(type); return !!(resolved.callSignatures.length || resolved.constructSignatures.length || - resolved.members["bind"] && isTypeSubtypeOf(type, globalFunctionType)); + resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type) { var flags = type.flags; @@ -27221,6 +27921,9 @@ var ts; if (flags & 512) { return strictNullChecks ? 1981320 : 4193160; } + if (flags & 16777216) { + return strictNullChecks ? 6166480 : 8378320; + } if (flags & 16384) { var constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); @@ -27256,10 +27959,16 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 || node.parent.kind === 258 ? + var isDestructuringDefaultAssignment = node.parent.kind === 176 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 260 && isDestructuringAssignmentTarget(node.parent.parent); + return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } + function isDestructuringAssignmentTarget(parent) { + return parent.parent.kind === 193 && parent.parent.left === parent || + parent.parent.kind === 215 && parent.parent.initializer === parent; + } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); } @@ -27275,21 +27984,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 213: - return stringType; case 214: + return stringType; + case 215: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 192: + case 193: return getAssignedTypeOfBinaryExpression(parent); - case 186: + case 187: return undefinedType; - case 175: + case 176: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 196: + case 197: return getAssignedTypeOfSpreadExpression(parent); - case 258: + case 260: return getAssignedTypeOfPropertyAssignment(parent); - case 259: + case 261: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -27297,7 +28006,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 172 ? + var type = pattern.kind === 173 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -27312,35 +28021,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 213) { + if (node.parent.parent.kind === 214) { return stringType; } - if (node.parent.parent.kind === 214) { + if (node.parent.parent.kind === 215) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 224 ? + return node.kind === 225 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 224 || node.kind === 174 ? + return node.kind === 225 || node.kind === 175 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 224 && node.initializer && + return node.kind === 225 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 174 && node.parent.kind === 192 && + node.kind !== 175 && node.parent.kind === 193 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 183: + case 184: return getReferenceCandidate(node.expression); - case 192: + case 193: switch (node.operatorToken.kind) { case 57: return getReferenceCandidate(node.left); @@ -27352,13 +28061,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 183 || - parent.kind === 192 && parent.operatorToken.kind === 57 && parent.left === node || - parent.kind === 192 && parent.operatorToken.kind === 25 && parent.right === node ? + return parent.kind === 184 || + parent.kind === 193 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 193 && parent.operatorToken.kind === 25 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 254) { + if (clause.kind === 256) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -27460,8 +28169,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -27479,11 +28188,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 177 && (parent.name.text === "length" || - parent.parent.kind === 179 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 178 && + var isLengthPushOrUnshift = parent.kind === 178 && (parent.name.text === "length" || + parent.parent.kind === 180 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 179 && parent.expression === root && - parent.parent.kind === 192 && + parent.parent.kind === 193 && parent.parent.operatorToken.kind === 57 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -27512,7 +28221,7 @@ var ts; } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 17810431)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -27522,7 +28231,7 @@ var ts; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; var resultType = getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 201 && getTypeWithFacts(resultType, 524288).flags & 8192) { + if (reference.parent.kind === 202 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; @@ -27536,7 +28245,16 @@ var ts; } } var type = void 0; - if (flow.flags & 16) { + if (flow.flags & 4096) { + flow.locked = true; + type = getTypeAtFlowNode(flow.antecedent); + flow.locked = false; + } + else if (flow.flags & 2048) { + flow = flow.antecedent; + continue; + } + else if (flow.flags & 16) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; @@ -27567,7 +28285,7 @@ var ts; } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 177) { + if (container && container !== flowContainer && reference.kind !== 178) { flow = container.flowNode; continue; } @@ -27610,7 +28328,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 179 ? + var expr = node.kind === 180 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -27618,7 +28336,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 179) { + if (node.kind === 180) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -27670,6 +28388,9 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; + if (antecedent.flags & 2048 && antecedent.lock.locked) { + continue; + } var flowType = getTypeAtFlowNode(antecedent); var type = getTypeFromFlowType(flowType); if (type === declaredType && declaredType === initialType) { @@ -27693,8 +28414,9 @@ var ts; if (!key) { key = getFlowCacheKey(reference); } - if (cache[key]) { - return cache[key]; + var cached = cache.get(key); + if (cached) { + return cached; } for (var i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { @@ -27716,8 +28438,9 @@ var ts; firstAntecedentType = flowType; } var type = getTypeFromFlowType(flowType); - if (cache[key]) { - return cache[key]; + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; } if (!ts.contains(antecedentTypes, type)) { antecedentTypes.push(type); @@ -27733,10 +28456,11 @@ var ts; if (isIncomplete(firstAntecedentType)) { return createFlowType(result, true); } - return cache[key] = result; + cache.set(key, result); + return result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 177 && + return expr.kind === 178 && declaredType.flags & 65536 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -27770,10 +28494,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 187 && right_1.kind === 9) { + if (left_1.kind === 188 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 187 && left_1.kind === 9) { + if (right_1.kind === 188 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -27819,7 +28543,7 @@ var ts; assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); } - if (type.flags & 33281) { + if (type.flags & 16810497) { return type; } if (assumeTrue) { @@ -27844,14 +28568,14 @@ var ts; assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 65536)) { - var targetType = typeofTypesByName[literal.text]; + var targetType = typeofTypesByName.get(literal.text); if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; } } var facts = assumeTrue ? - typeofEQFacts[literal.text] || 64 : - typeofNEFacts[literal.text] || 8192; + typeofEQFacts.get(literal.text) || 64 : + typeofNEFacts.get(literal.text) || 8192; return getTypeWithFacts(type, facts); } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { @@ -27951,7 +28675,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 178 || invokedExpression.kind === 177) { + if (invokedExpression.kind === 179 || invokedExpression.kind === 178) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -27968,15 +28692,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 177: + case 178: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 179: + case 180: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 183: + case 184: return narrowType(type, expr.expression, assumeTrue); - case 192: + case 193: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 190: + case 191: if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } @@ -28003,9 +28727,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 232 || - node.kind === 262 || - node.kind === 147) { + node.kind === 233 || + node.kind === 264 || + node.kind === 148) { return node; } } @@ -28036,7 +28760,7 @@ var ts; if (node.kind === 70) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 144) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 145) { symbol.isAssigned = true; } } @@ -28056,7 +28780,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 185) { + if (container.kind === 186) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { @@ -28074,7 +28798,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; - if (declaration_1.kind === 227 + if (declaration_1.kind === 228 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -28086,11 +28810,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 197) { + else if (declaration_1.kind === 198) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 147 && ts.hasModifier(container, 32)) { + if (container.kind === 148 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -28120,12 +28844,12 @@ var ts; if (!(localOrExportSymbol.flags & 3) || assignmentKind === 1 || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 144; + var isParameter = ts.getRootDeclaration(declaration).kind === 145; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && (flowContainer.kind === 184 || - flowContainer.kind === 185 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 185 || + flowContainer.kind === 186 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -28161,7 +28885,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 257) { + symbol.valueDeclaration.parent.kind === 259) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -28179,8 +28903,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 212 && - ts.getAncestor(symbol.valueDeclaration, 225).parent === container && + if (container.kind === 213 && + ts.getAncestor(symbol.valueDeclaration, 226).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -28192,14 +28916,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 183) { + while (current.parent.kind === 184) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 190 || current.parent.kind === 191)) { + else if ((current.parent.kind === 191 || current.parent.kind === 192)) { var expr = current.parent; isAssigned = expr.operator === 42 || expr.operator === 43; } @@ -28218,7 +28942,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 147 || container.kind === 150) { + if (container.kind === 148 || container.kind === 151) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -28262,32 +28986,32 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 150) { + if (container.kind === 151) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 185) { + if (container.kind === 186) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 231: + case 232: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 230: + case 231: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 150: + case 151: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 148: case 147: - case 146: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 142: + case 143: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -28296,7 +29020,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 184 && + if (container.kind === 185 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -28331,27 +29055,27 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 275) { + if (jsdocType && jsdocType.kind === 278) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 278) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 281) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 144) { + if (n.kind === 145) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 179 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 180 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 185) { + while (container && container.kind === 186) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -28360,16 +29084,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 142) { + while (current && current !== container && current.kind !== 143) { current = current.parent; } - if (current && current.kind === 142) { + if (current && current.kind === 143) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 176)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 177)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -28377,7 +29101,7 @@ var ts; } return unknownType; } - if (!isCallExpression && container.kind === 150) { + if (!isCallExpression && container.kind === 151) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if ((ts.getModifierFlags(container) & 32) || isCallExpression) { @@ -28387,7 +29111,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 149 && ts.getModifierFlags(container) & 256) { + if (container.kind === 150 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -28398,7 +29122,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 176) { + if (container.parent.kind === 177) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -28416,7 +29140,7 @@ var ts; } return unknownType; } - if (container.kind === 150 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 151 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -28428,24 +29152,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 150; + return container.kind === 151; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 176) { + if (ts.isClassLike(container.parent) || container.parent.kind === 177) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 149 || - container.kind === 148 || - container.kind === 151 || - container.kind === 152; + return container.kind === 150 || + container.kind === 149 || + container.kind === 152 || + container.kind === 153; } else { - return container.kind === 149 || - container.kind === 148 || - container.kind === 151 || + return container.kind === 150 || + container.kind === 149 || container.kind === 152 || + container.kind === 153 || + container.kind === 148 || container.kind === 147 || - container.kind === 146 || - container.kind === 150; + container.kind === 151; } } } @@ -28453,7 +29177,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 185) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 186) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -28468,23 +29192,23 @@ var ts; var func = parameter.parent; if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { var iife = ts.getImmediatelyInvokedFunctionExpression(func); - if (iife) { + if (iife && iife.arguments) { var indexOfParameter = ts.indexOf(func.parameters, parameter); - if (iife.arguments && indexOfParameter < iife.arguments.length) { - if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return createArrayType(getUnionType(restTypes)); + if (parameter.dotDotDotToken) { + var restTypes = []; + for (var i = indexOfParameter; i < iife.arguments.length; i++) { + restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); } - var links = getNodeLinks(iife); - var cached = links.resolvedSignature; - links.resolvedSignature = anySignature; - var type = getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])); - links.resolvedSignature = cached; - return type; + return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; } + var links = getNodeLinks(iife); + var cached = links.resolvedSignature; + links.resolvedSignature = anySignature; + var type = indexOfParameter < iife.arguments.length ? + getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + parameter.initializer ? undefined : undefinedWideningType; + links.resolvedSignature = cached; + return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -28509,7 +29233,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 144) { + if (declaration.kind === 145) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -28520,11 +29244,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_19 = declaration.propertyName || declaration.name; + var name = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_19)) { - var text = ts.getTextOfPropertyName(name_19); + !ts.isBindingPattern(name)) { + var text = ts.getTextOfPropertyName(name); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -28561,7 +29285,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 144 && node.parent.initializer === node) { + if (node.parent.kind === 145 && node.parent.initializer === node) { return true; } node = node.parent; @@ -28570,8 +29294,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 150 || - functionDecl.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 152))) { + functionDecl.kind === 151 || + functionDecl.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 153))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -28590,7 +29314,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 181) { + if (template.parent.kind === 182) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -28627,8 +29351,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -28695,19 +29419,16 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxAttribute(attribute) { - var kind = attribute.kind; - var jsxElement = attribute.parent; - var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 251) { - if (!attrsType || isTypeAny(attrsType)) { + var attributesType = getContextualType(attribute.parent); + if (ts.isJsxAttribute(attribute)) { + if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attrsType, attribute.name.text); + return getTypeOfPropertyOfType(attributesType, attribute.name.text); } - else if (attribute.kind === 252) { - return attrsType; + else { + return attributesType; } - ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); } function getApparentTypeOfContextualType(node) { var type = getContextualType(node); @@ -28722,42 +29443,45 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 224: - case 144: + case 225: + case 145: + case 148: case 147: - case 146: - case 174: - return getContextualTypeForInitializerExpression(node); - case 185: - case 217: - return getContextualTypeForReturnExpression(node); - case 195: - return getContextualTypeForYieldOperand(parent); - case 179: - case 180: - return getContextualTypeForArgument(parent, node); - case 182: - case 200: - return getTypeFromTypeNode(parent.type); - case 192: - return getContextualTypeForBinaryOperand(node); - case 258: - case 259: - return getContextualTypeForObjectLiteralElement(parent); case 175: - return getContextualTypeForElementExpression(node); - case 193: - return getContextualTypeForConditionalOperand(node); - case 203: - ts.Debug.assert(parent.parent.kind === 194); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 186: + case 218: + return getContextualTypeForReturnExpression(node); + case 196: + return getContextualTypeForYieldOperand(parent); + case 180: + case 181: + return getContextualTypeForArgument(parent, node); case 183: + case 201: + return getTypeFromTypeNode(parent.type); + case 193: + return getContextualTypeForBinaryOperand(node); + case 260: + case 261: + return getContextualTypeForObjectLiteralElement(parent); + case 176: + return getContextualTypeForElementExpression(node); + case 194: + return getContextualTypeForConditionalOperand(node); + case 204: + ts.Debug.assert(parent.parent.kind === 195); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 184: return getContextualType(parent); - case 253: + case 255: return getContextualType(parent); - case 251: case 252: + case 254: return getContextualTypeForJsxAttribute(parent); + case 250: + case 249: + return getAttributesTypeFromJsxOpeningLikeElement(parent); } return undefined; } @@ -28785,7 +29509,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 184 || node.kind === 185; + return node.kind === 185 || node.kind === 186; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -28798,7 +29522,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -28808,8 +29532,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var current = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -28839,8 +29563,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 174 && !!node.initializer) || - (node.kind === 192 && node.operatorToken.kind === 57); + return (node.kind === 175 && !!node.initializer) || + (node.kind === 193 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -28849,7 +29573,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 196) { + if (inDestructuringPattern && e.kind === 197) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -28861,7 +29585,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 196; + hasSpreadElement = hasSpreadElement || e.kind === 197; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -28872,7 +29596,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 173 || pattern.kind === 175)) { + if (pattern && (pattern.kind === 174 || pattern.kind === 176)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -28880,7 +29604,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 198) { + if (patternElement.kind !== 199) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -28897,7 +29621,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 142 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 143 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -28943,7 +29667,7 @@ var ts; var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 172 || contextualType.pattern.kind === 176); + (contextualType.pattern.kind === 173 || contextualType.pattern.kind === 177); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -28952,27 +29676,27 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 258 || - memberDecl.kind === 259 || + if (memberDecl.kind === 260 || + memberDecl.kind === 261 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 258) { + if (memberDecl.kind === 260) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 149) { + else if (memberDecl.kind === 150) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 259); + ts.Debug.assert(memberDecl.kind === 261); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; - var prop = createSymbol(4 | 67108864 | member.flags, member.name); + var prop = createSymbol(4 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 258 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 259 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 260 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 261 && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 536870912; + prop.flags |= 67108864; } if (ts.hasDynamicName(memberDecl)) { patternWithComputedProperties = true; @@ -28981,7 +29705,7 @@ var ts; else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & 512)) { var impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { - prop.flags |= impliedProp.flags & 536870912; + prop.flags |= impliedProp.flags & 67108864; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -28996,12 +29720,12 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 260) { - if (languageVersion < 5) { + else if (memberDecl.kind === 262) { + if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), true); + spread = getSpreadType(spread, createObjectLiteralType()); propertiesArray = []; propertiesTable = ts.createMap(); hasComputedStringProperty = false; @@ -29013,12 +29737,12 @@ var ts; error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } - spread = getSpreadType(spread, type, false); + spread = getSpreadType(spread, type); offset = i + 1; continue; } else { - ts.Debug.assert(memberDecl.kind === 151 || memberDecl.kind === 152); + ts.Debug.assert(memberDecl.kind === 152 || memberDecl.kind === 153); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -29030,25 +29754,25 @@ var ts; } } else { - propertiesTable[member.name] = member; + propertiesTable.set(member.name, member); } propertiesArray.push(member); } if (contextualTypeHasPattern) { for (var _i = 0, _a = getPropertiesOfType(contextualType); _i < _a.length; _i++) { var prop = _a[_i]; - if (!propertiesTable[prop.name]) { - if (!(prop.flags & 536870912)) { + if (!propertiesTable.get(prop.name)) { + if (!(prop.flags & 67108864)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } - propertiesTable[prop.name] = prop; + propertiesTable.set(prop.name, prop); propertiesArray.push(prop); } } } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), true); + spread = getSpreadType(spread, createObjectLiteralType()); } if (spread.flags & 32768) { spread.flags |= propagatedFlags; @@ -29077,7 +29801,7 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (1 | 4096 | 2048) || + return !!(type.flags & (1 | 4096 | 2048 | 16777216) || type.flags & 32768 && !isGenericMappedType(type) || type.flags & 196608 && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } @@ -29096,13 +29820,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 253: + case 255: checkJsxExpression(child); break; - case 247: + case 248: checkJsxElement(child); break; - case 248: + case 249: checkJsxSelfClosingElement(child); break; } @@ -29113,71 +29837,88 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 177 || tagName.kind === 98) { + if (tagName.kind === 178 || tagName.kind === 98) { 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 (isUnhyphenatedJsxName(node.name.text)) { - var attributeType = getTypeOfPropertyOfType(elementAttributesType, ts.getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0); - if (attributeType) { - correspondingPropType = attributeType; + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, contextualMapper) { + var attributes = openingLikeElement.attributes; + var attributesTable = ts.createMap(); + var spread = emptyObjectType; + var attributesArray = []; + for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { + var attributeDecl = _a[_i]; + var member = attributeDecl.symbol; + if (ts.isJsxAttribute(attributeDecl)) { + var exprType = attributeDecl.initializer ? + checkExpression(attributeDecl.initializer, contextualMapper) : + trueType; + var attributeSymbol = createSymbol(4 | 134217728 | member.flags, member.name); + attributeSymbol.declarations = member.declarations; + attributeSymbol.parent = member.parent; + if (member.valueDeclaration) { + attributeSymbol.valueDeclaration = member.valueDeclaration; } - else { - if (!correspondingPropType) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; - } + attributeSymbol.type = exprType; + attributeSymbol.target = member; + attributesTable.set(attributeSymbol.name, attributeSymbol); + attributesArray.push(attributeSymbol); + } + else { + ts.Debug.assert(attributeDecl.kind === 254); + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); } + var exprType = checkExpression(attributeDecl.expression); + if (!(exprType.flags & (32768 | 1))) { + error(attributeDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + return anyType; + } + if (isTypeAny(exprType)) { + return anyType; + } + spread = getSpreadType(spread, exprType); } } - var exprType; - if (node.initializer) { - exprType = checkExpression(node.initializer); + if (spread !== emptyObjectType) { + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); + } + attributesArray = getPropertiesOfType(spread); } - else { - exprType = booleanType; + attributesTable = ts.createMap(); + if (attributesArray) { + ts.forEach(attributesArray, function (attr) { + if (!filter || filter(attr)) { + attributesTable.set(attr.name, attr); + } + }); } - if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, node); + return createJsxAttributesType(attributes.symbol, attributesTable); + function createJsxAttributesType(symbol, attributesTable) { + var result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, undefined, undefined); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; + result.flags |= 33554432 | 4194304 | freshObjectLiteralFlag; + result.objectFlags |= 128; + return result; } - nameTable[node.name.text] = true; - return exprType; } - function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { - if (compilerOptions.jsx === 2) { - checkExternalEmitHelpers(node, 2); - } - var type = checkExpression(node.expression); - var props = getPropertiesOfType(type); - for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { - var prop = props_2[_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 checkJsxAttributes(node, contextualMapper) { + return createJsxAttributesTypeFromAttributesProperty(node.parent, undefined, contextualMapper); } function getJsxType(name) { - if (jsxTypes[name] === undefined) { - return jsxTypes[name] = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType; + var jsxType = jsxTypes.get(name); + if (jsxType === undefined) { + jsxTypes.set(name, jsxType = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType); } - return jsxTypes[name]; + return jsxType; } function getIntrinsicTagSymbol(node) { var links = getNodeLinks(node); @@ -29242,23 +29983,84 @@ var ts; return undefined; } } - function getResolvedJsxType(node, elemType, elemClassType) { - if (!elemType) { - elemType = checkExpression(node.tagName); + function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, undefined); + if (callSignature !== unknownSignature) { + var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); + var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + paramType = intersectTypes(intrinsicAttributes, paramType); + } + return paramType; + } + } + } } - if (elemType.flags & 65536) { - var types = elemType.types; - return getUnionType(ts.map(types, function (type) { - return getResolvedJsxType(node, type, elemClassType); + return undefined; + } + function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + var candidatesOutArray = []; + getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); + var result = void 0; + var allMatchingAttributesType = void 0; + for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { + var candidate = candidatesOutArray_1[_i]; + var callReturnType = getReturnTypeOfSignature(candidate); + var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var shouldBeCandidate = true; + for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { + var attribute = _b[_a]; + if (ts.isJsxAttribute(attribute) && + isUnhyphenatedJsxName(attribute.name.text) && + !getPropertyOfType(paramType, attribute.name.text)) { + shouldBeCandidate = false; + break; + } + } + if (shouldBeCandidate) { + result = intersectTypes(result, paramType); + } + allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); + } + } + if (!result) { + result = allMatchingAttributesType; + } + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + result = intersectTypes(intrinsicAttributes, result); + } + return result; + } + } + return undefined; + } + function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { + if (!elementType) { + elementType = checkExpression(openingLikeElement.tagName); + } + if (elementType.flags & 65536) { + var types = elementType.types; + return getUnionType(types.map(function (type) { + return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); }), true); } - if (elemType.flags & 2) { + if (elementType.flags & 2) { return anyType; } - else if (elemType.flags & 32) { + else if (elementType.flags & 32) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { - var stringLiteralTypeName = elemType.text; + var stringLiteralTypeName = elementType.text; var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); if (intrinsicProp) { return getTypeOfSymbol(intrinsicProp); @@ -29267,28 +30069,19 @@ var ts; if (indexSignatureType) { return indexSignatureType; } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + error(openingLikeElement, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); } return anyType; } - var elemInstanceType = getJsxElementInstanceType(node, elemType); - if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { - if (jsxElementType) { - var callSignatures = elemType && getSignaturesOfType(elemType, 0); - var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); - if (intrinsicAttributes !== unknownType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } + var elemInstanceType = getJsxElementInstanceType(openingLikeElement, elementType); + var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? + tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : + defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); + if (statelessAttributesType) { + return statelessAttributesType; } - if (elemClassType) { - checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + if (elementClassType) { + checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } if (isTypeAny(elemInstanceType)) { return elemInstanceType; @@ -29309,7 +30102,7 @@ var ts; return attributesType; } else if (attributesType.flags & 65536) { - error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); + error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); return anyType; } else { @@ -29334,30 +30127,49 @@ var ts; } } } - function getJsxElementAttributesType(node) { + function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) { + ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName)); var links = getNodeLinks(node); - if (!links.resolvedJsxType) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1) { - return links.resolvedJsxType = getTypeOfSymbol(symbol); - } - else if (links.jsxFlags & 2) { - return links.resolvedJsxType = getIndexInfoOfSymbol(symbol, 0).type; - } - else { - return links.resolvedJsxType = unknownType; - } + if (!links.resolvedJsxElementAttributesType) { + var symbol = getIntrinsicTagSymbol(node); + if (links.jsxFlags & 1) { + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + } + else if (links.jsxFlags & 2) { + return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, 0).type; } else { - var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxType = getResolvedJsxType(node, undefined, elemClassType); + return links.resolvedJsxElementAttributesType = unknownType; } } - return links.resolvedJsxType; + return links.resolvedJsxElementAttributesType; + } + function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { + var links = getNodeLinks(node); + if (!links.resolvedJsxElementAttributesType) { + var elemClassType = getJsxGlobalElementClassType(); + return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); + } + return links.resolvedJsxElementAttributesType; + } + function getAllAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, true); + } + } + function getAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, false); + } } function getJsxAttributePropertySymbol(attrib) { - var attributesType = getJsxElementAttributesType(attrib.parent); + var attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent); var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } @@ -29393,34 +30205,25 @@ var ts; markAliasSymbolAsReferenced(reactSym); } } - var targetAttributesType = getJsxElementAttributesType(node); - var nameTable = ts.createMap(); - var sawSpreadedAny = false; - for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 251) { - checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); - } - else { - ts.Debug.assert(node.attributes[i].kind === 252); - var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if (isTypeAny(spreadType)) { - sawSpreadedAny = true; - } - } + checkJsxAttributesAssignableToTagNameAttributes(node); + } + function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement) { + var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? + getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : + getCustomJsxElementAttributesType(openingLikeElement, false); + var sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, function (attribute) { + return isUnhyphenatedJsxName(attribute.name) || !!(getPropertyOfType(targetAttributesType, attribute.name)); + }); + if (targetAttributesType === emptyObjectType && (isTypeAny(sourceAttributesType) || sourceAttributesType.properties.length > 0)) { + error(openingLikeElement, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); } - if (targetAttributesType && !sawSpreadedAny) { - var targetProperties = getPropertiesOfType(targetAttributesType); - for (var i = 0; i < targetProperties.length; i++) { - if (!(targetProperties[i].flags & 536870912) && - !nameTable[targetProperties[i].name]) { - error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); - } - } + else { + checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); } } - function checkJsxExpression(node) { + function checkJsxExpression(node, contextualMapper) { if (node.expression) { - var type = checkExpression(node.expression); + var type = checkExpression(node.expression, contextualMapper); if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); } @@ -29431,27 +30234,48 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 147; + return s.valueDeclaration ? s.valueDeclaration.kind : 148; } function getDeclarationModifierFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; + if (s.valueDeclaration) { + var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + return s.parent && s.parent.flags & 32 ? flags : flags & ~28; + } + if (getCheckFlags(s) & 2) { + var checkFlags = s.checkFlags; + var accessModifier = checkFlags & 128 ? 8 : + checkFlags & 32 ? 4 : + 16; + var staticModifier = checkFlags & 256 ? 32 : 0; + return accessModifier | staticModifier; + } + if (s.flags & 16777216) { + return 4 | 32; + } + return 0; } function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; } - function checkClassPropertyAccess(node, left, type, prop) { + function checkPropertyAccessibility(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 || node.kind === 224 ? + var errorNode = node.kind === 178 || node.kind === 225 ? node.name : node.right; + if (getCheckFlags(prop) & 128) { + error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); + return false; + } if (left.kind === 96) { - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 149) { - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - return false; + if (languageVersion < 2) { + var propKind = getDeclarationKindFromSymbol(prop); + if (propKind !== 150 && propKind !== 149) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } } if (flags & 128) { - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } } @@ -29461,7 +30285,7 @@ var ts; if (flags & 8) { var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } return true; @@ -29471,10 +30295,10 @@ var ts; } var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return hasBaseType(enclosingClass, declaringClass) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; }); if (!enclosingClass) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); return false; } if (flags & 32) { @@ -29490,16 +30314,17 @@ var ts; return true; } function checkNonNullExpression(node) { - var type = checkExpression(node); - if (strictNullChecks) { - var kind = getFalsyFlags(type) & 6144; - if (kind) { - error(node, kind & 2048 ? kind & 4096 ? - ts.Diagnostics.Object_is_possibly_null_or_undefined : - ts.Diagnostics.Object_is_possibly_undefined : - ts.Diagnostics.Object_is_possibly_null); - } - return getNonNullableType(type); + return checkNonNullType(checkExpression(node), node); + } + function checkNonNullType(type, errorNode) { + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 6144; + if (kind) { + error(errorNode, kind & 2048 ? kind & 4096 ? + ts.Diagnostics.Object_is_possibly_null_or_undefined : + ts.Diagnostics.Object_is_possibly_undefined : + ts.Diagnostics.Object_is_possibly_null); + var t = getNonNullableType(type); + return t.flags & (6144 | 8192) ? unknownType : t; } return type; } @@ -29528,7 +30353,7 @@ var ts; noUnusedIdentifiers && (prop.flags & 106500) && prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8)) { - if (prop.flags & 16777216) { + if (getCheckFlags(prop) & 1) { getSymbolLinks(prop).target.isReferenced = true; } else { @@ -29536,6 +30361,15 @@ var ts; } } } + function isInPropertyInitializer(node) { + while (node) { + if (node.parent && node.parent.kind === 148 && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { var type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -29547,16 +30381,23 @@ var ts; } var prop = getPropertyOfType(apparentType, right.text); if (!prop) { + var stringIndexType = getIndexTypeOfType(apparentType, 0); + if (stringIndexType) { + return stringIndexType; + } if (right.text && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & 16384 && type.isThisType ? apparentType : type); } return unknownType; } + if (prop.valueDeclaration && + isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; - if (prop.parent && prop.parent.flags & 32) { - checkClassPropertyAccess(node, left, apparentType, prop); - } + checkPropertyAccessibility(node, left, apparentType, prop); var propType = getTypeOfSymbol(prop); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { @@ -29565,7 +30406,7 @@ var ts; return unknownType; } } - if (node.kind !== 177 || assignmentKind === 1 || + if (node.kind !== 178 || assignmentKind === 1 || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 65536)) { return propType; @@ -29574,21 +30415,21 @@ var ts; return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 177 + var left = node.kind === 178 ? 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) { - return checkClassPropertyAccess(node, left, type, prop); + if (prop) { + return checkPropertyAccessibility(node, left, type, prop); } } return true; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 225) { + if (initializer.kind === 226) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -29610,7 +30451,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 213 && + if (node.kind === 214 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -29628,7 +30469,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 180 && node.parent.expression === node) { + if (node.parent.kind === 181 && 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); @@ -29648,7 +30489,7 @@ var ts; error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } - return getIndexedAccessType(objectType, indexType, node); + return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === unknownType) { @@ -29681,10 +30522,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 181) { + if (node.kind === 182) { checkExpression(node.template); } - else if (node.kind !== 145) { + else if (node.kind !== 146) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -29706,19 +30547,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_9 = signature.declaration && signature.declaration.parent; + var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_9 === lastParent) { + if (lastParent && parent === lastParent) { index++; } else { - lastParent = parent_9; + lastParent = parent; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_9; + lastParent = parent; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -29735,7 +30576,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 196) { + if (arg && arg.kind === 197) { return i; } } @@ -29748,11 +30589,14 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 181) { + if (ts.isJsxOpeningLikeElement(node)) { + return true; + } + if (node.kind === 182) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 194) { + if (tagExpression.template.kind === 195) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -29764,7 +30608,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 145) { + else if (node.kind === 146) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -29772,7 +30616,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 180); + ts.Debug.assert(callExpression.kind === 181); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -29780,8 +30624,10 @@ var ts; typeArguments = callExpression.typeArguments; spreadArgIndex = getSpreadArgumentIndex(args); } + var numTypeParameters = ts.length(signature.typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters); var hasRightNumberOfTypeArgs = !typeArguments || - (signature.typeParameters && typeArguments.length === signature.typeParameters.length); + (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters); if (!hasRightNumberOfTypeArgs) { return false; } @@ -29831,7 +30677,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 !== 198) { + if (arg === undefined || arg.kind !== 199) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -29856,7 +30702,7 @@ var ts; var typeParameters = signature.typeParameters; var typeArgumentsAreAssignable = true; var mapper; - for (var i = 0; i < typeParameters.length; i++) { + for (var i = 0; i < typeArgumentNodes.length; i++) { if (typeArgumentsAreAssignable) { var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { @@ -29876,9 +30722,29 @@ var ts; } return typeArgumentsAreAssignable; } + function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { + var callIsIncomplete = node.attributes.end === node.end; + if (callIsIncomplete) { + return true; + } + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + var paramType = getTypeAtPosition(signature, 0); + var attributesType = checkExpressionWithContextualType(node.attributes, paramType, undefined); + var argProperties = getPropertiesOfType(attributesType); + for (var _i = 0, argProperties_1 = argProperties; _i < argProperties_1.length; _i++) { + var arg = argProperties_1[_i]; + if (!getPropertyOfType(paramType, arg.name) && isUnhyphenatedJsxName(arg.name)) { + return false; + } + } + return checkTypeRelatedTo(attributesType, paramType, relation, undefined, headMessage); + } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { + if (ts.isJsxOpeningLikeElement(node)) { + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 180) { + if (thisType && thisType !== voidType && node.kind !== 181) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -29891,7 +30757,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 !== 198) { + if (arg === undefined || arg.kind !== 199) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -29906,51 +30772,54 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 179) { + if (node.kind === 180) { var callee = node.expression; - if (callee.kind === 177) { + if (callee.kind === 178) { return callee.expression; } - else if (callee.kind === 178) { + else if (callee.kind === 179) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 181) { + if (node.kind === 182) { var template = node.template; args = [undefined]; - if (template.kind === 194) { + if (template.kind === 195) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 145) { + else if (node.kind === 146) { return undefined; } + else if (ts.isJsxOpeningLikeElement(node)) { + args = node.attributes.properties.length > 0 ? [node.attributes] : emptyArray; + } else { args = node.arguments || emptyArray; } return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 145) { + if (node.kind === 146) { switch (node.parent.kind) { - case 227: - case 197: + case 228: + case 198: return 1; - case 147: + case 148: return 2; - case 149: - case 151: + case 150: case 152: + case 153: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 144: + case 145: return 3; } } @@ -29959,48 +30828,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 227) { + if (node.kind === 228) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 144) { + if (node.kind === 145) { node = node.parent; - if (node.kind === 150) { + if (node.kind === 151) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 152 || + node.kind === 153) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 227) { + if (node.kind === 228) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 144) { + if (node.kind === 145) { node = node.parent; - if (node.kind === 150) { + if (node.kind === 151) { return anyType; } } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 152 || + node.kind === 153) { var element = node; switch (element.name.kind) { case 70: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 142: + case 143: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -30017,20 +30886,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 227) { + if (node.kind === 228) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 144) { + if (node.kind === 145) { return numberType; } - if (node.kind === 147) { + if (node.kind === 148) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 150 || + node.kind === 152 || + node.kind === 153) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -30051,26 +30920,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex) { - if (node.kind === 145) { + if (node.kind === 146) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 181) { + else if (argIndex === 0 && node.kind === 182) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 145 || - (argIndex === 0 && node.kind === 181)) { + if (node.kind === 146 || + (argIndex === 0 && node.kind === 182)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 145) { + if (node.kind === 146) { return node.expression; } - else if (argIndex === 0 && node.kind === 181) { + else if (argIndex === 0 && node.kind === 182) { return node.template; } else { @@ -30078,10 +30947,11 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 181; - var isDecorator = node.kind === 145; + var isTaggedTemplate = node.kind === 182; + var isDecorator = node.kind === 146; + var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; - if (!isTaggedTemplate && !isDecorator) { + if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) { typeArguments = node.typeArguments; if (node.expression.kind !== 96) { ts.forEach(typeArguments, checkSourceElement); @@ -30109,7 +30979,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 179 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 180 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -30123,6 +30993,9 @@ var ts; return result; } if (candidateForArgumentError) { + if (isJsxOpeningOrSelfClosingElement) { + return candidateForArgumentError; + } checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); } else if (candidateForTypeArgumentError) { @@ -30138,7 +31011,7 @@ var ts; if (headMessage) { diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); } - reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); + reportNoCommonSupertypeError(inferenceCandidates, node.tagName || node.expression || node.tag, diagnosticChainHead); } } else { @@ -30181,13 +31054,13 @@ var ts; if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNode); + typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); - typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; } if (!typeArgumentsAreValid) { break; @@ -30378,16 +31251,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 227: - case 197: + case 228: + case 198: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 144: + case 145: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 147: + case 148: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 149: - case 151: + case 150: case 152: + case 153: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -30412,16 +31285,42 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray, headMessage); } + function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray) { + ts.Debug.assert(!(elementType.flags & 65536)); + var callSignature = resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray); + return callSignature; + } + function resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray) { + if (elementType.flags & 65536) { + var types = elementType.types; + var result = void 0; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); + } + return result; + } + var callSignatures = elementType && getSignaturesOfType(elementType, 0); + if (callSignatures && callSignatures.length > 0) { + var callSignature = void 0; + callSignature = resolveCall(openingLikeElement, callSignatures, candidatesOutArray); + return callSignature; + } + return undefined; + } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 179: - return resolveCallExpression(node, candidatesOutArray); case 180: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 181: + return resolveNewExpression(node, candidatesOutArray); + case 182: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 145: + case 146: return resolveDecorator(node, candidatesOutArray); + case 250: + case 249: + return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); } @@ -30452,12 +31351,12 @@ var ts; if (node.expression.kind === 96) { return voidType; } - if (node.kind === 180) { + if (node.kind === 181) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 150 && - declaration.kind !== 154 && - declaration.kind !== 159 && + declaration.kind !== 151 && + declaration.kind !== 155 && + declaration.kind !== 160 && !ts.isJSDocConstructSignature(declaration)) { var funcSymbol = node.expression.kind === 70 ? getResolvedSymbol(node.expression) : @@ -30488,9 +31387,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 226 + ? 227 : resolvedRequire.flags & 3 - ? 224 + ? 225 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -30524,7 +31423,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return unknownType; } - else if (container.kind === 150) { + else if (container.kind === 151) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -30562,7 +31461,7 @@ var ts; var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { if (!parameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); } assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } @@ -30600,8 +31499,8 @@ var ts; if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 172 || - parameter.valueDeclaration.name.kind === 173)) { + (parameter.valueDeclaration.name.kind === 173 || + parameter.valueDeclaration.name.kind === 174)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -30631,6 +31530,9 @@ var ts; error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } + else if (!getGlobalPromiseConstructorSymbol()) { + error(func, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } return promiseType; } function getReturnTypeFromBody(func, contextualMapper) { @@ -30640,7 +31542,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 205) { + if (func.body.kind !== 206) { 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); @@ -30719,7 +31621,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 219 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 220 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -30748,7 +31650,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 184 || func.kind === 185)) { + func.kind === 185 || func.kind === 186)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -30765,7 +31667,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 205 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 206 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -30792,9 +31694,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 184) { + if (!hasGrammarError && node.kind === 185) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -30828,7 +31730,7 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 149) { + if (produceDiagnostics && node.kind !== 150) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithCapturedNewTargetVariable(node, node.name); @@ -30836,7 +31738,7 @@ var ts; return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -30846,7 +31748,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 205) { + if (node.body.kind === 206) { checkSourceElement(node.body); } else { @@ -30872,19 +31774,19 @@ var ts; return true; } function isReadonlySymbol(symbol) { - return symbol.isReadonly || - symbol.flags & 4 && (getDeclarationModifierFlagsFromSymbol(symbol) & 64) !== 0 || - symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 || + return !!(getCheckFlags(symbol) & 4 || + symbol.flags & 4 && getDeclarationModifierFlagsFromSymbol(symbol) & 64 || + symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 || symbol.flags & 98304 && !(symbol.flags & 65536) || - (symbol.flags & 8) !== 0; + symbol.flags & 8); } function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 177 || expr.kind === 178) && + (expr.kind === 178 || expr.kind === 179) && expr.expression.kind === 98) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 150)) + if (!(func && func.kind === 151)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -30893,13 +31795,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 177 || expr.kind === 178) { + if (expr.kind === 178 || expr.kind === 179) { var node = ts.skipParentheses(expr.expression); if (node.kind === 70) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 238; + return declaration && declaration.kind === 239; } } } @@ -30907,7 +31809,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage) { var node = ts.skipParentheses(expr); - if (node.kind !== 70 && node.kind !== 177 && node.kind !== 178) { + if (node.kind !== 70 && node.kind !== 178 && node.kind !== 179) { error(expr, invalidReferenceMessage); return false; } @@ -30916,7 +31818,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 177 && expr.kind !== 178) { + if (expr.kind !== 178 && expr.kind !== 179) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -30929,7 +31831,7 @@ var ts; } function checkTypeOfExpression(node) { checkExpression(node.expression); - return stringType; + return typeofType; } function checkVoidExpression(node) { checkExpression(node.expression); @@ -30959,6 +31861,7 @@ var ts; case 36: case 37: case 51: + checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 512)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } @@ -30970,7 +31873,7 @@ var ts; booleanType; case 42: case 43: - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); } @@ -30983,7 +31886,7 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); } @@ -30995,8 +31898,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -31010,8 +31913,8 @@ var ts; } if (type.flags & 65536) { var types = type.types; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var t = types_19[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -31020,8 +31923,8 @@ var ts; } if (type.flags & 131072) { var types = type.types; - for (var _a = 0, types_18 = types; _a < types_18.length; _a++) { - var t = types_18[_a]; + for (var _a = 0, types_20 = types; _a < types_20.length; _a++) { + var t = types_20[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -31042,7 +31945,10 @@ var ts; if (isTypeOfKind(leftType, 8190)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } - if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { + if (!(isTypeAny(rightType) || + getSignaturesOfType(rightType, 0).length || + getSignaturesOfType(rightType, 1).length || + isTypeSubtypeOf(rightType, globalFunctionType))) { error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; @@ -31051,6 +31957,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 | 512))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } @@ -31068,22 +31976,22 @@ var ts; return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 258 || property.kind === 259) { - var name_20 = property.name; - if (name_20.kind === 142) { - checkComputedPropertyName(name_20); + if (property.kind === 260 || property.kind === 261) { + var name = property.name; + if (name.kind === 143) { + checkComputedPropertyName(name); } - if (isComputedNonLiteralName(name_20)) { + if (isComputedNonLiteralName(name)) { return undefined; } - var text = ts.getTextOfPropertyName(name_20); + var text = ts.getTextOfPropertyName(name); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 259) { + if (property.kind === 261) { return checkDestructuringAssignment(property, type); } else { @@ -31091,10 +31999,10 @@ var ts; } } else { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 260) { + else if (property.kind === 262) { if (languageVersion < 5) { checkExternalEmitHelpers(property, 4); } @@ -31122,8 +32030,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 198) { - if (element.kind !== 196) { + if (element.kind !== 199) { + if (element.kind !== 197) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -31149,7 +32057,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 192 && restExpression.operatorToken.kind === 57) { + if (restExpression.kind === 193 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -31162,7 +32070,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 259) { + if (exprOrAssignment.kind === 261) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -31176,21 +32084,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 192 && target.operatorToken.kind === 57) { + if (target.kind === 193 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 176) { + if (target.kind === 177) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 175) { + if (target.kind === 176) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 260 ? + var error = target.parent.kind === 262 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -31204,35 +32112,35 @@ var ts; case 70: case 9: case 11: - case 181: - case 194: + case 182: + case 195: case 12: case 8: case 100: case 85: case 94: - case 137: - case 184: - case 197: + case 138: case 185: - case 175: + case 198: + case 186: case 176: - case 187: - case 201: + case 177: + case 188: + case 202: + case 249: case 248: - case 247: return true; - case 193: + case 194: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 192: + case 193: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 190: case 191: + case 192: switch (node.operator) { case 50: case 36: @@ -31241,9 +32149,9 @@ var ts; return true; } return false; - case 188: - case 182: - case 200: + case 189: + case 183: + case 201: default: return false; } @@ -31263,7 +32171,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 57 && (left.kind === 176 || left.kind === 175)) { + if (operator === 57 && (left.kind === 177 || left.kind === 176)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -31294,12 +32202,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (leftType.flags & 6144) - leftType = rightType; - if (rightType.flags & 6144) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); var suggestedOperator = void 0; if ((leftType.flags & 136) && (rightType.flags & 136) && @@ -31319,12 +32223,10 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (leftType.flags & 6144) - leftType = rightType; - if (rightType.flags & 6144) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + if (!isTypeOfKind(leftType, 1 | 262178) && !isTypeOfKind(rightType, 1 | 262178)) { + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); + } var resultType = void 0; if (isTypeOfKind(leftType, 340) && isTypeOfKind(rightType, 340)) { resultType = numberType; @@ -31353,8 +32255,8 @@ var ts; case 29: case 30: if (checkForDisallowedESSymbolOperand(operator)) { - leftType = getBaseTypeOfLiteralType(leftType); - rightType = getBaseTypeOfLiteralType(rightType); + leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); + rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } @@ -31523,7 +32425,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 182 || node.kind === 200; + return node.kind === 183 || node.kind === 201; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -31534,11 +32436,11 @@ var ts; function isLiteralContextualType(contextualType) { if (contextualType) { if (contextualType.flags & 540672) { - var apparentType = getApparentTypeOfTypeVariable(contextualType); - if (apparentType.flags & (2 | 4 | 8 | 16)) { + var constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; + if (constraint.flags & (2 | 4 | 8 | 16)) { return true; } - contextualType = apparentType; + contextualType = constraint; } return maybeTypeOfKind(contextualType, (480 | 262144)); } @@ -31549,14 +32451,14 @@ var ts; return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -31578,7 +32480,7 @@ var ts; return type; } function getTypeOfExpression(node) { - if (node.kind === 179 && node.expression.kind !== 96) { + if (node.kind === 180 && node.expression.kind !== 96) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -31589,7 +32491,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 141) { + if (node.kind === 142) { type = checkQualifiedName(node); } else { @@ -31597,9 +32499,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 177 && node.parent.expression === node) || - (node.parent.kind === 178 && node.parent.expression === node) || - ((node.kind === 70 || node.kind === 141) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 178 && node.parent.expression === node) || + (node.parent.kind === 179 && node.parent.expression === node) || + ((node.kind === 70 || node.kind === 142) && 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); } @@ -31621,68 +32523,70 @@ var ts; case 100: case 85: return checkLiteralExpression(node); - case 194: + case 195: return checkTemplateExpression(node); case 12: return stringType; case 11: return globalRegExpType; - case 175: - return checkArrayLiteral(node, contextualMapper); case 176: - return checkObjectLiteral(node, contextualMapper); + return checkArrayLiteral(node, contextualMapper); case 177: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, contextualMapper); case 178: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 179: + return checkIndexedAccess(node); case 180: - return checkCallExpression(node); case 181: - return checkTaggedTemplateExpression(node); - case 183: - return checkExpression(node.expression, contextualMapper); - case 197: - return checkClassExpression(node); - case 184: - case 185: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 187: - return checkTypeOfExpression(node); + return checkCallExpression(node); case 182: - case 200: - return checkAssertion(node); - case 201: - return checkNonNullAssertion(node); - case 202: - return checkMetaProperty(node); - case 186: - return checkDeleteExpression(node); - case 188: - return checkVoidExpression(node); - case 189: - return checkAwaitExpression(node); - case 190: - return checkPrefixUnaryExpression(node); - case 191: - return checkPostfixUnaryExpression(node); - case 192: - return checkBinaryExpression(node, contextualMapper); - case 193: - return checkConditionalExpression(node, contextualMapper); - case 196: - return checkSpreadExpression(node, contextualMapper); + return checkTaggedTemplateExpression(node); + case 184: + return checkExpression(node.expression, contextualMapper); case 198: + return checkClassExpression(node); + case 185: + case 186: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 188: + return checkTypeOfExpression(node); + case 183: + case 201: + return checkAssertion(node); + case 202: + return checkNonNullAssertion(node); + case 203: + return checkMetaProperty(node); + case 187: + return checkDeleteExpression(node); + case 189: + return checkVoidExpression(node); + case 190: + return checkAwaitExpression(node); + case 191: + return checkPrefixUnaryExpression(node); + case 192: + return checkPostfixUnaryExpression(node); + case 193: + return checkBinaryExpression(node, contextualMapper); + case 194: + return checkConditionalExpression(node, contextualMapper); + case 197: + return checkSpreadExpression(node, contextualMapper); + case 199: return undefinedWideningType; - case 195: + case 196: return checkYieldExpression(node); - case 253: - return checkJsxExpression(node); - case 247: - return checkJsxElement(node); + case 255: + return checkJsxExpression(node, contextualMapper); case 248: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 249: + return checkJsxSelfClosingElement(node); + case 253: + return checkJsxAttributes(node, contextualMapper); + case 250: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -31692,7 +32596,16 @@ var ts; grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } checkSourceElement(node.constraint); - getConstraintOfTypeParameter(getDeclaredTypeOfTypeParameter(getSymbolOfNode(node))); + checkSourceElement(node.default); + var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); + if (!hasNonCircularBaseConstraint(typeParameter)) { + error(node.constraint, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); + } + var constraintType = getConstraintOfTypeParameter(typeParameter); + var defaultType = getDefaultFromTypeParameter(typeParameter); + if (constraintType && defaultType) { + checkTypeAssignableTo(defaultType, getTypeWithThisArgument(constraintType, defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } @@ -31703,7 +32616,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 150 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 151 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -31714,7 +32627,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 150 || func.kind === 154 || func.kind === 159) { + if (func.kind === 151 || func.kind === 155 || func.kind === 160) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -31726,9 +32639,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 149 || - node.kind === 226 || - node.kind === 184; + return node.kind === 150 || + node.kind === 227 || + node.kind === 185; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -31769,9 +32682,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_21 = _a[_i].name; - if (ts.isBindingPattern(name_21) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_21, parameterName, typePredicate.parameterName)) { + var name = _a[_i].name; + if (ts.isBindingPattern(name) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -31784,16 +32697,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 186: + case 154: + case 227: case 185: - case 153: - case 226: - case 184: - case 158: + case 159: + case 150: case 149: - case 148: - var parent_10 = node.parent; - if (node === parent_10.type) { - return parent_10; + var parent = node.parent; + if (node === parent.type) { + return parent; } } } @@ -31803,27 +32716,27 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_22 = element.name; - if (name_22.kind === 70 && - name_22.text === predicateVariableName) { + var name = element.name; + if (name.kind === 70 && + name.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_22.kind === 173 || - name_22.kind === 172) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, predicateVariableNode, predicateVariableName)) { + else if (name.kind === 174 || + name.kind === 173) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } } } } function checkSignatureDeclaration(node) { - if (node.kind === 155) { + if (node.kind === 156) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 || node.kind === 226 || node.kind === 159 || - node.kind === 153 || node.kind === 150 || - node.kind === 154) { + else if (node.kind === 159 || node.kind === 227 || node.kind === 160 || + node.kind === 154 || node.kind === 151 || + node.kind === 155) { checkGrammarFunctionLikeDeclaration(node); } if (ts.isAsyncFunctionLike(node) && languageVersion < 4) { @@ -31841,10 +32754,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 154: + case 155: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 153: + case 154: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -31875,7 +32788,7 @@ var ts; var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150) { + if (member.kind === 151) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -31884,36 +32797,65 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114; }); + var isStatic = ts.getModifierFlags(member) & 32; var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 151: + case 152: addName(names, member.name, memberName, 1); break; - case 152: + case 153: addName(names, member.name, memberName, 2); break; - case 147: + case 148: addName(names, member.name, memberName, 3); break; + case 150: + addName(names, member.name, memberName, 4); + break; } } } } function addName(names, location, name, meaning) { - var prev = names[name]; + var prev = names.get(name); if (prev) { - if (prev & meaning) { + if (prev & 4) { + if (meaning !== 4) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + } + else if (prev & meaning) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { - names[name] = prev | meaning; + names.set(name, prev | meaning); } } else { - names[name] = meaning; + names.set(name, meaning); + } + } + } + function checkClassForStaticPropertyNameConflicts(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + var memberNameNode = member.name; + var isStatic = ts.getModifierFlags(member) & 32; + if (isStatic && memberNameNode) { + var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode); + switch (memberName) { + case "name": + case "length": + case "caller": + case "arguments": + case "prototype": + var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; + var className = getNameOfSymbol(getSymbolOfNode(node)); + error(memberNameNode, message, memberName, className); + break; + } } } } @@ -31921,7 +32863,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 146) { + if (member.kind == 147) { var memberName = void 0; switch (member.name.kind) { case 9: @@ -31932,18 +32874,18 @@ var ts; default: continue; } - if (names[memberName]) { + if (names.get(memberName)) { error(member.symbol.valueDeclaration.name, ts.Diagnostics.Duplicate_identifier_0, memberName); error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName); } else { - names[memberName] = true; + names.set(memberName, true); } } } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 228) { + if (node.kind === 229) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -31958,7 +32900,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 134: + case 135: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -32025,12 +32967,12 @@ var ts; if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 && n.kind !== 226) { + else if (n.kind !== 185 && n.kind !== 227) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 147 && + return n.kind === 148 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -32050,7 +32992,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -32073,18 +33015,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 151) { + if (node.kind === 152) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 151 ? 152 : 151; + var otherKind = node.kind === 152 ? 153 : 152; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -32098,11 +33040,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 151) { + if (node.kind === 152) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 176) { + if (node.parent.kind !== 177) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -32125,6 +33067,7 @@ var ts; checkDecorators(node); } function checkTypeArgumentConstraints(typeParameters, typeArgumentNodes) { + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); var typeArguments; var mapper; var result = true; @@ -32132,7 +33075,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -32183,25 +33126,42 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessIndexType(type, accessNode) { + if (!(type.flags & 524288)) { + return type; + } + var objectType = type.objectType; + var indexType = type.indexType; + if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + return type; + } + if (maybeTypeOfKind(objectType, 540672) && isTypeOfKind(indexType, 340)) { + var constraint = getBaseConstraintOfType(objectType); + if (constraint && getIndexInfoOfType(constraint, 1)) { + return type; + } + } + error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); + return type; + } function checkIndexedAccessType(node) { - getTypeFromIndexedAccessTypeNode(node); + checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node) { checkSourceElement(node.typeParameter); checkSourceElement(node.type); var type = getTypeFromMappedTypeNode(node); var constraintType = getConstraintTypeFromMappedType(type); - var keyType = constraintType.flags & 540672 ? getApparentTypeOfTypeVariable(constraintType) : constraintType; - checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint); + checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 228 && - n.parent.kind !== 227 && - n.parent.kind !== 197 && + if (n.parent.kind !== 229 && + n.parent.kind !== 228 && + n.parent.kind !== 198 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -32278,7 +33238,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) { - var reportError = (node.kind === 149 || node.kind === 148) && + var reportError = (node.kind === 150 || node.kind === 149) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -32307,15 +33267,15 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var current = declarations_5[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 228 || node.parent.kind === 161 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 229 || node.parent.kind === 162 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 226 || node.kind === 149 || node.kind === 148 || node.kind === 150) { + if (node.kind === 227 || node.kind === 150 || node.kind === 149 || node.kind === 151) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -32426,16 +33386,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 228: + case 229: return 2097152; - case 231: + case 232: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 227: - case 230: + case 228: + case 231: return 2097152 | 1048576; - case 235: + case 236: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -32553,7 +33513,12 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455, true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; if (promiseConstructorType === unknownType) { - error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + if (promiseConstructorName.kind === 70 && promiseConstructorName.text === "Promise" && getTargetType(returnType) === tryGetGlobalPromiseType()) { + error(node.type, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } + else { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + } return unknownType; } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); @@ -32583,22 +33548,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 227: + case 228: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 144: + case 145: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 147: + case 148: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 149: - case 151: + case 150: case 152: + case 153: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -32632,13 +33597,13 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8); - if (node.kind === 144) { + if (node.kind === 145) { checkExternalEmitHelpers(firstDecorator, 32); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 227: + case 228: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -32647,19 +33612,19 @@ var ts; } } break; - case 149: - case 151: + case 150: case 152: + case 153: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markTypeNodeAsReferenced(node.type); break; - case 147: + case 148: markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); break; - case 144: + case 145: markTypeNodeAsReferenced(node.type); break; } @@ -32680,7 +33645,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 142) { + if (node.name && node.name.kind === 143) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -32722,43 +33687,43 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 262: - case 231: + case 264: + case 232: checkUnusedModuleMembers(node); break; - case 227: - case 197: + case 228: + case 198: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 228: + case 229: checkUnusedTypeParameters(node); break; - case 205: - case 233: - case 212: + case 206: + case 234: case 213: case 214: + case 215: checkUnusedLocalsAndParameters(node); break; - case 150: - case 184: - case 226: - case 185: - case 149: case 151: + case 185: + case 227: + case 186: + case 150: case 152: + case 153: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 148: - case 153: + case 149: case 154: case 155: - case 158: + case 156: case 159: + case 160: checkUnusedTypeParameters(node); break; } @@ -32767,11 +33732,10 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 228 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_2 = function (key) { - var local = node.locals[key]; + if (node.parent.kind !== 229 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + node.locals.forEach(function (local) { if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 145) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -32784,10 +33748,7 @@ var ts; ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d.name || d, local.name); }); } } - }; - for (var key in node.locals) { - _loop_2(key); - } + }); } } function isRemovedPropertyFromObjectSpread(node) { @@ -32800,9 +33761,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 224 && - (declaration.parent.parent.kind === 213 || - declaration.parent.parent.kind === 214)) { + if (declaration.kind === 225 && + (declaration.parent.parent.kind === 214 || + declaration.parent.parent.kind === 215)) { return; } } @@ -32821,12 +33782,12 @@ var ts; if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149 || member.kind === 147) { + if (member.kind === 150 || member.kind === 148) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 150) { + else if (member.kind === 151) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -32857,8 +33818,7 @@ var ts; } function checkUnusedModuleMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { - for (var key in node.locals) { - var local = node.locals[key]; + node.locals.forEach(function (local) { if (!local.isReferenced && !local.exportSymbol) { for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; @@ -32867,11 +33827,11 @@ var ts; } } } - } + }); } } function checkBlock(node) { - if (node.kind === 205) { + if (node.kind === 206) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -32893,19 +33853,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 147 || - node.kind === 146 || + if (node.kind === 148 || + node.kind === 147 || + node.kind === 150 || node.kind === 149 || - node.kind === 148 || - node.kind === 151 || - node.kind === 152) { + node.kind === 152 || + node.kind === 153) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 144 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 145 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -32977,11 +33937,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 262 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 264 && ts.isExternalOrCommonJsModule(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)); } } @@ -32989,11 +33949,11 @@ var ts; if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 262 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 264 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -33001,7 +33961,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 224 && !node.initializer) { + if (node.kind === 225 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -33011,25 +33971,25 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 225); - var container = varDeclList.parent.kind === 206 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 226); + var container = varDeclList.parent.kind === 207 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 205 && ts.isFunctionLike(container.parent) || + (container.kind === 206 && ts.isFunctionLike(container.parent) || + container.kind === 233 || container.kind === 232 || - container.kind === 231 || - container.kind === 262); + container.kind === 264); if (!namesShareScope) { - var name_23 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_23, name_23); + var name = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 144) { + if (ts.getRootDeclaration(node).kind !== 145) { return; } var func = ts.getContainingFunction(node); @@ -33038,7 +33998,7 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 177) { + if (n.kind === 178) { return visit(n.expression); } else if (n.kind === 70) { @@ -33052,8 +34012,8 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144 || - symbol.valueDeclaration.kind === 174) { + if (symbol.valueDeclaration.kind === 145 || + symbol.valueDeclaration.kind === 175) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -33062,7 +34022,7 @@ var ts; if (ts.isFunctionLike(current.parent)) { return; } - if (current.parent.kind === 147 && + if (current.parent.kind === 148 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)) { return; @@ -33084,37 +34044,37 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 174) { - if (node.parent.kind === 172 && languageVersion < 5 && !ts.isInAmbientContext(node)) { + if (node.kind === 175) { + if (node.parent.kind === 173 && languageVersion < 5 && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4); } - if (node.propertyName && node.propertyName.kind === 142) { + if (node.propertyName && node.propertyName.kind === 143) { checkComputedPropertyName(node.propertyName); } - var parent_11 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_11); - var name_24 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_24)); + var parent = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent); + var name = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); markPropertyAsReferenced(property); - if (parent_11.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); + if (parent.initializer && property) { + checkPropertyAccessibility(parent, parent.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 144 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 145 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 213) { + if (node.initializer && node.parent.parent.kind !== 214) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -33123,7 +34083,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 213) { + if (node.initializer && node.parent.parent.kind !== 214) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -33141,9 +34101,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 147 && node.kind !== 146) { + if (node.kind !== 148 && node.kind !== 147) { checkExportsOnMergedDeclarations(node); - if (node.kind === 224 || node.kind === 174) { + if (node.kind === 225 || node.kind === 175) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -33154,8 +34114,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 && right.kind === 224) || - (left.kind === 224 && right.kind === 144)) { + if ((left.kind === 145 && right.kind === 225) || + (left.kind === 225 && right.kind === 145)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -33182,7 +34142,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 176) { + if (node.modifiers && node.parent.kind === 177) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -33201,7 +34161,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 207) { + if (node.thenStatement.kind === 208) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -33218,12 +34178,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 225) { + if (node.initializer && node.initializer.kind === 226) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 225) { + if (node.initializer.kind === 226) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -33241,13 +34201,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 225) { + if (node.initializer.kind === 226) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 175 || varExpr.kind === 176) { + if (varExpr.kind === 176 || varExpr.kind === 177) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -33266,7 +34226,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 225) { + if (node.initializer.kind === 226) { 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); @@ -33276,7 +34236,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 175 || varExpr.kind === 176) { + if (varExpr.kind === 176 || varExpr.kind === 177) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -33452,7 +34412,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 152))); + return !!(node.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 153))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -33474,30 +34434,30 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 152) { + if (func.kind === 153) { if (node.expression) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); + error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 150) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { - error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + else if (func.kind === 151) { + if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node.expression || node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); if (promisedType) { - checkTypeAssignableTo(awaitedType, promisedType, node.expression || node); + checkTypeAssignableTo(awaitedType, promisedType, node); } } else { - checkTypeAssignableTo(exprType, returnType, node.expression || node); + checkTypeAssignableTo(exprType, returnType, node); } } } - else if (func.kind !== 150 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 151 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -33523,7 +34483,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 255 && !hasDuplicateDefaultClause) { + if (clause.kind === 257 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -33535,7 +34495,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 254) { + if (produceDiagnostics && clause.kind === 256) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var caseIsLiteral = isLiteralType(caseType); @@ -33561,7 +34521,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 220 && current.label.text === node.label.text) { + if (current.kind === 221 && 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; @@ -33594,14 +34554,14 @@ var ts; grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - var blockLocals = catchClause.block.locals; - if (blockLocals) { - for (var caughtName in catchClause.locals) { - var blockLocal = blockLocals[caughtName]; + var blockLocals_1 = catchClause.block.locals; + if (blockLocals_1) { + ts.forEachKey(catchClause.locals, function (caughtName) { + var blockLocal = blockLocals_1.get(caughtName); if (blockLocal && (blockLocal.flags & 2) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } - } + }); } } } @@ -33649,12 +34609,13 @@ var ts; if (!indexType) { return; } - if (indexKind === 1 && !isNumericName(prop.valueDeclaration.name)) { + var propDeclaration = prop.valueDeclaration; + if (indexKind === 1 && !(propDeclaration ? isNumericName(propDeclaration.name) : isNumericLiteralName(prop.name))) { return; } var errorNode; - if (prop.valueDeclaration.name.kind === 142 || prop.parent === containingType.symbol) { - errorNode = prop.valueDeclaration; + if (propDeclaration && (propDeclaration.name.kind === 143 || prop.parent === containingType.symbol)) { + errorNode = propDeclaration; } else if (indexDeclaration) { errorNode = indexDeclaration; @@ -33679,15 +34640,23 @@ var ts; case "string": case "symbol": case "void": + case "object": error(name, message, name.text); } } function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { + var seenDefault = false; for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { + if (node.default) { + seenDefault = true; + } + else if (seenDefault) { + error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters); + } for (var j = 0; j < i; j++) { if (typeParameterDeclarations[j].symbol === node.symbol) { error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name)); @@ -33697,23 +34666,57 @@ var ts; } } } - function checkTypeParameterListsIdentical(node, symbol) { + function checkTypeParameterListsIdentical(symbol) { if (symbol.declarations.length === 1) { return; } - var firstDecl; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 227 || declaration.kind === 228) { - if (!firstDecl) { - firstDecl = declaration; - } - else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); + var links = getSymbolLinks(symbol); + if (!links.typeParametersChecked) { + links.typeParametersChecked = true; + var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); + if (declarations.length <= 1) { + return; + } + var type = getDeclaredTypeOfSymbol(symbol); + if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { + var name = symbolToString(symbol); + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; + error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } } } + function areTypeParametersIdentical(declarations, typeParameters) { + var maxTypeArgumentCount = ts.length(typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; + var numTypeParameters = ts.length(declaration.typeParameters); + if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { + return false; + } + for (var i = 0; i < numTypeParameters; i++) { + var source = declaration.typeParameters[i]; + var target = typeParameters[i]; + if (source.name.text !== target.symbol.name) { + return false; + } + var sourceConstraint = source.constraint && getTypeFromTypeNode(source.constraint); + var targetConstraint = getConstraintFromTypeParameter(target); + if ((sourceConstraint || targetConstraint) && + (!sourceConstraint || !targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint))) { + return false; + } + var sourceDefault = source.default && getTypeFromTypeNode(source.default); + var targetDefault = getDefaultFromTypeParameter(target); + if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) { + return false; + } + } + } + return true; + } function checkClassExpression(node) { checkClassLikeDeclaration(node); checkNodeDeferred(node); @@ -33747,8 +34750,11 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); + if (!ts.isInAmbientContext(node)) { + checkClassForStaticPropertyNameConflicts(node); + } var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { if (languageVersion < 2 && !ts.isInAmbientContext(node)) { @@ -33757,7 +34763,8 @@ var ts; var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType_1 = baseTypes[0]; - var staticBaseType = getBaseConstructorTypeOfClass(type); + var baseConstructorType = getBaseConstructorTypeOfClass(type); + var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { @@ -33771,14 +34778,17 @@ var ts; } checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType_1.symbol.valueDeclaration && + if (baseConstructorType.flags & 540672 && !isMixinConstructorType(staticType)) { + error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); + } + if (baseType_1.symbol && baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 227) { + baseType_1.symbol.valueDeclaration.kind === 228) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 540672)) { var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType_1; })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); @@ -33798,8 +34808,7 @@ var ts; if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - var declaredType = getObjectFlags(t) & 4 ? t.target : t; - if (getObjectFlags(declaredType) & 3) { + if (isValidBaseType(t)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -33827,17 +34836,22 @@ var ts; } } function getTargetSymbol(s) { - return s.flags & 16777216 ? getSymbolLinks(s).target : s; + return getCheckFlags(s) & 1 ? s.target : s; } function getClassLikeDeclarationOfSymbol(symbol) { return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); } + function getClassOrInterfaceDeclarationsOfSymbol(symbol) { + return ts.filter(symbol.declarations, function (d) { + return d.kind === 228 || d.kind === 229; + }); + } function checkKindsOfPropertyMemberOverrides(type, baseType) { - var baseProperties = getPropertiesOfObjectType(baseType); + var baseProperties = getPropertiesOfType(baseType); for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); - if (base.flags & 134217728) { + if (base.flags & 16777216) { continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); @@ -33847,7 +34861,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 197) { + if (derivedClassDecl.kind === 198) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -33891,32 +34905,7 @@ var ts; } } function isAccessor(kind) { - return kind === 151 || kind === 152; - } - function areTypeParametersIdentical(list1, list2) { - if (!list1 && !list2) { - return true; - } - if (!list1 || !list2 || list1.length !== list2.length) { - return false; - } - for (var i = 0; i < list1.length; i++) { - var tp1 = list1[i]; - var tp2 = list2[i]; - if (tp1.name.text !== tp2.name.text) { - return false; - } - if (!tp1.constraint && !tp2.constraint) { - continue; - } - if (!tp1.constraint || !tp2.constraint) { - return false; - } - if (!isTypeIdenticalTo(getTypeFromTypeNode(tp1.constraint), getTypeFromTypeNode(tp2.constraint))) { - return false; - } - } - return true; + return kind === 152 || kind === 153; } function checkInheritedPropertiesAreIdentical(type, typeNode) { var baseTypes = getBaseTypes(type); @@ -33924,16 +34913,16 @@ var ts; return true; } var seen = ts.createMap(); - ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.name, { prop: p, containingType: type }); }); var ok = true; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; - var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { var prop = properties_7[_a]; - var existing = seen[prop.name]; + var existing = seen.get(prop.name); if (!existing) { - seen[prop.name] = { prop: prop, containingType: base }; + seen.set(prop.name, { prop: prop, containingType: base }); } else { var isInheritedProperty = existing.containingType !== type; @@ -33957,8 +34946,8 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 228); + checkTypeParameterListsIdentical(symbol); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 229); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -34054,7 +35043,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 190: + case 191: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -34065,7 +35054,7 @@ var ts; case 51: return ~value_1; } return undefined; - case 192: + case 193: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -34091,11 +35080,11 @@ var ts; case 8: checkGrammarNumericLiteral(e); return +e.text; - case 183: + case 184: return evalConstant(e.expression); case 70: + case 179: case 178: - case 177: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -34106,7 +35095,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 178) { + if (e.kind === 179) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -34123,7 +35112,7 @@ var ts; if (current.kind === 70) { break; } - else if (current.kind === 177) { + else if (current.kind === 178) { current = current.expression; } else { @@ -34184,7 +35173,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 230) { + if (declaration.kind !== 231) { return false; } var enumDeclaration = declaration; @@ -34205,10 +35194,10 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var declaration = declarations_5[_i]; - if ((declaration.kind === 227 || - (declaration.kind === 226 && ts.nodeIsPresent(declaration.body))) && + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 228 || + (declaration.kind === 227 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -34267,7 +35256,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 227); + var mergedClass = ts.getDeclarationOfKind(symbol, 228); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -34275,7 +35264,7 @@ var ts; } if (isAmbientExternalModule) { if (ts.isExternalModuleAugmentation(node)) { - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 134217728); if (checkBody && node.body) { for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -34310,42 +35299,42 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 206: + case 207: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 241: case 242: + case 243: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 235: case 236: + case 237: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 174: - case 224: - var name_25 = node.name; - if (ts.isBindingPattern(name_25)) { - for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { + case 175: + case 225: + var name = node.name; + if (ts.isBindingPattern(name)) { + for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 227: - case 230: - case 226: case 228: case 231: + case 227: case 229: + case 232: + case 230: if (isGlobalAugmentation) { return; } var symbol = getSymbolOfNode(node); if (symbol) { - var reportError = !(symbol.flags & 33554432); + var reportError = !(symbol.flags & 134217728); if (!reportError) { reportError = ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } @@ -34357,12 +35346,12 @@ var ts; switch (node.kind) { case 70: return node; - case 141: + case 142: do { node = node.left; } while (node.kind !== 70); return node; - case 177: + case 178: do { node = node.expression; } while (node.kind !== 70); @@ -34375,9 +35364,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 262 && !inAmbientExternalModule) { - error(moduleName, node.kind === 242 ? + var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 264 && !inAmbientExternalModule) { + error(moduleName, node.kind === 243 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -34398,7 +35387,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 244 ? + var message = node.kind === 245 ? 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)); @@ -34425,7 +35414,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 238) { + if (importClause.namedBindings.kind === 239) { checkImportBinding(importClause.namedBindings); } else { @@ -34476,8 +35465,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 262 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 233 && + !node.moduleSpecifier && ts.isInAmbientContext(node); + if (node.parent.kind !== 264 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -34490,7 +35481,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 262 || node.parent.kind === 232 || node.parent.kind === 231; + var isInAppropriateContext = node.parent.kind === 264 || node.parent.kind === 233 || node.parent.kind === 232; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -34513,8 +35504,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 262 ? node.parent : node.parent.parent; - if (container.kind === 231 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 264 ? node.parent : node.parent.parent; + if (container.kind === 232 && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -34543,18 +35534,13 @@ var ts; } } function hasExportedMembers(moduleSymbol) { - for (var id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; + return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; }); } function checkExternalModuleExports(node) { var moduleSymbol = getSymbolOfNode(node); var links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - var exportEqualsSymbol = moduleSymbol.exports["export="]; + var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; if (!isTopLevelInExternalModuleAugmentation(declaration)) { @@ -34562,31 +35548,31 @@ var ts; } } var exports = getExportsOfModule(moduleSymbol); - for (var id in exports) { + exports && exports.forEach(function (_a, id) { + var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { - continue; + return; } - var _a = exports[id], declarations = _a.declarations, flags = _a.flags; if (flags & (1920 | 64 | 384)) { - continue; + return; } var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); if (flags & 524288 && exportedDeclarationsCount <= 2) { - continue; + return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, id)); } } } - } + }); links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 226 && declaration.kind !== 149) || + return (declaration.kind !== 227 && declaration.kind !== 150) || !!declaration.body; } } @@ -34597,123 +35583,123 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 231: - case 227: + case 232: case 228: - case 226: + case 229: + case 227: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 143: - return checkTypeParameter(node); case 144: + return checkTypeParameter(node); + case 145: return checkParameter(node); + case 148: case 147: - case 146: return checkPropertyDeclaration(node); - case 158: case 159: - case 153: + case 160: case 154: - return checkSignatureDeclaration(node); case 155: return checkSignatureDeclaration(node); - case 149: - case 148: - return checkMethodDeclaration(node); - case 150: - return checkConstructorDeclaration(node); - case 151: - case 152: - return checkAccessorDeclaration(node); - case 157: - return checkTypeReferenceNode(node); case 156: + return checkSignatureDeclaration(node); + case 150: + case 149: + return checkMethodDeclaration(node); + case 151: + return checkConstructorDeclaration(node); + case 152: + case 153: + return checkAccessorDeclaration(node); + case 158: + return checkTypeReferenceNode(node); + case 157: return checkTypePredicate(node); - case 160: - return checkTypeQuery(node); case 161: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 162: - return checkArrayType(node); + return checkTypeLiteral(node); case 163: - return checkTupleType(node); + return checkArrayType(node); case 164: + return checkTupleType(node); case 165: - return checkUnionOrIntersectionType(node); case 166: - case 168: - return checkSourceElement(node.type); + return checkUnionOrIntersectionType(node); + case 167: case 169: - return checkIndexedAccessType(node); + return checkSourceElement(node.type); case 170: + return checkIndexedAccessType(node); + case 171: return checkMappedType(node); - case 226: - return checkFunctionDeclaration(node); - case 205: - case 232: - return checkBlock(node); - case 206: - return checkVariableStatement(node); - case 208: - return checkExpressionStatement(node); - case 209: - return checkIfStatement(node); - case 210: - return checkDoStatement(node); - case 211: - return checkWhileStatement(node); - case 212: - return checkForStatement(node); - case 213: - return checkForInStatement(node); - case 214: - return checkForOfStatement(node); - case 215: - case 216: - return checkBreakOrContinueStatement(node); - case 217: - return checkReturnStatement(node); - case 218: - return checkWithStatement(node); - case 219: - return checkSwitchStatement(node); - case 220: - return checkLabeledStatement(node); - case 221: - return checkThrowStatement(node); - case 222: - return checkTryStatement(node); - case 224: - return checkVariableDeclaration(node); - case 174: - return checkBindingElement(node); case 227: - return checkClassDeclaration(node); - case 228: - return checkInterfaceDeclaration(node); - case 229: - return checkTypeAliasDeclaration(node); - case 230: - return checkEnumDeclaration(node); - case 231: - return checkModuleDeclaration(node); - case 236: - return checkImportDeclaration(node); - case 235: - return checkImportEqualsDeclaration(node); - case 242: - return checkExportDeclaration(node); - case 241: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 206: + case 233: + return checkBlock(node); case 207: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 209: + return checkExpressionStatement(node); + case 210: + return checkIfStatement(node); + case 211: + return checkDoStatement(node); + case 212: + return checkWhileStatement(node); + case 213: + return checkForStatement(node); + case 214: + return checkForInStatement(node); + case 215: + return checkForOfStatement(node); + case 216: + case 217: + return checkBreakOrContinueStatement(node); + case 218: + return checkReturnStatement(node); + case 219: + return checkWithStatement(node); + case 220: + return checkSwitchStatement(node); + case 221: + return checkLabeledStatement(node); + case 222: + return checkThrowStatement(node); case 223: + return checkTryStatement(node); + case 225: + return checkVariableDeclaration(node); + case 175: + return checkBindingElement(node); + case 228: + return checkClassDeclaration(node); + case 229: + return checkInterfaceDeclaration(node); + case 230: + return checkTypeAliasDeclaration(node); + case 231: + return checkEnumDeclaration(node); + case 232: + return checkModuleDeclaration(node); + case 237: + return checkImportDeclaration(node); + case 236: + return checkImportEqualsDeclaration(node); + case 243: + return checkExportDeclaration(node); + case 242: + return checkExportAssignment(node); + case 208: checkGrammarStatementInAmbientContext(node); return; - case 245: + case 224: + checkGrammarStatementInAmbientContext(node); + return; + case 246: return checkMissingDeclaration(node); } } @@ -34726,17 +35712,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 184: case 185: + case 186: + case 150: case 149: - case 148: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 151: case 152: + case 153: checkAccessorDeferred(node); break; - case 197: + case 198: checkClassExpressionDeferred(node); break; } @@ -34824,7 +35810,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 218 && node.parent.statement === node) { + if (node.parent.kind === 219 && node.parent.statement === node) { return true; } node = node.parent; @@ -34846,28 +35832,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 262: + case 264: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 231: + case 232: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 230: + case 231: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 197: + case 198: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 227: case 228: + case 229: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 184: + case 185: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -34885,17 +35871,16 @@ var ts; function copySymbol(symbol, meaning) { if (symbol.flags & meaning) { var id = symbol.name; - if (!symbols[id]) { - symbols[id] = symbol; + if (!symbols.has(id)) { + symbols.set(id, symbol); } } } function copySymbols(source, meaning) { if (meaning) { - for (var id in source) { - var symbol = source[id]; + source.forEach(function (symbol) { copySymbol(symbol, meaning); - } + }); } } } @@ -34906,27 +35891,27 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 143: - case 227: + case 144: case 228: case 229: case 230: + case 231: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 141) { + while (node.parent && node.parent.kind === 142) { node = node.parent; } - return node.parent && (node.parent.kind === 157 || node.parent.kind === 273); + return node.parent && (node.parent.kind === 158 || node.parent.kind === 276); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 177) { + while (node.parent && node.parent.kind === 178) { node = node.parent; } - return node.parent && node.parent.kind === 199; + return node.parent && node.parent.kind === 200; } function forEachEnclosingClass(node, callback) { var result; @@ -34943,13 +35928,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 141) { + while (nodeOnRightSide.parent.kind === 142) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 235) { + if (nodeOnRightSide.parent.kind === 236) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 241) { + if (nodeOnRightSide.parent.kind === 242) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -34961,7 +35946,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 177) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 178) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -34973,11 +35958,11 @@ var ts; default: } } - if (entityName.parent.kind === 241 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 242 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 177 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 235); + if (entityName.kind !== 178 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 236); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -34986,7 +35971,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 199) { + if (entityName.parent.kind === 200) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -35008,14 +35993,14 @@ var ts; } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 177) { + else if (entityName.kind === 178) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 141) { + else if (entityName.kind === 142) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -35024,19 +36009,19 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 273) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 158 || entityName.parent.kind === 276) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 251) { + else if (entityName.parent.kind === 252) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 156) { + if (entityName.parent.kind === 157) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 262) { + if (node.kind === 264) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -35052,8 +36037,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 174 && - node.parent.parent.kind === 172 && + else if (node.parent.kind === 175 && + node.parent.parent.kind === 173 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -35064,8 +36049,8 @@ var ts; } switch (node.kind) { case 70: - case 177: - case 141: + case 178: + case 142: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98: var container = ts.getThisContainer(node, false); @@ -35078,18 +36063,18 @@ var ts; case 96: var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 167: + case 168: return getTypeFromTypeNode(node).symbol; case 122: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 150) { + if (constructorDeclaration && constructorDeclaration.kind === 151) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 236 || node.parent.kind === 242) && + ((node.parent.kind === 237 || node.parent.kind === 243) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -35097,7 +36082,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 178 && node.parent.argumentExpression === node) { + if (node.parent.kind === 179 && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -35111,7 +36096,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 259) { + if (location && location.kind === 261) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -35161,20 +36146,20 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 176 || expr.kind === 175); - if (expr.parent.kind === 214) { + ts.Debug.assert(expr.kind === 177 || expr.kind === 176); + if (expr.parent.kind === 215) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 192) { + if (expr.parent.kind === 193) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 258) { + if (expr.parent.kind === 260) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 175); + ts.Debug.assert(expr.parent.kind === 176); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); @@ -35200,30 +36185,33 @@ var ts; var propsByName = createSymbolTable(getPropertiesOfType(type)); if (getSignaturesOfType(type, 0).length || getSignaturesOfType(type, 1).length) { ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { - if (!propsByName[p.name]) { - propsByName[p.name] = p; + if (!propsByName.has(p.name)) { + propsByName.set(p.name, p); } }); } return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (symbol.flags & 268435456) { + if (getCheckFlags(symbol) & 2) { var symbols_3 = []; - var name_26 = symbol.name; + var name_2 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_26); + var symbol = getPropertyOfType(t, name_2); if (symbol) { symbols_3.push(symbol); } }); return symbols_3; } - else if (symbol.flags & 67108864) { + else if (symbol.flags & 134217728) { if (symbol.leftSpread) { var links = symbol; return [links.leftSpread, links.rightSpread]; } + if (symbol.mappedTypeOrigin) { + return getRootSymbols(symbol.mappedTypeOrigin); + } var target = void 0; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -35239,7 +36227,8 @@ var ts; if (!ts.isGeneratedIdentifier(node)) { node = ts.getParseTreeNode(node, ts.isIdentifier); if (node) { - return getReferencedValueSymbol(node) === argumentsSymbol; + var isPropertyName_1 = node.parent.kind === 178 && node.parent.name === node; + return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } return false; @@ -35255,7 +36244,7 @@ var ts; if (symbolLinks.exportsSomeValue === undefined) { symbolLinks.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & 107455) - : ts.forEachProperty(getExportsOfModule(moduleSymbol), isValue); + : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { @@ -35281,7 +36270,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 262) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 264) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -35319,7 +36308,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 205 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 206 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -35359,16 +36348,16 @@ var ts; return true; } switch (node.kind) { - case 235: - case 237: + case 236: case 238: - case 240: - case 244: + case 239: + case 241: + case 245: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 242: + case 243: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 241: + case 242: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -35378,7 +36367,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 262 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 264 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -35420,6 +36409,12 @@ var ts; } return false; } + function isRequiredInitializedParameter(parameter) { + return strictNullChecks && + !isOptionalParameter(parameter) && + parameter.initializer && + !(ts.getModifierFlags(parameter) & 92); + } function getNodeCheckFlags(node) { node = ts.getParseTreeNode(node); return node ? getNodeLinks(node).flags : undefined; @@ -35429,7 +36424,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 261) { + if (node.kind === 263) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -35445,15 +36440,17 @@ var ts; } function getTypeReferenceSerializationKind(typeName, location) { var valueSymbol = resolveEntityName(typeName, 107455, true, false, location); - var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); - if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { - return ts.TypeReferenceSerializationKind.Promise; - } - var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; - if (constructorType && isConstructorType(constructorType)) { - return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; - } var typeSymbol = resolveEntityName(typeName, 793064, true, false, location); + if (valueSymbol && valueSymbol === typeSymbol) { + var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); + if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { + return ts.TypeReferenceSerializationKind.Promise; + } + var constructorType = getTypeOfSymbol(valueSymbol); + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + } if (!typeSymbol) { return ts.TypeReferenceSerializationKind.ObjectType; } @@ -35497,6 +36494,9 @@ var ts; var type = symbol && !(symbol.flags & (2048 | 131072)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : unknownType; + if (flags & 4096) { + type = includeFalsyTypes(type, 2048); + } getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { @@ -35511,10 +36511,13 @@ var ts; var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(node)); resolveBaseTypesOfClass(classType); var baseType = classType.resolvedBaseTypes.length ? classType.resolvedBaseTypes[0] : unknownType; + if (!baseType.symbol) { + writer.reportIllegalExtends(); + } getSymbolDisplayBuilder().buildTypeDisplay(baseType, writer, enclosingDeclaration, flags); } function hasGlobalName(name) { - return !!globals[name]; + return globals.has(name); } function getReferencedValueSymbol(reference, startInDeclarationContainer) { var resolvedSymbol = getNodeLinks(reference).resolvedSymbol; @@ -35523,9 +36526,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_12 = reference.parent; - if (ts.isDeclaration(parent_12) && reference === parent_12.name) { - location = getDeclarationContainer(parent_12); + var parent = reference.parent; + if (ts.isDeclaration(parent) && reference === parent.name) { + location = getDeclarationContainer(parent); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -35558,14 +36561,13 @@ var ts; var fileToDirective; if (resolvedTypeReferenceDirectives) { fileToDirective = ts.createFileMap(); - for (var key in resolvedTypeReferenceDirectives) { - var resolvedDirective = resolvedTypeReferenceDirectives[key]; + resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) { if (!resolvedDirective) { - continue; + return; } var file = host.getSourceFile(resolvedDirective.resolvedFileName); fileToDirective.set(file.path, key); - } + }); } return { getReferencedExportContainer: getReferencedExportContainer, @@ -35579,6 +36581,7 @@ var ts; isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, + isRequiredInitializedParameter: isRequiredInitializedParameter, writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, writeTypeOfExpression: writeTypeOfExpression, @@ -35603,7 +36606,7 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 177) || (node.kind === 70 && isInTypeQuery(node)) + var meaning = (node.kind === 178) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -35638,15 +36641,15 @@ var ts; } var current = symbol; while (true) { - var parent_13 = getParentOfSymbol(current); - if (parent_13) { - current = parent_13; + var parent = getParentOfSymbol(current); + if (parent) { + current = parent; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 262 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 264 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -35665,7 +36668,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 262); + return ts.getDeclarationOfKind(moduleSymbol, 264); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -35686,11 +36689,11 @@ var ts; } if (file.symbol && file.symbol.globalExports) { var source = file.symbol.globalExports; - for (var id in source) { - if (!(id in globals)) { - globals[id] = source[id]; + source.forEach(function (sourceSymbol, id) { + if (!globals.has(id)) { + globals.set(id, sourceSymbol); } - } + }); } } if (augmentations) { @@ -35756,10 +36759,10 @@ var ts; var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1; helper <= 128; helper <<= 1) { if (uncheckedHelpers & helper) { - var name_27 = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_27), 107455); + var name = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name), 107455); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_27); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); } } } @@ -35794,7 +36797,7 @@ var ts; return emptyObjectType; } function createThenableType() { - var thenPropertySymbol = createSymbol(67108864 | 4, "then"); + var thenPropertySymbol = createSymbol(4, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; var thenableType = createObjectType(16); thenableType.properties = [thenPropertySymbol]; @@ -35808,14 +36811,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 149 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 150 && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 151 || node.kind === 152) { + else if (node.kind === 152 || node.kind === 153) { 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); @@ -35833,16 +36836,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 130) { - if (node.kind === 146 || node.kind === 148) { + if (node.kind === 147 || node.kind === 149) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 155) { + if (node.kind === 156) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 75: - if (node.kind !== 230 && node.parent.kind === 227) { + if (node.kind !== 231 && node.parent.kind === 228) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -35868,7 +36871,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 232 || node.parent.kind === 262) { + else if (node.parent.kind === 233 || node.parent.kind === 264) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -35891,10 +36894,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 232 || node.parent.kind === 262) { + else if (node.parent.kind === 233 || node.parent.kind === 264) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -35907,7 +36910,7 @@ var ts; if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 147 && node.kind !== 146 && node.kind !== 155 && node.kind !== 144) { + else if (node.kind !== 148 && node.kind !== 147 && node.kind !== 156 && node.kind !== 145) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; @@ -35926,10 +36929,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 228) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; @@ -35941,13 +36944,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 228) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 232) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 233) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -35957,14 +36960,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 227) { - if (node.kind !== 149 && - node.kind !== 147 && - node.kind !== 151 && - node.kind !== 152) { + if (node.kind !== 228) { + if (node.kind !== 150 && + node.kind !== 148 && + node.kind !== 152 && + node.kind !== 153) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 227 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 228 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -35983,7 +36986,7 @@ var ts; 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 === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -35991,7 +36994,7 @@ var ts; break; } } - if (node.kind === 150) { + if (node.kind === 151) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -36006,13 +37009,13 @@ var ts; } return; } - else if ((node.kind === 236 || node.kind === 235) && flags & 2) { + else if ((node.kind === 237 || node.kind === 236) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 144 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 145 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 144 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 145 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -36028,37 +37031,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 151: case 152: - case 150: - case 147: - case 146: - case 149: + case 153: + case 151: case 148: - case 155: - case 231: + case 147: + case 150: + case 149: + case 156: + case 232: + case 237: case 236: - case 235: + case 243: case 242: - case 241: - case 184: case 185: - case 144: + case 186: + case 145: return false; default: - if (node.parent.kind === 232 || node.parent.kind === 262) { + if (node.parent.kind === 233 || node.parent.kind === 264) { return false; } switch (node.kind) { - case 226: - return nodeHasAnyModifiersExcept(node, 119); case 227: - return nodeHasAnyModifiersExcept(node, 116); + return nodeHasAnyModifiersExcept(node, 119); case 228: - case 206: + return nodeHasAnyModifiersExcept(node, 116); case 229: - return true; + case 207: case 230: + return true; + case 231: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -36071,10 +37074,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 149: - case 226: - case 184: + case 150: + case 227: case 185: + case 186: if (!node.asteriskToken) { return false; } @@ -36136,7 +37139,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 185) { + if (node.kind === 186) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -36171,7 +37174,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 !== 134 && parameter.type.kind !== 132) { + if (parameter.type.kind !== 135 && parameter.type.kind !== 132) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -36198,7 +37201,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 198) { + if (arg.kind === 199) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -36268,19 +37271,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 142) { + if (node.kind !== 143) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 192 && computedPropertyName.expression.operatorToken.kind === 25) { + if (computedPropertyName.expression.kind === 193 && computedPropertyName.expression.operatorToken.kind === 25) { 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 === 226 || - node.kind === 184 || - node.kind === 149); + ts.Debug.assert(node.kind === 227 || + node.kind === 185 || + node.kind === 150); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -36305,87 +37308,87 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 260) { + if (prop.kind === 262) { continue; } - var name_28 = prop.name; - if (name_28.kind === 142) { - checkGrammarComputedPropertyName(name_28); + var name = prop.name; + if (name.kind === 143) { + checkGrammarComputedPropertyName(name); } - if (prop.kind === 259 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 261 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 || prop.kind !== 149) { + if (mod.kind !== 119 || prop.kind !== 150) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; - if (prop.kind === 258 || prop.kind === 259) { + if (prop.kind === 260 || prop.kind === 261) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_28.kind === 8) { - checkGrammarNumericLiteral(name_28); + if (name.kind === 8) { + checkGrammarNumericLiteral(name); } currentKind = Property; } - else if (prop.kind === 149) { + else if (prop.kind === 150) { currentKind = Property; } - else if (prop.kind === 151) { + else if (prop.kind === 152) { currentKind = GetAccessor; } - else if (prop.kind === 152) { + else if (prop.kind === 153) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_28); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { continue; } - if (!seen[effectiveName]) { - seen[effectiveName] = currentKind; + var existingKind = seen.get(effectiveName); + if (!existingKind) { + seen.set(effectiveName, currentKind); } else { - var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_28, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_28)); + grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[effectiveName] = currentKind | existingKind; + seen.set(effectiveName, currentKind | existingKind); } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } } function checkGrammarJsxElement(node) { var seen = ts.createMap(); - for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 252) { + if (attr.kind === 254) { continue; } var jsxAttr = attr; - var name_29 = jsxAttr.name; - if (!seen[name_29.text]) { - seen[name_29.text] = true; + var name = jsxAttr.name; + if (!seen.get(name.text)) { + seen.set(name.text, true); } else { - return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 253 && !initializer.expression) { + if (initializer && initializer.kind === 255 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -36394,7 +37397,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 225) { + if (forInOrOfStatement.initializer.kind === 226) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -36402,20 +37405,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 213 + var diagnostic = forInOrOfStatement.kind === 214 ? 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 = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 213 + var diagnostic = forInOrOfStatement.kind === 214 ? 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 === 213 + var diagnostic = forInOrOfStatement.kind === 214 ? 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); @@ -36442,11 +37445,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 151 ? + return grammarErrorOnNode(accessor.name, kind === 152 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 152) { + else if (kind === 153) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -36465,10 +37468,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 151 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 152 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 151 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 152 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -36483,7 +37486,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 176) { + if (node.parent.kind === 177) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -36499,10 +37502,10 @@ 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 === 228) { + else if (node.parent.kind === 229) { 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 === 161) { + else if (node.parent.kind === 162) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -36513,9 +37516,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 220: + case 221: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 215 + var isMisplacedContinueLabel = node.kind === 216 && !ts.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); @@ -36523,8 +37526,8 @@ var ts; return false; } break; - case 219: - if (node.kind === 216 && !node.label) { + case 220: + if (node.kind === 217 && !node.label) { return false; } break; @@ -36537,13 +37540,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 216 + var message = node.kind === 217 ? 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 === 216 + var message = node.kind === 217 ? 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); @@ -36555,7 +37558,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 173 || node.name.kind === 172) { + if (node.name.kind === 174 || node.name.kind === 173) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -36565,11 +37568,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 190 && expr.operator === 37 && + expr.kind === 191 && expr.operator === 37 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 213 && node.parent.parent.kind !== 214) { + if (node.parent.parent.kind !== 214 && node.parent.parent.kind !== 215) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -36596,9 +37599,29 @@ var ts; } } } + if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && + !ts.isInAmbientContext(node.parent.parent) && ts.hasModifier(node.parent.parent, 1)) { + checkESModuleMarker(node.name); + } var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } + function checkESModuleMarker(name) { + if (name.kind === 70) { + if (ts.unescapeIdentifier(name.text) === "__esModule") { + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); + } + } + else { + var elements = name.elements; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; + if (!ts.isOmittedExpression(element)) { + return checkESModuleMarker(element.name); + } + } + } + } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 70) { if (name.originalKeywordKind === 109) { @@ -36607,8 +37630,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { - var element = elements_2[_i]; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var element = elements_3[_i]; if (!ts.isOmittedExpression(element)) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -36626,15 +37649,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 209: case 210: case 211: - case 218: case 212: + case 219: case 213: case 214: + case 215: return false; - case 220: + case 221: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -36696,7 +37719,7 @@ var ts; return true; } } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 229) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -36704,7 +37727,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 161) { + else if (node.parent.kind === 162) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -36717,13 +37740,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 228 || - node.kind === 229 || + if (node.kind === 229 || + node.kind === 230 || + node.kind === 237 || node.kind === 236 || - node.kind === 235 || + node.kind === 243 || node.kind === 242 || - node.kind === 241 || - node.kind === 234 || + node.kind === 235 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -36732,7 +37755,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 === 206) { + if (ts.isDeclaration(decl) || decl.kind === 207) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -36751,7 +37774,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 === 205 || node.parent.kind === 232 || node.parent.kind === 262) { + if (node.parent.kind === 206 || node.parent.kind === 233 || node.parent.kind === 264) { 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); @@ -36767,10 +37790,10 @@ var ts; if (languageVersion >= 1) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 171)) { + else if (ts.isChildOfNodeWithKind(node, 172)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 261)) { + else if (ts.isChildOfNodeWithKind(node, 263)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -36790,11 +37813,11 @@ var ts; } function getAmbientModules() { var result = []; - for (var sym in globals) { + globals.forEach(function (global, sym) { if (ambientModuleSymbolRegex.test(sym)) { - result.push(globals[sym]); + result.push(global); } - } + }); return result; } } @@ -36802,55 +37825,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ; - var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[141] = [ - { name: "left", test: ts.isEntityName }, - { name: "right", test: ts.isIdentifier } - ], - _a[145] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[182] = [ - { name: "type", test: ts.isTypeNode }, - { name: "expression", test: ts.isUnaryExpression } - ], - _a[200] = [ - { name: "expression", test: ts.isExpression }, - { name: "type", test: ts.isTypeNode } - ], - _a[201] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[230] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "members", test: ts.isEnumMember } - ], - _a[231] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isModuleName }, - { name: "body", test: ts.isModuleBody } - ], - _a[232] = [ - { name: "statements", test: ts.isStatement } - ], - _a[235] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "moduleReference", test: ts.isModuleReference } - ], - _a[246] = [ - { name: "expression", test: ts.isExpression, optional: true } - ], - _a[261] = [ - { name: "name", test: ts.isPropertyName }, - { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } - ], - _a)); function reduceNode(node, f, initial) { return node ? f(initial, node) : initial; } @@ -36864,41 +37838,45 @@ var ts; var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; - if ((kind > 0 && kind <= 140)) { + if ((kind > 0 && kind <= 141)) { return initial; } - if ((kind >= 156 && kind <= 171)) { + if ((kind >= 157 && kind <= 172)) { return initial; } var result = initial; switch (node.kind) { - case 204: - case 207: - case 198: - case 223: - case 294: + case 205: + case 208: + case 199: + case 224: + case 297: break; case 142: - result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); break; - case 144: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); + case 143: + result = reduceNode(node.expression, cbNode, result); break; case 145: - result = reduceNode(node.expression, cbNode, result); - break; - case 147: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 149: + case 146: + result = reduceNode(node.expression, cbNode, result); + break; + case 148: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 150: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -36907,53 +37885,48 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 150: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; case 151: - result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; case 152: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 153: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 172: case 173: + case 174: result = reduceNodes(node.elements, cbNodes, result); break; - case 174: + case 175: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 175: + case 176: result = reduceNodes(node.elements, cbNodes, result); break; - case 176: - result = reduceNodes(node.properties, cbNodes, result); - break; case 177: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.properties, cbNodes, result); break; case 178: result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.argumentExpression, cbNode, result); + result = reduceNode(node.name, cbNode, result); break; case 179: result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); + result = reduceNode(node.argumentExpression, cbNode, result); break; case 180: result = reduceNode(node.expression, cbNode, result); @@ -36961,10 +37934,19 @@ var ts; result = reduceNodes(node.arguments, cbNodes, result); break; case 181: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 182: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 184: + case 183: + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 185: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -36972,126 +37954,133 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 185: + case 186: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 183: - case 186: + case 184: case 187: case 188: case 189: - case 195: + case 190: case 196: - case 201: + case 197: + case 202: result = reduceNode(node.expression, cbNode, result); break; - case 190: case 191: + case 192: result = reduceNode(node.operand, cbNode, result); break; - case 192: + case 193: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 193: + case 194: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 194: + case 195: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 197: + case 198: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 199: + case 200: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 203: + case 201: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.type, cbNode, result); + break; + case 202: + result = reduceNode(node.expression, cbNode, result); + break; + case 204: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 205: + case 206: result = reduceNodes(node.statements, cbNodes, result); break; - case 206: + case 207: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 208: + case 209: result = reduceNode(node.expression, cbNode, result); break; - case 209: + case 210: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 210: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; case 211: - case 218: - result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); break; case 212: + case 219: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 213: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 213: case 214: + case 215: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 217: - case 221: + case 218: + case 222: result = reduceNode(node.expression, cbNode, result); break; - case 219: + case 220: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 220: + case 221: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 222: + case 223: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 224: + case 225: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 225: - result = reduceNodes(node.declarations, cbNodes, result); - break; case 226: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); + result = reduceNodes(node.declarations, cbNodes, result); break; case 227: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 228: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -37099,113 +38088,131 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; + case 231: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 232: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; case 233: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 234: result = reduceNodes(node.clauses, cbNodes, result); break; case 236: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.moduleReference, cbNode, result); + break; + case 237: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 237: + case 238: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 238: - result = reduceNode(node.name, cbNode, result); - break; case 239: - case 243: - result = reduceNodes(node.elements, cbNodes, result); + result = reduceNode(node.name, cbNode, result); break; case 240: case 244: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 241: + case 245: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 241: + case 242: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 242: + case 243: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; case 247: + result = reduceNode(node.expression, cbNode, result); + break; + case 248: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 248: case 249: - result = reduceNode(node.tagName, cbNode, result); - result = reduceNodes(node.attributes, cbNodes, result); - break; case 250: result = reduceNode(node.tagName, cbNode, result); + result = reduceNode(node.attributes, cbNode, result); break; case 251: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 252: - result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.tagName, cbNode, result); break; case 253: - result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.properties, cbNodes, result); + break; + case 252: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); break; case 254: result = reduceNode(node.expression, cbNode, result); + break; case 255: - result = reduceNodes(node.statements, cbNodes, result); + result = reduceNode(node.expression, cbNode, result); break; case 256: + result = reduceNode(node.expression, cbNode, result); + case 257: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 258: result = reduceNodes(node.types, cbNodes, result); break; - case 257: + case 259: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 258: + case 260: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 259: + case 261: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 260: + case 262: result = reduceNode(node.expression, cbNode, result); break; - case 262: + case 263: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + case 264: result = reduceNodes(node.statements, cbNodes, result); break; - case 295: + case 298: result = reduceNode(node.expression, cbNode, result); break; default: - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_1 = edgeTraversalPath; _i < edgeTraversalPath_1.length; _i++) { - var edge = edgeTraversalPath_1[_i]; - var value = node[edge.name]; - if (value !== undefined) { - result = ts.isArray(value) - ? reduceNodes(value, cbNodes, result) - : cbNode(result, value); - } - } - } break; } return result; } ts.reduceEachChild = reduceEachChild; - function visitNode(node, visitor, test, optional, lift, parenthesize, parentNode) { + function visitNode(node, visitor, test, optional, lift) { if (node === undefined || visitor === undefined) { return node; } @@ -37227,15 +38234,12 @@ var ts; else { visitedNode = visited; } - if (parenthesize !== undefined) { - visitedNode = parenthesize(visitedNode, parentNode); - } Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); return visitedNode; } ts.visitNode = visitNode; - function visitNodes(nodes, visitor, test, start, count, parenthesize, parentNode) { + function visitNodes(nodes, visitor, test, start, count) { if (nodes === undefined) { return undefined; } @@ -37248,7 +38252,7 @@ var ts; count = length - start; } if (start > 0 || count < length) { - updated = ts.createNodeArray([], undefined, nodes.hasTrailingComma && start + count === length); + updated = ts.createNodeArray([], nodes.hasTrailingComma && start + count === length); } for (var i = 0; i < count; i++) { var node = nodes[i + start]; @@ -37256,27 +38260,22 @@ var ts; var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { - updated = ts.createNodeArray(nodes.slice(0, i), nodes, nodes.hasTrailingComma); + updated = ts.createNodeArray(nodes.slice(0, i), nodes.hasTrailingComma); + ts.setTextRange(updated, nodes); } if (visited) { if (ts.isArray(visited)) { for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) { var visitedNode = visited_1[_i]; - visitedNode = parenthesize - ? parenthesize(visitedNode, parentNode) - : visitedNode; Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); updated.push(visitedNode); } } else { - var visitedNode = parenthesize - ? parenthesize(visited, parentNode) - : visited; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); - updated.push(visitedNode); + Debug.assertNode(visited, test); + aggregateTransformFlags(visited); + updated.push(visited); } } } @@ -37288,10 +38287,10 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); - return ts.createNodeArray(ts.concatenate(statements, declarations), statements); + return ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements); } ts.visitLexicalEnvironment = visitLexicalEnvironment; function visitParameterList(nodes, visitor, context) { @@ -37318,203 +38317,206 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 140)) { + if ((kind > 0 && kind <= 141)) { return node; } - if ((kind >= 156 && kind <= 171)) { + if ((kind >= 157 && kind <= 172)) { return node; } switch (node.kind) { - case 204: - case 207: - case 198: - case 223: + case 205: + case 208: + case 199: + case 224: return node; case 142: + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); + case 143: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 144: + case 145: return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), node.dotDotDotToken, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 147: + case 146: + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); + case 148: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 149: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 150: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); + return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 151: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); case 152: + return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 153: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 172: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 173: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 174: - return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); case 175: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); case 176: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); case 177: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); case 178: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); case 179: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); case 180: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); case 181: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 182: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); case 183: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 184: - return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 185: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 186: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 187: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 188: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); case 189: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); case 190: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 191: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); case 193: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 191: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 192: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); case 194: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 195: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); case 196: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); case 197: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 198: return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 199: + case 200: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 203: + case 201: + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); + case 202: + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + case 204: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 205: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); case 206: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 207: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 208: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 209: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 210: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); case 211: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 212: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 213: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 214: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 215: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 216: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 217: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 218: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); case 219: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 220: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); case 221: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 222: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 223: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); - case 224: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 225: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 226: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); case 227: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 228: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); + case 231: + return ts.updateEnumDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNodes(node.members, visitor, ts.isEnumMember)); + case 232: + return ts.updateModuleDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); case 233: + return ts.updateModuleBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 234: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 236: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + return ts.updateImportEqualsDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); case 237: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 238: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 239: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 240: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 241: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 242: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 243: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); case 244: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 245: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 247: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); case 248: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 249: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 250: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 251: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 252: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 253: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxAttributes(node, visitNodes(node.properties, visitor, ts.isJsxAttributeLike)); + case 249: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 250: + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 251: + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + case 252: + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 254: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 255: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 256: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); case 257: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); case 258: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); case 259: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 260: - return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 261: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); case 262: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 263: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 264: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 295: + case 298: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: - var updated = void 0; - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_2 = edgeTraversalPath; _i < edgeTraversalPath_2.length; _i++) { - var edge = edgeTraversalPath_2[_i]; - var value = node[edge.name]; - if (value !== undefined) { - var visited = ts.isArray(value) - ? visitNodes(value, visitor, edge.test, 0, value.length, edge.parenthesize, node) - : visitNode(value, visitor, edge.test, edge.optional, edge.lift, edge.parenthesize, node); - if (updated !== undefined || visited !== value) { - if (updated === undefined) { - updated = ts.getMutableClone(node); - } - if (visited !== value) { - updated[edge.name] = visited; - } - } - } - } - } - return updated ? ts.updateNode(updated, node) : node; + return node; } } ts.visitEachChild = visitEachChild; @@ -37523,17 +38525,17 @@ var ts; return statements; } return ts.isNodeArray(statements) - ? ts.createNodeArray(ts.concatenate(statements, declarations), statements) + ? ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements) : ts.addRange(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; function mergeFunctionBodyLexicalEnvironment(body, declarations) { if (body && declarations !== undefined && declarations.length > 0) { if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.createNodeArray(ts.concatenate(body.statements, declarations), body.statements)); + return ts.updateBlock(body, ts.setTextRange(ts.createNodeArray(ts.concatenate(body.statements, declarations)), body.statements)); } else { - return ts.createBlock(ts.createNodeArray([ts.createReturn(body, body)].concat(declarations), body), body, true); + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray([ts.setTextRange(ts.createReturn(body), body)].concat(declarations)), body), true), body); } } return body; @@ -37578,7 +38580,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 199)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 200)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -37626,7 +38628,6 @@ var ts; } } })(Debug = ts.Debug || (ts.Debug = {})); - var _a; })(ts || (ts = {})); var ts; (function (ts) { @@ -37683,7 +38684,7 @@ var ts; ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression); var expression = createAssignmentCallback ? createAssignmentCallback(target, value, location) - : ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value, location); + : ts.setTextRange(ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location); expression.original = original; emitExpression(expression); } @@ -37721,10 +38722,11 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_30 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_30, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value); variable.original = original; - if (ts.isIdentifier(name_30)) { + ts.setTextRange(variable, location); + if (ts.isIdentifier(name)) { ts.setEmitFlags(variable, 64); } ts.aggregateTransformFlags(variable); @@ -37870,8 +38872,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_31 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_31); + var name = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name); } } function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) { @@ -37882,7 +38884,7 @@ var ts; var temp = ts.createTempVariable(undefined); if (flattenContext.hoistTempVariables) { flattenContext.context.hoistVariableDeclaration(temp); - flattenContext.emitExpression(ts.createAssignment(temp, value, location)); + flattenContext.emitExpression(ts.setTextRange(ts.createAssignment(temp, value), location)); } else { flattenContext.emitBindingOrAssignment(temp, value, location, undefined); @@ -37932,7 +38934,10 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), undefined, [value, ts.createArrayLiteral(propertyNames, location)]); + return ts.createCall(ts.getHelperName("__rest"), undefined, [ + value, + ts.setTextRange(ts.createArrayLiteral(propertyNames), location) + ]); } })(ts || (ts = {})); var ts; @@ -37948,8 +38953,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(177); context.enableSubstitution(178); + context.enableSubstitution(179); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -37982,15 +38987,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 262: + case 264: + case 234: case 233: - case 232: - case 205: + case 206: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 228: case 227: - case 226: if (ts.hasModifier(node, 2)) { break; } @@ -38015,13 +39020,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 236: + case 237: return visitImportDeclaration(node); - case 235: + case 236: return visitImportEqualsDeclaration(node); - case 241: - return visitExportAssignment(node); case 242: + return visitExportAssignment(node); + case 243: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -38031,11 +39036,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 242 || - node.kind === 236 || + if (node.kind === 243 || node.kind === 237 || - (node.kind === 235 && - node.moduleReference.kind === 246)) { + node.kind === 238 || + (node.kind === 236 && + node.moduleReference.kind === 247)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -38051,15 +39056,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 150: - return undefined; - case 147: - case 155: case 151: + return undefined; + case 148: + case 156: case 152: - case 149: + case 153: + case 150: return visitorWorker(node); - case 204: + case 205: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -38090,23 +39095,22 @@ var ts; case 75: case 123: case 130: - case 162: case 163: - case 161: - case 156: - case 143: + case 164: + case 162: + case 157: + case 144: case 118: case 121: - case 134: + case 135: case 132: case 129: case 104: - case 135: - case 159: - case 158: + case 136: case 160: - case 157: - case 164: + case 159: + case 161: + case 158: case 165: case 166: case 167: @@ -38114,57 +39118,58 @@ var ts; case 169: case 170: case 171: - case 155: - case 145: - case 229: - case 147: - return undefined; - case 150: - return visitConstructor(node); - case 228: - return ts.createNotEmittedStatement(node); - case 227: - return visitClassDeclaration(node); - case 197: - return visitClassExpression(node); - case 256: - return visitHeritageClause(node); - case 199: - return visitExpressionWithTypeArguments(node); - case 149: - return visitMethodDeclaration(node); - case 151: - return visitGetAccessor(node); - case 152: - return visitSetAccessor(node); - case 226: - return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); - case 185: - return visitArrowFunction(node); - case 144: - return visitParameter(node); - case 183: - return visitParenthesizedExpression(node); - case 182: - case 200: - return visitAssertionExpression(node); - case 179: - return visitCallExpression(node); - case 180: - return visitNewExpression(node); - case 201: - return visitNonNullExpression(node); + case 172: + case 156: + case 146: case 230: - return visitEnumDeclaration(node); - case 206: - return visitVariableStatement(node); - case 224: - return visitVariableDeclaration(node); + case 148: + return undefined; + case 151: + return visitConstructor(node); + case 229: + return ts.createNotEmittedStatement(node); + case 228: + return visitClassDeclaration(node); + case 198: + return visitClassExpression(node); + case 258: + return visitHeritageClause(node); + case 200: + return visitExpressionWithTypeArguments(node); + case 150: + return visitMethodDeclaration(node); + case 152: + return visitGetAccessor(node); + case 153: + return visitSetAccessor(node); + case 227: + return visitFunctionDeclaration(node); + case 185: + return visitFunctionExpression(node); + case 186: + return visitArrowFunction(node); + case 145: + return visitParameter(node); + case 184: + return visitParenthesizedExpression(node); + case 183: + case 201: + return visitAssertionExpression(node); + case 180: + return visitCallExpression(node); + case 181: + return visitNewExpression(node); + case 202: + return visitNonNullExpression(node); case 231: + return visitEnumDeclaration(node); + case 207: + return visitVariableStatement(node); + case 225: + return visitVariableDeclaration(node); + case 232: return visitModuleDeclaration(node); - case 235: + case 236: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38224,11 +39229,12 @@ var ts; return ts.singleOrMany(statements); } function createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, hasStaticProperties) { - var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); + var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause)); var emitFlags = ts.getEmitFlags(node); if (hasStaticProperties) { emitFlags |= 32; } + ts.setTextRange(classDeclaration, node); ts.setOriginalNode(classDeclaration, node); ts.setEmitFlags(classDeclaration, emitFlags); return classDeclaration; @@ -38239,10 +39245,14 @@ var ts; var declName = ts.getLocalName(node, false, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, hasExtendsClause); - var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members, location); + var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); - var statement = ts.createLetStatement(declName, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression, location); + ts.setTextRange(classExpression, location); + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declName, undefined, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression) + ], 1)); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, location); ts.setCommentRange(statement, node); return statement; } @@ -38250,7 +39260,9 @@ var ts; var staticProperties = getInitializedProperties(node, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84; })); - var classExpression = ts.setOriginalNode(ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members, node), node); + var classExpression = ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members); + ts.setOriginalNode(classExpression, node); + ts.setTextRange(classExpression, node); if (staticProperties.length > 0) { var expressions = []; var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -38273,7 +39285,7 @@ var ts; members.push(constructor); } ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); - return ts.createNodeArray(members, node.members); + return ts.setTextRange(ts.createNodeArray(members), node.members); } function transformConstructor(node, hasExtendsClause) { var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); @@ -38284,7 +39296,7 @@ var ts; } var parameters = transformConstructorParameters(constructor); var body = transformConstructorBody(node, constructor, hasExtendsClause); - return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor(undefined, undefined, parameters, body, constructor || node), constructor)); + return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor(undefined, undefined, parameters, body), constructor || node), constructor)); } function transformConstructorParameters(constructor) { return ts.visitParameterList(constructor && constructor.parameters, visitor, context) @@ -38308,7 +39320,7 @@ var ts; ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } ts.addRange(statements, endLexicalEnvironment()); - return ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : undefined, true); + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined); } function addPrologueDirectivesAndInitialSuperCall(ctor, result) { if (ctor.body) { @@ -38318,7 +39330,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -38340,7 +39352,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 | 48); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536); - return ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), propertyName, node.name), localName), ts.moveRangePos(node, -1))); + return ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1))); } function getInitializedProperties(node, isStatic) { return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); @@ -38352,7 +39364,7 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 147 + return member.kind === 148 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } @@ -38425,12 +39437,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 151: case 152: + case 153: return getAllDecoratorsOfAccessors(node, member); - case 149: + case 150: return getAllDecoratorsOfMethod(member); - case 147: + case 148: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -38509,7 +39521,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 147 + ? member.kind === 148 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -38587,43 +39599,43 @@ var ts; (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, undefined, true))); + decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, true))); } } } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 149 - || kind === 151 + return kind === 150 || kind === 152 - || kind === 147; + || kind === 153 + || kind === 148; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 149; + return node.kind === 150; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 227: - case 197: + case 228: + case 198: return ts.getFirstConstructorWithBody(node) !== undefined; - case 149: - case 151: + case 150: case 152: + case 153: return true; } return false; } function serializeTypeOfNode(node) { switch (node.kind) { - case 147: - case 144: - case 151: - return serializeTypeNode(node.type); + case 148: + case 145: case 152: + return serializeTypeNode(node.type); + case 153: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 227: - case 197: - case 149: + case 228: + case 198: + case 150: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -38655,7 +39667,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 151) { + if (container && node.kind === 152) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -38678,24 +39690,24 @@ var ts; } switch (node.kind) { case 104: - case 137: + case 138: case 94: case 129: return ts.createVoidZero(); - case 166: + case 167: return serializeTypeNode(node.type); - case 158: case 159: + case 160: return ts.createIdentifier("Function"); - case 162: case 163: + case 164: return ts.createIdentifier("Array"); - case 156: + case 157: case 121: return ts.createIdentifier("Boolean"); - case 134: + case 135: return ts.createIdentifier("String"); - case 171: + case 172: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); @@ -38711,22 +39723,22 @@ var ts; break; case 132: return ts.createIdentifier("Number"); - case 135: + case 136: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 157: + case 158: return serializeTypeReferenceNode(node); + case 166: case 165: - case 164: return serializeUnionOrIntersectionType(node); - case 160: - case 168: + case 161: case 169: case 170: - case 161: + case 171: + case 162: case 118: - case 167: + case 168: break; default: ts.Debug.failBadSyntaxKind(node); @@ -38794,15 +39806,15 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 70: - var name_32 = ts.getMutableClone(node); - name_32.flags &= ~8; - name_32.original = undefined; - name_32.parent = currentScope; + var name = ts.getMutableClone(node); + name.flags &= ~8; + name.original = undefined; + name.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_32), ts.createLiteral("undefined")), name_32); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } - return name_32; - case 141: + return name; + case 142: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -38846,7 +39858,7 @@ var ts; hoistVariableDeclaration(generatedName); expression = ts.createAssignment(generatedName, expression); } - return ts.setOriginalNode(ts.createComputedPropertyName(expression, name), name); + return ts.updateComputedPropertyName(name, expression); } else { return name; @@ -38855,13 +39867,12 @@ var ts; function visitHeritageClause(node) { if (node.token === 84) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(84, types, node); + return ts.setTextRange(ts.createHeritageClause(84, types), node); } return undefined; } function visitExpressionWithTypeArguments(node) { - var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); - return ts.createExpressionWithTypeArguments(undefined, expression, node); + return ts.updateExpressionWithTypeArguments(node, undefined, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); } function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); @@ -38935,8 +39946,9 @@ var ts; if (ts.parameterIsThisKeyword(node)) { return undefined; } - var parameter = ts.createParameter(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), ts.moveRangePastModifiers(node)); + var parameter = ts.createParameter(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); ts.setOriginalNode(parameter, node); + ts.setTextRange(parameter, ts.moveRangePastModifiers(node)); ts.setCommentRange(parameter, node); ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); ts.setEmitFlags(parameter.name, 32); @@ -38948,7 +39960,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); + return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -38960,7 +39972,7 @@ var ts; return ts.flattenDestructuringAssignment(node, visitor, context, 0, false, createNamespaceExportExpression); } else { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), node); + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node); } } function visitVariableDeclaration(node) { @@ -39014,8 +40026,9 @@ var ts; var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg]), node); + var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg])); ts.setOriginalNode(enumStatement, node); + ts.setTextRange(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); statements.push(ts.createEndOfDeclarationMarker(node)); @@ -39029,11 +40042,11 @@ var ts; ts.addRange(statements, ts.map(node.members, transformEnumMember)); ts.addRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceLocalName; - return ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); + return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true); } function transformEnumMember(member) { var name = getExpressionForPropertyName(member, false); - return ts.createStatement(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name, member), member); + return ts.setTextRange(ts.createStatement(ts.setTextRange(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name), member)), member); } function transformEnumMemberDeclarationValue(member) { var value = resolver.getConstantValue(member); @@ -39065,16 +40078,16 @@ var ts; if (!currentScopeFirstDeclarationsOfName) { currentScopeFirstDeclarationsOfName = ts.createMap(); } - if (!(name in currentScopeFirstDeclarationsOfName)) { - currentScopeFirstDeclarationsOfName[name] = node; + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_33 = node.symbol && node.symbol.name; - if (name_33) { - return currentScopeFirstDeclarationsOfName[name_33] === node; + var name = node.symbol && node.symbol.name; + if (name) { + return currentScopeFirstDeclarationsOfName.get(name) === node; } } return false; @@ -39086,7 +40099,7 @@ var ts; ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 230) { + if (node.kind === 231) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -39127,8 +40140,9 @@ var ts; var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); + var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg])); ts.setOriginalNode(moduleStatement, node); + ts.setTextRange(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); statements.push(ts.createEndOfDeclarationMarker(node)); @@ -39146,7 +40160,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 232) { + if (body.kind === 233) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -39168,14 +40182,15 @@ var ts; currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 232) { + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); + ts.setTextRange(block, blockLocation); + if (body.kind !== 233) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 231) { + if (moduleDeclaration.body.kind === 232) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -39195,7 +40210,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 238) { + if (node.kind === 239) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -39247,9 +40262,9 @@ var ts; var moduleReference = ts.createExpressionFromEntityName(node.moduleReference); ts.setEmitFlags(moduleReference, 1536 | 2048); if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { - return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ + return ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.setOriginalNode(ts.createVariableDeclaration(node.name, undefined, moduleReference), node) - ]), node), node); + ])), node), node); } else { return ts.setOriginalNode(createNamespaceExport(node.name, moduleReference, node), node); @@ -39270,7 +40285,7 @@ var ts; && ts.hasModifier(node, 512); } function expressionToStatement(expression) { - return ts.createStatement(expression, undefined); + return ts.createStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), ts.getLocalName(node)); @@ -39280,10 +40295,10 @@ var ts; statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue), location); + return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue, location); + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); } function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) { return ts.getNamespaceMemberName(currentNamespaceContainerName, name, false, true); @@ -39299,7 +40314,7 @@ var ts; function getClassAliasIfNeeded(node) { if (resolver.getNodeCheckFlags(node) & 8388608) { enableSubstitutionForClassAliases(); - var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); + var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.unescapeIdentifier(node.name.text) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; hoistVariableDeclaration(classAlias); return classAlias; @@ -39323,24 +40338,24 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(70); - classAliases = ts.createMap(); + classAliases = []; } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(259); - context.enableEmitNotification(231); + context.enableSubstitution(261); + context.enableEmitNotification(232); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 231; + return ts.getOriginalNode(node).kind === 232; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 230; + return ts.getOriginalNode(node).kind === 231; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2; @@ -39348,12 +40363,12 @@ var ts; if (enabledSubstitutions & 8 && isTransformedEnumDeclaration(node)) { applicableSubstitutions |= 8; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -39363,14 +40378,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_34 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_34); + var name = node.name; + var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_34, initializer, node); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); } - return ts.createPropertyAssignment(name_34, exportedName, node); + return ts.setTextRange(ts.createPropertyAssignment(name, exportedName), node); } } return node; @@ -39379,9 +40394,9 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 177: - return substitutePropertyAccessExpression(node); case 178: + return substitutePropertyAccessExpression(node); + case 179: return substituteElementAccessExpression(node); } return node; @@ -39411,11 +40426,11 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 262) { - var substitute = (applicableSubstitutions & 2 && container.kind === 231) || - (applicableSubstitutions & 8 && container.kind === 230); + if (container && container.kind !== 264) { + var substitute = (applicableSubstitutions & 2 && container.kind === 232) || + (applicableSubstitutions & 8 && container.kind === 231); if (substitute) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } } } @@ -39462,10 +40477,10 @@ var ts; }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(paramHelper); - return ts.createCall(ts.getHelperName("__param"), undefined, [ + return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), undefined, [ ts.createLiteral(parameterOffset), expression - ], location); + ]), location); } var metadataHelper = { name: "typescript:metadata", @@ -39489,7 +40504,7 @@ var ts; function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) { context.requestEmitHelper(decorateHelper); var argumentsArray = []; - argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, undefined, true)); + argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, true)); argumentsArray.push(target); if (memberName) { argumentsArray.push(memberName); @@ -39497,7 +40512,7 @@ var ts; argumentsArray.push(descriptor); } } - return ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray, location); + return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray), location); } })(ts || (ts = {})); var ts; @@ -39524,37 +40539,37 @@ var ts; return node; } switch (node.kind) { - case 176: + case 177: return visitObjectLiteralExpression(node); - case 192: + case 193: return visitBinaryExpression(node, noDestructuringValue); - case 224: + case 225: return visitVariableDeclaration(node); - case 214: + case 215: return visitForOfStatement(node); - case 212: + case 213: return visitForStatement(node); - case 188: + case 189: return visitVoidExpression(node); - case 150: - return visitConstructorDeclaration(node); - case 149: - return visitMethodDeclaration(node); case 151: - return visitGetAccessorDeclaration(node); + return visitConstructorDeclaration(node); + case 150: + return visitMethodDeclaration(node); case 152: + return visitGetAccessorDeclaration(node); + case 153: return visitSetAccessorDeclaration(node); - case 226: + case 227: return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); case 185: + return visitFunctionExpression(node); + case 186: return visitArrowFunction(node); - case 144: + case 145: return visitParameter(node); - case 208: + case 209: return visitExpressionStatement(node); - case 183: + case 184: return visitParenthesizedExpression(node, noDestructuringValue); default: return ts.visitEachChild(node, visitor, context); @@ -39563,9 +40578,9 @@ var ts; function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; - for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { - var e = elements_3[_i]; - if (e.kind === 260) { + for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { + var e = elements_4[_i]; + if (e.kind === 262) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -39577,7 +40592,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 258) { + if (e.kind === 260) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -39594,7 +40609,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 1048576) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 176) { + if (objects.length && objects[0].kind !== 177) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -39638,25 +40653,26 @@ var ts; var firstDeclaration = ts.firstOrUndefined(initializer.declarations); var declarations = ts.flattenDestructuringBinding(firstDeclaration, visitor, context, 1, temp, false, true); if (ts.some(declarations)) { - var statement = ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(initializer, declarations), initializer); + var statement = ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(initializer, declarations)); + ts.setTextRange(statement, initializer); leadingStatements = ts.append(leadingStatements, statement); } } else if (ts.isAssignmentPattern(initializer)) { temp = ts.createTempVariable(undefined); - var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.createAssignment(initializer, temp, node.initializer)), visitor, context, 1); - leadingStatements = ts.append(leadingStatements, ts.createStatement(expression, node.initializer)); + var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.setTextRange(ts.createAssignment(initializer, temp), node.initializer)), visitor, context, 1); + leadingStatements = ts.append(leadingStatements, ts.setTextRange(ts.createStatement(expression), node.initializer)); } } if (temp) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var statement = ts.visitNode(node.statement, visitor, ts.isStatement); var block = ts.isBlock(statement) - ? ts.updateBlock(statement, ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements), statement.statements)) - : ts.createBlock(ts.append(leadingStatements, statement), statement, true); - return ts.updateForOf(node, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, undefined, undefined, node.initializer) - ], node.initializer, 1), expression, block); + ? ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements)), statement.statements)) + : ts.setTextRange(ts.createBlock(ts.append(leadingStatements, statement), true), statement); + return ts.updateForOf(node, ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer) + ], 1), node.initializer), expression, block); } return ts.visitEachChild(node, visitor, context); } @@ -39706,7 +40722,7 @@ var ts; var trailingStatements = endLexicalEnvironment(); if (ts.some(leadingStatements) || ts.some(trailingStatements)) { var block = ts.convertToFunctionBody(body, true); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements)), block.statements)); } return body; } @@ -39719,6 +40735,9 @@ var ts; text: "\n var __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };" }; function createAssignHelper(context, attributesSegments) { + if (context.getCompilerOptions().target >= 2) { + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), undefined, attributesSegments); + } context.requestEmitHelper(assignHelper); return ts.createCall(ts.getHelperName("__assign"), undefined, attributesSegments); } @@ -39750,11 +40769,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 247: - return visitJsxElement(node, false); case 248: + return visitJsxElement(node, false); + case 249: return visitJsxSelfClosingElement(node, false); - case 253: + case 255: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -39764,11 +40783,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 253: + case 255: return visitJsxExpression(node); - case 247: - return visitJsxElement(node, true); case 248: + return visitJsxElement(node, true); + case 249: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -39784,7 +40803,7 @@ var ts; function visitJsxOpeningLikeElement(node, children, isChild, location) { var tagName = getTagName(node); var objectProperties; - var attrs = node.attributes; + var attrs = node.attributes.properties; if (attrs.length === 0) { objectProperties = ts.createNull(); } @@ -39816,15 +40835,15 @@ var ts; } function transformJsxAttributeInitializer(node) { if (node === undefined) { - return ts.createLiteral(true); + return ts.createTrue(); } else if (node.kind === 9) { var decoded = tryDecodeEntities(node.text); - return decoded ? ts.createLiteral(decoded, node) : node; + return decoded ? ts.setTextRange(ts.createLiteral(decoded), node) : node; } - else if (node.kind === 253) { + else if (node.kind === 255) { if (node.expression === undefined) { - return ts.createLiteral(true); + return ts.createTrue(); } return visitJsxExpression(node); } @@ -39833,43 +40852,35 @@ var ts; } } function visitJsxText(node) { - var text = ts.getTextOfNode(node, true); - var parts; + var fixed = fixupWhitespaceAndDecodeEntities(ts.getTextOfNode(node, true)); + return fixed === undefined ? undefined : ts.createLiteral(fixed); + } + function fixupWhitespaceAndDecodeEntities(text) { + var acc; 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); - if (!parts) { - parts = []; - } - parts.push(ts.createLiteral(decodeEntities(part))); + if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) { + acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); } firstNonWhitespace = -1; } - else if (!ts.isWhiteSpace(c)) { + else if (!ts.isWhiteSpaceSingleLine(c)) { lastNonWhitespace = i; if (firstNonWhitespace === -1) { firstNonWhitespace = i; } } } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - if (!parts) { - parts = []; - } - parts.push(ts.createLiteral(decodeEntities(part))); - } - if (parts) { - return ts.reduceLeft(parts, aggregateJsxTextParts); - } - return undefined; + return firstNonWhitespace !== -1 + ? addLineOfJsxText(acc, text.substr(firstNonWhitespace)) + : acc; } - function aggregateJsxTextParts(left, right) { - return ts.createAdd(ts.createAdd(left, ts.createLiteral(" ")), right); + function addLineOfJsxText(acc, trimmedLine) { + var decoded = decodeEntities(trimmedLine); + return acc === undefined ? decoded : acc + " " + decoded; } function decodeEntities(text) { return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) { @@ -39880,7 +40891,7 @@ var ts; return String.fromCharCode(parseInt(hex, 16)); } else { - var ch = entities[word]; + var ch = entities.get(word); return ch ? String.fromCharCode(ch) : match; } }); @@ -39890,16 +40901,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 247) { + if (node.kind === 248) { return getTagName(node.openingElement); } else { - var name_35 = node.tagName; - if (ts.isIdentifier(name_35) && ts.isIntrinsicJsxName(name_35.text)) { - return ts.createLiteral(name_35.text); + var name = node.tagName; + if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.text)) { + return ts.createLiteral(name.text); } else { - return ts.createExpressionFromEntityName(name_35); + return ts.createExpressionFromEntityName(name); } } } @@ -39917,7 +40928,7 @@ var ts; } } ts.transformJsx = transformJsx; - var entities = ts.createMap({ + var entities = ts.createMapFromTemplate({ "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, @@ -40205,22 +41216,22 @@ var ts; switch (node.kind) { case 119: return undefined; - case 189: + case 190: return visitAwaitExpression(node); - case 149: + case 150: return visitMethodDeclaration(node); - case 226: + case 227: return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); case 185: + return visitFunctionExpression(node); + case 186: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); } function visitMethodDeclaration(node) { return ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) @@ -40250,14 +41261,15 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 185; + var isArrowFunction = node.kind === 186; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(statements, node.body, true); + var block = ts.createBlock(statements, true); + ts.setTextRange(block, node.body); if (languageVersion >= 2) { if (resolver.getNodeCheckFlags(node) & 4096) { enableSubstitutionForAsyncMethodsWithSuper(); @@ -40275,7 +41287,7 @@ var ts; var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(block.statements, declarations), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); } return expression; } @@ -40288,7 +41300,7 @@ var ts; startLexicalEnvironment(); var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); var declarations = endLexicalEnvironment(); - return ts.updateBlock(visited, ts.createNodeArray(ts.concatenate(visited.statements, declarations), visited.statements)); + return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); } } function getPromiseConstructor(type) { @@ -40305,23 +41317,23 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(179); - context.enableSubstitution(177); + context.enableSubstitution(180); context.enableSubstitution(178); - context.enableEmitNotification(227); - context.enableEmitNotification(149); - context.enableEmitNotification(151); - context.enableEmitNotification(152); + context.enableSubstitution(179); + context.enableEmitNotification(228); context.enableEmitNotification(150); + context.enableEmitNotification(152); + context.enableEmitNotification(153); + context.enableEmitNotification(151); } } function substituteExpression(node) { switch (node.kind) { - case 177: - return substitutePropertyAccessExpression(node); case 178: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 179: + return substituteElementAccessExpression(node); + case 180: if (enabledSubstitutions & 1) { return substituteCallExpression(node); } @@ -40364,36 +41376,36 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 227 - || kind === 150 - || kind === 149 + return kind === 228 || kind === 151 - || kind === 152; + || kind === 150 + || kind === 152 + || kind === 153; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { if (enabledSubstitutions & 1 && isSuperContainer(node)) { var savedCurrentSuperContainer = currentSuperContainer; currentSuperContainer = node; - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSuperContainer = savedCurrentSuperContainer; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } return node; } function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { if (flags & 4096) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value"), location); } else { - return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), location); } } function getSuperContainerAsyncMethodFlags() { @@ -40446,7 +41458,7 @@ var ts; return node; } switch (node.kind) { - case 192: + case 193: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40470,19 +41482,19 @@ var ts; if (ts.isElementAccessExpression(left)) { var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, left.argumentExpression), left); - value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, left); + target = ts.setTextRange(ts.createElementAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(ts.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left); + value = ts.setTextRange(ts.createElementAccess(expressionTemp, argumentExpressionTemp), left); } else if (ts.isPropertyAccessExpression(left)) { var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), left.name, left); - value = ts.createPropertyAccess(expressionTemp, left.name, left); + target = ts.setTextRange(ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), left.name), left); + value = ts.setTextRange(ts.createPropertyAccess(expressionTemp, left.name), left); } else { target = left; value = left; } - return ts.createAssignment(target, ts.createMathPow(value, right, node), node); + return ts.setTextRange(ts.createAssignment(target, ts.createMathPow(value, right, node)), node); } function visitExponentiationExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); @@ -40530,7 +41542,7 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return hierarchyFacts & 4096 - && node.kind === 217 + && node.kind === 218 && !node.expression; } function shouldVisitNode(node) { @@ -40563,91 +41575,91 @@ var ts; switch (node.kind) { case 114: return undefined; - case 227: + case 228: return visitClassDeclaration(node); - case 197: + case 198: return visitClassExpression(node); - case 144: + case 145: return visitParameter(node); - case 226: + case 227: return visitFunctionDeclaration(node); - case 185: + case 186: return visitArrowFunction(node); - case 184: + case 185: return visitFunctionExpression(node); - case 224: + case 225: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 225: + case 226: return visitVariableDeclarationList(node); - case 219: - return visitSwitchStatement(node); - case 233: - return visitCaseBlock(node); - case 205: - return visitBlock(node, false); - case 216: - case 215: - return visitBreakOrContinueStatement(node); case 220: + return visitSwitchStatement(node); + case 234: + return visitCaseBlock(node); + case 206: + return visitBlock(node, false); + case 217: + case 216: + return visitBreakOrContinueStatement(node); + case 221: return visitLabeledStatement(node); - case 210: case 211: - return visitDoOrWhileStatement(node, undefined); case 212: - return visitForStatement(node, undefined); + return visitDoOrWhileStatement(node, undefined); case 213: - return visitForInStatement(node, undefined); + return visitForStatement(node, undefined); case 214: + return visitForInStatement(node, undefined); + case 215: return visitForOfStatement(node, undefined); - case 208: + case 209: return visitExpressionStatement(node); - case 176: + case 177: return visitObjectLiteralExpression(node); - case 257: - return visitCatchClause(node); case 259: + return visitCatchClause(node); + case 261: return visitShorthandPropertyAssignment(node); - case 142: + case 143: return visitComputedPropertyName(node); - case 175: + case 176: return visitArrayLiteralExpression(node); - case 179: - return visitCallExpression(node); case 180: + return visitCallExpression(node); + case 181: return visitNewExpression(node); - case 183: + case 184: return visitParenthesizedExpression(node, true); - case 192: + case 193: return visitBinaryExpression(node, true); case 12: case 13: case 14: case 15: return visitTemplateLiteral(node); - case 181: + case 182: return visitTaggedTemplateExpression(node); - case 194: - return visitTemplateExpression(node); case 195: - return visitYieldExpression(node); + return visitTemplateExpression(node); case 196: + return visitYieldExpression(node); + case 197: return visitSpreadElement(node); case 96: return visitSuperKeyword(false); case 98: return visitThisKeyword(node); - case 202: + case 203: return visitMetaProperty(node); - case 149: + case 150: return visitMethodDeclaration(node); - case 151: case 152: + case 153: return visitAccessorDeclaration(node); - case 206: + case 207: return visitVariableStatement(node); - case 217: + case 218: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -40662,7 +41674,7 @@ var ts; ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, 0, 0); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } function visitSwitchStatement(node) { if (convertedLoopState !== undefined) { @@ -40717,20 +41729,20 @@ var ts; if (ts.isGeneratedIdentifier(node)) { return node; } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + if (node.text !== "arguments" || !resolver.isArgumentsLocalBinding(node)) { return node; } return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 216 ? 2 : 4; - var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + var jump = node.kind === 217 ? 2 : 4; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 216) { + if (node.kind === 217) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -40740,7 +41752,7 @@ var ts; } } else { - if (node.kind === 216) { + if (node.kind === 217) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -40773,8 +41785,9 @@ var ts; var variable = ts.createVariableDeclaration(ts.getLocalName(node, true), undefined, transformClassLikeDeclarationToExpression(node)); ts.setOriginalNode(variable, node); var statements = []; - var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable]), node); + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable])); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, node); ts.startOnNewLine(statement); statements.push(statement); if (ts.hasModifier(node, 1)) { @@ -40829,13 +41842,13 @@ var ts; ts.setEmitFlags(statement, 1536 | 384); statements.push(statement); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true); ts.setEmitFlags(block, 1536); return block; } function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node)), extendsClauseElement)); + statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node))), extendsClauseElement)); } } function addConstructor(statements, node, extendsClauseElement) { @@ -40844,7 +41857,8 @@ var ts; var ancestorFacts = enterSubtree(16278, 73); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); + ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 8); } @@ -40891,24 +41905,25 @@ var ts; if (constructor) { prependCaptureNewTargetIfNeeded(statements, constructor, false); } - var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true); + ts.setTextRange(block, constructor ? constructor.body : node); if (!constructor) { ts.setEmitFlags(block, 1536); } return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 217) { + if (statement.kind === 218) { return true; } - else if (statement.kind === 209) { + else if (statement.kind === 210) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 205) { + else if (statement.kind === 206) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -40937,7 +41952,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 208 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 209 && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -40945,8 +41960,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 | 32768))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 192 - || superCallExpression.left.kind !== 179) { + if (superCallExpression.kind !== 193 + || superCallExpression.left.kind !== 180) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } ts.setCommentRange(returnStatement, ts.getCommentRange(ts.setEmitFlags(superCallExpression.left, 1536))); @@ -40970,10 +41985,10 @@ var ts; return undefined; } else if (ts.isBindingPattern(node.name)) { - return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined, node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined), node), node); } else if (node.initializer) { - return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined, node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined), node), node); } else { return node; @@ -40988,15 +42003,15 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_36 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_36)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_36, initializer); + if (ts.isBindingPattern(name)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_36, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer); } } } @@ -41011,10 +42026,11 @@ var ts; } function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer)), parameter)) - ], parameter), 1 | 32 | 384), undefined, parameter); + var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([ + ts.createStatement(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer))), parameter)) + ]), parameter), 1 | 32 | 384)); statement.startsOnNewLine = true; + ts.setTextRange(statement, parameter); ts.setEmitFlags(statement, 384 | 32 | 524288); statements.push(statement); } @@ -41031,22 +42047,22 @@ var ts; var expressionName = ts.getSynthesizedClone(parameter.name); var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) - ]), parameter), 524288)); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ])), parameter), 524288)); + var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) - ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 + ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ + ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp - : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) + : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), parameter)) ])); ts.setEmitFlags(forStatement, 524288); ts.startOnNewLine(forStatement); statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 && node.kind !== 185) { + if (node.transformFlags & 32768 && node.kind !== 186) { captureThisForNode(statements, node, ts.createThis()); } } @@ -41054,8 +42070,9 @@ var ts; enableSubstitutionsForCapturedThis(); var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("_this", undefined, initializer) - ]), originalStatement); + ])); ts.setEmitFlags(captureThisStatement, 1536 | 524288); + ts.setTextRange(captureThisStatement, originalStatement); ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } @@ -41063,18 +42080,18 @@ var ts; if (hierarchyFacts & 16384) { var newTarget = void 0; switch (node.kind) { - case 185: + case 186: return statements; - case 149: - case 151: + case 150: case 152: + case 153: newTarget = ts.createVoidZero(); break; - case 150: + case 151: newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); break; - case 226: - case 184: + case 227: + case 185: newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 92, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); break; default: @@ -41095,20 +42112,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 204: + case 205: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 149: + case 150: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 151: case 152: + case 153: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 150: + case 151: break; default: ts.Debug.failBadSyntaxKind(node); @@ -41117,7 +42134,7 @@ var ts; } } function transformSemicolonClassElementToStatement(member) { - return ts.createEmptyStatement(member); + return ts.setTextRange(ts.createEmptyStatement(), member); } function transformClassMethodDeclarationToStatement(receiver, member, container) { var ancestorFacts = enterSubtree(0, 0); @@ -41127,7 +42144,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); ts.setEmitFlags(memberFunction, 1536); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), member); + var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); ts.setEmitFlags(statement, 48); @@ -41135,8 +42152,9 @@ var ts; return statement; } function transformAccessorsToStatement(receiver, accessors, container) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false), ts.getSourceMapRange(accessors.firstAccessor)); + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false)); ts.setEmitFlags(statement, 1536); + ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { @@ -41165,11 +42183,11 @@ var ts; ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } - properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); + properties.push(ts.createPropertyAssignment("enumerable", ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue())); var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ target, propertyName, - ts.createObjectLiteral(properties, undefined, true) + ts.createObjectLiteral(properties, true) ]); if (startsOnNewLine) { call.startsOnNewLine = true; @@ -41184,7 +42202,8 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = enterSubtree(16256, 66); - var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node), node); + var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + ts.setTextRange(func, node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8); exitSubtree(ancestorFacts, 0, 0); @@ -41231,12 +42250,12 @@ var ts; : enterSubtree(16286, 65); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 && !name && (node.kind === 226 || node.kind === 184)) { + if (hierarchyFacts & 16384 && !name && (node.kind === 227 || node.kind === 185)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152, 0); convertedLoopState = savedConvertedLoopState; - return ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body, location), node); + return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body), location), node); } function transformFunctionBody(node) { var multiLine = false; @@ -41264,7 +42283,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 185); + ts.Debug.assert(node.kind === 186); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -41276,7 +42295,8 @@ var ts; } } var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, body); + var returnStatement = ts.createReturn(expression); + ts.setTextRange(returnStatement, body); ts.setEmitFlags(returnStatement, 384 | 32 | 1024); statements.push(returnStatement); closeBraceLocation = body; @@ -41287,7 +42307,8 @@ var ts; if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), multiLine); + ts.setTextRange(block, node.body); if (!multiLine && singleLine) { ts.setEmitFlags(block, 1); } @@ -41299,7 +42320,7 @@ var ts; } function visitFunctionBodyDownLevel(node) { var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); - return ts.updateBlock(updated, ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, true), updated.statements)); + return ts.updateBlock(updated, ts.setTextRange(ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, true)), updated.statements)); } function visitBlock(node, isFunctionBody) { if (isFunctionBody) { @@ -41314,9 +42335,9 @@ var ts; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 183: + case 184: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 192: + case 193: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -41324,9 +42345,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 183: + case 184: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 192: + case 193: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -41358,7 +42379,7 @@ var ts; } } if (assignments) { - updated = ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); + updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); })), node); } else { updated = undefined; @@ -41378,8 +42399,9 @@ var ts; var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 ? visitVariableDeclarationInLetDeclarationList : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, node); + var declarationList = ts.createVariableDeclarationList(declarations); ts.setOriginalNode(declarationList, node); + ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); if (node.transformFlags & 8388608 && (ts.isBindingPattern(node.declarations[0].name) @@ -41433,10 +42455,10 @@ var ts; return updated; } function recordLabel(node) { - convertedLoopState.labels[node.label.text] = node.label.text; + convertedLoopState.labels.set(node.label.text, node.label.text); } function resetLabel(node) { - convertedLoopState.labels[node.label.text] = undefined; + convertedLoopState.labels.set(node.label.text, undefined); } function visitLabeledStatement(node) { if (convertedLoopState && !convertedLoopState.labels) { @@ -41471,7 +42493,7 @@ var ts; var statements = []; var counter = ts.createLoopVariable(); var rhsReference = expression.kind === 70 - ? ts.createUniqueName(expression.text) + ? ts.createUniqueName(ts.unescapeIdentifier(expression.text)) : ts.createTempVariable(undefined); var elementAccess = ts.createElementAccess(rhsReference, counter); if (ts.isVariableDeclarationList(initializer)) { @@ -41481,17 +42503,18 @@ var ts; var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, elementAccess); - var declarationList = ts.createVariableDeclarationList(declarations, initializer); + var declarationList = ts.createVariableDeclarationList(declarations); ts.setOriginalNode(declarationList, initializer); + ts.setTextRange(declarationList, initializer); var firstDeclaration = declarations[0]; var lastDeclaration = ts.lastOrUndefined(declarations); ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); statements.push(ts.createVariableStatement(undefined, declarationList)); } else { - statements.push(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.createVariableDeclarationList([ + statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) - ], ts.moveRangePos(initializer, -1)), initializer), ts.moveRangeEnd(initializer, -1))); + ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); } } else { @@ -41501,7 +42524,7 @@ var ts; } else { assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createStatement(assignment), ts.moveRangeEnd(initializer, -1))); } } var bodyLocation; @@ -41510,7 +42533,7 @@ var ts; ts.addRange(statements, convertedLoopBodyStatements); } else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -41521,25 +42544,27 @@ var ts; } } ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression)); - var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); + var body = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation)); + ts.setTextRange(body, bodyLocation); ts.setEmitFlags(body, 48 | 384); - var forStatement = ts.createFor(ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) - ], node.expression), 1048576), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); + var forStatement = ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)), + ts.setTextRange(ts.createVariableDeclaration(rhsReference, undefined, expression), node.expression) + ]), node.expression), 1048576), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), body); ts.setEmitFlags(forStatement, 256); + ts.setTextRange(forStatement, node); return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 210: case 211: - return visitDoOrWhileStatement(node, outermostLabeledStatement); case 212: - return visitForStatement(node, outermostLabeledStatement); + return visitDoOrWhileStatement(node, outermostLabeledStatement); case 213: - return visitForInStatement(node, outermostLabeledStatement); + return visitForStatement(node, outermostLabeledStatement); case 214: + return visitForInStatement(node, outermostLabeledStatement); + case 215: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -41554,7 +42579,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 142) { + if (property.name.kind === 143) { numInitialProperties = i; break; } @@ -41565,7 +42590,7 @@ var ts; } var temp = ts.createTempVariable(hoistVariableDeclaration); var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 32768)); if (node.multiLine) { assignment.startsOnNewLine = true; } @@ -41616,11 +42641,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 212: case 213: case 214: + case 215: var initializer = node.initializer; - if (initializer && initializer.kind === 225) { + if (initializer && initializer.kind === 226) { loopInitializer = initializer; } break; @@ -41657,13 +42682,13 @@ var ts; copyOutParameters(loopOutParameters, 1, statements_4); } ts.addRange(statements_4, lexicalEnvironment); - loopBody = ts.createBlock(statements_4, undefined, true); + loopBody = ts.createBlock(statements_4, true); } if (ts.isBlock(loopBody)) { loopBody.multiLine = true; } else { - loopBody = ts.createBlock([loopBody], undefined, true); + loopBody = ts.createBlock([loopBody], true); } var isAsyncBlockContainingAwait = hierarchyFacts & 4 && (node.statement.transformFlags & 16777216) !== 0; @@ -41730,7 +42755,7 @@ var ts; var clone_4 = ts.getMutableClone(node); clone_4.statement = undefined; clone_4 = ts.visitEachChild(clone_4, visitor, context); - clone_4.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, true); clone_4.transformFlags = 0; ts.aggregateTransformFlags(clone_4); loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); @@ -41794,23 +42819,22 @@ var ts; if (!state.labeledNonLocalBreaks) { state.labeledNonLocalBreaks = ts.createMap(); } - state.labeledNonLocalBreaks[labelText] = labelMarker; + state.labeledNonLocalBreaks.set(labelText, labelMarker); } else { if (!state.labeledNonLocalContinues) { state.labeledNonLocalContinues = ts.createMap(); } - state.labeledNonLocalContinues[labelText] = labelMarker; + state.labeledNonLocalContinues.set(labelText, labelMarker); } } function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { if (!table) { return; } - for (var labelText in table) { - var labelMarker = table[labelText]; + table.forEach(function (labelMarker, labelText) { var statements = []; - if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) { var label = ts.createIdentifier(labelText); statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); } @@ -41819,7 +42843,7 @@ var ts; statements.push(ts.createReturn(loopResultName)); } caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); - } + }); } function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { var name = decl.name; @@ -41834,7 +42858,7 @@ var ts; else { loopParameters.push(ts.createParameter(undefined, undefined, undefined, name)); if (resolver.getNodeCheckFlags(decl) & 2097152) { - var outParamName = ts.createUniqueName("out_" + name.text); + var outParamName = ts.createUniqueName("out_" + ts.unescapeIdentifier(name.text)); loopOutParameters.push({ originalName: name, outParamName: outParamName }); } } @@ -41845,20 +42869,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 151: case 152: + case 153: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 149: + case 150: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 258: + case 260: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 259: + case 261: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -41868,14 +42892,16 @@ var ts; } } function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -41883,7 +42909,8 @@ var ts; } function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { var ancestorFacts = enterSubtree(0, 0); - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container), method); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container)); + ts.setTextRange(expression, method); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -41895,9 +42922,11 @@ var ts; var updated; if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var newVariableDeclaration = ts.createVariableDeclaration(temp); + ts.setTextRange(newVariableDeclaration, node.variableDeclaration); var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); - var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); + var list = ts.createVariableDeclarationList(vars); + ts.setTextRange(list, node.variableDeclaration); var destructure = ts.createVariableStatement(undefined, list); updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); } @@ -41915,7 +42944,7 @@ var ts; ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined); ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression)); - return ts.createPropertyAssignment(node.name, functionExpression, node); + return ts.setTextRange(ts.createPropertyAssignment(node.name, functionExpression), node); } function visitAccessorDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); @@ -41928,7 +42957,7 @@ var ts; return updated; } function visitShorthandPropertyAssignment(node) { - return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), node); + return ts.setTextRange(ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name)), node); } function visitComputedPropertyName(node) { var ancestorFacts = enterSubtree(0, 8192); @@ -41990,7 +43019,7 @@ var ts; })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 175 + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 176 ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -42005,7 +43034,7 @@ var ts; return ts.map(chunk, visitExpressionOfSpread); } function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { - return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, undefined, hasTrailingComma), visitor, ts.isExpression), undefined, multiLine); + return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -42014,7 +43043,7 @@ var ts; return ts.visitNode(node.expression, visitor, ts.isExpression); } function visitTemplateLiteral(node) { - return ts.createLiteral(node.text, node); + return ts.setTextRange(ts.createLiteral(node.text), node); } function visitTaggedTemplateExpression(node) { var tag = ts.visitNode(node.tag, visitor, ts.isExpression); @@ -42048,7 +43077,7 @@ var ts; var isLast = node.kind === 12 || node.kind === 15; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); - return ts.createLiteral(text, node); + return ts.setTextRange(ts.createLiteral(text), node); } function visitTemplateExpression(node) { var expressions = []; @@ -42056,7 +43085,8 @@ var ts; addTemplateSpans(expressions, node); var expression = ts.reduceLeft(expressions, ts.createAdd); if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); + expression.pos = node.pos; + expression.end = node.end; } return expression; } @@ -42097,16 +43127,16 @@ var ts; } return node; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8 ? 65 | 16 : 65); - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); exitSubtree(ancestorFacts, 0, 0); return; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { @@ -42118,18 +43148,18 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(98); - context.enableEmitNotification(150); - context.enableEmitNotification(149); context.enableEmitNotification(151); + context.enableEmitNotification(150); context.enableEmitNotification(152); + context.enableEmitNotification(153); + context.enableEmitNotification(186); context.enableEmitNotification(185); - context.enableEmitNotification(184); - context.enableEmitNotification(226); + context.enableEmitNotification(227); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -42149,10 +43179,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 174: - case 227: - case 230: - case 224: + case 175: + case 228: + case 231: + case 225: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -42179,7 +43209,7 @@ var ts; function substituteThisKeyword(node) { if (enabledSubstitutions & 1 && hierarchyFacts & 16) { - return ts.createIdentifier("_this", node); + return ts.setTextRange(ts.createIdentifier("_this"), node); } return node; } @@ -42195,11 +43225,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 208) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 209) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 179) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 180) { return false; } var callTarget = statementExpression.expression; @@ -42207,7 +43237,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 196) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 197) { return false; } var expression = callArgument.expression; @@ -42231,13 +43261,85 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var instructionNames = ts.createMap((_a = {}, - _a[2] = "return", - _a[3] = "break", - _a[4] = "yield", - _a[5] = "yield*", - _a[7] = "endfinally", - _a)); + function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(250); + context.enableEmitNotification(251); + context.enableEmitNotification(249); + noSubstitution = []; + } + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(178); + context.enableSubstitution(260); + return transformSourceFile; + function transformSourceFile(node) { + return node; + } + function onEmitNode(hint, node, emitCallback) { + switch (node.kind) { + case 250: + case 251: + case 249: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(hint, node, emitCallback); + } + function onSubstituteNode(hint, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(hint, node); + } + node = previousOnSubstituteNode(hint, node); + if (ts.isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); + } + else if (ts.isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + var literalName = trySubstituteReservedName(node.name); + if (literalName) { + return ts.setTextRange(ts.createElementAccess(node.expression, literalName), node); + } + return node; + } + function substitutePropertyAssignment(node) { + var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return ts.updatePropertyAssignment(node, literalName, node.initializer); + } + return node; + } + function trySubstituteReservedName(name) { + var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); + if (token >= 71 && token <= 106) { + return ts.setTextRange(ts.createLiteral(name), name); + } + return undefined; + } + } + ts.transformES5 = transformES5; +})(ts || (ts = {})); +var ts; +(function (ts) { + function getInstructionName(instruction) { + switch (instruction) { + case 2: return "return"; + case 3: return "break"; + case 4: return "yield"; + case 5: return "yield*"; + case 7: return "endfinally"; + } + } function transformGenerators(context) { var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); @@ -42303,13 +43405,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 210: - return visitDoStatement(node); case 211: + return visitDoStatement(node); + case 212: return visitWhileStatement(node); - case 219: - return visitSwitchStatement(node); case 220: + return visitSwitchStatement(node); + case 221: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -42317,24 +43419,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 226: + case 227: return visitFunctionDeclaration(node); - case 184: + case 185: return visitFunctionExpression(node); - case 151: case 152: + case 153: return visitAccessorDeclaration(node); - case 206: + case 207: return visitVariableStatement(node); - case 212: - return visitForStatement(node); case 213: + return visitForStatement(node); + case 214: return visitForInStatement(node); - case 216: - return visitBreakStatement(node); - case 215: - return visitContinueStatement(node); case 217: + return visitBreakStatement(node); + case 216: + return visitContinueStatement(node); + case 218: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -42350,21 +43452,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 192: - return visitBinaryExpression(node); case 193: + return visitBinaryExpression(node); + case 194: return visitConditionalExpression(node); - case 195: + case 196: return visitYieldExpression(node); - case 175: - return visitArrayLiteralExpression(node); case 176: + return visitArrayLiteralExpression(node); + case 177: return visitObjectLiteralExpression(node); - case 178: - return visitElementAccessExpression(node); case 179: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 180: + return visitCallExpression(node); + case 181: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -42372,9 +43474,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 226: + case 227: return visitFunctionDeclaration(node); - case 184: + case 185: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -42383,7 +43485,7 @@ var ts; } function visitFunctionDeclaration(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { - node = ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -42404,7 +43506,7 @@ var ts; } function visitFunctionExpression(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { - node = ts.setOriginalNode(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -42474,7 +43576,7 @@ var ts; operationArguments = savedOperationArguments; operationLocations = savedOperationLocations; state = savedState; - return ts.createBlock(statements, body, body.multiLine); + return ts.setTextRange(ts.createBlock(statements, body.multiLine), body); } function visitVariableStatement(node) { if (node.transformFlags & 16777216) { @@ -42531,10 +43633,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 177: + case 178: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 178: + case 179: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -42543,7 +43645,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 57, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.setTextRange(ts.createAssignment(target, ts.setTextRange(ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -42642,13 +43744,13 @@ var ts; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, location, multiLine); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { emitAssignment(temp, hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, undefined, multiLine)); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); hasAssignedTemp = true; leadingElement = undefined; expressions = []; @@ -42662,7 +43764,7 @@ var ts; var multiLine = node.multiLine; var numInitialProperties = countInitialNodesWithoutYield(properties); var temp = declareLocal(); - emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, multiLine)); + emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine)); var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties); expressions.push(multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); return ts.inlineExpressions(expressions); @@ -42701,7 +43803,7 @@ var ts; function visitNewExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, ts.createVoidZero())), undefined, [], node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, ts.createVoidZero())), undefined, []), node), node); } return ts.visitEachChild(node, visitor, context); } @@ -42730,35 +43832,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 205: + case 206: return transformAndEmitBlock(node); - case 208: - return transformAndEmitExpressionStatement(node); case 209: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 210: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 211: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 212: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 213: + return transformAndEmitForStatement(node); + case 214: return transformAndEmitForInStatement(node); - case 215: - return transformAndEmitContinueStatement(node); case 216: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 217: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 218: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 219: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 220: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 221: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 222: + return transformAndEmitThrowStatement(node); + case 223: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -42778,9 +43880,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - var name_37 = ts.getSynthesizedClone(variable.name); - ts.setCommentRange(name_37, variable.name); - hoistVariableDeclaration(name_37); + var name = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name, variable.name); + hoistVariableDeclaration(name); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -42889,7 +43991,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression), initializer)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -42899,7 +44001,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression), node.incrementor)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -43044,7 +44146,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 255 && defaultClauseIndex === -1) { + if (clause.kind === 257 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -43054,7 +44156,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 254) { + if (clause.kind === 256) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -43156,9 +44258,9 @@ var ts; } return -1; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } return node; @@ -43170,14 +44272,14 @@ var ts; return node; } function substituteExpressionIdentifier(node) { - if (renamedCatchVariables && ts.hasProperty(renamedCatchVariables, node.text)) { + if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { var original = ts.getOriginalNode(node); if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_38 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_38) { - var clone_7 = ts.getMutableClone(name_38); + var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; + if (name) { + var clone_7 = ts.getMutableClone(name); ts.setSourceMapRange(clone_7, node); ts.setCommentRange(clone_7, node); return clone_7; @@ -43285,10 +44387,10 @@ var ts; var name = declareLocal(text); if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = ts.createMap(); + renamedCatchVariableDeclarations = []; context.enableSubstitution(70); } - renamedCatchVariables[text] = true; + renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; var exception = peekBlock(); ts.Debug.assert(exception.state < 1); @@ -43489,23 +44591,23 @@ var ts; } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); - literal.trailingComment = instructionNames[instruction]; + literal.trailingComment = getInstructionName(instruction); return literal; } function createInlineBreak(label, location) { ts.Debug.assert(label > 0, "Invalid label: " + label); - return ts.createReturn(ts.createArrayLiteral([ + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), location); + ])), location); } function createInlineReturn(expression, location) { - return ts.createReturn(ts.createArrayLiteral(expression + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), location); + : [createInstruction(2)])), location); } function createGeneratorResume(location) { - return ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, [], location); + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, []), location); } function emitNop() { emitWorker(0); @@ -43571,7 +44673,7 @@ var ts; currentExceptionBlock = undefined; withBlockStack = undefined; var buildResult = buildStatements(); - return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 262144)); + return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, buildResult.length > 0)), 262144)); } function buildStatements() { if (operations) { @@ -43780,51 +44882,51 @@ var ts; } } function writeAssign(left, right, operationLocation) { - writeStatement(ts.createStatement(ts.createAssignment(left, right), operationLocation)); + writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); } function writeThrow(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createThrow(expression, operationLocation)); + writeStatement(ts.setTextRange(ts.createThrow(expression), operationLocation)); } function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), operationLocation), 384)); + : [createInstruction(2)])), operationLocation), 384)); } function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation), 384)); + ])), operationLocation), 384)); } function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation), 384)), 1)); + ])), operationLocation), 384)), 1)); } function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation), 384)), 1)); + ])), operationLocation), 384)), 1)); } function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4), expression] - : [createInstruction(4)]), operationLocation), 384)); + : [createInstruction(4)])), operationLocation), 384)); } function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(5), expression - ]), operationLocation), 384)); + ])), operationLocation), 384)); } function writeEndfinally() { lastOperationWasAbrupt = true; @@ -43844,135 +44946,586 @@ var ts; priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; - var _a; })(ts || (ts = {})); var ts; (function (ts) { - function transformES5(context) { - var compilerOptions = context.getCompilerOptions(); - var previousOnEmitNode; - var noSubstitution; - if (compilerOptions.jsx === 1) { - previousOnEmitNode = context.onEmitNode; - context.onEmitNode = onEmitNode; - context.enableEmitNotification(249); - context.enableEmitNotification(250); - context.enableEmitNotification(248); - noSubstitution = []; + function transformModule(context) { + function getTransformModuleDelegate(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.AMD: return transformAMDModule; + case ts.ModuleKind.UMD: return transformUMDModule; + default: return transformCommonJSModule; + } } + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var compilerOptions = context.getCompilerOptions(); + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var moduleKind = ts.getEmitModuleKind(compilerOptions); var previousOnSubstituteNode = context.onSubstituteNode; - context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(177); - context.enableSubstitution(258); - return transformSourceFile; - function transformSourceFile(node) { - return node; - } - function onEmitNode(emitContext, node, emitCallback) { - switch (node.kind) { - case 249: - case 250: - case 248: - var tagName = node.tagName; - noSubstitution[ts.getOriginalNodeId(tagName)] = true; - break; - } - previousOnEmitNode(emitContext, node, emitCallback); - } - function onSubstituteNode(emitContext, node) { - if (node.id && noSubstitution && noSubstitution[node.id]) { - return previousOnSubstituteNode(emitContext, node); - } - node = previousOnSubstituteNode(emitContext, node); - if (ts.isPropertyAccessExpression(node)) { - return substitutePropertyAccessExpression(node); - } - else if (ts.isPropertyAssignment(node)) { - return substitutePropertyAssignment(node); - } - return node; - } - function substitutePropertyAccessExpression(node) { - var literalName = trySubstituteReservedName(node.name); - if (literalName) { - return ts.createElementAccess(node.expression, literalName, node); - } - return node; - } - function substitutePropertyAssignment(node) { - var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); - if (literalName) { - return ts.updatePropertyAssignment(node, literalName, node.initializer); - } - return node; - } - function trySubstituteReservedName(name) { - var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); - if (token >= 71 && token <= 106) { - return ts.createLiteral(name, name); - } - return undefined; - } - } - ts.transformES5 = transformES5; -})(ts || (ts = {})); -var ts; -(function (ts) { - function transformES2015Module(context) { - var compilerOptions = context.getCompilerOptions(); var previousOnEmitNode = context.onEmitNode; - var previousOnSubstituteNode = context.onSubstituteNode; - context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(262); + context.onEmitNode = onEmitNode; context.enableSubstitution(70); + context.enableSubstitution(193); + context.enableSubstitution(191); + context.enableSubstitution(192); + context.enableSubstitution(261); + context.enableEmitNotification(264); + var moduleInfoMap = []; + var deferredExports = []; var currentSourceFile; + var currentModuleInfo; + var noSubstitution; return transformSourceFile; function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { + if (ts.isDeclarationFile(node) + || !(ts.isExternalModule(node) + || compilerOptions.isolatedModules)) { return node; } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements); - ts.append(statements, ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + currentSourceFile = node; + currentModuleInfo = ts.collectExternalModuleInfo(node, resolver, compilerOptions); + moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo; + var transformModule = getTransformModuleDelegate(moduleKind); + var updated = transformModule(node); + currentSourceFile = undefined; + currentModuleInfo = undefined; + return ts.aggregateTransformFlags(updated); + } + function transformCommonJSModule(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + ts.addRange(statements, endLexicalEnvironment()); + addExportEqualsIfNeeded(statements, false); + var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); + if (currentModuleInfo.hasExportStarsToExportValues) { + ts.addEmitHelper(updated, exportStarHelper); + } + return updated; + } + function transformAMDModule(node) { + var define = ts.createIdentifier("define"); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ + ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(undefined, undefined, undefined, "require"), + ts.createParameter(undefined, undefined, undefined, "exports") + ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ]))) + ]), node.statements)); + } + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement(undefined, [ + ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], true), undefined)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(undefined, undefined, undefined, "require"), + ts.createParameter(undefined, undefined, undefined, "exports") + ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ])) + ]), node.statements)); + } + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + var aliasedModuleNames = []; + var unaliasedModuleNames = []; + var importAliasNames = []; + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(undefined, undefined, undefined, amdDependency.name)); } else { - return ts.visitEachChild(node, visitor, context); + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); } } - return node; - } - function visitor(node) { - switch (node.kind) { - case 235: - return undefined; - case 241: - return visitExportAssignment(node); + for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { + var importNode = _c[_b]; + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + ts.setEmitFlags(importAliasName, 4); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } } - return node; + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; } - function visitExportAssignment(node) { - return node.isExportEquals ? undefined : node; + function transformAsynchronousModuleBody(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + ts.addRange(statements, endLexicalEnvironment()); + addExportEqualsIfNeeded(statements, true); + var body = ts.createBlock(statements, true); + if (currentModuleInfo.hasExportStarsToExportValues) { + ts.addEmitHelper(body, exportStarHelper); + } + return body; } - function onEmitNode(emitContext, node, emitCallback) { - if (ts.isSourceFile(node)) { - currentSourceFile = node; - previousOnEmitNode(emitContext, node, emitCallback); - currentSourceFile = undefined; + function addExportEqualsIfNeeded(statements, emitAsReturn) { + if (currentModuleInfo.exportEquals) { + if (emitAsReturn) { + var statement = ts.createReturn(currentModuleInfo.exportEquals.expression); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 384 | 1536); + statements.push(statement); + } + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression)); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 1536); + statements.push(statement); + } + } + } + function sourceElementVisitor(node) { + switch (node.kind) { + case 237: + return visitImportDeclaration(node); + case 236: + return visitImportEqualsDeclaration(node); + case 243: + return visitExportDeclaration(node); + case 242: + return visitExportAssignment(node); + case 207: + return visitVariableStatement(node); + case 227: + return visitFunctionDeclaration(node); + case 228: + return visitClassDeclaration(node); + case 299: + return visitMergeDeclarationMarker(node); + case 300: + return visitEndOfDeclarationMarker(node); + default: + return node; + } + } + function visitImportDeclaration(node) { + var statements; + var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); + if (moduleKind !== ts.ModuleKind.AMD) { + if (!node.importClause) { + return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); + } + else { + var variables = []; + if (namespaceDeclaration && !ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, createRequireCall(node))); + } + else { + variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), undefined, createRequireCall(node))); + if (namespaceDeclaration && ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node))); + } + } + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, languageVersion >= 2 ? 2 : 0)), node)); + } + } + else if (namespaceDeclaration && ts.isDefaultImport(node)) { + statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node)), node) + ], languageVersion >= 2 ? 2 : 0))); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); } else { - previousOnEmitNode(emitContext, node, emitCallback); + statements = appendExportsOfImportDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (moduleName) { + args.push(moduleName); + } + return ts.createCall(ts.createIdentifier("require"), undefined, args); + } + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; + if (moduleKind !== ts.ModuleKind.AMD) { + if (ts.hasModifier(node, 1)) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(node.name, createRequireCall(node))), node)); + } + else { + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node)) + ], languageVersion >= 2 ? 2 : 0)), node)); + } + } + else { + if (ts.hasModifier(node, 1)) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); + } + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportEqualsDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function visitExportDeclaration(node) { + if (!node.moduleSpecifier) { + return undefined; + } + var generatedName = ts.getGeneratedNameForNode(node); + if (node.exportClause) { + var statements = []; + if (moduleKind !== ts.ModuleKind.AMD) { + statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node)) + ])), node)); + } + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); + } + return ts.singleOrMany(statements); + } + else { + return ts.setTextRange(ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ + moduleKind !== ts.ModuleKind.AMD + ? createRequireCall(node) + : generatedName + ])), node); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (ts.isIdentifier(node) && emitContext === 1) { - return substituteExpressionIdentifier(node); + function visitExportAssignment(node) { + if (node.isExportEquals) { + return undefined; + } + var statements; + var original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, node, true); + } + else { + statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, node, true); + } + return ts.singleOrMany(statements); + } + function visitFunctionDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1)) { + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, node.parameters, undefined, node.body), node), node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function visitClassDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1)) { + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, node.heritageClauses, node.members), node), node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function visitVariableStatement(node) { + var statements; + var variables; + var expressions; + if (ts.hasModifier(node, 1)) { + var modifiers = void 0; + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { + if (!modifiers) { + modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + } + variables = ts.append(variables, variable); + } + else if (variable.initializer) { + expressions = ts.append(expressions, transformInitializedVariable(variable)); + } + } + if (variables) { + statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); + } + if (expressions) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + } + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); + } + else { + statements = appendExportsOfVariableStatement(statements, node); + } + return ts.singleOrMany(statements); + } + function transformInitializedVariable(node) { + if (ts.isBindingPattern(node.name)) { + return ts.flattenDestructuringAssignment(node, undefined, context, 0, false, createExportExpression); + } + else { + return ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name), node.name), node.initializer); + } + } + function visitMergeDeclarationMarker(node) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); + } + return node; + } + function hasAssociatedEndOfDeclarationMarker(node) { + return (ts.getEmitFlags(node) & 2097152) !== 0; + } + function visitEndOfDeclarationMarker(node) { + var id = ts.getOriginalNodeId(node); + var statements = deferredExports[id]; + if (statements) { + delete deferredExports[id]; + return ts.append(statements, node); + } + return node; + } + function appendExportsOfImportDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + var importClause = decl.importClause; + if (!importClause) { + return statements; + } + if (importClause.name) { + statements = appendExportsOfDeclaration(statements, importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + switch (namedBindings.kind) { + case 239: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 240: + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var importBinding = _a[_i]; + statements = appendExportsOfDeclaration(statements, importBinding); + } + break; + } + } + return statements; + } + function appendExportsOfImportEqualsDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + return appendExportsOfDeclaration(statements, decl); + } + function appendExportsOfVariableStatement(statements, node) { + if (currentModuleInfo.exportEquals) { + return statements; + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + statements = appendExportsOfBindingElement(statements, decl); + } + return statements; + } + function appendExportsOfBindingElement(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + statements = appendExportsOfBindingElement(statements, element); + } + } + } + else if (!ts.isGeneratedIdentifier(decl.name)) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + function appendExportsOfHoistedDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.hasModifier(decl, 1)) { + var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : decl.name; + statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), decl); + } + if (decl.name) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + function appendExportsOfDeclaration(statements, decl) { + var name = ts.getDeclarationName(decl); + var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(name.text); + if (exportSpecifiers) { + for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { + var exportSpecifier = exportSpecifiers_1[_i]; + statements = appendExportStatement(statements, exportSpecifier.name, name, exportSpecifier.name); + } + } + return statements; + } + function appendExportStatement(statements, exportName, expression, location, allowComments) { + statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); + return statements; + } + function createUnderscoreUnderscoreESModule() { + var statement; + if (languageVersion === 0) { + statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true))); + } + else { + statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ])); + } + ts.setEmitFlags(statement, 524288); + return statement; + } + function createExportStatement(name, value, location, allowComments) { + var statement = ts.setTextRange(ts.createStatement(createExportExpression(name, value)), location); + ts.startOnNewLine(statement); + if (!allowComments) { + ts.setEmitFlags(statement, 1536); + } + return statement; + } + function createExportExpression(name, value, location) { + return ts.setTextRange(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location); + } + function modifierVisitor(node) { + switch (node.kind) { + case 83: + case 78: + return undefined; + } + return node; + } + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264) { + currentSourceFile = node; + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; + noSubstitution = []; + previousOnEmitNode(hint, node, emitCallback); + currentSourceFile = undefined; + currentModuleInfo = undefined; + noSubstitution = undefined; + } + else { + previousOnEmitNode(hint, node, emitCallback); + } + } + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (node.id && noSubstitution[node.id]) { + return node; + } + if (hint === 1) { + return substituteExpression(node); + } + else if (ts.isShorthandPropertyAssignment(node)) { + return substituteShorthandPropertyAssignment(node); + } + return node; + } + function substituteShorthandPropertyAssignment(node) { + var name = node.name; + var exportedOrImportedName = substituteExpressionIdentifier(name); + if (exportedOrImportedName !== name) { + if (node.objectAssignmentInitializer) { + var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); + } + return ts.setTextRange(ts.createPropertyAssignment(name, exportedOrImportedName), node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 70: + return substituteExpressionIdentifier(node); + case 193: + return substituteBinaryExpression(node); + case 192: + case 191: + return substituteUnaryExpression(node); } return node; } @@ -43982,11 +45535,83 @@ var ts; if (externalHelpersModuleName) { return ts.createPropertyAccess(externalHelpersModuleName, node); } + return node; + } + if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); + if (exportContainer && exportContainer.kind === 264) { + return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); + } + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts.isImportClause(importDeclaration)) { + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node); + } + else if (ts.isImportSpecifier(importDeclaration)) { + var name = importDeclaration.propertyName || importDeclaration.name; + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name)), node); + } + } } return node; } + function substituteBinaryExpression(node) { + if (ts.isAssignmentOperator(node.operatorToken.kind) + && ts.isIdentifier(node.left) + && !ts.isGeneratedIdentifier(node.left) + && !ts.isLocalName(node.left) + && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + var expression = node; + for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { + var exportName = exportedNames_1[_i]; + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression, node); + } + return expression; + } + } + return node; + } + function substituteUnaryExpression(node) { + if ((node.operator === 42 || node.operator === 43) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var expression = node.kind === 192 + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1)), node) + : node; + for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { + var exportName = exportedNames_2[_i]; + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression); + } + return expression; + } + } + return node; + } + function getExports(name) { + if (!ts.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) { + return currentModuleInfo + && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; + } + } + } } - ts.transformES2015Module = transformES2015Module; + ts.transformModule = transformModule; + var exportStarHelper = { + name: "typescript:export-star", + scoped: true, + text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" + }; })(ts || (ts = {})); var ts; (function (ts) { @@ -44000,14 +45625,14 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70); - context.enableSubstitution(192); - context.enableSubstitution(190); + context.enableSubstitution(193); context.enableSubstitution(191); - context.enableEmitNotification(262); - var moduleInfoMap = ts.createMap(); - var deferredExports = ts.createMap(); - var exportFunctionsMap = ts.createMap(); - var noSubstitutionMap = ts.createMap(); + context.enableSubstitution(192); + context.enableEmitNotification(264); + var moduleInfoMap = []; + var deferredExports = []; + var exportFunctionsMap = []; + var noSubstitutionMap = []; var currentSourceFile; var moduleInfo; var exportFunction; @@ -44026,7 +45651,8 @@ var ts; currentSourceFile = node; enclosingBlockScopedContainer = node; moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); - exportFunction = exportFunctionsMap[id] = ts.createUniqueName("exports"); + exportFunction = ts.createUniqueName("exports"); + exportFunctionsMap[id] = exportFunction; contextObject = ts.createUniqueName("context"); var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); @@ -44036,11 +45662,11 @@ var ts; ], undefined, moduleBodyBlock); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); - var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.createNodeArray([ + var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ], node.statements)), 1024); + ]), node.statements)), 1024); if (!(compilerOptions.outFile || compilerOptions.out)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -44063,12 +45689,12 @@ var ts; var externalImport = externalImports[i]; var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; + var groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { dependencyGroups[groupIndex].externalImports.push(externalImport); } else { - groupIndices[text] = dependencyGroups.length; + groupIndices.set(text, dependencyGroups.length); dependencyGroups.push({ name: externalModuleName, externalImports: [externalImport] @@ -44089,21 +45715,23 @@ var ts; ts.addRange(statements, hoistedStatements); ts.addRange(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + var moduleObject = ts.createObjectLiteral([ ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) - ]), true))); - return ts.createBlock(statements, undefined, true); + ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, true))) + ]); + moduleObject.multiLine = true; + statements.push(ts.createReturn(moduleObject)); + return ts.createBlock(statements, true); } function addExportStarIfNeeded(statements) { if (!moduleInfo.hasExportStarsToExportValues) { return; } - if (!moduleInfo.exportedNames && ts.isEmpty(moduleInfo.exportSpecifiers)) { + if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) { var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 242 && externalImport.exportClause) { + if (externalImport.kind === 243 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -44121,12 +45749,12 @@ var ts; if (exportedLocalName.text === "default") { continue; } - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createTrue())); } } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 242) { + if (externalImport.kind !== 243) { continue; } var exportDecl = externalImport; @@ -44135,12 +45763,12 @@ var ts; } for (var _f = 0, _g = exportDecl.exportClause.elements; _f < _g.length; _f++) { var element = _g[_f]; - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createTrue())); } } var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, undefined, true)) + ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, true)) ]))); var exportStarFunction = createExportStarFunction(exportedNamesStorageRef); statements.push(exportStarFunction); @@ -44165,7 +45793,7 @@ var ts; ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1) ])), ts.createStatement(ts.createCall(exportFunction, undefined, [exports])) - ], undefined, true)); + ], true)); } function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; @@ -44178,15 +45806,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 236: + case 237: if (!entry.importClause) { break; } - case 235: + case 236: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 242: + case 243: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -44194,7 +45822,7 @@ var ts; var e = _d[_c]; properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); } - statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, undefined, true)]))); + statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, true)]))); } else { statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); @@ -44202,19 +45830,19 @@ var ts; break; } } - setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, undefined, true))); + setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, true))); } - return ts.createArrayLiteral(setters, undefined, true); + return ts.createArrayLiteral(setters, true); } function sourceElementVisitor(node) { switch (node.kind) { - case 236: + case 237: return visitImportDeclaration(node); - case 235: + case 236: return visitImportEqualsDeclaration(node); - case 242: + case 243: return undefined; - case 241: + case 242: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -44281,7 +45909,7 @@ var ts; var statements; var name = ts.getLocalName(node); hoistVariableDeclaration(name); - statements = ts.append(statements, ts.createStatement(ts.createAssignment(name, ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement), node)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); @@ -44309,7 +45937,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { var id = ts.getOriginalNodeId(node); @@ -44335,7 +45963,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 1048576) === 0 - && (enclosingBlockScopedContainer.kind === 262 + && (enclosingBlockScopedContainer.kind === 264 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -44353,11 +45981,11 @@ var ts; function createVariableAssignment(name, value, location, isExportedDeclaration) { hoistVariableDeclaration(ts.getSynthesizedClone(name)); return isExportedDeclaration - ? createExportExpression(name, preventSubstitution(ts.createAssignment(name, value, location))) - : preventSubstitution(ts.createAssignment(name, value, location)); + ? createExportExpression(name, preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location))) + : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -44390,10 +46018,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 238: + case 239: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 239: + case 240: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -44463,10 +46091,10 @@ var ts; return statements; } var name = ts.getDeclarationName(decl); - var exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + var exportSpecifiers = moduleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { - for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { - var exportSpecifier = exportSpecifiers_1[_i]; + for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { + var exportSpecifier = exportSpecifiers_2[_i]; if (exportSpecifier.name.text !== excludeName) { statements = appendExportStatement(statements, exportSpecifier.name, name); } @@ -44492,43 +46120,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 206: + case 207: return visitVariableStatement(node); - case 226: - return visitFunctionDeclaration(node); case 227: + return visitFunctionDeclaration(node); + case 228: return visitClassDeclaration(node); - case 212: - return visitForStatement(node); case 213: - return visitForInStatement(node); + return visitForStatement(node); case 214: + return visitForInStatement(node); + case 215: return visitForOfStatement(node); - case 210: - return visitDoStatement(node); case 211: + return visitDoStatement(node); + case 212: return visitWhileStatement(node); - case 220: + case 221: return visitLabeledStatement(node); - case 218: - return visitWithStatement(node); case 219: + return visitWithStatement(node); + case 220: return visitSwitchStatement(node); - case 233: + case 234: return visitCaseBlock(node); - case 254: + case 256: return visitCaseClause(node); - case 255: - return visitDefaultClause(node); - case 222: - return visitTryStatement(node); case 257: + return visitDefaultClause(node); + case 223: + return visitTryStatement(node); + case 259: return visitCatchClause(node); - case 205: + case 206: return visitBlock(node); - case 296: + case 299: return visitMergeDeclarationMarker(node); - case 297: + case 300: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -44619,7 +46247,7 @@ var ts; } function destructuringVisitor(node) { if (node.transformFlags & 1024 - && node.kind === 192) { + && node.kind === 193) { return visitDestructuringAssignment(node); } else if (node.transformFlags & 2048) { @@ -44656,7 +46284,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 262; + return container !== undefined && container.kind === 264; } else { return false; @@ -44670,8 +46298,8 @@ var ts; } return node; } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 262) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -44680,22 +46308,22 @@ var ts; if (noSubstitution) { delete noSubstitutionMap[id]; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); if (isSubstitutionPrevented(node)) { return node; } - if (emitContext === 1) { + if (hint === 1) { return substituteExpression(node); } return node; @@ -44704,10 +46332,10 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 192: + case 193: return substituteBinaryExpression(node); - case 190: case 191: + case 192: return substituteUnaryExpression(node); } return node; @@ -44724,678 +46352,10 @@ var ts; var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node); } else if (ts.isImportSpecifier(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name), node); - } - } - } - return node; - } - function substituteBinaryExpression(node) { - if (ts.isAssignmentOperator(node.operatorToken.kind) - && ts.isIdentifier(node.left) - && !ts.isGeneratedIdentifier(node.left) - && !ts.isLocalName(node.left) - && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { - var exportedNames = getExports(node.left); - if (exportedNames) { - var expression = node; - for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { - var exportName = exportedNames_1[_i]; - expression = createExportExpression(exportName, preventSubstitution(expression)); - } - return expression; - } - } - return node; - } - function substituteUnaryExpression(node) { - if ((node.operator === 42 || node.operator === 43) - && ts.isIdentifier(node.operand) - && !ts.isGeneratedIdentifier(node.operand) - && !ts.isLocalName(node.operand) - && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { - var exportedNames = getExports(node.operand); - if (exportedNames) { - var expression = node.kind === 191 - ? ts.createPrefix(node.operator, node.operand, node) - : node; - for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { - var exportName = exportedNames_2[_i]; - expression = createExportExpression(exportName, preventSubstitution(expression)); - } - if (node.kind === 191) { - expression = node.operator === 42 - ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) - : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); - } - return expression; - } - } - return node; - } - function getExports(name) { - var exportedNames; - if (!ts.isGeneratedIdentifier(name)) { - var valueDeclaration = resolver.getReferencedImportDeclaration(name) - || resolver.getReferencedValueDeclaration(name); - if (valueDeclaration) { - var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 262) { - exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); - } - exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); - } - } - return exportedNames; - } - function preventSubstitution(node) { - if (noSubstitution === undefined) - noSubstitution = ts.createMap(); - noSubstitution[ts.getNodeId(node)] = true; - return node; - } - function isSubstitutionPrevented(node) { - return noSubstitution && node.id && noSubstitution[node.id]; - } - } - ts.transformSystemModule = transformSystemModule; -})(ts || (ts = {})); -var ts; -(function (ts) { - function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var moduleKind = ts.getEmitModuleKind(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(70); - context.enableSubstitution(192); - context.enableSubstitution(190); - context.enableSubstitution(191); - context.enableSubstitution(259); - context.enableEmitNotification(262); - var moduleInfoMap = ts.createMap(); - var deferredExports = ts.createMap(); - var currentSourceFile; - var currentModuleInfo; - var noSubstitution; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node) - || !(ts.isExternalModule(node) - || compilerOptions.isolatedModules)) { - return node; - } - currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); - var transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule(node); - currentSourceFile = undefined; - currentModuleInfo = undefined; - return ts.aggregateTransformFlags(updated); - } - function transformCommonJSModule(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); - ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, false); - var updated = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); - if (currentModuleInfo.hasExportStarsToExportValues) { - ts.addEmitHelper(updated, exportStarHelper); - } - return updated; - } - function transformAMDModule(node) { - var define = ts.createIdentifier("define"); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - return ts.updateSourceFileNode(node, ts.createNodeArray([ - ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ - ts.createParameter(undefined, undefined, undefined, "require"), - ts.createParameter(undefined, undefined, undefined, "exports") - ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) - ]))) - ], node.statements)); - } - function transformUMDModule(node) { - var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.createBlock([ - ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ - ts.createVariableStatement(undefined, [ - ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [ - ts.createIdentifier("require"), - ts.createIdentifier("exports") - ])) - ]), - ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) - ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, [ - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - ts.createIdentifier("factory") - ])) - ]))) - ], undefined, true)); - return ts.updateSourceFileNode(node, ts.createNodeArray([ - ts.createStatement(ts.createCall(umdHeader, undefined, [ - ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ - ts.createParameter(undefined, undefined, undefined, "require"), - ts.createParameter(undefined, undefined, undefined, "exports") - ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) - ])) - ], node.statements)); - } - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - var aliasedModuleNames = []; - var unaliasedModuleNames = []; - var importAliasNames = []; - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(undefined, undefined, undefined, amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { - var importNode = _c[_b]; - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - ts.setEmitFlags(importAliasName, 4); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - function transformAsynchronousModuleBody(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); - ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, true); - var body = ts.createBlock(statements, undefined, true); - if (currentModuleInfo.hasExportStarsToExportValues) { - ts.addEmitHelper(body, exportStarHelper); - } - return body; - } - function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (currentModuleInfo.exportEquals) { - if (emitAsReturn) { - var statement = ts.createReturn(currentModuleInfo.exportEquals.expression, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 | 1536); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression), currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536); - statements.push(statement); - } - } - } - function sourceElementVisitor(node) { - switch (node.kind) { - case 236: - return visitImportDeclaration(node); - case 235: - return visitImportEqualsDeclaration(node); - case 242: - return visitExportDeclaration(node); - case 241: - return visitExportAssignment(node); - case 206: - return visitVariableStatement(node); - case 226: - return visitFunctionDeclaration(node); - case 227: - return visitClassDeclaration(node); - case 296: - return visitMergeDeclarationMarker(node); - case 297: - return visitEndOfDeclarationMarker(node); - default: - return node; - } - } - function visitImportDeclaration(node) { - var statements; - var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (moduleKind !== ts.ModuleKind.AMD) { - if (!node.importClause) { - return ts.createStatement(createRequireCall(node), node); - } - else { - var variables = []; - if (namespaceDeclaration && !ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, createRequireCall(node))); - } - else { - variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), undefined, createRequireCall(node))); - if (namespaceDeclaration && ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node))); - } - } - statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, undefined, languageVersion >= 2 ? 2 : 0), node)); - } - } - else if (namespaceDeclaration && ts.isDefaultImport(node)) { - statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node), node) - ], undefined, languageVersion >= 2 ? 2 : 0))); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfImportDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (moduleName) { - args.push(moduleName); - } - return ts.createCall(ts.createIdentifier("require"), undefined, args); - } - function visitImportEqualsDeclaration(node) { - ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); - var statements; - if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(node.name, createRequireCall(node)), node)); - } - else { - statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node)) - ], undefined, languageVersion >= 2 ? 2 : 0), node)); - } - } - else { - if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node)), node)); - } - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfImportEqualsDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - return undefined; - } - var generatedName = ts.getGeneratedNameForNode(node); - if (node.exportClause) { - var statements = []; - if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node)) - ]), node)); - } - for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { - var specifier = _a[_i]; - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue), specifier)); - } - return ts.singleOrMany(statements); - } - else { - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ - moduleKind !== ts.ModuleKind.AMD - ? createRequireCall(node) - : generatedName - ]), node); - } - } - function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; - } - var statements; - var original = node.original; - if (original && hasAssociatedEndOfDeclarationMarker(original)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, node, true); - } - else { - statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, node, true); - } - return ts.singleOrMany(statements); - } - function visitFunctionDeclaration(node) { - var statements; - if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, node.parameters, undefined, node.body, node), node)); - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfHoistedDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - function visitClassDeclaration(node) { - var statements; - if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, node.heritageClauses, node.members, node), node)); - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfHoistedDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - function visitVariableStatement(node) { - var statements; - var variables; - var expressions; - if (ts.hasModifier(node, 1)) { - var modifiers = void 0; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { - if (!modifiers) { - modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); - } - variables = ts.append(variables, variable); - } - else if (variable.initializer) { - expressions = ts.append(expressions, transformInitializedVariable(variable)); - } - } - if (variables) { - statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); - } - if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); - } - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); - } - else { - statements = appendExportsOfVariableStatement(statements, node); - } - return ts.singleOrMany(statements); - } - function transformInitializedVariable(node) { - if (ts.isBindingPattern(node.name)) { - return ts.flattenDestructuringAssignment(node, undefined, context, 0, false, createExportExpression); - } - else { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name, node.name), node.initializer); - } - } - function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); - } - return node; - } - function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 2097152) !== 0; - } - function visitEndOfDeclarationMarker(node) { - var id = ts.getOriginalNodeId(node); - var statements = deferredExports[id]; - if (statements) { - delete deferredExports[id]; - return ts.append(statements, node); - } - return node; - } - function appendExportsOfImportDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - var importClause = decl.importClause; - if (!importClause) { - return statements; - } - if (importClause.name) { - statements = appendExportsOfDeclaration(statements, importClause); - } - var namedBindings = importClause.namedBindings; - if (namedBindings) { - switch (namedBindings.kind) { - case 238: - statements = appendExportsOfDeclaration(statements, namedBindings); - break; - case 239: - for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { - var importBinding = _a[_i]; - statements = appendExportsOfDeclaration(statements, importBinding); - } - break; - } - } - return statements; - } - function appendExportsOfImportEqualsDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - return appendExportsOfDeclaration(statements, decl); - } - function appendExportsOfVariableStatement(statements, node) { - if (currentModuleInfo.exportEquals) { - return statements; - } - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - statements = appendExportsOfBindingElement(statements, decl); - } - return statements; - } - function appendExportsOfBindingElement(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - if (ts.isBindingPattern(decl.name)) { - for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - statements = appendExportsOfBindingElement(statements, element); - } - } - } - else if (!ts.isGeneratedIdentifier(decl.name)) { - statements = appendExportsOfDeclaration(statements, decl); - } - return statements; - } - function appendExportsOfHoistedDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - if (ts.hasModifier(decl, 1)) { - var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : decl.name; - statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), decl); - } - if (decl.name) { - statements = appendExportsOfDeclaration(statements, decl); - } - return statements; - } - function appendExportsOfDeclaration(statements, decl) { - var name = ts.getDeclarationName(decl); - var exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; - if (exportSpecifiers) { - for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { - var exportSpecifier = exportSpecifiers_2[_i]; - statements = appendExportStatement(statements, exportSpecifier.name, name, exportSpecifier.name); - } - } - return statements; - } - function appendExportStatement(statements, exportName, expression, location, allowComments) { - if (exportName.text === "default") { - var sourceFile = ts.getOriginalNode(currentSourceFile, ts.isSourceFile); - if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 0) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements = ts.append(statements, ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } - statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); - return statements; - } - function createExportStatement(name, value, location, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value), location); - ts.startOnNewLine(statement); - if (!allowComments) { - ts.setEmitFlags(statement, 1536); - } - return statement; - } - function createExportExpression(name, value, location) { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value, location); - } - function modifierVisitor(node) { - switch (node.kind) { - case 83: - case 78: - return undefined; - } - return node; - } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 262) { - currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; - noSubstitution = ts.createMap(); - previousOnEmitNode(emitContext, node, emitCallback); - currentSourceFile = undefined; - currentModuleInfo = undefined; - noSubstitution = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (node.id && noSubstitution[node.id]) { - return node; - } - if (emitContext === 1) { - return substituteExpression(node); - } - else if (ts.isShorthandPropertyAssignment(node)) { - return substituteShorthandPropertyAssignment(node); - } - return node; - } - function substituteShorthandPropertyAssignment(node) { - var name = node.name; - var exportedOrImportedName = substituteExpressionIdentifier(name); - if (exportedOrImportedName !== name) { - if (node.objectAssignmentInitializer) { - var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, node); - } - return ts.createPropertyAssignment(name, exportedOrImportedName, node); - } - return node; - } - function substituteExpression(node) { - switch (node.kind) { - case 70: - return substituteExpressionIdentifier(node); - case 192: - return substituteBinaryExpression(node); - case 191: - case 190: - return substituteUnaryExpression(node); - } - return node; - } - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } - return node; - } - if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { - var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 262) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); - } - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); - } - else if (ts.isImportSpecifier(importDeclaration)) { - var name_39 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_39), node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name)), node); } } } @@ -45412,8 +46372,7 @@ var ts; var expression = node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { var exportName = exportedNames_3[_i]; - noSubstitution[ts.getNodeId(expression)] = true; - expression = createExportExpression(exportName, expression, node); + expression = createExportExpression(exportName, preventSubstitution(expression)); } return expression; } @@ -45428,13 +46387,17 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 191 - ? ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1), node) + var expression = node.kind === 192 + ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { var exportName = exportedNames_4[_i]; - noSubstitution[ts.getNodeId(expression)] = true; - expression = createExportExpression(exportName, expression); + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + if (node.kind === 192) { + expression = node.operator === 42 + ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) + : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } return expression; } @@ -45442,34 +46405,116 @@ var ts; return node; } function getExports(name) { + var exportedNames; if (!ts.isGeneratedIdentifier(name)) { var valueDeclaration = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { - return currentModuleInfo - && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; + var exportContainer = resolver.getReferencedExportContainer(name, false); + if (exportContainer && exportContainer.kind === 264) { + exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); + } + exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); } } + return exportedNames; + } + function preventSubstitution(node) { + if (noSubstitution === undefined) + noSubstitution = []; + noSubstitution[ts.getNodeId(node)] = true; + return node; + } + function isSubstitutionPrevented(node) { + return noSubstitution && node.id && noSubstitution[node.id]; } - var _a; } - ts.transformModule = transformModule; - var exportStarHelper = { - name: "typescript:export-star", - scoped: true, - text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" - }; + ts.transformSystemModule = transformSystemModule; })(ts || (ts = {})); var ts; (function (ts) { - var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, - _a[ts.ModuleKind.System] = ts.transformSystemModule, - _a[ts.ModuleKind.AMD] = ts.transformModule, - _a[ts.ModuleKind.CommonJS] = ts.transformModule, - _a[ts.ModuleKind.UMD] = ts.transformModule, - _a[ts.ModuleKind.None] = ts.transformModule, - _a)); + function transformES2015Module(context) { + var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.enableEmitNotification(264); + context.enableSubstitution(70); + var currentSourceFile; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); + if (externalHelpersModuleName) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements); + ts.append(statements, ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); + } + else { + return ts.visitEachChild(node, visitor, context); + } + } + return node; + } + function visitor(node) { + switch (node.kind) { + case 236: + return undefined; + case 242: + return visitExportAssignment(node); + } + return node; + } + function visitExportAssignment(node) { + return node.isExportEquals ? undefined : node; + } + function onEmitNode(hint, node, emitCallback) { + if (ts.isSourceFile(node)) { + currentSourceFile = node; + previousOnEmitNode(hint, node, emitCallback); + currentSourceFile = undefined; + } + else { + previousOnEmitNode(hint, node, emitCallback); + } + } + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (ts.isIdentifier(node) && hint === 1) { + return substituteExpressionIdentifier(node); + } + return node; + } + function substituteExpressionIdentifier(node) { + if (ts.getEmitFlags(node) & 4096) { + var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); + if (externalHelpersModuleName) { + return ts.createPropertyAccess(externalHelpersModuleName, node); + } + } + return node; + } + } + ts.transformES2015Module = transformES2015Module; +})(ts || (ts = {})); +var ts; +(function (ts) { + function getModuleTransformer(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.ES2015: + return ts.transformES2015Module; + case ts.ModuleKind.System: + return ts.transformSystemModule; + default: + return ts.transformModule; + } + } function getTransformers(compilerOptions) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -45492,7 +46537,7 @@ var ts; transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); + transformers.push(getModuleTransformer(moduleKind)); if (languageVersion < 1) { transformers.push(ts.transformES5); } @@ -45500,7 +46545,7 @@ var ts; } ts.getTransformers = getTransformers; function transformFiles(resolver, host, sourceFiles, transformers) { - var enabledSyntaxKindFeatures = new Array(298); + var enabledSyntaxKindFeatures = new Array(301); var lexicalEnvironmentDisabled = false; var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; @@ -45521,16 +46566,19 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, - onSubstituteNode: function (_emitContext, node) { return node; }, + onSubstituteNode: function (_, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, + onEmitNode: function (hint, node, callback) { return callback(hint, node); }, enableEmitNotification: enableEmitNotification, isEmitNotificationEnabled: isEmitNotificationEnabled }; + ts.performance.mark("beforeTransform"); var transformation = ts.chain.apply(void 0, transformers)(context); var transformed = ts.map(sourceFiles, transformSourceFile); lexicalEnvironmentDisabled = true; + ts.performance.mark("afterTransform"); + ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { transformed: transformed, emitNodeWithSubstitution: emitNodeWithSubstitution, @@ -45549,16 +46597,12 @@ var ts; return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0 && (ts.getEmitFlags(node) & 4) === 0; } - function emitNodeWithSubstitution(emitContext, node, emitCallback) { + function emitNodeWithSubstitution(hint, node, emitCallback) { if (node) { if (isSubstitutionEnabled(node)) { - var substitute = context.onSubstituteNode(emitContext, node); - if (substitute && substitute !== node) { - emitCallback(emitContext, substitute); - return; - } + node = context.onSubstituteNode(hint, node) || node; } - emitCallback(emitContext, node); + emitCallback(hint, node); } } function enableEmitNotification(kind) { @@ -45568,13 +46612,13 @@ var ts; return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0 || (ts.getEmitFlags(node) & 2) !== 0; } - function emitNodeWithNotification(emitContext, node, emitCallback) { + function emitNodeWithNotification(hint, node, emitCallback) { if (node) { if (isEmitNotificationEnabled(node)) { - context.onEmitNode(emitContext, node, emitCallback); + context.onEmitNode(hint, node, emitCallback); } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } } @@ -45656,7 +46700,6 @@ var ts; } } ts.transformFiles = transformFiles; - var _a; })(ts || (ts = {})); var ts; (function (ts) { @@ -45690,7 +46733,7 @@ var ts; getText: getText, getSourceMappingURL: getSourceMappingURL, }; - function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { + function initialize(filePath, sourceMapFilePath, sourceFileOrBundle) { if (disabled) { return; } @@ -45721,9 +46764,8 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (!isBundledEmit) { - ts.Debug.assert(sourceFiles.length === 1); - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFiles[0], host, sourceMapDir)); + if (sourceFileOrBundle.kind === 264) { + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); @@ -45814,28 +46856,28 @@ var ts; ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); } } - function emitNodeWithSourceMap(emitContext, node, emitCallback) { + function emitNodeWithSourceMap(hint, node, emitCallback) { if (disabled) { - return emitCallback(emitContext, node); + return emitCallback(hint, node); } if (node) { var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 294 + if (node.kind !== 297 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); } if (emitFlags & 64) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } - if (node.kind !== 294 + if (node.kind !== 297 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -45936,11 +46978,10 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function createCommentWriter(host, writer, sourceMap) { - var compilerOptions = host.getCompilerOptions(); - var extendedDiagnostics = compilerOptions.extendedDiagnostics; - var newLine = host.getNewLine(); - var emitPos = sourceMap.emitPos; + function createCommentWriter(printerOptions, emitPos) { + var extendedDiagnostics = printerOptions.extendedDiagnostics; + var newLine = ts.getNewLineCharacter(printerOptions); + var writer; var containerPos = -1; var containerEnd = -1; var declarationListContainerEnd = -1; @@ -45949,17 +46990,19 @@ var ts; var currentLineMap; var detachedCommentsInfo; var hasWrittenComment = false; - var disabled = compilerOptions.removeComments; + var disabled = printerOptions.removeComments; return { reset: reset, + setWriter: setWriter, setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, + emitLeadingCommentsOfPosition: emitLeadingCommentsOfPosition, }; - function emitNodeWithComments(emitContext, node, emitCallback) { + function emitNodeWithComments(hint, node, emitCallback) { if (disabled) { - emitCallback(emitContext, node); + emitCallback(hint, node); return; } if (node) { @@ -45968,18 +47011,18 @@ var ts; if ((pos < 0 && end < 0) || (pos === end)) { if (emitFlags & 2048) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } else { if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 294; + var isEmittedNode = node.kind !== 297; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { @@ -45993,7 +47036,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 225) { + if (node.kind === 226) { declarationListContainerEnd = end; } } @@ -46002,11 +47045,11 @@ var ts; } if (emitFlags & 2048) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } if (extendedDiagnostics) { ts.performance.mark("beginEmitNodeWithComment"); @@ -46077,9 +47120,11 @@ var ts; ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; } - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -46087,6 +47132,12 @@ var ts; writer.write(" "); } } + function emitLeadingCommentsOfPosition(pos) { + if (disabled || pos === -1) { + return; + } + emitLeadingComments(pos, true); + } function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } @@ -46094,9 +47145,11 @@ var ts; if (!writer.isAtStartOfLine()) { writer.write(" "); } - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -46114,9 +47167,11 @@ var ts; } } function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -46145,6 +47200,9 @@ var ts; currentLineMap = undefined; detachedCommentsInfo = undefined; } + function setWriter(output) { + writer = output; + } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; currentText = currentSourceFile.text; @@ -46176,9 +47234,11 @@ var ts; } } function writeComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); } function isTripleSlashComment(commentPos, commentEnd) { if (currentText.charCodeAt(commentPos + 1) === 47 && @@ -46198,15 +47258,17 @@ var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, targetSourceFile) { var declarationDiagnostics = ts.createDiagnosticCollection(); - ts.forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); + ts.forEachEmittedFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); - function getDeclarationDiagnosticsFromFile(_a, sources, isBundledEmit) { + function getDeclarationDiagnosticsFromFile(_a, sourceFileOrBundle) { var declarationFilePath = _a.declarationFilePath; - emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit, false); + emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sourceFileOrBundle, false); } } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles) { + function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles) { + var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var isBundledEmit = sourceFileOrBundle.kind === 265; var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -46268,7 +47330,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 236); + ts.Debug.assert(aliasEmitInfo.node.kind === 237); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -46291,9 +47353,9 @@ var ts; } }); if (usedTypeDirectiveReferences) { - for (var directive in usedTypeDirectiveReferences) { + ts.forEachKey(usedTypeDirectiveReferences, function (directive) { referencesOutput += "/// " + newLine; - } + }); } return { reportedDeclarationError: reportedDeclarationError, @@ -46318,6 +47380,7 @@ var ts; var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; writer.reportInaccessibleThisError = reportInaccessibleThisError; + writer.reportIllegalExtends = reportIllegalExtends; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -46340,10 +47403,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 224) { + if (declaration.kind === 225) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 239 || declaration.kind === 240 || declaration.kind === 237) { + else if (declaration.kind === 240 || declaration.kind === 241 || declaration.kind === 238) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -46354,7 +47417,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 236) { + if (moduleElementEmitInfo.node.kind === 237) { moduleElementEmitInfo.isVisible = true; } else { @@ -46362,12 +47425,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 231) { + if (nodeToCheck.kind === 232) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 231) { + if (nodeToCheck.kind === 232) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -46386,8 +47449,8 @@ var ts; } for (var _i = 0, typeReferenceDirectives_1 = typeReferenceDirectives; _i < typeReferenceDirectives_1.length; _i++) { var directive = typeReferenceDirectives_1[_i]; - if (!(directive in usedTypeDirectiveReferences)) { - usedTypeDirectiveReferences[directive] = directive; + if (!usedTypeDirectiveReferences.has(directive)) { + usedTypeDirectiveReferences.set(directive, directive); } } } @@ -46414,6 +47477,12 @@ var ts; handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); } + function reportIllegalExtends() { + if (errorNameNode) { + reportedDeclarationError = true; + emitterDiagnostics.add(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced, ts.declarationNameToString(errorNameNode))); + } + } function reportInaccessibleThisError() { if (errorNameNode) { reportedDeclarationError = true; @@ -46423,12 +47492,16 @@ var ts; function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); - if (type) { + var shouldUseResolverType = declaration.kind === 145 && + resolver.isRequiredInitializedParameter(declaration); + if (type && !shouldUseResolverType) { emitType(type); } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 | 1024, writer); + var format = 2 | 1024 | + (shouldUseResolverType ? 4096 : 0); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer); errorNameNode = undefined; } } @@ -46480,49 +47553,50 @@ var ts; function emitType(type) { switch (type.kind) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 133: + case 136: case 104: - case 137: + case 138: case 94: case 129: - case 167: - case 171: - return writeTextOfNode(currentText, type); - case 199: - return emitExpressionWithTypeArguments(type); - case 157: - return emitTypeReference(type); - case 160: - return emitTypeQuery(type); - case 162: - return emitArrayType(type); - case 163: - return emitTupleType(type); - case 164: - return emitUnionType(type); - case 165: - return emitIntersectionType(type); - case 166: - return emitParenType(type); case 168: - return emitTypeOperator(type); - case 169: - return emitIndexedAccessType(type); - case 170: - return emitMappedType(type); + case 172: + return writeTextOfNode(currentText, type); + case 200: + return emitExpressionWithTypeArguments(type); case 158: - case 159: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 161: + return emitTypeQuery(type); + case 163: + return emitArrayType(type); + case 164: + return emitTupleType(type); + case 165: + return emitUnionType(type); + case 166: + return emitIntersectionType(type); + case 167: + return emitParenType(type); + case 169: + return emitTypeOperator(type); + case 170: + return emitIndexedAccessType(type); + case 171: + return emitMappedType(type); + case 159: + case 160: + return emitSignatureDeclarationWithJsDocComments(type); + case 162: return emitTypeLiteral(type); case 70: return emitEntityName(type); - case 141: + case 142: return emitEntityName(type); - case 156: + case 157: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -46530,22 +47604,22 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 141 ? entityName.left : entityName.expression; - var right = entityName.kind === 141 ? entityName.right : entityName.name; + var left = entityName.kind === 142 ? entityName.left : entityName.expression; + var right = entityName.kind === 142 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 235 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 236 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 177); + ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 178); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -46649,15 +47723,15 @@ var ts; } function getExportDefaultTempVariableName() { var baseName = "_default"; - if (!(baseName in currentIdentifiers)) { + if (!currentIdentifiers.has(baseName)) { return baseName; } var count = 0; while (true) { count++; - var name_40 = baseName + "_" + count; - if (!(name_40 in currentIdentifiers)) { - return name_40; + var name = baseName + "_" + count; + if (!currentIdentifiers.has(name)) { + return name; } } } @@ -46701,10 +47775,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 235 || - (node.parent.kind === 262 && isCurrentFileExternalModule)) { + else if (node.kind === 236 || + (node.parent.kind === 264 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 262) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 264) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -46713,7 +47787,7 @@ var ts; }); } else { - if (node.kind === 236) { + if (node.kind === 237) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -46731,30 +47805,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 226: - return writeFunctionDeclaration(node); - case 206: - return writeVariableStatement(node); - case 228: - return writeInterfaceDeclaration(node); case 227: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 207: + return writeVariableStatement(node); case 229: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 228: + return writeClassDeclaration(node); case 230: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 231: + return writeEnumDeclaration(node); + case 232: return writeModuleDeclaration(node); - case 235: - return writeImportEqualsDeclaration(node); case 236: + return writeImportEqualsDeclaration(node); + case 237: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 262) { + if (node.parent.kind === 264) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -46762,7 +47836,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 228 && !noDeclare) { + else if (node.kind !== 229 && !noDeclare) { write("declare "); } } @@ -46812,7 +47886,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 238) { + if (namedBindings.kind === 239) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -46835,7 +47909,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 238) { + if (node.importClause.namedBindings.kind === 239) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -46852,13 +47926,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 231; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 232; var moduleSpecifier; - if (parent.kind === 235) { + if (parent.kind === 236) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 231) { + else if (parent.kind === 232) { moduleSpecifier = parent.name; } else { @@ -46926,7 +48000,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 232) { + while (node.body && node.body.kind !== 233) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -46996,7 +48070,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 149 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 150 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -47006,52 +48080,69 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 158 || - node.parent.kind === 159 || - (node.parent.parent && node.parent.parent.kind === 161)) { - ts.Debug.assert(node.parent.kind === 149 || - node.parent.kind === 148 || - node.parent.kind === 158 || + if (node.parent.kind === 159 || + node.parent.kind === 160 || + (node.parent.parent && node.parent.parent.kind === 162)) { + ts.Debug.assert(node.parent.kind === 150 || + node.parent.kind === 149 || node.parent.kind === 159 || - node.parent.kind === 153 || - node.parent.kind === 154); + node.parent.kind === 160 || + node.parent.kind === 154 || + node.parent.kind === 155); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } + if (node.default && !isPrivateMethodTypeParameter(node)) { + write(" = "); + if (node.parent.kind === 159 || + node.parent.kind === 160 || + (node.parent.parent && node.parent.parent.kind === 162)) { + ts.Debug.assert(node.parent.kind === 150 || + node.parent.kind === 149 || + node.parent.kind === 159 || + node.parent.kind === 160 || + node.parent.kind === 154 || + node.parent.kind === 155); + emitType(node.default); + } + else { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.default, getTypeParameterConstraintVisibilityError); + } + } function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 227: + case 228: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 228: + case 229: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 154: + case 155: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 153: + case 154: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 150: case 149: - case 148: if (ts.hasModifier(node.parent, 32)) { 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 === 227) { + else if (node.parent.parent.kind === 228) { 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 226: + case 227: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 229: + case 230: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -47070,7 +48161,7 @@ var ts; write(">"); } } - function emitHeritageClause(typeReferences, isImplementsList) { + function emitHeritageClause(className, typeReferences, isImplementsList) { if (typeReferences) { write(isImplementsList ? " implements " : " extends "); emitCommaList(typeReferences, emitTypeOfTypeReference); @@ -47084,17 +48175,19 @@ var ts; } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; + errorNameNode = className; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 | 1024, writer); + errorNameNode = undefined; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 227) { + if (node.parent.parent.kind === 228) { 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; + ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } else { - diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; + diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; } return { diagnosticMessage: diagnosticMessage, @@ -47126,9 +48219,10 @@ var ts; emitTypeParameters(node.typeParameters); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); + node.name; + emitHeritageClause(node.name, [baseTypeNode], false); } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), true); + emitHeritageClause(node.name, ts.getClassImplementsHeritageClauseElements(node), true); write(" {"); writeLine(); increaseIndent(); @@ -47149,7 +48243,7 @@ var ts; emitTypeParameters(node.typeParameters); var interfaceExtendsTypes = ts.filter(ts.getInterfaceBaseTypeNodes(node), function (base) { return ts.isEntityNameExpression(base.expression); }); if (interfaceExtendsTypes && interfaceExtendsTypes.length) { - emitHeritageClause(interfaceExtendsTypes, false); + emitHeritageClause(node.name, interfaceExtendsTypes, false); } write(" {"); writeLine(); @@ -47171,17 +48265,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 224 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 225 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 147 || node.kind === 146 || - (node.kind === 144 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 148 || node.kind === 147 || + (node.kind === 145 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 147 || node.kind === 146) && node.parent.kind === 161) { + if ((node.kind === 148 || node.kind === 147) && node.parent.kind === 162) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -47194,14 +48288,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 224) { + if (node.kind === 225) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 === 147 || node.kind === 146) { + else if (node.kind === 148 || node.kind === 147) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -47209,7 +48303,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 === 227) { + else if (node.parent.kind === 228) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47235,7 +48329,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 198) { + if (element.kind !== 199) { elements.push(element); } } @@ -47301,7 +48395,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 151 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 152 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -47314,7 +48408,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 151 + return accessor.kind === 152 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -47323,7 +48417,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 152) { + if (accessorWithTypeAnnotation.kind === 153) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -47369,17 +48463,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 226) { + if (node.kind === 227) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 149 || node.kind === 150) { + else if (node.kind === 150 || node.kind === 151) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 226) { + if (node.kind === 227) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 150) { + else if (node.kind === 151) { write("constructor"); } else { @@ -47399,15 +48493,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 155) { + if (node.kind === 156) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 154 || node.kind === 159) { + if (node.kind === 155 || node.kind === 160) { write("new "); } - else if (node.kind === 158) { + else if (node.kind === 159) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -47418,20 +48512,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 155) { + if (node.kind === 156) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 158 || node.kind === 159; - if (isFunctionTypeOrConstructorType || node.parent.kind === 161) { + var isFunctionTypeOrConstructorType = node.kind === 159 || node.kind === 160; + if (isFunctionTypeOrConstructorType || node.parent.kind === 162) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 150 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 151 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -47445,23 +48539,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 154: + case 155: diagnosticMessage = symbolAccessibilityResult.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 153: + case 154: diagnosticMessage = symbolAccessibilityResult.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 155: + case 156: diagnosticMessage = symbolAccessibilityResult.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 150: case 149: - case 148: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -47469,7 +48563,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 === 227) { + else if (node.parent.kind === 228) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -47482,7 +48576,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 226: + case 227: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -47514,9 +48608,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 158 || - node.parent.kind === 159 || - node.parent.parent.kind === 161) { + if (node.parent.kind === 159 || + node.parent.kind === 160 || + node.parent.parent.kind === 162) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -47532,26 +48626,26 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 150: + case 151: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 154: + case 155: return symbolAccessibilityResult.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 153: + case 154: return symbolAccessibilityResult.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 155: + case 156: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; + case 150: case 149: - case 148: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -47559,7 +48653,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 === 227) { + else if (node.parent.parent.kind === 228) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -47571,7 +48665,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 226: + case 227: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47582,12 +48676,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 172) { + if (bindingPattern.kind === 173) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 173) { + else if (bindingPattern.kind === 174) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -47598,10 +48692,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 198) { + if (bindingElement.kind === 199) { write(" "); } - else if (bindingElement.kind === 174) { + else if (bindingElement.kind === 175) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -47623,39 +48717,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 226: - case 231: - case 235: - case 228: case 227: - case 229: - case 230: - return emitModuleElement(node, isModuleElementVisible(node)); - case 206: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 232: case 236: + case 229: + case 228: + case 230: + case 231: + return emitModuleElement(node, isModuleElementVisible(node)); + case 207: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 237: return emitModuleElement(node, !node.importClause); - case 242: + case 243: return emitExportDeclaration(node); + case 151: case 150: case 149: - case 148: return writeFunctionDeclaration(node); - case 154: - case 153: case 155: + case 154: + case 156: return emitSignatureDeclarationWithJsDocComments(node); - case 151: case 152: + case 153: return emitAccessorDeclaration(node); + case 148: case 147: - case 146: return emitPropertyDeclaration(node); - case 261: + case 263: return emitEnumMemberDeclaration(node); - case 241: + case 242: return emitExportAssignment(node); - case 262: + case 264: return emitSourceFile(node); } } @@ -47666,14 +48760,15 @@ var ts; declFileName = referencedFile.fileName; } else { - ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(declarationFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, sourceFileOrBundle) { + var isBundledEmit = sourceFileOrBundle.kind === 265; if (isBundledEmit && !addBundledFileReference) { return; } @@ -47683,10 +48778,11 @@ var ts; } } } - function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { - var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles); + function writeDeclarationFile(declarationFilePath, sourceFileOrBundle, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { + var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { + var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; var declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); ts.writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); @@ -47710,44 +48806,39 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var id = function (s) { return s; }; - var nullTransformers = [function (_) { return id; }]; + var delimiters = createDelimiterMap(); + var brackets = createBracketsMap(); function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { - var delimiters = createDelimiterMap(); - var brackets = createBracketsMap(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = emitOnlyDtsFiles ? nullTransformers : ts.getTransformers(compilerOptions); + var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); - var write = writer.write, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var sourceMap = ts.createSourceMapWriter(host, writer); - var emitNodeWithSourceMap = sourceMap.emitNodeWithSourceMap, emitTokenWithSourceMap = sourceMap.emitTokenWithSourceMap; - var comments = ts.createCommentWriter(host, writer, sourceMap); - var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition; - var nodeIdToGeneratedName; - var autoGeneratedIdToGeneratedName; - var generatedNameSet; - var tempFlags; var currentSourceFile; - var currentText; - var currentFileIdentifiers; var bundledHelpers; var isOwnFileEmit; var emitSkipped = false; var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); - ts.performance.mark("beforeTransform"); - var _a = ts.transformFiles(resolver, host, sourceFiles, transformers), transformed = _a.transformed, emitNodeWithSubstitution = _a.emitNodeWithSubstitution, emitNodeWithNotification = _a.emitNodeWithNotification; - ts.performance.measure("transformTime", "beforeTransform"); + var transform = ts.transformFiles(resolver, host, sourceFiles, transformers); + var printer = createPrinter(compilerOptions, { + hasGlobalName: resolver.hasGlobalName, + onEmitNode: transform.emitNodeWithNotification, + onSubstituteNode: transform.emitNodeWithSubstitution, + onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, + onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, + onEmitSourceMapOfPosition: sourceMap.emitPos, + onEmitHelpers: emitHelpers, + onSetSourceFile: setSourceFile, + }); ts.performance.mark("beforePrint"); - ts.forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); - for (var _b = 0, sourceFiles_4 = sourceFiles; _b < sourceFiles_4.length; _b++) { - var sourceFile = sourceFiles_4[_b]; + for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { + var sourceFile = sourceFiles_2[_a]; ts.disposeEmitNodes(sourceFile); } return { @@ -47756,17 +48847,18 @@ var ts; emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList }; - function emitFile(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, isBundledEmit) { + function emitSourceFileOrBundle(_a, sourceFileOrBundle) { + var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath; if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { if (!emitOnlyDtsFiles) { - printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle); } } else { emitSkipped = true; } if (declarationFilePath) { - emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; + emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFileOrBundle(sourceFileOrBundle), host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; } if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { @@ -47780,24 +48872,24 @@ var ts; } } } - function printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit) { - sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); - nodeIdToGeneratedName = []; - autoGeneratedIdToGeneratedName = []; - generatedNameSet = ts.createMap(); - bundledHelpers = isBundledEmit ? ts.createMap() : undefined; - isOwnFileEmit = !isBundledEmit; - if (isBundledEmit && moduleKind) { - for (var _a = 0, sourceFiles_5 = sourceFiles; _a < sourceFiles_5.length; _a++) { - var sourceFile = sourceFiles_5[_a]; - emitHelpers(sourceFile, true); - } + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle) { + var bundle = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 264 ? sourceFileOrBundle : undefined; + var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; + sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFileOrBundle); + if (bundle) { + bundledHelpers = ts.createMap(); + isOwnFileEmit = false; + printer.writeBundle(bundle, writer); } - ts.forEach(sourceFiles, printSourceFile); - writeLine(); + else { + isOwnFileEmit = true; + printer.writeFile(sourceFile, writer); + } + writer.writeLine(); var sourceMappingURL = sourceMap.getSourceMappingURL(); if (sourceMappingURL) { - write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); + writer.write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); } if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) { ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), false, sourceFiles); @@ -47807,23 +48899,165 @@ var ts; } ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles); sourceMap.reset(); - comments.reset(); writer.reset(); - tempFlags = 0; currentSourceFile = undefined; - currentText = undefined; + bundledHelpers = undefined; isOwnFileEmit = false; } - function printSourceFile(node) { + function setSourceFile(node) { currentSourceFile = node; - currentText = node.text; - currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); - comments.setSourceFile(node); - pipelineEmitWithNotification(0, node); } - function emit(node) { - pipelineEmitWithNotification(3, node); + function emitHelpers(node, writeLines) { + var helpersEmitted = false; + var bundle = node.kind === 265 ? node : undefined; + if (bundle && moduleKind === ts.ModuleKind.None) { + return; + } + var numNodes = bundle ? bundle.sourceFiles.length : 1; + for (var i = 0; i < numNodes; i++) { + var currentNode = bundle ? bundle.sourceFiles[i] : node; + var sourceFile = ts.isSourceFile(currentNode) ? currentNode : currentSourceFile; + var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = ts.isSourceFile(currentNode) && !isOwnFileEmit; + var helpers = ts.getEmitHelpers(currentNode); + if (helpers) { + for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { + var helper = _b[_a]; + if (!helper.scoped) { + if (shouldSkip) + continue; + if (shouldBundle) { + if (bundledHelpers.get(helper.name)) { + continue; + } + bundledHelpers.set(helper.name, true); + } + } + else if (bundle) { + continue; + } + writeLines(helper.text); + helpersEmitted = true; + } + } + } + return helpersEmitted; + } + } + ts.emitFiles = emitFiles; + function createPrinter(printerOptions, handlers) { + if (printerOptions === void 0) { printerOptions = {}; } + if (handlers === void 0) { handlers = {}; } + var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, onSubstituteNode = handlers.onSubstituteNode; + var newLine = ts.getNewLineCharacter(printerOptions); + var languageVersion = ts.getEmitScriptTarget(printerOptions); + var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); + var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; + var currentSourceFile; + var nodeIdToGeneratedName; + var autoGeneratedIdToGeneratedName; + var generatedNames; + var tempFlagsStack; + var tempFlags; + var writer; + var ownWriter; + reset(); + return { + printNode: printNode, + printFile: printFile, + printBundle: printBundle, + writeNode: writeNode, + writeFile: writeFile, + writeBundle: writeBundle + }; + function printNode(hint, node, sourceFile) { + switch (hint) { + case 0: + ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); + break; + case 2: + ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); + break; + case 1: + ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); + break; + } + switch (node.kind) { + case 264: return printFile(node); + case 265: return printBundle(node); + } + writeNode(hint, node, sourceFile, beginPrint()); + return endPrint(); + } + function printBundle(bundle) { + writeBundle(bundle, beginPrint()); + return endPrint(); + } + function printFile(sourceFile) { + writeFile(sourceFile, beginPrint()); + return endPrint(); + } + function writeNode(hint, node, sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(hint, node, sourceFile); + reset(); + writer = previousWriter; + } + function writeBundle(bundle, output) { + var previousWriter = writer; + setWriter(output); + emitHelpersIndirect(bundle); + for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + print(0, sourceFile, sourceFile); + } + reset(); + writer = previousWriter; + } + function writeFile(sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(0, sourceFile, sourceFile); + reset(); + writer = previousWriter; + } + function beginPrint() { + return ownWriter || (ownWriter = ts.createTextWriter(newLine)); + } + function endPrint() { + var text = ownWriter.getText(); + ownWriter.reset(); + return text; + } + function print(hint, node, sourceFile) { + setSourceFile(sourceFile); + pipelineEmitWithNotification(hint, node); + } + function setSourceFile(sourceFile) { + currentSourceFile = sourceFile; + comments.setSourceFile(sourceFile); + if (onSetSourceFile) { + onSetSourceFile(sourceFile); + } + } + function setWriter(output) { + writer = output; + comments.setWriter(output); + } + function reset() { + nodeIdToGeneratedName = []; + autoGeneratedIdToGeneratedName = []; + generatedNames = ts.createMap(); + tempFlagsStack = []; + tempFlags = 0; + comments.reset(); + setWriter(undefined); + } + function emit(node, hint) { + if (hint === void 0) { hint = 3; } + pipelineEmitWithNotification(hint, node); } function emitIdentifierName(node) { pipelineEmitWithNotification(2, node); @@ -47831,51 +49065,60 @@ var ts; function emitExpression(node) { pipelineEmitWithNotification(1, node); } - function pipelineEmitWithNotification(emitContext, node) { - emitNodeWithNotification(emitContext, node, pipelineEmitWithComments); + function pipelineEmitWithNotification(hint, node) { + if (onEmitNode) { + onEmitNode(hint, node, pipelineEmitWithComments); + } + else { + pipelineEmitWithComments(hint, node); + } } - function pipelineEmitWithComments(emitContext, node) { - if (emitContext === 0) { - pipelineEmitWithSourceMap(emitContext, node); + function pipelineEmitWithComments(hint, node) { + if (emitNodeWithComments && hint !== 0) { + emitNodeWithComments(hint, node, pipelineEmitWithSourceMap); + } + else { + pipelineEmitWithSourceMap(hint, node); + } + } + function pipelineEmitWithSourceMap(hint, node) { + if (onEmitSourceMapOfNode && hint !== 0 && hint !== 2) { + onEmitSourceMapOfNode(hint, node, pipelineEmitWithSubstitution); + } + else { + pipelineEmitWithSubstitution(hint, node); + } + } + function pipelineEmitWithSubstitution(hint, node) { + if (onSubstituteNode) { + onSubstituteNode(hint, node, pipelineEmitWithHint); + } + else { + pipelineEmitWithHint(hint, node); + } + } + function pipelineEmitWithHint(hint, node) { + switch (hint) { + case 0: return pipelineEmitSourceFile(node); + case 2: return pipelineEmitIdentifierName(node); + case 1: return pipelineEmitExpression(node); + case 3: return pipelineEmitUnspecified(node); + } + } + function pipelineEmitSourceFile(node) { + ts.Debug.assertNode(node, ts.isSourceFile); + emitSourceFile(node); + } + function pipelineEmitIdentifierName(node) { + ts.Debug.assertNode(node, ts.isIdentifier); + emitIdentifier(node); + } + function pipelineEmitUnspecified(node) { + var kind = node.kind; + if (ts.isKeyword(kind)) { + writeTokenText(kind); return; } - emitNodeWithComments(emitContext, node, pipelineEmitWithSourceMap); - } - function pipelineEmitWithSourceMap(emitContext, node) { - if (emitContext === 0 - || emitContext === 2) { - pipelineEmitWithSubstitution(emitContext, node); - return; - } - emitNodeWithSourceMap(emitContext, node, pipelineEmitWithSubstitution); - } - function pipelineEmitWithSubstitution(emitContext, node) { - emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext); - } - function pipelineEmitForContext(emitContext, node) { - switch (emitContext) { - case 0: return pipelineEmitInSourceFileContext(node); - case 2: return pipelineEmitInIdentifierNameContext(node); - case 3: return pipelineEmitInUnspecifiedContext(node); - case 1: return pipelineEmitInExpressionContext(node); - } - } - function pipelineEmitInSourceFileContext(node) { - var kind = node.kind; - switch (kind) { - case 262: - return emitSourceFile(node); - } - } - function pipelineEmitInIdentifierNameContext(node) { - var kind = node.kind; - switch (kind) { - case 70: - return emitIdentifier(node); - } - } - function pipelineEmitInUnspecifiedContext(node) { - var kind = node.kind; switch (kind) { case 13: case 14: @@ -47883,229 +49126,197 @@ var ts; return emitLiteral(node); case 70: return emitIdentifier(node); - case 75: - case 78: - case 83: - case 104: - case 111: - case 112: - case 113: - case 114: - case 116: - case 117: - case 118: - case 119: - case 120: - case 121: - case 122: - case 123: - case 124: - case 125: - case 127: - case 128: - case 129: - case 130: - case 131: - case 132: - case 133: - case 134: - case 135: - case 136: - case 137: - case 138: - case 139: - case 140: - writeTokenText(kind); - return; - case 141: - return emitQualifiedName(node); case 142: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 143: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 144: - return emitParameter(node); + return emitTypeParameter(node); case 145: - return emitDecorator(node); + return emitParameter(node); case 146: - return emitPropertySignature(node); + return emitDecorator(node); case 147: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 148: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 149: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 150: - return emitConstructor(node); + return emitMethodDeclaration(node); case 151: + return emitConstructor(node); case 152: - return emitAccessorDeclaration(node); case 153: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 154: - return emitConstructSignature(node); + return emitCallSignature(node); case 155: - return emitIndexSignature(node); + return emitConstructSignature(node); case 156: - return emitTypePredicate(node); + return emitIndexSignature(node); case 157: - return emitTypeReference(node); + return emitTypePredicate(node); case 158: - return emitFunctionType(node); + return emitTypeReference(node); case 159: - return emitConstructorType(node); + return emitFunctionType(node); case 160: - return emitTypeQuery(node); + return emitConstructorType(node); case 161: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 162: - return emitArrayType(node); + return emitTypeLiteral(node); case 163: - return emitTupleType(node); + return emitArrayType(node); case 164: - return emitUnionType(node); + return emitTupleType(node); case 165: - return emitIntersectionType(node); + return emitUnionType(node); case 166: - return emitParenthesizedType(node); - case 199: - return emitExpressionWithTypeArguments(node); + return emitIntersectionType(node); case 167: - return emitThisType(); + return emitParenthesizedType(node); + case 200: + return emitExpressionWithTypeArguments(node); case 168: - return emitTypeOperator(node); + return emitThisType(); case 169: - return emitIndexedAccessType(node); + return emitTypeOperator(node); case 170: - return emitMappedType(node); + return emitIndexedAccessType(node); case 171: - return emitLiteralType(node); + return emitMappedType(node); case 172: - return emitObjectBindingPattern(node); + return emitLiteralType(node); case 173: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 174: + return emitArrayBindingPattern(node); + case 175: return emitBindingElement(node); - case 203: - return emitTemplateSpan(node); case 204: - return emitSemicolonClassElement(); + return emitTemplateSpan(node); case 205: - return emitBlock(node); + return emitSemicolonClassElement(); case 206: - return emitVariableStatement(node); + return emitBlock(node); case 207: - return emitEmptyStatement(); + return emitVariableStatement(node); case 208: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 209: - return emitIfStatement(node); + return emitExpressionStatement(node); case 210: - return emitDoStatement(node); + return emitIfStatement(node); case 211: - return emitWhileStatement(node); + return emitDoStatement(node); case 212: - return emitForStatement(node); + return emitWhileStatement(node); case 213: - return emitForInStatement(node); + return emitForStatement(node); case 214: - return emitForOfStatement(node); + return emitForInStatement(node); case 215: - return emitContinueStatement(node); + return emitForOfStatement(node); case 216: - return emitBreakStatement(node); + return emitContinueStatement(node); case 217: - return emitReturnStatement(node); + return emitBreakStatement(node); case 218: - return emitWithStatement(node); + return emitReturnStatement(node); case 219: - return emitSwitchStatement(node); + return emitWithStatement(node); case 220: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 221: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 222: - return emitTryStatement(node); + return emitThrowStatement(node); case 223: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 224: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 225: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 226: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 227: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 228: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 229: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 230: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 231: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 232: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 233: + return emitModuleBlock(node); + case 234: return emitCaseBlock(node); - case 235: - return emitImportEqualsDeclaration(node); case 236: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 237: - return emitImportClause(node); + return emitImportDeclaration(node); case 238: - return emitNamespaceImport(node); + return emitImportClause(node); case 239: - return emitNamedImports(node); + return emitNamespaceImport(node); case 240: - return emitImportSpecifier(node); + return emitNamedImports(node); case 241: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 242: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 243: - return emitNamedExports(node); + return emitExportDeclaration(node); case 244: - return emitExportSpecifier(node); + return emitNamedExports(node); case 245: - return; + return emitExportSpecifier(node); case 246: + return; + case 247: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 249: - return emitJsxOpeningElement(node); case 250: - return emitJsxClosingElement(node); + return emitJsxOpeningElement(node); case 251: - return emitJsxAttribute(node); + return emitJsxClosingElement(node); case 252: - return emitJsxSpreadAttribute(node); + return emitJsxAttribute(node); case 253: - return emitJsxExpression(node); + return emitJsxAttributes(node); case 254: - return emitCaseClause(node); + return emitJsxSpreadAttribute(node); case 255: - return emitDefaultClause(node); + return emitJsxExpression(node); case 256: - return emitHeritageClause(node); + return emitCaseClause(node); case 257: - return emitCatchClause(node); + return emitDefaultClause(node); case 258: - return emitPropertyAssignment(node); + return emitHeritageClause(node); case 259: - return emitShorthandPropertyAssignment(node); + return emitCatchClause(node); case 260: - return emitSpreadAssignment(node); + return emitPropertyAssignment(node); case 261: + return emitShorthandPropertyAssignment(node); + case 262: + return emitSpreadAssignment(node); + case 263: return emitEnumMember(node); } if (ts.isExpression(node)) { return pipelineEmitWithSubstitution(1, node); } } - function pipelineEmitInExpressionContext(node) { + function pipelineEmitExpression(node) { var kind = node.kind; switch (kind) { case 8: @@ -48123,68 +49334,81 @@ var ts; case 98: writeTokenText(kind); return; - case 175: - return emitArrayLiteralExpression(node); case 176: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 177: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 178: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 179: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 180: - return emitNewExpression(node); + return emitCallExpression(node); case 181: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 182: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 183: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 184: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 185: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 186: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 187: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 188: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 189: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 190: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 191: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 192: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 193: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 194: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 195: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 196: - return emitSpreadExpression(node); + return emitYieldExpression(node); case 197: - return emitClassExpression(node); + return emitSpreadExpression(node); case 198: + return emitClassExpression(node); + case 199: return; - case 200: - return emitAsExpression(node); case 201: - return emitNonNullExpression(node); + return emitAsExpression(node); case 202: + return emitNonNullExpression(node); + case 203: return emitMetaProperty(node); - case 247: - return emitJsxElement(node); case 248: + return emitJsxElement(node); + case 249: return emitJsxSelfClosingElement(node); - case 295: + case 298: return emitPartiallyEmittedExpression(node); } } + function emitBodyIndirect(node, elements, emitCallback) { + if (emitBodyWithDetachedComments) { + emitBodyWithDetachedComments(node, elements, emitCallback); + } + else { + emitCallback(node); + } + } + function emitHelpersIndirect(node) { + if (onEmitHelpers) { + onEmitHelpers(node, writeLines); + } + } function emitNumericLiteral(node) { emitLiteral(node); if (node.trailingComment) { @@ -48193,7 +49417,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralTextOfNode(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) + if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } @@ -48280,7 +49504,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 151 ? "get " : "set "); + write(node.kind === 152 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -48380,17 +49604,13 @@ var ts; write("{"); writeLine(); increaseIndent(); - if (node.readonlyToken) { - write("readonly "); - } + writeIfPresent(node.readonlyToken, "readonly "); write("["); emit(node.typeParameter.name); write(" in "); emit(node.typeParameter.constraint); write("]"); - if (node.questionToken) { - write("?"); - } + writeIfPresent(node.questionToken, "?"); write(": "); emit(node.type); write(";"); @@ -48462,7 +49682,7 @@ var ts; var indentAfterDot = false; if (!(ts.getEmitFlags(node) & 65536)) { var dotRangeStart = node.expression.end; - var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; + var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; var dotToken = { kind: 22, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); @@ -48478,13 +49698,15 @@ var ts; function needsDotDotForPropertyAccess(expression) { if (expression.kind === 8) { var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(22)) < 0; + return ts.getNumericLiteralFlags(text, 15) === 0 + && !expression.isOctalLiteral + && text.indexOf(ts.tokenToString(22)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); return isFinite(constantValue) && Math.floor(constantValue) === constantValue - && compilerOptions.removeComments; + && printerOptions.removeComments; } } function emitElementAccessExpression(node) { @@ -48510,11 +49732,9 @@ var ts; emitExpression(node.template); } function emitTypeAssertionExpression(node) { - if (node.type) { - write("<"); - emit(node.type); - write(">"); - } + write("<"); + emit(node.type); + write(">"); emitExpression(node.expression); } function emitParenthesizedExpression(node) { @@ -48561,7 +49781,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 190 + return operand.kind === 191 && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } @@ -48645,6 +49865,9 @@ var ts; else { writeToken(16, node.pos, node); emitBlockStatements(node); + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); writeToken(17, node.statements.end, node); } } @@ -48678,7 +49901,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 209) { + if (node.elseStatement.kind === 210) { write(" "); emit(node.elseStatement); } @@ -48740,7 +49963,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 225) { + if (node.kind === 226) { emit(node); } else { @@ -48837,11 +50060,10 @@ var ts; emitBlockFunctionBody(body); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); emitSignatureHead(node); emitBlockFunctionBody(body); - tempFlags = savedTempFlags; + popNameGenerationScope(); } if (indentedFlag) { decreaseIndent(); @@ -48890,9 +50112,10 @@ var ts; function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) + var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine - : emitBlockFunctionBodyWorker); + : emitBlockFunctionBodyWorker; + emitBodyIndirect(body, body.statements, emitBlockFunctionBody); decreaseIndent(); writeToken(17, body.statements.end, body); } @@ -48901,8 +50124,9 @@ var ts; } function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) { var statementOffset = emitPrologueDirectives(body.statements, true); - var helpersEmitted = emitHelpers(body); - if (statementOffset === 0 && !helpersEmitted && emitBlockFunctionBodyOnSingleLine) { + var pos = writer.getTextPos(); + emitHelpersIndirect(body); + if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); emitList(body, body.statements, 384); increaseIndent(); @@ -48925,15 +50149,14 @@ var ts; } emitTypeParameters(node, node.typeParameters); emitList(node, node.heritageClauses, 256); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 65); write("}"); + popNameGenerationScope(); if (indentedFlag) { decreaseIndent(); } - tempFlags = savedTempFlags; } function emitInterfaceDeclaration(node) { emitDecorators(node, node.decorators); @@ -48960,19 +50183,18 @@ var ts; emitModifiers(node, node.modifiers); write("enum "); emit(node.name); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 81); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 231) { + while (body.kind === 232) { write("."); emit(body.name); body = body.body; @@ -48985,13 +50207,12 @@ var ts; write("{ }"); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write("{"); increaseIndent(); emitBlockStatements(node); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } } function emitCaseBlock(node) { @@ -49093,14 +50314,18 @@ var ts; write("<"); emitJsxTagName(node.tagName); write(" "); - emitList(node, node.attributes, 131328); + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write("/>"); } function emitJsxOpeningElement(node) { write("<"); emitJsxTagName(node.tagName); - writeIfAny(node.attributes, " "); - emitList(node, node.attributes, 131328); + writeIfAny(node.attributes.properties, " "); + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write(">"); } function emitJsxText(node) { @@ -49111,6 +50336,9 @@ var ts; emitJsxTagName(node.tagName); write(">"); } + function emitJsxAttributes(node) { + emitList(node, node.properties, 131328); + } function emitJsxAttribute(node) { emit(node.name); emitWithPrefix("=", node.initializer); @@ -49168,7 +50396,6 @@ var ts; emitList(node, node.types, 272); } function emitCatchClause(node) { - writeLine(); var openParenPos = writeToken(73, node.pos); write(" "); writeToken(18, openParenPos); @@ -49181,7 +50408,7 @@ var ts; emit(node.name); write(": "); var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512) === 0) { + if (emitTrailingCommentsOfPosition && (ts.getEmitFlags(initializer) & 512) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -49207,16 +50434,15 @@ var ts; function emitSourceFile(node) { writeLine(); emitShebang(); - emitBodyWithDetachedComments(node, node.statements, emitSourceFileWorker); + emitBodyIndirect(node, node.statements, emitSourceFileWorker); } function emitSourceFileWorker(node) { var statements = node.statements; var statementOffset = emitPrologueDirectives(statements); - var savedTempFlags = tempFlags; - tempFlags = 0; - emitHelpers(node); + pushNameGenerationScope(); + emitHelpersIndirect(node); emitList(node, statements, 1, statementOffset); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitPartiallyEmittedExpression(node) { emitExpression(node.expression); @@ -49235,67 +50461,8 @@ var ts; } return statements.length; } - function emitHelpers(node, isBundle) { - var sourceFile = ts.isSourceFile(node) ? node : currentSourceFile; - var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); - var shouldBundle = ts.isSourceFile(node) && !isOwnFileEmit; - var helpersEmitted = false; - var helpers = ts.getEmitHelpers(node); - if (helpers) { - for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { - var helper = _b[_a]; - if (!helper.scoped) { - if (shouldSkip) - continue; - if (shouldBundle) { - if (bundledHelpers[helper.name]) { - continue; - } - bundledHelpers[helper.name] = true; - } - } - else if (isBundle) { - continue; - } - writeLines(helper.text); - helpersEmitted = true; - } - } - if (helpersEmitted) { - writeLine(); - } - return helpersEmitted; - } - function writeLines(text) { - var lines = text.split(/\r\n?|\n/g); - var indentation = guessIndentation(lines); - for (var i = 0; i < lines.length; i++) { - var line = indentation ? lines[i].slice(indentation) : lines[i]; - if (line.length) { - if (i > 0) { - writeLine(); - } - write(line); - } - } - } - function guessIndentation(lines) { - var indentation; - for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { - var line = lines_1[_a]; - for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { - if (!ts.isWhiteSpace(line.charCodeAt(i))) { - if (indentation === undefined || i < indentation) { - indentation = i; - break; - } - } - } - } - return indentation; - } function emitShebang() { - var shebang = ts.getShebang(currentText); + var shebang = ts.getShebang(currentSourceFile.text); if (shebang) { write(shebang); writeLine(); @@ -49410,6 +50577,9 @@ var ts; for (var i = 0; i < count; i++) { var child = children[start + i]; if (previousSibling) { + if (delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } write(delimiter); if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { if ((format & (3 | 64)) === 0) { @@ -49424,8 +50594,10 @@ var ts; } } if (shouldEmitInterveningComments) { - var commentRange = ts.getCommentRange(child); - emitTrailingCommentsOfPosition(commentRange.pos); + if (emitTrailingCommentsOfPosition) { + var commentRange = ts.getCommentRange(child); + emitTrailingCommentsOfPosition(commentRange.pos); + } } else { shouldEmitInterveningComments = mayEmitInterveningComments; @@ -49441,6 +50613,9 @@ var ts; if (format & 16 && hasTrailingComma) { write(","); } + if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } if (format & 64) { decreaseIndent(); } @@ -49455,6 +50630,38 @@ var ts; write(getClosingBracket(format)); } } + function write(s) { + writer.write(s); + } + function writeLine() { + writer.writeLine(); + } + function increaseIndent() { + writer.increaseIndent(); + } + function decreaseIndent() { + writer.decreaseIndent(); + } + function writeIfAny(nodes, text) { + if (ts.some(nodes)) { + write(text); + } + } + function writeIfPresent(node, text) { + if (node) { + write(text); + } + } + function writeToken(token, pos, contextNode) { + return onEmitSourceMapOfToken + ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) + : writeTokenText(token, pos); + } + function writeTokenText(token, pos) { + var tokenString = ts.tokenToString(token); + write(tokenString); + return pos < 0 ? pos : pos + tokenString.length; + } function writeLineOrSpace(node) { if (ts.getEmitFlags(node) & 1) { write(" "); @@ -49463,23 +50670,32 @@ var ts; writeLine(); } } - function writeIfAny(nodes, text) { - if (nodes && nodes.length > 0) { - write(text); + function writeLines(text) { + var lines = text.split(/\r\n?|\n/g); + var indentation = guessIndentation(lines); + for (var i = 0; i < lines.length; i++) { + var line = indentation ? lines[i].slice(indentation) : lines[i]; + if (line.length) { + writeLine(); + write(line); + writeLine(); + } } } - function writeIfPresent(node, text) { - if (node !== undefined) { - write(text); + function guessIndentation(lines) { + var indentation; + for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { + var line = lines_1[_a]; + for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { + if (!ts.isWhiteSpace(line.charCodeAt(i))) { + if (indentation === undefined || i < indentation) { + indentation = i; + break; + } + } + } } - } - function writeToken(token, pos, contextNode) { - return emitTokenWithSourceMap(contextNode, token, pos, writeTokenText); - } - function writeTokenText(token, pos) { - var tokenString = ts.tokenToString(token); - write(tokenString); - return pos < 0 ? pos : pos + tokenString.length; + return indentation; } function increaseIndentIf(value, valueToWriteWhenNotIndenting) { if (value) { @@ -49585,15 +50801,23 @@ var ts; && !ts.nodeIsSynthesized(node2) && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } + function isSingleLineEmptyBlock(block) { + return !block.multiLine + && isEmptyBlock(block); + } + function isEmptyBlock(block) { + return block.statements.length === 0 + && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + } function skipSynthesizedParentheses(node) { - while (node.kind === 183 && ts.nodeIsSynthesized(node)) { + while (node.kind === 184 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; } function getTextOfNode(node, includeTrivia) { if (ts.isGeneratedIdentifier(node)) { - return getGeneratedIdentifier(node); + return generateName(node); } else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { return ts.unescapeIdentifier(node.text); @@ -49618,23 +50842,37 @@ var ts; } return ts.getLiteralText(node, currentSourceFile, languageVersion); } - function isSingleLineEmptyBlock(block) { - return !block.multiLine - && isEmptyBlock(block); + function pushNameGenerationScope() { + tempFlagsStack.push(tempFlags); + tempFlags = 0; } - function isEmptyBlock(block) { - return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + function popNameGenerationScope() { + tempFlags = tempFlagsStack.pop(); + } + function generateName(name) { + if (name.autoGenerateKind === 4) { + var node = getNodeForGeneratedName(name); + return generateNameCached(node); + } + else { + var autoGenerateId = name.autoGenerateId; + return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(makeName(name))); + } + } + function generateNameCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); } function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentFileIdentifiers, name) && - !ts.hasProperty(generatedNameSet, name); + return !(hasGlobalName && hasGlobalName(name)) + && !currentSourceFile.identifiers.has(name) + && !generatedNames.has(name); } function isUniqueLocalName(name, container) { for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { + if (node.locals) { + var local = node.locals.get(name); + if (local && local.flags & (107455 | 1048576 | 8388608)) { return false; } } @@ -49643,21 +50881,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_41 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_41)) { + var name = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name)) { tempFlags |= flags; - return name_41; + return name; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_42 = count < 26 + var name = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_42)) { - return name_42; + if (isUniqueName(name)) { + return name; } } } @@ -49670,7 +50908,8 @@ var ts; while (true) { var generatedName = baseName + i; if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; + generatedNames.set(generatedName, generatedName); + return generatedName; } i++; } @@ -49693,7 +50932,7 @@ var ts; } function generateNameForMethodOrAccessor(node) { if (ts.isIdentifier(node.name)) { - return generateNameForNodeCached(node.name); + return generateNameCached(node.name); } return makeTempVariableName(0); } @@ -49701,34 +50940,34 @@ var ts; switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); + case 232: case 231: - case 230: return generateNameForModuleOrEnum(node); - case 236: - case 242: + case 237: + case 243: return generateNameForImportOrExportDeclaration(node); - case 226: case 227: - case 241: + case 228: + case 242: return generateNameForExportDefault(); - case 197: + case 198: return generateNameForClassExpression(); - case 149: - case 151: + case 150: case 152: + case 153: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); } } - function generateName(name) { + function makeName(name) { switch (name.autoGenerateKind) { case 1: return makeTempVariableName(0); case 2: return makeTempVariableName(268435456); case 3: - return makeUniqueName(name.text); + return makeUniqueName(ts.unescapeIdentifier(name.text)); } ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } @@ -49747,47 +50986,33 @@ var ts; } return node; } - function generateNameForNodeCached(node) { - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); - } - function getGeneratedIdentifier(name) { - if (name.autoGenerateKind === 4) { - var node = getNodeForGeneratedName(name); - return generateNameForNodeCached(node); - } - else { - var autoGenerateId = name.autoGenerateId; - return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(generateName(name))); - } - } - function createDelimiterMap() { - var delimiters = []; - delimiters[0] = ""; - delimiters[16] = ","; - delimiters[4] = " |"; - delimiters[8] = " &"; - return delimiters; - } - function getDelimiter(format) { - return delimiters[format & 28]; - } - function createBracketsMap() { - var brackets = []; - brackets[512] = ["{", "}"]; - brackets[1024] = ["(", ")"]; - brackets[2048] = ["<", ">"]; - brackets[4096] = ["[", "]"]; - return brackets; - } - function getOpeningBracket(format) { - return brackets[format & 7680][0]; - } - function getClosingBracket(format) { - return brackets[format & 7680][1]; - } } - ts.emitFiles = emitFiles; + ts.createPrinter = createPrinter; + function createDelimiterMap() { + var delimiters = []; + delimiters[0] = ""; + delimiters[16] = ","; + delimiters[4] = " |"; + delimiters[8] = " &"; + return delimiters; + } + function getDelimiter(format) { + return delimiters[format & 28]; + } + function createBracketsMap() { + var brackets = []; + brackets[512] = ["{", "}"]; + brackets[1024] = ["(", ")"]; + brackets[2048] = ["<", ">"]; + brackets[4096] = ["[", "]"]; + return brackets; + } + function getOpeningBracket(format) { + return brackets[format & 7680][0]; + } + function getClosingBracket(format) { + return brackets[format & 7680][1]; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -49871,11 +51096,11 @@ var ts; return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; } function directoryExists(directoryPath) { - if (directoryPath in existingDirectories) { + if (existingDirectories.has(directoryPath)) { return true; } if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; + existingDirectories.set(directoryPath, true); return true; } return false; @@ -49894,9 +51119,10 @@ var ts; } var hash = ts.sys.createHash(data); var mtimeBefore = ts.sys.getModifiedTime(fileName); - if (mtimeBefore && fileName in outputFingerprints) { - var fingerprint = outputFingerprints[fileName]; - if (fingerprint.byteOrderMark === writeByteOrderMark && + if (mtimeBefore) { + var fingerprint = outputFingerprints.get(fileName); + if (fingerprint && + fingerprint.byteOrderMark === writeByteOrderMark && fingerprint.hash === hash && fingerprint.mtime.getTime() === mtimeBefore.getTime()) { return; @@ -49904,11 +51130,11 @@ var ts; } ts.sys.writeFile(fileName, data, writeByteOrderMark); var mtimeAfter = ts.sys.getModifiedTime(fileName); - outputFingerprints[fileName] = { + outputFingerprints.set(fileName, { hash: hash, byteOrderMark: writeByteOrderMark, mtime: mtimeAfter - }; + }); } function writeFile(fileName, data, writeByteOrderMark, onError) { try { @@ -50007,10 +51233,14 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_43 = names_1[_i]; - var result = name_43 in cache - ? cache[name_43] - : cache[name_43] = loader(name_43, containingFile); + var name = names_1[_i]; + var result = void 0; + if (cache.has(name)) { + result = cache.get(name); + } + else { + cache.set(name, result = loader(name, containingFile)); + } resolutions.push(result); } return resolutions; @@ -50119,7 +51349,7 @@ var ts; return program; function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); } @@ -50138,7 +51368,7 @@ var ts; classifiableNames = ts.createMap(); for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { var sourceFile = files_2[_i]; - ts.copyProperties(sourceFile.classifiableNames, classifiableNames); + ts.copyEntries(sourceFile.classifiableNames, classifiableNames); } } return classifiableNames; @@ -50321,7 +51551,7 @@ var ts; }; } function isSourceFileFromExternalLibrary(file) { - return sourceFilesFoundSearchingNodeModules[file.path]; + return sourceFilesFoundSearchingNodeModules.get(file.path); } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); @@ -50438,57 +51668,57 @@ var ts; return diagnostics; function walk(node) { switch (parent.kind) { - case 144: - case 147: + case 145: + case 148: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 184: - case 226: + case 153: case 185: - case 226: - case 224: + case 227: + case 186: + case 227: + case 225: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 235: + case 236: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 241: + case 242: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 256: + case 258: var heritageClause = node; if (heritageClause.token === 107) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 228: + case 229: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 231: + case 232: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 229: + case 230: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 230: + case 231: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 182: + case 183: var typeAssertionExpression = node; diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; @@ -50503,26 +51733,26 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 227: - case 149: - case 148: + case 228: case 150: + case 149: case 151: case 152: - case 184: - case 226: + case 153: case 185: - case 226: + case 227: + case 186: + case 227: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 206: + case 207: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 206); + return checkModifiers(nodes, parent.kind === 207); } break; - case 147: + case 148: if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; @@ -50533,15 +51763,15 @@ var ts; return; } break; - case 144: + case 145: if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 179: case 180: - case 199: + case 181: + case 200: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; @@ -50629,11 +51859,10 @@ var ts; if (options.importHelpers && (options.isolatedModules || isExternalModuleFile) && !file.isDeclarationFile) { - var externalHelpersModuleReference = ts.createSynthesizedNode(9); - externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(236); - importDecl.parent = file; + var externalHelpersModuleReference = ts.createLiteral(ts.externalHelpersModuleNameText); + var importDecl = ts.createImportDeclaration(undefined, undefined, undefined); externalHelpersModuleReference.parent = importDecl; + importDecl.parent = file; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -50649,9 +51878,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 237: case 236: - case 235: - case 242: + case 243: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -50663,7 +51892,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 231: + case 232: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -50747,18 +51976,18 @@ var ts; if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd); } - if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { - sourceFilesFoundSearchingNodeModules[file_1.path] = false; + if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth == 0) { + sourceFilesFoundSearchingNodeModules.set(file_1.path, false); if (!options.noResolve) { processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } - else if (file_1 && modulesWithElidedImports[file_1.path]) { + else if (file_1 && modulesWithElidedImports.get(file_1.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } } @@ -50774,7 +52003,7 @@ var ts; }); filesByName.set(path, file); if (file) { - sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0); + sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; if (host.useCaseSensitiveFileNames()) { var existingFile = filesByNameIgnoreCase.get(path); @@ -50818,7 +52047,7 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { - var previousResolution = resolvedTypeReferenceDirectives[typeReferenceDirective]; + var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { return; } @@ -50846,7 +52075,7 @@ var ts; fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { - resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective; + resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); } } function createDiagnostic(refFile, refPos, refEnd, message) { @@ -50887,7 +52116,7 @@ var ts; var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { - modulesWithElidedImports[file.path] = true; + modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = ts.toPath(resolvedFileName, currentDirectory, getCanonicalFileName); @@ -50905,8 +52134,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var file = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var file = sourceFiles_3[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -50917,8 +52146,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -51069,7 +52298,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { + ts.forEachEmittedFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -51182,12 +52411,13 @@ var ts; }, { name: "jsx", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "preserve": 1, + "react-native": 3, "react": 2 }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, }, { name: "reactNamespace", @@ -51217,7 +52447,7 @@ var ts; { name: "module", shortName: "m", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "none": ts.ModuleKind.None, "commonjs": ts.ModuleKind.CommonJS, "amd": ts.ModuleKind.AMD, @@ -51231,7 +52461,7 @@ var ts; }, { name: "newLine", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "crlf": 0, "lf": 1 }), @@ -51328,8 +52558,8 @@ var ts; shortName: "p", type: "string", isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY + description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY }, { name: "removeComments", @@ -51379,7 +52609,7 @@ var ts; { name: "target", shortName: "t", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "es3": 0, "es5": 1, "es6": 2, @@ -51416,7 +52646,7 @@ var ts; }, { name: "moduleResolution", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "node": ts.ModuleResolutionKind.NodeJs, "classic": ts.ModuleResolutionKind.Classic, }), @@ -51521,7 +52751,7 @@ var ts; type: "list", element: { name: "lib", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "es5": "lib.es5.d.ts", "es6": "lib.es2015.d.ts", "es2015": "lib.es2015.d.ts", @@ -51567,6 +52797,15 @@ var ts; name: "alwaysStrict", type: "boolean", description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + }, + { + name: "plugins", + type: "list", + isTSConfigOnly: true, + element: { + name: "plugin", + type: "object" + } } ]; ts.typeAcquisitionDeclarations = [ @@ -51621,9 +52860,9 @@ var ts; var optionNameMap = ts.createMap(); var shortOptionNames = ts.createMap(); ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; + optionNameMap.set(option.name.toLowerCase(), option); if (option.shortName) { - shortOptionNames[option.shortName] = option.name; + shortOptionNames.set(option.shortName, option.name); } }); optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; @@ -51631,7 +52870,7 @@ var ts; } ts.getOptionNameMap = getOptionNameMap; function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -51680,11 +52919,12 @@ var ts; } else if (s.charCodeAt(0) === 45) { s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); - if (s in shortOptionNames) { - s = shortOptionNames[s]; + var short = shortOptionNames.get(s); + if (short !== undefined) { + s = short; } - if (s in optionNameMap) { - var opt = optionNameMap[s]; + var opt = optionNameMap.get(s); + if (opt) { if (opt.isTSConfigOnly) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } @@ -51810,19 +53050,18 @@ var ts; } } function getNameOfCompilerOptionValue(value, customTypeMap) { - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { return key; } - } - return undefined; + }); } function serializeCompilerOptions(options) { - var result = ts.createMap(); + var result = {}; var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_44 in options) { - if (ts.hasProperty(options, name_44)) { - switch (name_44) { + for (var name in options) { + if (ts.hasProperty(options, name)) { + switch (name) { case "init": case "watch": case "version": @@ -51830,12 +53069,12 @@ var ts; case "project": break; default: - var value = options[name_44]; - var optionDefinition = optionsNameMap[name_44.toLowerCase()]; + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { - result[name_44] = value; + result[name] = value; } else { if (optionDefinition.type === "list") { @@ -51844,10 +53083,10 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_44] = convertedValue; + result[name] = convertedValue; } else { - result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -52054,8 +53293,8 @@ var ts; } var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; + var opt = optionNameMap.get(id); + if (opt) { defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); } else { @@ -52089,8 +53328,9 @@ var ts; } function convertJsonOptionOfCustomType(opt, value, errors) { var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; + var val = opt.type.get(key); + if (val !== undefined) { + return val; } else { errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); @@ -52124,7 +53364,7 @@ var ts; for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { var fileName = fileNames_1[_i]; var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; + literalFileMap.set(keyMapper(file), file); } } if (include && include.length > 0) { @@ -52135,14 +53375,13 @@ var ts; } removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; + if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) { + wildcardFileMap.set(key, file); } } } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); + var literalFiles = ts.arrayFrom(literalFileMap.values()); + var wildcardFiles = ts.arrayFrom(wildcardFileMap.values()); return { fileNames: literalFiles.concat(wildcardFiles), wildcardDirectories: wildcardDirectories @@ -52150,8 +53389,8 @@ var ts; } function validateSpecs(specs, errors, allowTrailingRecursion) { var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + var spec = specs_1[_i]; if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); } @@ -52170,7 +53409,7 @@ var ts; function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); + var wildcardDirectories = {}; if (include !== undefined) { var recursiveKeys = []; for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { @@ -52191,14 +53430,16 @@ var ts; } } } - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; + for (var key in wildcardDirectories) + if (ts.hasProperty(wildcardDirectories, key)) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } } } - } + ; } return wildcardDirectories; } @@ -52217,11 +53458,11 @@ var ts; } function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); + var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions); for (var i = 0; i < adjustedExtensionPriority; i++) { var higherPriorityExtension = extensions[i]; var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { return true; } } @@ -52229,17 +53470,13 @@ var ts; } function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions); for (var i = nextExtensionPriority; i < extensions.length; i++) { var lowerPriorityExtension = extensions[i]; var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; + wildcardFiles.delete(lowerPriorityPath); } } - function addFileToOutput(output, file) { - output.push(file); - return output; - } function caseSensitiveKeyMapper(key) { return key; } @@ -52300,11 +53537,13 @@ var ts; var gutterSeparator = " "; var resetEscapeSequence = "\u001b[0m"; var ellipsis = "..."; - var categoryFormatMap = ts.createMap((_a = {}, - _a[ts.DiagnosticCategory.Warning] = yellowForegroundEscapeSequence, - _a[ts.DiagnosticCategory.Error] = redForegroundEscapeSequence, - _a[ts.DiagnosticCategory.Message] = blueForegroundEscapeSequence, - _a)); + function getCategoryFormat(category) { + switch (category) { + case ts.DiagnosticCategory.Warning: return yellowForegroundEscapeSequence; + case ts.DiagnosticCategory.Error: return redForegroundEscapeSequence; + case ts.DiagnosticCategory.Message: return blueForegroundEscapeSequence; + } + } function formatAndReset(text, formatStyle) { return formatStyle + text + resetEscapeSequence; } @@ -52353,7 +53592,7 @@ var ts; output += ts.sys.newLine; output += relativeFileName + "(" + (firstLine + 1) + "," + (firstLineChar + 1) + "): "; } - var categoryColor = categoryFormatMap[diagnostic.category]; + var categoryColor = getCategoryFormat(diagnostic.category); var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); output += formatAndReset(category, categoryColor) + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine); output += ts.sys.newLine + ts.sys.newLine; @@ -52365,7 +53604,7 @@ var ts; var loc = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); output += diagnostic.file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + "): "; } - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + ts.sys.newLine; + output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + (ts.sys.newLine + ts.sys.newLine + ts.sys.newLine); ts.sys.write(output); } function padLeft(s, length) { @@ -52544,9 +53783,11 @@ var ts; reportWatchDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Compilation_complete_Watching_for_file_changes)); } function cachedFileExists(fileName) { - return fileName in cachedExistingFiles - ? cachedExistingFiles[fileName] - : cachedExistingFiles[fileName] = hostFileExists(fileName); + var fileExists = cachedExistingFiles.get(fileName); + if (fileExists === undefined) { + cachedExistingFiles.set(fileName, fileExists = hostFileExists(fileName)); + } + return fileExists; } function getSourceFile(fileName, languageVersion, onError) { if (cachedProgram) { @@ -52698,17 +53939,17 @@ var ts; var nameSize = 0; var valueSize = 0; for (var _i = 0, statistics_1 = statistics; _i < statistics_1.length; _i++) { - var _a = statistics_1[_i], name_45 = _a.name, value = _a.value; - if (name_45.length > nameSize) { - nameSize = name_45.length; + var _a = statistics_1[_i], name = _a.name, value = _a.value; + if (name.length > nameSize) { + nameSize = name.length; } if (value.length > valueSize) { valueSize = value.length; } } for (var _b = 0, statistics_2 = statistics; _b < statistics_2.length; _b++) { - var _c = statistics_2[_b], name_46 = _c.name, value = _c.value; - ts.sys.write(padRight(name_46 + ":", nameSize + 2) + padLeft(value.toString(), valueSize) + ts.sys.newLine); + var _c = statistics_2[_b], name = _c.name, value = _c.value; + ts.sys.write(padRight(name + ":", nameSize + 2) + padLeft(value.toString(), valueSize) + ts.sys.newLine); } } function reportStatisticalValue(name, value) { @@ -52762,13 +54003,9 @@ var ts; var description = void 0; if (option.name === "lib") { description = getDiagnosticText(option.description); - var options = []; var element = option.element; var typeMap = element.type; - for (var key in typeMap) { - options.push("'" + key + "'"); - } - optionsDescriptionMap[description] = options; + optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; })); } else { description = getDiagnosticText(option.description); @@ -52783,7 +54020,7 @@ var ts; for (var i = 0; i < usageColumn.length; i++) { var usage = usageColumn[i]; var description = descriptionColumn[i]; - var kindsList = optionsDescriptionMap[description]; + var kindsList = optionsDescriptionMap.get(description); output.push(usage + makePadding(marginLength - usage.length + 2) + description + ts.sys.newLine); if (kindsList) { output.push(makePadding(marginLength + 4)); @@ -52821,7 +54058,6 @@ var ts; } return; } - var _a; })(ts || (ts = {})); if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) { ts.sys.tryEnableSourceMapsForHost(); diff --git a/lib/tsserver.js b/lib/tsserver.js index 10cfa276fec..04ad7e50ce9 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -25,6 +25,428 @@ var __extends = (this && this.__extends) || (function () { })(); var ts; (function (ts) { + var SyntaxKind; + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 126] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 127] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 128] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 129] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 130] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 131] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 132] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 133] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 134] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 135] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 136] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 137] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 138] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 139] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 140] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 141] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 142] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 143] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 144] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 145] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 146] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 147] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 148] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 149] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 150] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 151] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 152] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 153] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 154] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 155] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 156] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 157] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 158] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 159] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 160] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 161] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 162] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 163] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 164] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 165] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 166] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 167] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 168] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 169] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 170] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 171] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 172] = "LiteralType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 173] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 174] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 175] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 176] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 177] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 178] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 179] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 180] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 181] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 182] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 183] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 184] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 185] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 186] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 187] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 188] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 189] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 190] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 191] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 192] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 193] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 194] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 195] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 196] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 197] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 198] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 199] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 200] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 201] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 202] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 203] = "MetaProperty"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 204] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 205] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 206] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 207] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 208] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 209] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 210] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 211] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 212] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 213] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 214] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 215] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 216] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 217] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 218] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 219] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 220] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 221] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 222] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 223] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 224] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 225] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 226] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 227] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 228] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 229] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 230] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 231] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 232] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 233] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 234] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 235] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 236] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 237] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 238] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 239] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 240] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 241] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 242] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 243] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 244] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 245] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 246] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 247] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 248] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 249] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 250] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 251] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 252] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 253] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 254] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 255] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 256] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 257] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 258] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 259] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 260] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 261] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 262] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 263] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 264] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 265] = "Bundle"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 266] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 267] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 268] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 269] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 270] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 271] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 272] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 273] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 274] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 275] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 276] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 277] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 278] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 279] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 280] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 281] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 282] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 283] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 284] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 285] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 286] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 287] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 288] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 289] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 290] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 291] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 292] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 293] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 294] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 295] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["SyntaxList"] = 296] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 297] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 298] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 299] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 300] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["Count"] = 301] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 141] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 157] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 172] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 141] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 142] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 266] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 295] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 282] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 295] = "LastJSDocTagNode"; + })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); + var NodeFlags; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Let"] = 1] = "Let"; + NodeFlags[NodeFlags["Const"] = 2] = "Const"; + NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; + NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; + NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 96256] = "ContextFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; + })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); + var ModifierFlags; + (function (ModifierFlags) { + ModifierFlags[ModifierFlags["None"] = 0] = "None"; + ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; + ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; + ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; + ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; + ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; + ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; + ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; + ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; + ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; + ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; + ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; + ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault"; + })(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {})); + var JsxFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(JsxFlags = ts.JsxFlags || (ts.JsxFlags = {})); + var RelationComparisonResult; + (function (RelationComparisonResult) { + RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; + RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; + RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); + var GeneratedIdentifierKind; + (function (GeneratedIdentifierKind) { + GeneratedIdentifierKind[GeneratedIdentifierKind["None"] = 0] = "None"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Auto"] = 1] = "Auto"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Loop"] = 2] = "Loop"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; + })(GeneratedIdentifierKind = ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var FlowFlags; + (function (FlowFlags) { + FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; + FlowFlags[FlowFlags["Start"] = 2] = "Start"; + FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; + FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; + FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; + FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; + FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; + FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; + FlowFlags[FlowFlags["Label"] = 12] = "Label"; + FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; + })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -37,6 +459,45 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var TypeFormatFlags; + (function (TypeFormatFlags) { + TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; + TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; + TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; + TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; + TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; + TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; + TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; + TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; + TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 2048] = "SuppressAnyReturnType"; + TypeFormatFlags[TypeFormatFlags["AddUndefined"] = 4096] = "AddUndefined"; + })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var SymbolFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(SymbolFormatFlags = ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolAccessibility; + (function (SymbolAccessibility) { + SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; + SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; + SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; + })(SymbolAccessibility = ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + var SyntheticSymbolKind; + (function (SyntheticSymbolKind) { + SyntheticSymbolKind[SyntheticSymbolKind["UnionOrIntersection"] = 0] = "UnionOrIntersection"; + SyntheticSymbolKind[SyntheticSymbolKind["Spread"] = 1] = "Spread"; + })(SyntheticSymbolKind = ts.SyntheticSymbolKind || (ts.SyntheticSymbolKind = {})); + var TypePredicateKind; + (function (TypePredicateKind) { + TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; + TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; @@ -51,6 +512,189 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var SymbolFlags; + (function (SymbolFlags) { + SymbolFlags[SymbolFlags["None"] = 0] = "None"; + SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; + SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; + SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; + SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; + SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; + SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; + SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; + SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; + SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; + SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; + SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; + SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; + SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; + SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; + SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; + SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; + SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; + SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; + SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; + SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; + SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; + SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; + SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; + SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; + SymbolFlags[SymbolFlags["Prototype"] = 16777216] = "Prototype"; + SymbolFlags[SymbolFlags["ExportStar"] = 33554432] = "ExportStar"; + SymbolFlags[SymbolFlags["Optional"] = 67108864] = "Optional"; + SymbolFlags[SymbolFlags["Transient"] = 134217728] = "Transient"; + SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; + SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; + SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; + SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; + SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; + SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; + SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; + SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; + SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; + SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; + SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; + })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); + var CheckFlags; + (function (CheckFlags) { + CheckFlags[CheckFlags["Instantiated"] = 1] = "Instantiated"; + CheckFlags[CheckFlags["SyntheticProperty"] = 2] = "SyntheticProperty"; + CheckFlags[CheckFlags["Readonly"] = 4] = "Readonly"; + CheckFlags[CheckFlags["Partial"] = 8] = "Partial"; + CheckFlags[CheckFlags["HasNonUniformType"] = 16] = "HasNonUniformType"; + CheckFlags[CheckFlags["ContainsPublic"] = 32] = "ContainsPublic"; + CheckFlags[CheckFlags["ContainsProtected"] = 64] = "ContainsProtected"; + CheckFlags[CheckFlags["ContainsPrivate"] = 128] = "ContainsPrivate"; + CheckFlags[CheckFlags["ContainsStatic"] = 256] = "ContainsStatic"; + })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); + var NodeCheckFlags; + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["CaptureNewTarget"] = 8] = "CaptureNewTarget"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; + NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; + NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; + NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; + })(NodeCheckFlags = ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var TypeFlags; + (function (TypeFlags) { + TypeFlags[TypeFlags["Any"] = 1] = "Any"; + TypeFlags[TypeFlags["String"] = 2] = "String"; + TypeFlags[TypeFlags["Number"] = 4] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; + TypeFlags[TypeFlags["Void"] = 1024] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 4096] = "Null"; + TypeFlags[TypeFlags["Never"] = 8192] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; + TypeFlags[TypeFlags["Object"] = 32768] = "Object"; + TypeFlags[TypeFlags["Union"] = 65536] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 131072] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 262144] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 524288] = "IndexedAccess"; + TypeFlags[TypeFlags["FreshLiteral"] = 1048576] = "FreshLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 2097152] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; + TypeFlags[TypeFlags["JsxAttributes"] = 33554432] = "JsxAttributes"; + TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; + TypeFlags[TypeFlags["Intrinsic"] = 16793231] = "Intrinsic"; + TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 262178] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 196608] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 229376] = "StructuredType"; + TypeFlags[TypeFlags["StructuredOrTypeVariable"] = 1032192] = "StructuredOrTypeVariable"; + TypeFlags[TypeFlags["TypeVariable"] = 540672] = "TypeVariable"; + TypeFlags[TypeFlags["Narrowable"] = 17810431] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 16810497] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; + TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; + })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); + var ObjectFlags; + (function (ObjectFlags) { + ObjectFlags[ObjectFlags["Class"] = 1] = "Class"; + ObjectFlags[ObjectFlags["Interface"] = 2] = "Interface"; + ObjectFlags[ObjectFlags["Reference"] = 4] = "Reference"; + ObjectFlags[ObjectFlags["Tuple"] = 8] = "Tuple"; + ObjectFlags[ObjectFlags["Anonymous"] = 16] = "Anonymous"; + ObjectFlags[ObjectFlags["Mapped"] = 32] = "Mapped"; + ObjectFlags[ObjectFlags["Instantiated"] = 64] = "Instantiated"; + ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; + ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; + ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; + ObjectFlags[ObjectFlags["NonPrimitive"] = 1024] = "NonPrimitive"; + ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; + })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); + var SignatureKind; + (function (SignatureKind) { + SignatureKind[SignatureKind["Call"] = 0] = "Call"; + SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; + })(SignatureKind = ts.SignatureKind || (ts.SignatureKind = {})); + var IndexKind; + (function (IndexKind) { + IndexKind[IndexKind["String"] = 0] = "String"; + IndexKind[IndexKind["Number"] = 1] = "Number"; + })(IndexKind = ts.IndexKind || (ts.IndexKind = {})); + var SpecialPropertyAssignmentKind; + (function (SpecialPropertyAssignmentKind) { + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + })(SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); var DiagnosticCategory; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; @@ -71,6 +715,179 @@ var ts; ModuleKind[ModuleKind["System"] = 4] = "System"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); + var JsxEmit; + (function (JsxEmit) { + JsxEmit[JsxEmit["None"] = 0] = "None"; + JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; + JsxEmit[JsxEmit["React"] = 2] = "React"; + JsxEmit[JsxEmit["ReactNative"] = 3] = "ReactNative"; + })(JsxEmit = ts.JsxEmit || (ts.JsxEmit = {})); + var NewLineKind; + (function (NewLineKind) { + NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; + NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; + })(NewLineKind = ts.NewLineKind || (ts.NewLineKind = {})); + var ScriptKind; + (function (ScriptKind) { + ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; + ScriptKind[ScriptKind["JS"] = 1] = "JS"; + ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; + ScriptKind[ScriptKind["TS"] = 3] = "TS"; + ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + ScriptKind[ScriptKind["External"] = 5] = "External"; + })(ScriptKind = ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptTarget; + (function (ScriptTarget) { + ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; + ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; + ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["ESNext"] = 5] = "ESNext"; + ScriptTarget[ScriptTarget["Latest"] = 5] = "Latest"; + })(ScriptTarget = ts.ScriptTarget || (ts.ScriptTarget = {})); + var LanguageVariant; + (function (LanguageVariant) { + LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; + LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; + })(LanguageVariant = ts.LanguageVariant || (ts.LanguageVariant = {})); + var DiagnosticStyle; + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(DiagnosticStyle = ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var WatchDirectoryFlags; + (function (WatchDirectoryFlags) { + WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; + WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; + })(WatchDirectoryFlags = ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); + var CharacterCodes; + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; + CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; + CharacterCodes[CharacterCodes["space"] = 32] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; + CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; + CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; + CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; + CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; + CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; + CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; + CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["j"] = 106] = "j"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["B"] = 66] = "B"; + CharacterCodes[CharacterCodes["C"] = 67] = "C"; + CharacterCodes[CharacterCodes["D"] = 68] = "D"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["G"] = 71] = "G"; + CharacterCodes[CharacterCodes["H"] = 72] = "H"; + CharacterCodes[CharacterCodes["I"] = 73] = "I"; + CharacterCodes[CharacterCodes["J"] = 74] = "J"; + CharacterCodes[CharacterCodes["K"] = 75] = "K"; + CharacterCodes[CharacterCodes["L"] = 76] = "L"; + CharacterCodes[CharacterCodes["M"] = 77] = "M"; + CharacterCodes[CharacterCodes["N"] = 78] = "N"; + CharacterCodes[CharacterCodes["O"] = 79] = "O"; + CharacterCodes[CharacterCodes["P"] = 80] = "P"; + CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; + CharacterCodes[CharacterCodes["R"] = 82] = "R"; + CharacterCodes[CharacterCodes["S"] = 83] = "S"; + CharacterCodes[CharacterCodes["T"] = 84] = "T"; + CharacterCodes[CharacterCodes["U"] = 85] = "U"; + CharacterCodes[CharacterCodes["V"] = 86] = "V"; + CharacterCodes[CharacterCodes["W"] = 87] = "W"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(CharacterCodes = ts.CharacterCodes || (ts.CharacterCodes = {})); var Extension; (function (Extension) { Extension[Extension["Ts"] = 0] = "Ts"; @@ -80,6 +897,111 @@ var ts; Extension[Extension["Jsx"] = 4] = "Jsx"; Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension"; })(Extension = ts.Extension || (ts.Extension = {})); + var TransformFlags; + (function (TransformFlags) { + TransformFlags[TransformFlags["None"] = 0] = "None"; + TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; + TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; + TransformFlags[TransformFlags["ContainsJsx"] = 4] = "ContainsJsx"; + TransformFlags[TransformFlags["ContainsESNext"] = 8] = "ContainsESNext"; + TransformFlags[TransformFlags["ContainsES2017"] = 16] = "ContainsES2017"; + TransformFlags[TransformFlags["ContainsES2016"] = 32] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 64] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 128] = "ContainsES2015"; + TransformFlags[TransformFlags["Generator"] = 256] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 512] = "ContainsGenerator"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 2048] = "ContainsDestructuringAssignment"; + TransformFlags[TransformFlags["ContainsDecorators"] = 4096] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 8192] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 16384] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 32768] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 65536] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 131072] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 262144] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpread"] = 524288] = "ContainsSpread"; + TransformFlags[TransformFlags["ContainsObjectSpread"] = 1048576] = "ContainsObjectSpread"; + TransformFlags[TransformFlags["ContainsRest"] = 524288] = "ContainsRest"; + TransformFlags[TransformFlags["ContainsObjectRest"] = 1048576] = "ContainsObjectRest"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; + TransformFlags[TransformFlags["AssertJsx"] = 4] = "AssertJsx"; + TransformFlags[TransformFlags["AssertESNext"] = 8] = "AssertESNext"; + TransformFlags[TransformFlags["AssertES2017"] = 16] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 32] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 192] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 768] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 3072] = "AssertDestructuringAssignment"; + TransformFlags[TransformFlags["NodeExcludes"] = 536872257] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 601249089] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 601281857] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 601015617] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 601015617] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539358529] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574674241] = "ModuleExcludes"; + TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 540087617] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537396545] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 546309441] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 536872257] = "ParameterExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = 537920833] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = 537396545] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 274432] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 163840] = "ES2015FunctionSyntaxMask"; + })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); + var EmitFlags; + (function (EmitFlags) { + EmitFlags[EmitFlags["SingleLine"] = 1] = "SingleLine"; + EmitFlags[EmitFlags["AdviseOnEmitNode"] = 2] = "AdviseOnEmitNode"; + EmitFlags[EmitFlags["NoSubstitution"] = 4] = "NoSubstitution"; + EmitFlags[EmitFlags["CapturesThis"] = 8] = "CapturesThis"; + EmitFlags[EmitFlags["NoLeadingSourceMap"] = 16] = "NoLeadingSourceMap"; + EmitFlags[EmitFlags["NoTrailingSourceMap"] = 32] = "NoTrailingSourceMap"; + EmitFlags[EmitFlags["NoSourceMap"] = 48] = "NoSourceMap"; + EmitFlags[EmitFlags["NoNestedSourceMaps"] = 64] = "NoNestedSourceMaps"; + EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 128] = "NoTokenLeadingSourceMaps"; + EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 256] = "NoTokenTrailingSourceMaps"; + EmitFlags[EmitFlags["NoTokenSourceMaps"] = 384] = "NoTokenSourceMaps"; + EmitFlags[EmitFlags["NoLeadingComments"] = 512] = "NoLeadingComments"; + EmitFlags[EmitFlags["NoTrailingComments"] = 1024] = "NoTrailingComments"; + EmitFlags[EmitFlags["NoComments"] = 1536] = "NoComments"; + EmitFlags[EmitFlags["NoNestedComments"] = 2048] = "NoNestedComments"; + EmitFlags[EmitFlags["HelperName"] = 4096] = "HelperName"; + EmitFlags[EmitFlags["ExportName"] = 8192] = "ExportName"; + EmitFlags[EmitFlags["LocalName"] = 16384] = "LocalName"; + EmitFlags[EmitFlags["Indented"] = 32768] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 65536] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 131072] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 262144] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 524288] = "CustomPrologue"; + EmitFlags[EmitFlags["NoHoisting"] = 1048576] = "NoHoisting"; + EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 2097152] = "HasEndOfDeclarationMarker"; + })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); + var ExternalEmitHelpers; + (function (ExternalEmitHelpers) { + ExternalEmitHelpers[ExternalEmitHelpers["Extends"] = 1] = "Extends"; + ExternalEmitHelpers[ExternalEmitHelpers["Assign"] = 2] = "Assign"; + ExternalEmitHelpers[ExternalEmitHelpers["Rest"] = 4] = "Rest"; + ExternalEmitHelpers[ExternalEmitHelpers["Decorate"] = 8] = "Decorate"; + ExternalEmitHelpers[ExternalEmitHelpers["Metadata"] = 16] = "Metadata"; + ExternalEmitHelpers[ExternalEmitHelpers["Param"] = 32] = "Param"; + ExternalEmitHelpers[ExternalEmitHelpers["Awaiter"] = 64] = "Awaiter"; + ExternalEmitHelpers[ExternalEmitHelpers["Generator"] = 128] = "Generator"; + ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; + ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 128] = "LastEmitHelper"; + })(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {})); + var EmitHint; + (function (EmitHint) { + EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile"; + EmitHint[EmitHint["Expression"] = 1] = "Expression"; + EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; + EmitHint[EmitHint["Unspecified"] = 3] = "Unspecified"; + })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -98,32 +1020,32 @@ var ts; var measures; function mark(markName) { if (enabled) { - marks[markName] = ts.timestamp(); - counts[markName] = (counts[markName] || 0) + 1; + marks.set(markName, ts.timestamp()); + counts.set(markName, (counts.get(markName) || 0) + 1); profilerEvent(markName); } } performance.mark = mark; function measure(measureName, startMarkName, endMarkName) { if (enabled) { - var end = endMarkName && marks[endMarkName] || ts.timestamp(); - var start = startMarkName && marks[startMarkName] || profilerStart; - measures[measureName] = (measures[measureName] || 0) + (end - start); + var end = endMarkName && marks.get(endMarkName) || ts.timestamp(); + var start = startMarkName && marks.get(startMarkName) || profilerStart; + measures.set(measureName, (measures.get(measureName) || 0) + (end - start)); } } performance.measure = measure; function getCount(markName) { - return counts && counts[markName] || 0; + return counts && counts.get(markName) || 0; } performance.getCount = getCount; function getDuration(measureName) { - return measures && measures[measureName] || 0; + return measures && measures.get(measureName) || 0; } performance.getDuration = getDuration; function forEachMeasure(cb) { - for (var key in measures) { - cb(key, measures[key]); - } + measures.forEach(function (measure, key) { + cb(key, measure); + }); } performance.forEachMeasure = forEachMeasure; function enable() { @@ -142,22 +1064,102 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.2.0"; + ts.version = "2.3.0"; })(ts || (ts = {})); (function (ts) { - var createObject = Object.create; - ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - function createMap(template) { - var map = createObject(null); + var Ternary; + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(Ternary = ts.Ternary || (ts.Ternary = {})); + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(undefined, { usage: "sort", sensitivity: "accent" }) : undefined; + ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + function createDictionaryObject() { + var map = Object.create(null); map["__"] = undefined; delete map["__"]; + return map; + } + function createMap() { + return new MapCtr(); + } + ts.createMap = createMap; + function createMapFromTemplate(template) { + var map = new MapCtr(); for (var key in template) if (hasOwnProperty.call(template, key)) { - map[key] = template[key]; + map.set(key, template[key]); } return map; } - ts.createMap = createMap; + ts.createMapFromTemplate = createMapFromTemplate; + var MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); + function shimMap() { + var MapIterator = (function () { + function MapIterator(data, selector) { + this.index = 0; + this.data = data; + this.selector = selector; + this.keys = Object.keys(data); + } + MapIterator.prototype.next = function () { + var index = this.index; + if (index < this.keys.length) { + this.index++; + return { value: this.selector(this.data, this.keys[index]), done: false }; + } + return { value: undefined, done: true }; + }; + return MapIterator; + }()); + return (function () { + function class_1() { + this.data = createDictionaryObject(); + this.size = 0; + } + class_1.prototype.get = function (key) { + return this.data[key]; + }; + class_1.prototype.set = function (key, value) { + if (!this.has(key)) { + this.size++; + } + this.data[key] = value; + return this; + }; + class_1.prototype.has = function (key) { + return key in this.data; + }; + class_1.prototype.delete = function (key) { + if (this.has(key)) { + this.size--; + delete this.data[key]; + return true; + } + return false; + }; + class_1.prototype.clear = function () { + this.data = createDictionaryObject(); + this.size = 0; + }; + class_1.prototype.keys = function () { + return new MapIterator(this.data, function (_data, key) { return key; }); + }; + class_1.prototype.values = function () { + return new MapIterator(this.data, function (data, key) { return data[key]; }); + }; + class_1.prototype.entries = function () { + return new MapIterator(this.data, function (data, key) { return [key, data[key]]; }); + }; + class_1.prototype.forEach = function (action) { + for (var key in this.data) { + action(this.data[key], key); + } + }; + return class_1; + }()); + } function createFileMap(keyMapper) { var files = createMap(); return { @@ -170,32 +1172,27 @@ var ts; clear: clear, }; function forEachValueInMap(f) { - for (var key in files) { - f(key, files[key]); - } + files.forEach(function (file, key) { + f(key, file); + }); } function getKeys() { - var keys = []; - for (var key in files) { - keys.push(key); - } - return keys; + return arrayFrom(files.keys()); } function get(path) { - return files[toKey(path)]; + return files.get(toKey(path)); } function set(path, value) { - files[toKey(path)] = value; + files.set(toKey(path), value); } function contains(path) { - return toKey(path) in files; + return files.has(toKey(path)); } function remove(path) { - var key = toKey(path); - delete files[key]; + files.delete(toKey(path)); } function clear() { - files = createMap(); + files.clear(); } function toKey(path) { return keyMapper ? keyMapper(path) : path; @@ -209,6 +1206,16 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + var Comparison; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(Comparison = ts.Comparison || (ts.Comparison = {})); + function length(array) { + return array ? array.length : 0; + } + ts.length = length; function forEach(array, callback) { if (array) { for (var i = 0; i < array.length; i++) { @@ -249,6 +1256,15 @@ var ts; return undefined; } ts.find = find; + function findIndex(array, predicate) { + for (var i = 0; i < array.length; i++) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; + } + ts.findIndex = findIndex; function findMap(array, callback) { for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); @@ -470,21 +1486,18 @@ var ts; return result; } ts.spanMap = spanMap; - function mapObject(object, f) { - var result; - if (object) { - result = {}; - for (var _i = 0, _a = getOwnKeys(object); _i < _a.length; _i++) { - var v = _a[_i]; - var _b = f(v, object[v]) || [undefined, undefined], key = _b[0], value = _b[1]; - if (key !== undefined) { - result[key] = value; - } - } + function mapEntries(map, f) { + if (!map) { + return undefined; } + var result = createMap(); + map.forEach(function (value, key) { + var _a = f(key, value), newKey = _a[0], newValue = _a[1]; + result.set(newKey, newValue); + }); return result; } - ts.mapObject = mapObject; + ts.mapEntries = mapEntries; function some(array, predicate) { if (array) { if (predicate) { @@ -768,38 +1781,55 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - function forEachProperty(map, callback) { - var result; - for (var key in map) { - if (result = callback(map[key], key)) - break; + function arrayFrom(iterator) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(value); } return result; + var _b; } - ts.forEachProperty = forEachProperty; - function someProperties(map, predicate) { - for (var key in map) { - if (!predicate || predicate(map[key], key)) - return true; + ts.arrayFrom = arrayFrom; + function convertToArray(iterator, f) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(f(value)); } - return false; + return result; + var _b; } - ts.someProperties = someProperties; - function copyProperties(source, target) { - for (var key in source) { - target[key] = source[key]; + ts.convertToArray = convertToArray; + function forEachEntry(map, callback) { + var iterator = map.entries(); + for (var _a = iterator.next(), pair = _a.value, done = _a.done; !done; _b = iterator.next(), pair = _b.value, done = _b.done, _b) { + var key = pair[0], value = pair[1]; + var result = callback(value, key); + if (result) { + return result; + } } + return undefined; + var _b; } - ts.copyProperties = copyProperties; - function appendProperty(map, key, value) { - if (key === undefined || value === undefined) - return map; - if (map === undefined) - map = createMap(); - map[key] = value; - return map; + ts.forEachEntry = forEachEntry; + function forEachKey(map, callback) { + var iterator = map.keys(); + for (var _a = iterator.next(), key = _a.value, done = _a.done; !done; _b = iterator.next(), key = _b.value, done = _b.done, _b) { + var result = callback(key); + if (result) { + return result; + } + } + return undefined; + var _b; } - ts.appendProperty = appendProperty; + ts.forEachKey = forEachKey; + function copyEntries(source, target) { + source.forEach(function (value, key) { + target.set(key, value); + }); + } + ts.copyEntries = copyEntries; function assign(t) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -815,14 +1845,6 @@ var ts; return t; } ts.assign = assign; - function reduceProperties(map, callback, initial) { - var result = initial; - for (var key in map) { - result = callback(result, map[key], String(key)); - } - return result; - } - ts.reduceProperties = reduceProperties; function equalOwnProperties(left, right, equalityComparer) { if (left === right) return true; @@ -847,23 +1869,14 @@ var ts; var result = createMap(); for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { var value = array_8[_i]; - result[makeKey(value)] = makeValue ? makeValue(value) : value; + result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; } ts.arrayToMap = arrayToMap; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; function cloneMap(map) { var clone = createMap(); - copyProperties(map, clone); + copyEntries(map, clone); return clone; } ts.cloneMap = cloneMap; @@ -890,27 +1903,32 @@ var ts; return result; } ts.extend = extend; - function multiMapAdd(map, key, value) { - var values = map[key]; + function createMultiMap() { + var map = createMap(); + map.add = multiMapAdd; + map.remove = multiMapRemove; + return map; + } + ts.createMultiMap = createMultiMap; + function multiMapAdd(key, value) { + var values = this.get(key); if (values) { values.push(value); - return values; } else { - return map[key] = [value]; + this.set(key, values = [value]); } + return values; } - ts.multiMapAdd = multiMapAdd; - function multiMapRemove(map, key, value) { - var values = map[key]; + function multiMapRemove(key, value) { + var values = this.get(key); if (values) { unorderedRemoveItem(values, value); if (!values.length) { - delete map[key]; + this.delete(key); } } } - ts.multiMapRemove = multiMapRemove; function isArray(value) { return Array.isArray ? Array.isArray(value) : value instanceof Array; } @@ -1088,8 +2106,10 @@ var ts; if (b === undefined) return 1; if (ignoreCase) { - if (ts.collator && String.prototype.localeCompare) { - var result = a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); + if (ts.collator) { + var result = ts.localeCompareIsCorrect ? + ts.collator.compare(a, b) : + a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 : result > 0 ? 1 : 0; } a = a.toUpperCase(); @@ -1471,36 +2491,26 @@ var ts; var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; var singleAsteriskRegexFragmentOther = "[^/]*"; function getRegularExpressionForWildcard(specs, basePath, usage) { + var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); + if (!patterns || !patterns.length) { + return undefined; + } + var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; + } + ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + function getRegularExpressionsForWildcards(specs, basePath, usage) { if (specs === undefined || specs.length === 0) { return undefined; } var replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther; var singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther; var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; - var pattern = ""; - var hasWrittenSubpattern = false; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!spec) { - continue; - } - var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); - if (subPattern === undefined) { - continue; - } - if (hasWrittenSubpattern) { - pattern += "|"; - } - pattern += "(" + subPattern + ")"; - hasWrittenSubpattern = true; - } - if (!pattern) { - return undefined; - } - var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return flatMap(specs, function (spec) { + return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + }); } - ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function isImplicitGlob(lastPathComponent) { return !/[.*?]/.test(lastPathComponent); } @@ -1570,6 +2580,7 @@ var ts; currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); return { + includeFilePatterns: map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -1582,34 +2593,48 @@ var ts; currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); - var result = []; + var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; + var comparer = useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive; for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; visitDirectory(basePath, combinePaths(currentDirectory, basePath)); } - return result; + return flatten(results); function visitDirectory(path, absolutePath) { var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; + files = files.slice().sort(comparer); + directories = directories.slice().sort(comparer); + var _loop_1 = function (current) { + var name = combinePaths(path, current); + var absoluteName = combinePaths(absolutePath, current); + if (extensions && !fileExtensionIsAny(name, extensions)) + return "continue"; + if (excludeRegex && excludeRegex.test(absoluteName)) + return "continue"; + if (!includeFileRegexes) { + results[0].push(name); + } + else { + var includeIndex = findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); }); + if (includeIndex !== -1) { + results[includeIndex].push(name); + } + } + }; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var current = files_1[_i]; - var name_1 = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); - if ((!extensions || fileExtensionIsAny(name_1, extensions)) && - (!includeFileRegex || includeFileRegex.test(absoluteName)) && - (!excludeRegex || !excludeRegex.test(absoluteName))) { - result.push(name_1); - } + _loop_1(current); } for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var current = directories_1[_b]; - var name_2 = combinePaths(path, current); + var name = combinePaths(path, current); var absoluteName = combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { - visitDirectory(name_2, absoluteName); + visitDirectory(name, absoluteName); } } } @@ -1625,14 +2650,14 @@ var ts; includeBasePaths.push(getIncludeBasePath(absolute)); } includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); - var _loop_1 = function (includeBasePath) { + var _loop_2 = function (includeBasePath) { if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } }; for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { var includeBasePath = includeBasePaths_1[_a]; - _loop_1(includeBasePath); + _loop_2(includeBasePath); } } return basePaths; @@ -1672,13 +2697,13 @@ var ts; var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions); function getSupportedExtensions(options, extraFileExtensions) { var needAllExtensions = options && options.allowJs; - if (!extraFileExtensions || extraFileExtensions.length === 0) { + if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = (needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions).slice(0); + var extensions = allSupportedExtensions.slice(0); for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { var extInfo = extraFileExtensions_1[_i]; - if (needAllExtensions || extInfo.scriptKind === 3) { + if (extensions.indexOf(extInfo.extension) === -1) { extensions.push(extInfo.extension); } } @@ -1706,33 +2731,40 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + var ExtensionPriority; + (function (ExtensionPriority) { + ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; + ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; + ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; + ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; + })(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {})); function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { - return adjustExtensionPriority(i); + return adjustExtensionPriority(i, supportedExtensions); } } return 0; } ts.getExtensionPriority = getExtensionPriority; - function adjustExtensionPriority(extensionPriority) { + function adjustExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2) { return 0; } - else if (extensionPriority < 5) { + else if (extensionPriority < supportedExtensions.length) { return 2; } else { - return 5; + return supportedExtensions.length; } } ts.adjustExtensionPriority = adjustExtensionPriority; - function getNextLowestExtensionPriority(extensionPriority) { + function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2) { return 2; } else { - return 5; + return supportedExtensions.length; } } ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority; @@ -1790,6 +2822,13 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; + var AssertionLevel; + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(AssertionLevel = ts.AssertionLevel || (ts.AssertionLevel = {})); var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -2079,32 +3118,32 @@ var ts; var useNonPollingWatchers = process.env["TSC_NONPOLLING_WATCHER"]; function createWatchedFileSet() { var dirWatchers = ts.createMap(); - var fileWatcherCallbacks = ts.createMap(); + var fileWatcherCallbacks = ts.createMultiMap(); return { addFile: addFile, removeFile: removeFile }; function reduceDirWatcherRefCountForFile(fileName) { var dirName = ts.getDirectoryPath(fileName); - var watcher = dirWatchers[dirName]; + var watcher = dirWatchers.get(dirName); if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); - delete dirWatchers[dirName]; + dirWatchers.delete(dirName); } } } function addDirWatcher(dirPath) { - var watcher = dirWatchers[dirPath]; + var watcher = dirWatchers.get(dirPath); if (watcher) { watcher.referenceCount += 1; return; } watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; - dirWatchers[dirPath] = watcher; + dirWatchers.set(dirPath, watcher); return; } function addFileWatcherCallback(filePath, callback) { - ts.multiMapAdd(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.add(filePath, callback); } function addFile(fileName, callback) { addFileWatcherCallback(fileName, callback); @@ -2116,16 +3155,19 @@ var ts; reduceDirWatcherRefCountForFile(watchedFile.fileName); } function removeFileWatcherCallback(filePath, callback) { - ts.multiMapRemove(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.remove(filePath, callback); } function fileEventHandler(eventName, relativeFileName, baseDirPath) { var fileName = typeof relativeFileName !== "string" ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); - if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { - for (var _i = 0, _a = fileWatcherCallbacks[fileName]; _i < _a.length; _i++) { - var fileCallback = _a[_i]; - fileCallback(fileName); + if ((eventName === "change" || eventName === "rename")) { + var callbacks = fileWatcherCallbacks.get(fileName); + if (callbacks) { + for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) { + var fileCallback = callbacks_1[_i]; + fileCallback(fileName); + } } } } @@ -2190,10 +3232,10 @@ var ts; if (entry === "." || entry === "..") { continue; } - var name_3 = ts.combinePaths(path, entry); + var name = ts.combinePaths(path, entry); var stat = void 0; try { - stat = _fs.statSync(name_3); + stat = _fs.statSync(name); } catch (e) { continue; @@ -2214,6 +3256,11 @@ var ts; function readDirectory(path, extensions, excludes, includes) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries); } + var FileSystemEntryKind; + (function (FileSystemEntryKind) { + FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; + FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; + })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -2267,7 +3314,7 @@ var ts; }, watchDirectory: function (directoryName, callback, recursive) { var options; - if (!directoryExists(directoryName)) { + if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { @@ -2282,6 +3329,9 @@ var ts; } ; }); + function isUNCPath(s) { + return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47; + } }, resolvePath: function (path) { return _path.resolve(path); @@ -2592,6 +3642,7 @@ var ts; Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", message: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", message: "Invalid use of '{0}'. Modules are automatically in strict mode." }, + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", message: "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export_assignment_is_not_supported_when_module_flag_is_system_1218", message: "Export assignment is not supported when '--module' flag is 'system'." }, Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", message: "Generators are only available when targeting ECMAScript 2015 or higher." }, @@ -2870,6 +3921,8 @@ var ts; Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, + A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, + Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union 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_2601", message: "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_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2880,6 +3933,7 @@ var ts; 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_2607", message: "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_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, + Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -2928,11 +3982,15 @@ var ts; The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: { code: 2699, category: ts.DiagnosticCategory.Error, key: "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", message: "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'." }, Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, + Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, + Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "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_4002", message: "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_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2943,8 +4001,8 @@ var ts; Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4014", message: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_function_has_or_is_using_private_name_1_4016", message: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019", message: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "'extends' clause of exported class '{0}' has or is using private name '{1}'." }, + extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "'extends' clause of exported interface '{0}' has or is using private name '{1}'." }, Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023", message: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024", message: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_private_name_1_4025", message: "Exported variable '{0}' has or is using private name '{1}'." }, @@ -3007,6 +4065,7 @@ var ts; Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced: { code: 4093, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced_4093", message: "'extends' clause of exported class '{0}' refers to a type whose name cannot be referenced." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -3052,7 +4111,7 @@ var ts; Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, - Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_in_the_given_directory_6020", message: "Compile the project in the given directory." }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, @@ -3067,6 +4126,7 @@ var ts; LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, STRATEGY: { code: 6039, category: ts.DiagnosticCategory.Message, key: "STRATEGY_6039", message: "STRATEGY" }, + FILE_OR_DIRECTORY: { code: 6040, category: ts.DiagnosticCategory.Message, key: "FILE_OR_DIRECTORY_6040", message: "FILE OR DIRECTORY" }, Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation_complete_Watching_for_file_changes_6042", message: "Compilation complete. Watching for file changes." }, Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_map_file_6043", message: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_expects_an_argument_6044", message: "Compiler option '{0}' expects an argument." }, @@ -3100,7 +4160,7 @@ var ts; Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, @@ -3120,7 +4180,7 @@ var ts; File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, + package_json_does_not_have_a_0_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_0_field_6100", message: "'package.json' does not have a '{0}' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -3157,7 +4217,6 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, @@ -3210,7 +4269,7 @@ var ts; parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: ts.DiagnosticCategory.Error, key: "parameter_modifiers_can_only_be_used_in_a_ts_file_8012", message: "'parameter modifiers' 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_8015", message: "'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_8016", message: "'type assertion expressions' 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_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause." }, class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "class_expressions_are_not_currently_supported_9003", message: "'class' expressions are not currently supported." }, Language_service_is_disabled: { code: 9004, category: ts.DiagnosticCategory.Error, key: "Language_service_is_disabled_9004", message: "Language service is disabled." }, 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_17000", message: "JSX attributes must only be assigned a non-empty 'expression'." }, @@ -3234,9 +4293,10 @@ var ts; Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, + Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, @@ -3247,12 +4307,4531 @@ var ts; }; })(ts || (ts = {})); var ts; +(function (ts) { + function trace(host) { + host.trace(ts.formatMessage.apply(undefined, arguments)); + } + ts.trace = trace; + function isTraceEnabled(compilerOptions, host) { + return compilerOptions.traceResolution && host.trace !== undefined; + } + ts.isTraceEnabled = isTraceEnabled; + var Extensions; + (function (Extensions) { + Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; + Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; + Extensions[Extensions["DtsOnly"] = 2] = "DtsOnly"; + })(Extensions || (Extensions = {})); + function resolvedTypeScriptOnly(resolved) { + if (!resolved) { + return undefined; + } + ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); + return resolved.path; + } + function resolvedModuleFromResolved(_a, isExternalLibraryImport) { + var path = _a.path, extension = _a.extension; + return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; + } + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolved && resolvedModuleFromResolved(resolved, isExternalLibraryImport), failedLookupLocations: failedLookupLocations }; + } + function moduleHasNonRelativeName(moduleName) { + return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); + } + ts.moduleHasNonRelativeName = moduleHasNonRelativeName; + function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { + var jsonContent = readJson(packageJsonPath, state.host); + return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); + function tryReadFromField(fieldName) { + if (!ts.hasProperty(jsonContent, fieldName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName); + } + return; + } + var fileName = jsonContent[fieldName]; + if (typeof fileName !== "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof fileName); + } + return; + } + var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path); + } + return path; + } + } + function readJson(path, host) { + try { + var jsonText = host.readFile(path); + return jsonText ? JSON.parse(jsonText) : {}; + } + catch (e) { + return {}; + } + } + function getEffectiveTypeRoots(options, host) { + if (options.typeRoots) { + return options.typeRoots; + } + var currentDirectory; + if (options.configFilePath) { + currentDirectory = ts.getDirectoryPath(options.configFilePath); + } + else if (host.getCurrentDirectory) { + currentDirectory = host.getCurrentDirectory(); + } + if (currentDirectory !== undefined) { + return getDefaultTypeRoots(currentDirectory, host); + } + } + ts.getEffectiveTypeRoots = getEffectiveTypeRoots; + function getDefaultTypeRoots(currentDirectory, host) { + if (!host.directoryExists) { + return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; + } + var typeRoots; + forEachAncestorDirectory(currentDirectory, function (directory) { + var atTypes = ts.combinePaths(directory, nodeModulesAtTypes); + if (host.directoryExists(atTypes)) { + (typeRoots || (typeRoots = [])).push(atTypes); + } + return undefined; + }); + return typeRoots; + } + var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + var traceEnabled = isTraceEnabled(options, host); + var moduleResolutionState = { + compilerOptions: options, + host: host, + traceEnabled: traceEnabled + }; + var typeRoots = getEffectiveTypeRoots(options, host); + if (traceEnabled) { + if (containingFile === undefined) { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); + } + } + else { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); + } + } + } + var failedLookupLocations = []; + var resolved = primaryLookup(); + var primary = true; + if (!resolved) { + resolved = secondaryLookup(); + primary = false; + } + var resolvedTypeReferenceDirective; + if (resolved) { + resolved = realpath(resolved, host, traceEnabled); + if (traceEnabled) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); + } + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved }; + } + return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + function primaryLookup() { + if (typeRoots && typeRoots.length) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + } + return ts.forEach(typeRoots, function (typeRoot) { + var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); + var candidateDirectory = ts.getDirectoryPath(candidate); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); + }); + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); + } + } + } + function secondaryLookup() { + var resolvedFile; + var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile); + if (initialLocationForSecondaryLookup !== undefined) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); + } + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); + if (!resolvedFile && traceEnabled) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + return resolvedFile; + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + } + } + } + } + ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; + function getAutomaticTypeDirectiveNames(options, host) { + if (options.types) { + return options.types; + } + var result = []; + if (host.directoryExists && host.getDirectories) { + var typeRoots = getEffectiveTypeRoots(options, host); + if (typeRoots) { + for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { + var root = typeRoots_1[_i]; + if (host.directoryExists(root)) { + for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { + var typeDirectivePath = _b[_a]; + var normalized = ts.normalizePath(typeDirectivePath); + var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); + var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; + if (!isNotNeededPackage) { + result.push(ts.getBaseFileName(normalized)); + } + } + } + } + } + } + return result; + } + ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); + if (!perModuleNameCache) { + perModuleNameCache = createPerModuleNameCache(); + moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent = ts.getDirectoryPath(current); + if (parent === current || directoryPathMap.contains(parent)) { + break; + } + directoryPathMap.set(parent, result); + current = parent; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + } + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache.get(moduleName); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + } + else { + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache.set(moduleName, result); + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } + } + } + if (traceEnabled) { + if (result.resolvedModule) { + trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + else { + trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + } + } + return result; + } + ts.resolveModuleName = resolveModuleName; + function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { + if (moduleHasNonRelativeName(moduleName)) { + return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state); + } + else { + return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); + } + } + function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { + if (!state.compilerOptions.rootDirs) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + } + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var matchedRootDir; + var matchedNormalizedPrefix; + for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { + var rootDir = _a[_i]; + var normalizedRoot = ts.normalizePath(rootDir); + if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { + normalizedRoot += ts.directorySeparator; + } + var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && + (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); + } + if (isLongestMatchingPrefix) { + matchedNormalizedPrefix = normalizedRoot; + matchedRootDir = rootDir; + } + } + if (matchedNormalizedPrefix) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); + } + var suffix = candidate.substr(matchedNormalizedPrefix.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); + } + var resolvedFileName = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { + var rootDir = _c[_b]; + if (rootDir === matchedRootDir) { + continue; + } + var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); + } + var baseDirectory = ts.getDirectoryPath(candidate_1); + var resolvedFileName_1 = loader(extensions, candidate_1, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + if (resolvedFileName_1) { + return resolvedFileName_1; + } + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + } + } + return undefined; + } + function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state) { + if (!state.compilerOptions.baseUrl) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); + } + var matchedPattern = undefined; + if (state.compilerOptions.paths) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); + } + if (matchedPattern) { + var matchedStar_1 = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); + var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); + } + return ts.forEach(state.compilerOptions.paths[matchedPatternText], function (subst) { + var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst; + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + } + var tsExtension = ts.tryGetExtensionFromPath(candidate); + if (tsExtension !== undefined) { + var path_1 = tryFile(candidate, failedLookupLocations, false, state); + return path_1 && { path: path_1, extension: tsExtension }; + } + return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + }); + } + else { + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); + } + return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + } + } + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, false); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, jsOnly) { + if (jsOnly === void 0) { jsOnly = false; } + var containingDirectory = ts.getDirectoryPath(containingFile); + var traceEnabled = isTraceEnabled(compilerOptions, host); + var failedLookupLocations = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var result = jsOnly ? tryResolve(Extensions.JavaScript) : (tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript)); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; + return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); + } + return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + function tryResolve(extensions) { + var loader = function (extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, true); }; + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); + if (resolved) { + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); + } + if (moduleHasNonRelativeName(moduleName)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); + } + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state, true); + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); + } + } + } + ts.nodeModuleNameResolverWorker = nodeModuleNameResolverWorker; + function realpath(path, host, traceEnabled) { + if (!host.realpath) { + return path; + } + var real = ts.normalizePath(host.realpath(path)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); + } + return real; + } + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); + } + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson); + } + function directoryProbablyExists(directoryName, host) { + return !host.directoryExists || host.directoryExists(directoryName); + } + ts.directoryProbablyExists = directoryProbablyExists; + function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); + if (resolvedByAddingExtension) { + return resolvedByAddingExtension; + } + if (ts.hasJavaScriptFileExtension(candidate)) { + var extensionless = ts.removeFileExtension(candidate); + if (state.traceEnabled) { + var extension = candidate.substring(extensionless.length); + trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); + } + return tryAddingExtensions(extensionless, extensions, failedLookupLocations, onlyRecordFailures, state); + } + } + function tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state) { + if (!onlyRecordFailures) { + var directory = ts.getDirectoryPath(candidate); + if (directory) { + onlyRecordFailures = !directoryProbablyExists(directory, state.host); + } + } + switch (extensions) { + case Extensions.DtsOnly: + return tryExtension(".d.ts", ts.Extension.Dts); + case Extensions.TypeScript: + return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); + case Extensions.JavaScript: + return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); + } + function tryExtension(ext, extension) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); + return path && { path: path, extension: extension }; + } + } + function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } + } + } + failedLookupLocations.push(fileName); + return undefined; + } + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { + if (considerPackageJson === void 0) { considerPackageJson = true; } + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (considerPackageJson) { + var packageJsonPath = pathToPackageJson(candidate); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; + } + } + else { + if (directoryExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } + failedLookupLocations.push(packageJsonPath); + } + } + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + } + function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + if (!file) { + return undefined; + } + var onlyRecordFailures = !directoryProbablyExists(ts.getDirectoryPath(file), state.host); + var fromFile = tryFile(file, failedLookupLocations, onlyRecordFailures, state); + if (fromFile) { + var resolved = fromFile && resolvedIfExtensionMatches(extensions, fromFile); + if (resolved) { + return resolved; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile); + } + } + var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; + return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, false); + } + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } + function pathToPackageJson(directory) { + return ts.combinePaths(directory, "package.json"); + } + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + } + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); + } + function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, true, undefined); + } + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); + return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { + if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); + } + }); + } + function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + if (typesOnly === void 0) { typesOnly = false; } + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); + if (packageResult) { + return packageResult; + } + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); + } + } + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var failedLookupLocations = []; + var containingDirectory = ts.getDirectoryPath(containingFile); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); + function tryResolve(extensions) { + var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); + if (resolvedUsingSettings) { + return { value: resolvedUsingSettings }; + } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); + if (moduleHasNonRelativeName(moduleName)) { + var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } + var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); + }); + if (resolved_3) { + return resolved_3; + } + if (extensions === Extensions.TypeScript) { + return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); + } + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); + } + } + } + ts.classicNameResolver = classicNameResolver; + function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); + } + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var failedLookupLocations = []; + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); + return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); + } + ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } + function forEachAncestorDirectory(directory, callback) { + while (true) { + var result = callback(directory); + if (result !== undefined) { + return result; + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + return undefined; + } + directory = parentPath; + } + } +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.externalHelpersModuleNameText = "tslib"; + function getDeclarationOfKind(symbol, kind) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { + var declaration = declarations_1[_i]; + if (declaration.kind === kind) { + return declaration; + } + } + } + return undefined; + } + ts.getDeclarationOfKind = getDeclarationOfKind; + function findDeclaration(symbol, predicate) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; + if (predicate(declaration)) { + return declaration; + } + } + } + return undefined; + } + ts.findDeclaration = findDeclaration; + var stringWriters = []; + function getSingleLineStringWriter() { + if (stringWriters.length === 0) { + var str_1 = ""; + var writeText = function (text) { return str_1 += text; }; + return { + string: function () { return str_1; }, + writeKeyword: writeText, + writeOperator: writeText, + writePunctuation: writeText, + writeSpace: writeText, + writeStringLiteral: writeText, + writeParameter: writeText, + writeProperty: writeText, + writeSymbol: writeText, + writeLine: function () { return str_1 += " "; }, + increaseIndent: ts.noop, + decreaseIndent: ts.noop, + clear: function () { return str_1 = ""; }, + trackSymbol: ts.noop, + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop + }; + } + return stringWriters.pop(); + } + ts.getSingleLineStringWriter = getSingleLineStringWriter; + function releaseStringWriter(writer) { + writer.clear(); + stringWriters.push(writer); + } + ts.releaseStringWriter = releaseStringWriter; + function getFullWidth(node) { + return node.end - node.pos; + } + ts.getFullWidth = getFullWidth; + function hasResolvedModule(sourceFile, moduleNameText) { + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText)); + } + ts.hasResolvedModule = hasResolvedModule; + function getResolvedModule(sourceFile, moduleNameText) { + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules.get(moduleNameText) : undefined; + } + ts.getResolvedModule = getResolvedModule; + function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = ts.createMap(); + } + sourceFile.resolvedModules.set(moduleNameText, resolvedModule); + } + ts.setResolvedModule = setResolvedModule; + function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { + if (!sourceFile.resolvedTypeReferenceDirectiveNames) { + sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); + } + sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective); + } + ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; + function moduleResolutionIsEqualTo(oldResolution, newResolution) { + return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && + oldResolution.extension === newResolution.extension && + oldResolution.resolvedFileName === newResolution.resolvedFileName; + } + ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; + function typeDirectiveIsEqualTo(oldResolution, newResolution) { + return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; + } + ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; + function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { + if (names.length !== newResolutions.length) { + return false; + } + for (var i = 0; i < names.length; i++) { + var newResolution = newResolutions[i]; + var oldResolution = oldResolutions && oldResolutions.get(names[i]); + var changed = oldResolution + ? !newResolution || !comparer(oldResolution, newResolution) + : newResolution; + if (changed) { + return true; + } + } + return false; + } + ts.hasChangesInResolutions = hasChangesInResolutions; + function containsParseError(node) { + aggregateChildData(node); + return (node.flags & 131072) !== 0; + } + ts.containsParseError = containsParseError; + function aggregateChildData(node) { + if (!(node.flags & 262144)) { + var thisNodeOrAnySubNodesHasError = ((node.flags & 32768) !== 0) || + ts.forEachChild(node, containsParseError); + if (thisNodeOrAnySubNodesHasError) { + node.flags |= 131072; + } + node.flags |= 262144; + } + } + function getSourceFileOfNode(node) { + while (node && node.kind !== 264) { + node = node.parent; + } + return node; + } + ts.getSourceFileOfNode = getSourceFileOfNode; + function isStatementWithLocals(node) { + switch (node.kind) { + case 206: + case 234: + case 213: + case 214: + case 215: + return true; + } + return false; + } + ts.isStatementWithLocals = isStatementWithLocals; + function getStartPositionOfLine(line, sourceFile) { + ts.Debug.assert(line >= 0); + return ts.getLineStarts(sourceFile)[line]; + } + ts.getStartPositionOfLine = getStartPositionOfLine; + function nodePosToString(node) { + var file = getSourceFileOfNode(node); + var loc = ts.getLineAndCharacterOfPosition(file, node.pos); + return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + } + ts.nodePosToString = nodePosToString; + function getStartPosOfNode(node) { + return node.pos; + } + ts.getStartPosOfNode = getStartPosOfNode; + function isDefined(value) { + return value !== undefined; + } + ts.isDefined = isDefined; + function getEndLinePosition(line, sourceFile) { + ts.Debug.assert(line >= 0); + var lineStarts = ts.getLineStarts(sourceFile); + var lineIndex = line; + var sourceText = sourceFile.text; + if (lineIndex + 1 === lineStarts.length) { + return sourceText.length - 1; + } + else { + var start = lineStarts[lineIndex]; + var pos = lineStarts[lineIndex + 1] - 1; + ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos))); + while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) { + pos--; + } + return pos; + } + } + ts.getEndLinePosition = getEndLinePosition; + function nodeIsMissing(node) { + if (node === undefined) { + return true; + } + return node.pos === node.end && node.pos >= 0 && node.kind !== 1; + } + ts.nodeIsMissing = nodeIsMissing; + function nodeIsPresent(node) { + return !nodeIsMissing(node); + } + ts.nodeIsPresent = nodeIsPresent; + function getTokenPosOfNode(node, sourceFile, includeJsDoc) { + if (nodeIsMissing(node)) { + return node.pos; + } + if (isJSDocNode(node)) { + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); + } + if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { + return getTokenPosOfNode(node.jsDoc[0]); + } + if (node.kind === 296 && node._children.length > 0) { + return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + } + ts.getTokenPosOfNode = getTokenPosOfNode; + function isJSDocNode(node) { + return node.kind >= 266 && node.kind <= 295; + } + ts.isJSDocNode = isJSDocNode; + function isJSDocTag(node) { + return node.kind >= 282 && node.kind <= 295; + } + ts.isJSDocTag = isJSDocTag; + function getNonDecoratorTokenPosOfNode(node, sourceFile) { + if (nodeIsMissing(node) || !node.decorators) { + return getTokenPosOfNode(node, sourceFile); + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); + } + ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; + function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + if (nodeIsMissing(node)) { + return ""; + } + var text = sourceFile.text; + return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); + } + ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; + function getTextOfNodeFromSourceText(sourceText, node) { + if (nodeIsMissing(node)) { + return ""; + } + return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); + } + ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; + function getTextOfNode(node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); + } + ts.getTextOfNode = getTextOfNode; + function getLiteralText(node, sourceFile, languageVersion) { + if (languageVersion < 2 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + return getQuotedEscapedLiteralText('"', node.text, '"'); + } + if (!nodeIsSynthesized(node) && node.parent) { + var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); + if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { + return node.text; + } + return text; + } + switch (node.kind) { + case 9: + return getQuotedEscapedLiteralText('"', node.text, '"'); + case 12: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 13: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 15: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + ts.getLiteralText = getLiteralText; + function isBinaryOrOctalIntegerLiteral(node, text) { + return node.kind === 8 + && (getNumericLiteralFlags(text, 6) & 6) !== 0; + } + ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + var NumericLiteralFlags; + (function (NumericLiteralFlags) { + NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; + NumericLiteralFlags[NumericLiteralFlags["Hexadecimal"] = 1] = "Hexadecimal"; + NumericLiteralFlags[NumericLiteralFlags["Binary"] = 2] = "Binary"; + NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; + NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 8] = "Scientific"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctal"] = 6] = "BinaryOrOctal"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalOrHexadecimal"] = 7] = "BinaryOrOctalOrHexadecimal"; + NumericLiteralFlags[NumericLiteralFlags["All"] = 15] = "All"; + })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); + function getNumericLiteralFlags(text, hint) { + if (text.length > 1) { + switch (text.charCodeAt(1)) { + case 98: + case 66: + return 2; + case 111: + case 79: + return 4; + case 120: + case 88: + return 1; + } + if (hint & 8) { + for (var i = text.length - 1; i >= 0; i--) { + switch (text.charCodeAt(i)) { + case 101: + case 69: + return 8; + } + } + } + } + return 0; + } + ts.getNumericLiteralFlags = getNumericLiteralFlags; + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; + } + function escapeIdentifier(identifier) { + return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; + } + ts.escapeIdentifier = escapeIdentifier; + function makeIdentifierFromModuleName(moduleName) { + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); + } + ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; + function isBlockOrCatchScoped(declaration) { + return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 || + isCatchClauseVariableDeclarationOrBindingElement(declaration); + } + ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + function isCatchClauseVariableDeclarationOrBindingElement(declaration) { + var node = getRootDeclaration(declaration); + return node.kind === 225 && node.parent.kind === 259; + } + ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; + function isAmbientModule(node) { + return node && node.kind === 232 && + (node.name.kind === 9 || isGlobalScopeAugmentation(node)); + } + ts.isAmbientModule = isAmbientModule; + function isShorthandAmbientModuleSymbol(moduleSymbol) { + return isShorthandAmbientModule(moduleSymbol.valueDeclaration); + } + ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; + function isShorthandAmbientModule(node) { + return node && node.kind === 232 && (!node.body); + } + function isBlockScopedContainerTopLevel(node) { + return node.kind === 264 || + node.kind === 232 || + isFunctionLike(node); + } + ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; + function isGlobalScopeAugmentation(module) { + return !!(module.flags & 512); + } + ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; + function isExternalModuleAugmentation(node) { + if (!node || !isAmbientModule(node)) { + return false; + } + switch (node.parent.kind) { + case 264: + return ts.isExternalModule(node.parent); + case 233: + return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); + } + return false; + } + ts.isExternalModuleAugmentation = isExternalModuleAugmentation; + function isEffectiveExternalModule(node, compilerOptions) { + return ts.isExternalModule(node) || compilerOptions.isolatedModules; + } + ts.isEffectiveExternalModule = isEffectiveExternalModule; + function isBlockScope(node, parentNode) { + switch (node.kind) { + case 264: + case 234: + case 259: + case 232: + case 213: + case 214: + case 215: + case 151: + case 150: + case 152: + case 153: + case 227: + case 185: + case 186: + return true; + case 206: + return parentNode && !isFunctionLike(parentNode); + } + return false; + } + ts.isBlockScope = isBlockScope; + function getEnclosingBlockScopeContainer(node) { + var current = node.parent; + while (current) { + if (isBlockScope(current, current.parent)) { + return current; + } + current = current.parent; + } + } + ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; + function declarationNameToString(name) { + return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + } + ts.declarationNameToString = declarationNameToString; + function getTextOfPropertyName(name) { + switch (name.kind) { + case 70: + return name.text; + case 9: + case 8: + return name.text; + case 143: + if (isStringOrNumericLiteral(name.expression)) { + return name.expression.text; + } + } + return undefined; + } + ts.getTextOfPropertyName = getTextOfPropertyName; + function entityNameToString(name) { + switch (name.kind) { + case 70: + return getFullWidth(name) === 0 ? ts.unescapeIdentifier(name.text) : getTextOfNode(name); + case 142: + return entityNameToString(name.left) + "." + entityNameToString(name.right); + case 178: + return entityNameToString(name.expression) + "." + entityNameToString(name.name); + } + } + ts.entityNameToString = entityNameToString; + function createDiagnosticForNode(node, message, arg0, arg1, arg2) { + var sourceFile = getSourceFileOfNode(node); + return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2); + } + ts.createDiagnosticForNode = createDiagnosticForNode; + function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2) { + var span = getErrorSpanForNode(sourceFile, node); + return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); + } + ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; + function createDiagnosticForNodeFromMessageChain(node, messageChain) { + var sourceFile = getSourceFileOfNode(node); + var span = getErrorSpanForNode(sourceFile, node); + return { + file: sourceFile, + start: span.start, + length: span.length, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain.next ? messageChain : messageChain.messageText + }; + } + ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function getSpanOfTokenAtPosition(sourceFile, 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()); + } + ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; + function getErrorSpanForArrowFunction(sourceFile, node) { + var pos = ts.skipTrivia(sourceFile.text, node.pos); + if (node.body && node.body.kind === 206) { + var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; + var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; + if (startLine < endLine) { + return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1); + } + } + return ts.createTextSpanFromBounds(pos, node.end); + } + function getErrorSpanForNode(sourceFile, node) { + var errorNode = node; + switch (node.kind) { + case 264: + 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 225: + case 175: + case 228: + case 198: + case 229: + case 232: + case 231: + case 263: + case 227: + case 185: + case 150: + case 152: + case 153: + case 230: + errorNode = node.name; + break; + case 186: + return getErrorSpanForArrowFunction(sourceFile, node); + } + if (errorNode === undefined) { + return getSpanOfTokenAtPosition(sourceFile, node.pos); + } + var pos = nodeIsMissing(errorNode) + ? errorNode.pos + : ts.skipTrivia(sourceFile.text, errorNode.pos); + return ts.createTextSpanFromBounds(pos, errorNode.end); + } + ts.getErrorSpanForNode = getErrorSpanForNode; + function isExternalOrCommonJsModule(file) { + return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + } + ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; + function isDeclarationFile(file) { + return file.isDeclarationFile; + } + ts.isDeclarationFile = isDeclarationFile; + function isConstEnumDeclaration(node) { + return node.kind === 231 && isConst(node); + } + ts.isConstEnumDeclaration = isConstEnumDeclaration; + function isConst(node) { + return !!(ts.getCombinedNodeFlags(node) & 2) + || !!(ts.getCombinedModifierFlags(node) & 2048); + } + ts.isConst = isConst; + function isLet(node) { + return !!(ts.getCombinedNodeFlags(node) & 1); + } + ts.isLet = isLet; + function isSuperCall(n) { + return n.kind === 180 && n.expression.kind === 96; + } + ts.isSuperCall = isSuperCall; + function isPrologueDirective(node) { + return node.kind === 209 + && node.expression.kind === 9; + } + ts.isPrologueDirective = isPrologueDirective; + function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + } + ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; + function getLeadingCommentRangesOfNodeFromText(node, text) { + return ts.getLeadingCommentRanges(text, node.pos); + } + ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; + function getJSDocCommentRanges(node, text) { + var commentRanges = (node.kind === 145 || + node.kind === 144 || + node.kind === 185 || + node.kind === 186) ? + ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : + getLeadingCommentRangesOfNodeFromText(node, text); + return ts.filter(commentRanges, function (comment) { + return text.charCodeAt(comment.pos + 1) === 42 && + text.charCodeAt(comment.pos + 2) === 42 && + text.charCodeAt(comment.pos + 3) !== 47; + }); + } + ts.getJSDocCommentRanges = getJSDocCommentRanges; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + function isPartOfTypeNode(node) { + if (157 <= node.kind && node.kind <= 172) { + return true; + } + switch (node.kind) { + case 118: + case 132: + case 135: + case 121: + case 136: + case 138: + case 129: + return true; + case 104: + return node.parent.kind !== 189; + case 200: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); + case 70: + if (node.parent.kind === 142 && node.parent.right === node) { + node = node.parent; + } + else if (node.parent.kind === 178 && node.parent.name === node) { + node = node.parent; + } + ts.Debug.assert(node.kind === 70 || node.kind === 142 || node.kind === 178, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 142: + case 178: + case 98: + var parent = node.parent; + if (parent.kind === 161) { + return false; + } + if (157 <= parent.kind && parent.kind <= 172) { + return true; + } + switch (parent.kind) { + case 200: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); + case 144: + return node === parent.constraint; + case 148: + case 147: + case 145: + case 225: + return node === parent.type; + case 227: + case 185: + case 186: + case 151: + case 150: + case 149: + case 152: + case 153: + return node === parent.type; + case 154: + case 155: + case 156: + return node === parent.type; + case 183: + return node === parent.type; + case 180: + case 181: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 182: + return false; + } + } + return false; + } + ts.isPartOfTypeNode = isPartOfTypeNode; + function isChildOfNodeWithKind(node, kind) { + while (node) { + if (node.kind === kind) { + return true; + } + node = node.parent; + } + return false; + } + ts.isChildOfNodeWithKind = isChildOfNodeWithKind; + function isPrefixUnaryExpression(node) { + return node.kind === 191; + } + ts.isPrefixUnaryExpression = isPrefixUnaryExpression; + function forEachReturnStatement(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 218: + return visitor(node); + case 234: + case 206: + case 210: + case 211: + case 212: + case 213: + case 214: + case 215: + case 219: + case 220: + case 256: + case 257: + case 221: + case 223: + case 259: + return ts.forEachChild(node, traverse); + } + } + } + ts.forEachReturnStatement = forEachReturnStatement; + function forEachYieldExpression(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 196: + visitor(node); + var operand = node.expression; + if (operand) { + traverse(operand); + } + case 231: + case 229: + case 232: + case 230: + case 228: + case 198: + return; + default: + if (isFunctionLike(node)) { + var name = node.name; + if (name && name.kind === 143) { + traverse(name.expression); + return; + } + } + else if (!isPartOfTypeNode(node)) { + ts.forEachChild(node, traverse); + } + } + } + } + ts.forEachYieldExpression = forEachYieldExpression; + function getRestParameterElementType(node) { + if (node && node.kind === 163) { + return node.elementType; + } + else if (node && node.kind === 158) { + return ts.singleOrUndefined(node.typeArguments); + } + else { + return undefined; + } + } + ts.getRestParameterElementType = getRestParameterElementType; + function isVariableLike(node) { + if (node) { + switch (node.kind) { + case 175: + case 263: + case 145: + case 260: + case 148: + case 147: + case 261: + case 225: + return true; + } + } + return false; + } + ts.isVariableLike = isVariableLike; + function isAccessor(node) { + return node && (node.kind === 152 || node.kind === 153); + } + ts.isAccessor = isAccessor; + function isClassLike(node) { + return node && (node.kind === 228 || node.kind === 198); + } + ts.isClassLike = isClassLike; + function isFunctionLike(node) { + return node && isFunctionLikeKind(node.kind); + } + ts.isFunctionLike = isFunctionLike; + function isFunctionLikeKind(kind) { + switch (kind) { + case 151: + case 185: + case 227: + case 186: + case 150: + case 149: + case 152: + case 153: + case 154: + case 155: + case 156: + case 159: + case 160: + return true; + } + return false; + } + ts.isFunctionLikeKind = isFunctionLikeKind; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 150: + case 149: + case 151: + case 152: + case 153: + case 227: + case 185: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; + function isIterationStatement(node, lookInLabeledStatements) { + switch (node.kind) { + case 213: + case 214: + case 215: + case 211: + case 212: + return true; + case 221: + return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); + } + return false; + } + ts.isIterationStatement = isIterationStatement; + function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== 221) { + return node.statement; + } + node = node.statement; + } + } + ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; + function isFunctionBlock(node) { + return node && node.kind === 206 && isFunctionLike(node.parent); + } + ts.isFunctionBlock = isFunctionBlock; + function isObjectLiteralMethod(node) { + return node && node.kind === 150 && node.parent.kind === 177; + } + ts.isObjectLiteralMethod = isObjectLiteralMethod; + function isObjectLiteralOrClassExpressionMethod(node) { + return node.kind === 150 && + (node.parent.kind === 177 || + node.parent.kind === 198); + } + ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; + function isIdentifierTypePredicate(predicate) { + return predicate && predicate.kind === 1; + } + ts.isIdentifierTypePredicate = isIdentifierTypePredicate; + function isThisTypePredicate(predicate) { + return predicate && predicate.kind === 0; + } + ts.isThisTypePredicate = isThisTypePredicate; + function getContainingFunction(node) { + while (true) { + node = node.parent; + if (!node || isFunctionLike(node)) { + return node; + } + } + } + ts.getContainingFunction = getContainingFunction; + function getContainingClass(node) { + while (true) { + node = node.parent; + if (!node || isClassLike(node)) { + return node; + } + } + } + ts.getContainingClass = getContainingClass; + function getThisContainer(node, includeArrowFunctions) { + while (true) { + node = node.parent; + if (!node) { + return undefined; + } + switch (node.kind) { + case 143: + if (isClassLike(node.parent.parent)) { + return node; + } + node = node.parent; + break; + case 146: + if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + node = node.parent; + } + break; + case 186: + if (!includeArrowFunctions) { + continue; + } + case 227: + case 185: + case 232: + case 148: + case 147: + case 150: + case 149: + case 151: + case 152: + case 153: + case 154: + case 155: + case 156: + case 231: + case 264: + return node; + } + } + } + ts.getThisContainer = getThisContainer; + function getNewTargetContainer(node) { + var container = getThisContainer(node, false); + if (container) { + switch (container.kind) { + case 151: + case 227: + case 185: + return container; + } + } + return undefined; + } + ts.getNewTargetContainer = getNewTargetContainer; + function getSuperContainer(node, stopOnFunctions) { + while (true) { + node = node.parent; + if (!node) { + return node; + } + switch (node.kind) { + case 143: + node = node.parent; + break; + case 227: + case 185: + case 186: + if (!stopOnFunctions) { + continue; + } + case 148: + case 147: + case 150: + case 149: + case 151: + case 152: + case 153: + return node; + case 146: + if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + node = node.parent; + } + break; + } + } + } + ts.getSuperContainer = getSuperContainer; + function getImmediatelyInvokedFunctionExpression(func) { + if (func.kind === 185 || func.kind === 186) { + var prev = func; + var parent = func.parent; + while (parent.kind === 184) { + prev = parent; + parent = parent.parent; + } + if (parent.kind === 180 && parent.expression === prev) { + return parent; + } + } + } + ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; + function isSuperProperty(node) { + var kind = node.kind; + return (kind === 178 || kind === 179) + && node.expression.kind === 96; + } + ts.isSuperProperty = isSuperProperty; + function getEntityNameFromTypeNode(node) { + switch (node.kind) { + case 158: + case 276: + return node.typeName; + case 200: + return isEntityNameExpression(node.expression) + ? node.expression + : undefined; + case 70: + case 142: + return node; + } + return undefined; + } + ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; + function isCallLikeExpression(node) { + switch (node.kind) { + case 250: + case 249: + case 180: + case 181: + case 182: + case 146: + return true; + default: + return false; + } + } + ts.isCallLikeExpression = isCallLikeExpression; + function getInvokedExpression(node) { + if (node.kind === 182) { + return node.tag; + } + else if (isJsxOpeningLikeElement(node)) { + return node.tagName; + } + return node.expression; + } + ts.getInvokedExpression = getInvokedExpression; + function nodeCanBeDecorated(node) { + switch (node.kind) { + case 228: + return true; + case 148: + return node.parent.kind === 228; + case 152: + case 153: + case 150: + return node.body !== undefined + && node.parent.kind === 228; + case 145: + return node.parent.body !== undefined + && (node.parent.kind === 151 + || node.parent.kind === 150 + || node.parent.kind === 153) + && node.parent.parent.kind === 228; + } + return false; + } + ts.nodeCanBeDecorated = nodeCanBeDecorated; + function nodeIsDecorated(node) { + return node.decorators !== undefined + && nodeCanBeDecorated(node); + } + ts.nodeIsDecorated = nodeIsDecorated; + function nodeOrChildIsDecorated(node) { + return nodeIsDecorated(node) || childIsDecorated(node); + } + ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function childIsDecorated(node) { + switch (node.kind) { + case 228: + return ts.forEach(node.members, nodeOrChildIsDecorated); + case 150: + case 153: + return ts.forEach(node.parameters, nodeIsDecorated); + } + } + ts.childIsDecorated = childIsDecorated; + function isJSXTagName(node) { + var parent = node.parent; + if (parent.kind === 250 || + parent.kind === 249 || + parent.kind === 251) { + return parent.tagName === node; + } + return false; + } + ts.isJSXTagName = isJSXTagName; + function isPartOfExpression(node) { + switch (node.kind) { + case 98: + case 96: + case 94: + case 100: + case 85: + case 11: + case 176: + case 177: + case 178: + case 179: + case 180: + case 181: + case 182: + case 201: + case 183: + case 202: + case 184: + case 185: + case 198: + case 186: + case 189: + case 187: + case 188: + case 191: + case 192: + case 193: + case 194: + case 197: + case 195: + case 12: + case 199: + case 248: + case 249: + case 196: + case 190: + case 203: + return true; + case 142: + while (node.parent.kind === 142) { + node = node.parent; + } + return node.parent.kind === 161 || isJSXTagName(node); + case 70: + if (node.parent.kind === 161 || isJSXTagName(node)) { + return true; + } + case 8: + case 9: + case 98: + var parent = node.parent; + switch (parent.kind) { + case 225: + case 145: + case 148: + case 147: + case 263: + case 260: + case 175: + return parent.initializer === node; + case 209: + case 210: + case 211: + case 212: + case 218: + case 219: + case 220: + case 256: + case 222: + case 220: + return parent.expression === node; + case 213: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 226) || + forStatement.condition === node || + forStatement.incrementor === node; + case 214: + case 215: + var forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 226) || + forInStatement.expression === node; + case 183: + case 201: + return node === parent.expression; + case 204: + return node === parent.expression; + case 143: + return node === parent.expression; + case 146: + case 255: + case 254: + case 262: + return true; + case 200: + return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); + default: + if (isPartOfExpression(parent)) { + return true; + } + } + } + return false; + } + ts.isPartOfExpression = isPartOfExpression; + function isInstantiatedModule(node, preserveConstEnums) { + var moduleState = ts.getModuleInstanceState(node); + return moduleState === 1 || + (preserveConstEnums && moduleState === 2); + } + ts.isInstantiatedModule = isInstantiatedModule; + function isExternalModuleImportEqualsDeclaration(node) { + return node.kind === 236 && node.moduleReference.kind === 247; + } + ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; + function getExternalModuleImportEqualsDeclarationExpression(node) { + ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); + return node.moduleReference.expression; + } + ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; + function isInternalModuleImportEqualsDeclaration(node) { + return node.kind === 236 && node.moduleReference.kind !== 247; + } + ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function isSourceFileJavaScript(file) { + return isInJavaScriptFile(file); + } + ts.isSourceFileJavaScript = isSourceFileJavaScript; + function isInJavaScriptFile(node) { + return node && !!(node.flags & 65536); + } + ts.isInJavaScriptFile = isInJavaScriptFile; + function isRequireCall(expression, checkArgumentIsStringLiteral) { + var isRequire = expression.kind === 180 && + expression.expression.kind === 70 && + expression.expression.text === "require" && + expression.arguments.length === 1; + return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); + } + ts.isRequireCall = isRequireCall; + function isSingleOrDoubleQuote(charCode) { + return charCode === 39 || charCode === 34; + } + ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; + function isDeclarationOfFunctionExpression(s) { + if (s.valueDeclaration && s.valueDeclaration.kind === 225) { + var declaration = s.valueDeclaration; + return declaration.initializer && declaration.initializer.kind === 185; + } + return false; + } + ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; + function getSpecialPropertyAssignmentKind(expression) { + if (!isInJavaScriptFile(expression)) { + return 0; + } + if (expression.kind !== 193) { + return 0; + } + var expr = expression; + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 178) { + return 0; + } + var lhs = expr.left; + if (lhs.expression.kind === 70) { + var lhsId = lhs.expression; + if (lhsId.text === "exports") { + return 1; + } + else if (lhsId.text === "module" && lhs.name.text === "exports") { + return 2; + } + } + else if (lhs.expression.kind === 98) { + return 4; + } + else if (lhs.expression.kind === 178) { + var innerPropertyAccess = lhs.expression; + if (innerPropertyAccess.expression.kind === 70) { + var innerPropertyAccessIdentifier = innerPropertyAccess.expression; + if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { + return 1; + } + if (innerPropertyAccess.name.text === "prototype") { + return 3; + } + } + } + return 0; + } + ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + function getExternalModuleName(node) { + if (node.kind === 237) { + return node.moduleSpecifier; + } + if (node.kind === 236) { + var reference = node.moduleReference; + if (reference.kind === 247) { + return reference.expression; + } + } + if (node.kind === 243) { + return node.moduleSpecifier; + } + if (node.kind === 232 && node.name.kind === 9) { + return node.name; + } + } + ts.getExternalModuleName = getExternalModuleName; + function getNamespaceDeclarationNode(node) { + if (node.kind === 236) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 239) { + return importClause.namedBindings; + } + } + ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; + function isDefaultImport(node) { + return node.kind === 237 + && node.importClause + && !!node.importClause.name; + } + ts.isDefaultImport = isDefaultImport; + function hasQuestionToken(node) { + if (node) { + switch (node.kind) { + case 145: + case 150: + case 149: + case 261: + case 260: + case 148: + case 147: + return node.questionToken !== undefined; + } + } + return false; + } + ts.hasQuestionToken = hasQuestionToken; + function isJSDocConstructSignature(node) { + return node.kind === 278 && + node.parameters.length > 0 && + node.parameters[0].type.kind === 280; + } + ts.isJSDocConstructSignature = isJSDocConstructSignature; + function getCommentsFromJSDoc(node) { + return ts.map(getJSDocs(node), function (doc) { return doc.comment; }); + } + ts.getCommentsFromJSDoc = getCommentsFromJSDoc; + function hasJSDocParameterTags(node) { + var parameterTags = getJSDocTags(node, 285); + return parameterTags && parameterTags.length > 0; + } + ts.hasJSDocParameterTags = hasJSDocParameterTags; + function getJSDocTags(node, kind) { + var docs = getJSDocs(node); + if (docs) { + var result = []; + for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { + var doc = docs_1[_i]; + if (doc.kind === 285) { + if (doc.kind === kind) { + result.push(doc); + } + } + else { + result.push.apply(result, ts.filter(doc.tags, function (tag) { return tag.kind === kind; })); + } + } + return result; + } + } + function getFirstJSDocTag(node, kind) { + return node && ts.firstOrUndefined(getJSDocTags(node, kind)); + } + function getJSDocs(node) { + var cache = node.jsDocCache; + if (!cache) { + getJSDocsWorker(node); + node.jsDocCache = cache; + } + return cache; + function getJSDocsWorker(node) { + var parent = node.parent; + var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && + parent.initializer === node && + parent.parent.parent.kind === 207; + var isVariableOfVariableDeclarationStatement = isVariableLike(node) && + parent.parent.kind === 207; + var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : + isVariableOfVariableDeclarationStatement ? parent.parent : + undefined; + if (variableStatementNode) { + getJSDocsWorker(variableStatementNode); + } + var isSourceOfAssignmentExpressionStatement = parent && parent.parent && + parent.kind === 193 && + parent.operatorToken.kind === 57 && + parent.parent.kind === 209; + if (isSourceOfAssignmentExpressionStatement) { + getJSDocsWorker(parent.parent); + } + var isModuleDeclaration = node.kind === 232 && + parent && parent.kind === 232; + var isPropertyAssignmentExpression = parent && parent.kind === 260; + if (isModuleDeclaration || isPropertyAssignmentExpression) { + getJSDocsWorker(parent); + } + if (node.kind === 145) { + cache = ts.concatenate(cache, getJSDocParameterTags(node)); + } + if (isVariableLike(node) && node.initializer) { + cache = ts.concatenate(cache, node.initializer.jsDoc); + } + cache = ts.concatenate(cache, node.jsDoc); + } + } + function getJSDocParameterTags(param) { + if (!isParameter(param)) { + return undefined; + } + var func = param.parent; + var tags = getJSDocTags(func, 285); + if (!param.name) { + var i = func.parameters.indexOf(param); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 285; }); + if (paramTags && 0 <= i && i < paramTags.length) { + return [paramTags[i]]; + } + } + else if (param.name.kind === 70) { + var name_1 = param.name.text; + return ts.filter(tags, function (tag) { return tag.kind === 285 && tag.parameterName.text === name_1; }); + } + else { + return undefined; + } + } + ts.getJSDocParameterTags = getJSDocParameterTags; + function getJSDocType(node) { + var tag = getFirstJSDocTag(node, 287); + if (!tag && node.kind === 145) { + var paramTags = getJSDocParameterTags(node); + if (paramTags) { + tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); + } + } + return tag && tag.typeExpression && tag.typeExpression.type; + } + ts.getJSDocType = getJSDocType; + function getJSDocAugmentsTag(node) { + return getFirstJSDocTag(node, 284); + } + ts.getJSDocAugmentsTag = getJSDocAugmentsTag; + function getJSDocReturnTag(node) { + return getFirstJSDocTag(node, 286); + } + ts.getJSDocReturnTag = getJSDocReturnTag; + function getJSDocTemplateTag(node) { + return getFirstJSDocTag(node, 288); + } + ts.getJSDocTemplateTag = getJSDocTemplateTag; + function hasRestParameter(s) { + return isRestParameter(ts.lastOrUndefined(s.parameters)); + } + ts.hasRestParameter = hasRestParameter; + function hasDeclaredRestParameter(s) { + return isDeclaredRestParam(ts.lastOrUndefined(s.parameters)); + } + ts.hasDeclaredRestParameter = hasDeclaredRestParameter; + function isRestParameter(node) { + if (node && (node.flags & 65536)) { + if (node.type && node.type.kind === 279 || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 279; })) { + return true; + } + } + return isDeclaredRestParam(node); + } + ts.isRestParameter = isRestParameter; + function isDeclaredRestParam(node) { + return node && node.dotDotDotToken !== undefined; + } + ts.isDeclaredRestParam = isDeclaredRestParam; + var AssignmentKind; + (function (AssignmentKind) { + AssignmentKind[AssignmentKind["None"] = 0] = "None"; + AssignmentKind[AssignmentKind["Definite"] = 1] = "Definite"; + AssignmentKind[AssignmentKind["Compound"] = 2] = "Compound"; + })(AssignmentKind = ts.AssignmentKind || (ts.AssignmentKind = {})); + function getAssignmentTargetKind(node) { + var parent = node.parent; + while (true) { + switch (parent.kind) { + case 193: + var binaryOperator = parent.operatorToken.kind; + return isAssignmentOperator(binaryOperator) && parent.left === node ? + binaryOperator === 57 ? 1 : 2 : + 0; + case 191: + case 192: + var unaryOperator = parent.operator; + return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; + case 214: + case 215: + return parent.initializer === node ? 1 : 0; + case 184: + case 176: + case 197: + node = parent; + break; + case 261: + if (parent.name !== node) { + return 0; + } + node = parent.parent; + break; + case 260: + if (parent.name === node) { + return 0; + } + node = parent.parent; + break; + default: + return 0; + } + parent = node.parent; + } + } + ts.getAssignmentTargetKind = getAssignmentTargetKind; + function isAssignmentTarget(node) { + return getAssignmentTargetKind(node) !== 0; + } + ts.isAssignmentTarget = isAssignmentTarget; + function isDeleteTarget(node) { + if (node.kind !== 178 && node.kind !== 179) { + return false; + } + node = node.parent; + while (node && node.kind === 184) { + node = node.parent; + } + return node && node.kind === 187; + } + ts.isDeleteTarget = isDeleteTarget; + function isNodeDescendantOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + ts.isNodeDescendantOf = isNodeDescendantOf; + function isInAmbientContext(node) { + while (node) { + if (hasModifier(node, 2) || (node.kind === 264 && node.isDeclarationFile)) { + return true; + } + node = node.parent; + } + return false; + } + ts.isInAmbientContext = isInAmbientContext; + function isDeclarationName(name) { + if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { + return false; + } + var parent = name.parent; + if (parent.kind === 241 || parent.kind === 245) { + if (parent.propertyName) { + return true; + } + } + if (isDeclaration(parent)) { + return parent.name === name; + } + return false; + } + ts.isDeclarationName = isDeclarationName; + function isLiteralComputedPropertyDeclarationName(node) { + return (node.kind === 9 || node.kind === 8) && + node.parent.kind === 143 && + isDeclaration(node.parent.parent); + } + ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 148: + case 147: + case 150: + case 149: + case 152: + case 153: + case 263: + case 260: + case 178: + return parent.name === node; + case 142: + if (parent.right === node) { + while (parent.kind === 142) { + parent = parent.parent; + } + return parent.kind === 161; + } + return false; + case 175: + case 241: + return parent.propertyName === node; + case 245: + return true; + } + return false; + } + ts.isIdentifierName = isIdentifierName; + function isAliasSymbolDeclaration(node) { + return node.kind === 236 || + node.kind === 235 || + node.kind === 238 && !!node.name || + node.kind === 239 || + node.kind === 241 || + node.kind === 245 || + node.kind === 242 && exportAssignmentIsAlias(node); + } + ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; + function exportAssignmentIsAlias(node) { + return isEntityNameExpression(node.expression); + } + ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getClassExtendsHeritageClauseElement(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 84); + return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + } + ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + function getClassImplementsHeritageClauseElements(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 107); + return heritageClause ? heritageClause.types : undefined; + } + ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; + function getInterfaceBaseTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 84); + return heritageClause ? heritageClause.types : undefined; + } + ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; + function getHeritageClause(clauses, kind) { + if (clauses) { + for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { + var clause = clauses_1[_i]; + if (clause.token === kind) { + return clause; + } + } + } + return undefined; + } + ts.getHeritageClause = getHeritageClause; + function tryResolveScriptReference(host, sourceFile, reference) { + if (!host.getCompilerOptions().noResolve) { + var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); + return host.getSourceFile(referenceFileName); + } + } + ts.tryResolveScriptReference = tryResolveScriptReference; + function getAncestor(node, kind) { + while (node) { + if (node.kind === kind) { + return node; + } + node = node.parent; + } + return undefined; + } + ts.getAncestor = getAncestor; + function getFileReferenceFromReferencePath(comment, commentRange) { + var simpleReferenceRegEx = /^\/\/\/\s*/gim; + if (simpleReferenceRegEx.test(comment)) { + if (isNoDefaultLibRegEx.test(comment)) { + return { + isNoDefaultLib: true + }; + } + else { + var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); + var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); + if (refMatchResult || refLibResult) { + var start = commentRange.pos; + var end = commentRange.end; + return { + fileReference: { + pos: start, + end: end, + fileName: (refMatchResult || refLibResult)[3] + }, + isNoDefaultLib: false, + isTypeReferenceDirective: !!refLibResult + }; + } + return { + diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, + isNoDefaultLib: false + }; + } + } + return undefined; + } + ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; + function isKeyword(token) { + return 71 <= token && token <= 141; + } + ts.isKeyword = isKeyword; + function isTrivia(token) { + return 2 <= token && token <= 7; + } + ts.isTrivia = isTrivia; + function isAsyncFunctionLike(node) { + return isFunctionLike(node) && hasModifier(node, 256) && !isAccessor(node); + } + ts.isAsyncFunctionLike = isAsyncFunctionLike; + function isStringOrNumericLiteral(node) { + var kind = node.kind; + return kind === 9 + || kind === 8; + } + ts.isStringOrNumericLiteral = isStringOrNumericLiteral; + function hasDynamicName(declaration) { + return declaration.name && isDynamicName(declaration.name); + } + ts.hasDynamicName = hasDynamicName; + function isDynamicName(name) { + return name.kind === 143 && + !isStringOrNumericLiteral(name.expression) && + !isWellKnownSymbolSyntactically(name.expression); + } + ts.isDynamicName = isDynamicName; + function isWellKnownSymbolSyntactically(node) { + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); + } + ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; + function getPropertyNameForPropertyNameNode(name) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 145) { + return name.text; + } + if (name.kind === 143) { + var nameExpression = name.expression; + if (isWellKnownSymbolSyntactically(nameExpression)) { + var rightHandSideName = nameExpression.name.text; + return getPropertyNameForKnownSymbolName(rightHandSideName); + } + else if (nameExpression.kind === 9 || nameExpression.kind === 8) { + return nameExpression.text; + } + } + return undefined; + } + ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; + function getPropertyNameForKnownSymbolName(symbolName) { + return "__@" + symbolName; + } + ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; + function isESSymbolIdentifier(node) { + return node.kind === 70 && node.text === "Symbol"; + } + ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isPushOrUnshiftIdentifier(node) { + return node.text === "push" || node.text === "unshift"; + } + ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; + function isModifierKind(token) { + switch (token) { + case 116: + case 119: + case 75: + case 123: + case 78: + case 83: + case 113: + case 111: + case 112: + case 130: + case 114: + return true; + } + return false; + } + ts.isModifierKind = isModifierKind; + function isParameterDeclaration(node) { + var root = getRootDeclaration(node); + return root.kind === 145; + } + ts.isParameterDeclaration = isParameterDeclaration; + function getRootDeclaration(node) { + while (node.kind === 175) { + node = node.parent.parent; + } + return node; + } + ts.getRootDeclaration = getRootDeclaration; + function nodeStartsNewLexicalEnvironment(node) { + var kind = node.kind; + return kind === 151 + || kind === 185 + || kind === 227 + || kind === 186 + || kind === 150 + || kind === 152 + || kind === 153 + || kind === 232 + || kind === 264; + } + ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function nodeIsSynthesized(node) { + return ts.positionIsSynthesized(node.pos) + || ts.positionIsSynthesized(node.end); + } + ts.nodeIsSynthesized = nodeIsSynthesized; + function getOriginalSourceFileOrBundle(sourceFileOrBundle) { + if (sourceFileOrBundle.kind === 265) { + return ts.updateBundle(sourceFileOrBundle, ts.sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile)); + } + return getOriginalSourceFile(sourceFileOrBundle); + } + ts.getOriginalSourceFileOrBundle = getOriginalSourceFileOrBundle; + function getOriginalSourceFile(sourceFile) { + return ts.getParseTreeNode(sourceFile, isSourceFile) || sourceFile; + } + function getOriginalSourceFiles(sourceFiles) { + return ts.sameMap(sourceFiles, getOriginalSourceFile); + } + ts.getOriginalSourceFiles = getOriginalSourceFiles; + function getOriginalNodeId(node) { + node = ts.getOriginalNode(node); + return node ? ts.getNodeId(node) : 0; + } + ts.getOriginalNodeId = getOriginalNodeId; + var Associativity; + (function (Associativity) { + Associativity[Associativity["Left"] = 0] = "Left"; + Associativity[Associativity["Right"] = 1] = "Right"; + })(Associativity = ts.Associativity || (ts.Associativity = {})); + function getExpressionAssociativity(expression) { + var operator = getOperator(expression); + var hasArguments = expression.kind === 181 && expression.arguments !== undefined; + return getOperatorAssociativity(expression.kind, operator, hasArguments); + } + ts.getExpressionAssociativity = getExpressionAssociativity; + function getOperatorAssociativity(kind, operator, hasArguments) { + switch (kind) { + case 181: + return hasArguments ? 0 : 1; + case 191: + case 188: + case 189: + case 187: + case 190: + case 194: + case 196: + return 1; + case 193: + switch (operator) { + case 39: + case 57: + case 58: + case 59: + case 61: + case 60: + case 62: + case 63: + case 64: + case 65: + case 66: + case 67: + case 69: + case 68: + return 1; + } + } + return 0; + } + ts.getOperatorAssociativity = getOperatorAssociativity; + function getExpressionPrecedence(expression) { + var operator = getOperator(expression); + var hasArguments = expression.kind === 181 && expression.arguments !== undefined; + return getOperatorPrecedence(expression.kind, operator, hasArguments); + } + ts.getExpressionPrecedence = getExpressionPrecedence; + function getOperator(expression) { + if (expression.kind === 193) { + return expression.operatorToken.kind; + } + else if (expression.kind === 191 || expression.kind === 192) { + return expression.operator; + } + else { + return expression.kind; + } + } + ts.getOperator = getOperator; + function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { + switch (nodeKind) { + case 98: + case 96: + case 70: + case 94: + case 100: + case 85: + case 8: + case 9: + case 176: + case 177: + case 185: + case 186: + case 198: + case 248: + case 249: + case 11: + case 12: + case 195: + case 184: + case 199: + return 19; + case 182: + case 178: + case 179: + return 18; + case 181: + return hasArguments ? 18 : 17; + case 180: + return 17; + case 192: + return 16; + case 191: + case 188: + case 189: + case 187: + case 190: + return 15; + case 193: + switch (operatorKind) { + case 50: + case 51: + return 15; + case 39: + case 38: + case 40: + case 41: + return 14; + case 36: + case 37: + return 13; + case 44: + case 45: + case 46: + return 12; + case 26: + case 29: + case 28: + case 30: + case 91: + case 92: + return 11; + case 31: + case 33: + case 32: + case 34: + return 10; + case 47: + return 9; + case 49: + return 8; + case 48: + return 7; + case 52: + return 6; + case 53: + return 5; + case 57: + case 58: + case 59: + case 61: + case 60: + case 62: + case 63: + case 64: + case 65: + case 66: + case 67: + case 69: + case 68: + return 3; + case 25: + return 0; + default: + return -1; + } + case 194: + return 4; + case 196: + return 2; + case 197: + return 1; + default: + return -1; + } + } + ts.getOperatorPrecedence = getOperatorPrecedence; + function createDiagnosticCollection() { + var nonFileDiagnostics = []; + var fileDiagnostics = ts.createMap(); + var diagnosticsModified = false; + var modificationCount = 0; + return { + add: add, + getGlobalDiagnostics: getGlobalDiagnostics, + getDiagnostics: getDiagnostics, + getModificationCount: getModificationCount, + reattachFileDiagnostics: reattachFileDiagnostics + }; + function getModificationCount() { + return modificationCount; + } + function reattachFileDiagnostics(newFile) { + ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); + } + function add(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); + if (!diagnostics) { + diagnostics = []; + fileDiagnostics.set(diagnostic.file.fileName, diagnostics); + } + } + else { + diagnostics = nonFileDiagnostics; + } + diagnostics.push(diagnostic); + diagnosticsModified = true; + modificationCount++; + } + function getGlobalDiagnostics() { + sortAndDeduplicate(); + return nonFileDiagnostics; + } + function getDiagnostics(fileName) { + sortAndDeduplicate(); + if (fileName) { + return fileDiagnostics.get(fileName) || []; + } + var allDiagnostics = []; + function pushDiagnostic(d) { + allDiagnostics.push(d); + } + ts.forEach(nonFileDiagnostics, pushDiagnostic); + fileDiagnostics.forEach(function (diagnostics) { + ts.forEach(diagnostics, pushDiagnostic); + }); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function sortAndDeduplicate() { + if (!diagnosticsModified) { + return; + } + diagnosticsModified = false; + nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); + fileDiagnostics.forEach(function (diagnostics, key) { + fileDiagnostics.set(key, ts.sortAndDeduplicateDiagnostics(diagnostics)); + }); + } + } + ts.createDiagnosticCollection = createDiagnosticCollection; + var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var escapedCharsMap = ts.createMapFromTemplate({ + "\0": "\\0", + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\r": "\\r", + "\n": "\\n", + "\\": "\\\\", + "\"": "\\\"", + "\u2028": "\\u2028", + "\u2029": "\\u2029", + "\u0085": "\\u0085" + }); + function escapeString(s) { + return s.replace(escapedCharsRegExp, getReplacement); + } + ts.escapeString = escapeString; + function getReplacement(c) { + return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } + 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); + return "\\u" + paddedHexCode; + } + var nonAsciiCharacters = /[^\u0000-\u007F]/g; + function escapeNonAsciiCharacters(s) { + return nonAsciiCharacters.test(s) ? + s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : + s; + } + ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; + var indentStrings = ["", " "]; + function getIndentString(level) { + if (indentStrings[level] === undefined) { + indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + } + return indentStrings[level]; + } + ts.getIndentString = getIndentString; + function getIndentSize() { + return indentStrings[1].length; + } + ts.getIndentSize = getIndentSize; + function createTextWriter(newLine) { + var output; + var indent; + var lineStart; + var lineCount; + var linePos; + function write(s) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; + } + output += s; + } + } + function reset() { + output = ""; + indent = 0; + lineStart = true; + lineCount = 0; + linePos = 0; + } + function rawWrite(s) { + if (s !== undefined) { + if (lineStart) { + lineStart = false; + } + output += s; + } + } + function writeLiteral(s) { + if (s && s.length) { + write(s); + var lineStartsOfS = ts.computeLineStarts(s); + if (lineStartsOfS.length > 1) { + lineCount = lineCount + lineStartsOfS.length - 1; + linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + } + } + } + function writeLine() { + if (!lineStart) { + output += newLine; + lineCount++; + linePos = output.length; + lineStart = true; + } + } + function writeTextOfNode(text, node) { + write(getTextOfNodeFromSourceText(text, node)); + } + reset(); + return { + write: write, + rawWrite: rawWrite, + writeTextOfNode: writeTextOfNode, + writeLiteral: writeLiteral, + writeLine: writeLine, + increaseIndent: function () { indent++; }, + decreaseIndent: function () { indent--; }, + getIndent: function () { return indent; }, + getTextPos: function () { return output.length; }, + getLine: function () { return lineCount + 1; }, + getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, + getText: function () { return output; }, + isAtStartOfLine: function () { return lineStart; }, + reset: reset + }; + } + ts.createTextWriter = createTextWriter; + function getResolvedExternalModuleName(host, file) { + return file.moduleName || getExternalModuleNameFromPath(host, file.fileName); + } + ts.getResolvedExternalModuleName = getResolvedExternalModuleName; + function getExternalModuleNameFromDeclaration(host, resolver, declaration) { + var file = resolver.getExternalModuleFileFromDeclaration(declaration); + if (!file || isDeclarationFile(file)) { + return undefined; + } + return getResolvedExternalModuleName(host, file); + } + ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; + function getExternalModuleNameFromPath(host, fileName) { + var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; + var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); + var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false); + return ts.removeFileExtension(relativePath); + } + ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; + function getOwnEmitOutputFilePath(sourceFile, host, extension) { + var compilerOptions = host.getCompilerOptions(); + var emitOutputFilePathWithoutExtension; + if (compilerOptions.outDir) { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); + } + else { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); + } + return emitOutputFilePathWithoutExtension + extension; + } + ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; + function getDeclarationEmitOutputFilePath(sourceFile, host) { + var options = host.getCompilerOptions(); + var outputDir = options.declarationDir || options.outDir; + var path = outputDir + ? getSourceFilePathInNewDir(sourceFile, host, outputDir) + : sourceFile.fileName; + return ts.removeFileExtension(path) + ".d.ts"; + } + ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; + function getSourceFilesToEmit(host, targetSourceFile) { + var options = host.getCompilerOptions(); + var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); }; + if (options.outFile || options.out) { + var moduleKind = ts.getEmitModuleKind(options); + var moduleEmitEnabled_1 = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; + return ts.filter(host.getSourceFiles(), function (sourceFile) { + return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); + }); + } + else { + var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); }); + } + } + ts.getSourceFilesToEmit = getSourceFilesToEmit; + function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) { + return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !isDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); + } + ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); + var options = host.getCompilerOptions(); + if (options.outFile || options.out) { + if (sourceFiles.length) { + var jsFilePath = options.outFile || options.out; + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); + } + } + else { + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, sourceFile, emitOnlyDtsFiles); + } + } + } + ts.forEachEmittedFile = forEachEmittedFile; + function getSourceMapFilePath(jsFilePath, options) { + return options.sourceMap ? jsFilePath + ".map" : undefined; + } + function getOutputExtension(sourceFile, options) { + if (options.jsx === 1) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + return ".jsx"; + } + } + else if (sourceFile.languageVariant === 1) { + return ".jsx"; + } + } + return ".js"; + } + function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { + var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); + var commonSourceDirectory = host.getCommonSourceDirectory(); + var isSourceFileInCommonSourceDirectory = host.getCanonicalFileName(sourceFilePath).indexOf(host.getCanonicalFileName(commonSourceDirectory)) === 0; + sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath; + return ts.combinePaths(newDirPath, sourceFilePath); + } + ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; + function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { + host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); + }, sourceFiles); + } + ts.writeFile = writeFile; + function getLineOfLocalPosition(currentSourceFile, pos) { + return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; + } + ts.getLineOfLocalPosition = getLineOfLocalPosition; + function getLineOfLocalPositionFromLineMap(lineMap, pos) { + return ts.computeLineAndCharacterOfPosition(lineMap, pos).line; + } + ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; + function getFirstConstructorWithBody(node) { + return ts.forEach(node.members, function (member) { + if (member.kind === 151 && nodeIsPresent(member.body)) { + return member; + } + }); + } + ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function getSetAccessorTypeAnnotationNode(accessor) { + if (accessor && accessor.parameters.length > 0) { + var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); + return accessor.parameters[hasThis ? 1 : 0].type; + } + } + ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; + function getThisParameter(signature) { + if (signature.parameters.length) { + var thisParameter = signature.parameters[0]; + if (parameterIsThisKeyword(thisParameter)) { + return thisParameter; + } + } + } + ts.getThisParameter = getThisParameter; + function parameterIsThisKeyword(parameter) { + return isThisIdentifier(parameter.name); + } + ts.parameterIsThisKeyword = parameterIsThisKeyword; + function isThisIdentifier(node) { + return node && node.kind === 70 && identifierIsThisKeyword(node); + } + ts.isThisIdentifier = isThisIdentifier; + function identifierIsThisKeyword(id) { + return id.originalKeywordKind === 98; + } + ts.identifierIsThisKeyword = identifierIsThisKeyword; + function getAllAccessorDeclarations(declarations, accessor) { + var firstAccessor; + var secondAccessor; + var getAccessor; + var setAccessor; + if (hasDynamicName(accessor)) { + firstAccessor = accessor; + if (accessor.kind === 152) { + getAccessor = accessor; + } + else if (accessor.kind === 153) { + setAccessor = accessor; + } + else { + ts.Debug.fail("Accessor has wrong kind"); + } + } + else { + ts.forEach(declarations, function (member) { + if ((member.kind === 152 || member.kind === 153) + && hasModifier(member, 32) === hasModifier(accessor, 32)) { + var memberName = getPropertyNameForPropertyNameNode(member.name); + var accessorName = getPropertyNameForPropertyNameNode(accessor.name); + if (memberName === accessorName) { + if (!firstAccessor) { + firstAccessor = member; + } + else if (!secondAccessor) { + secondAccessor = member; + } + if (member.kind === 152 && !getAccessor) { + getAccessor = member; + } + if (member.kind === 153 && !setAccessor) { + setAccessor = member; + } + } + } + }); + } + return { + firstAccessor: firstAccessor, + secondAccessor: secondAccessor, + getAccessor: getAccessor, + setAccessor: setAccessor + }; + } + ts.getAllAccessorDeclarations = getAllAccessorDeclarations; + function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) { + emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments); + } + ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; + function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) { + if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos && + getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) { + writer.writeLine(); + } + } + ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition; + function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) { + if (pos !== commentPos && + getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) { + writer.writeLine(); + } + } + ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition; + function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { + if (comments && comments.length > 0) { + if (leadingSeparator) { + writer.write(" "); + } + var emitInterveningSeparator = false; + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; + if (emitInterveningSeparator) { + writer.write(" "); + emitInterveningSeparator = false; + } + writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + else { + emitInterveningSeparator = true; + } + } + if (emitInterveningSeparator && trailingSeparator) { + writer.write(" "); + } + } + } + ts.emitComments = emitComments; + function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) { + var leadingComments; + var currentDetachedCommentInfo; + if (removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment = void 0; + for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { + var comment = leadingComments_1[_i]; + if (lastComment) { + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end); + var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos); + if (commentLine >= lastCommentLine + 2) { + break; + } + } + detachedComments.push(comment); + lastComment = comment; + } + if (detachedComments.length) { + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); + var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); + emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment); + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + } + } + } + return currentDetachedCommentInfo; + function isPinnedComment(comment) { + return text.charCodeAt(comment.pos + 1) === 42 && + text.charCodeAt(comment.pos + 2) === 33; + } + } + ts.emitDetachedComments = emitDetachedComments; + function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { + if (text.charCodeAt(commentPos + 1) === 42) { + var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); + var lineCount = lineMap.length; + var firstCommentLineIndent = void 0; + for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) { + var nextLineStart = (currentLine + 1) === lineCount + ? text.length + 1 + : lineMap[currentLine + 1]; + if (pos !== commentPos) { + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos); + } + var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart); + if (spacesToEmit > 0) { + var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); + var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + writer.rawWrite(indentSizeSpaceString); + while (numberOfSingleSpacesToEmit) { + writer.rawWrite(" "); + numberOfSingleSpacesToEmit--; + } + } + else { + writer.rawWrite(""); + } + } + writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart); + pos = nextLineStart; + } + } + else { + writer.write(text.substring(commentPos, commentEnd)); + } + } + ts.writeCommentRange = writeCommentRange; + function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { + var end = Math.min(commentEnd, nextLineStart - 1); + var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + if (currentLineText) { + writer.write(currentLineText); + if (end !== commentEnd) { + writer.writeLine(); + } + } + else { + writer.writeLiteral(newLine); + } + } + function calculateIndent(text, pos, end) { + var currentLineIndent = 0; + for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { + if (text.charCodeAt(pos) === 9) { + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); + } + else { + currentLineIndent++; + } + } + return currentLineIndent; + } + function hasModifiers(node) { + return getModifierFlags(node) !== 0; + } + ts.hasModifiers = hasModifiers; + function hasModifier(node, flags) { + return (getModifierFlags(node) & flags) !== 0; + } + ts.hasModifier = hasModifier; + function getModifierFlags(node) { + if (node.modifierFlagsCache & 536870912) { + return node.modifierFlagsCache & ~536870912; + } + var flags = 0; + if (node.modifiers) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var modifier = _a[_i]; + flags |= modifierToFlag(modifier.kind); + } + } + if (node.flags & 4 || (node.kind === 70 && node.isInJSDocNamespace)) { + flags |= 1; + } + node.modifierFlagsCache = flags | 536870912; + return flags; + } + ts.getModifierFlags = getModifierFlags; + function modifierToFlag(token) { + switch (token) { + case 114: return 32; + case 113: return 4; + case 112: return 16; + case 111: return 8; + case 116: return 128; + case 83: return 1; + case 123: return 2; + case 75: return 2048; + case 78: return 512; + case 119: return 256; + case 130: return 64; + } + return 0; + } + ts.modifierToFlag = modifierToFlag; + function isLogicalOperator(token) { + return token === 53 + || token === 52 + || token === 50; + } + ts.isLogicalOperator = isLogicalOperator; + function isAssignmentOperator(token) { + return token >= 57 && token <= 69; + } + ts.isAssignmentOperator = isAssignmentOperator; + function tryGetClassExtendingExpressionWithTypeArguments(node) { + if (node.kind === 200 && + node.parent.token === 84 && + isClassLike(node.parent.parent)) { + return node.parent.parent; + } + } + ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; + function isAssignmentExpression(node, excludeCompoundAssignment) { + return isBinaryExpression(node) + && (excludeCompoundAssignment + ? node.operatorToken.kind === 57 + : isAssignmentOperator(node.operatorToken.kind)) + && isLeftHandSideExpression(node.left); + } + ts.isAssignmentExpression = isAssignmentExpression; + function isDestructuringAssignment(node) { + if (isAssignmentExpression(node, true)) { + var kind = node.left.kind; + return kind === 177 + || kind === 176; + } + return false; + } + ts.isDestructuringAssignment = isDestructuringAssignment; + function isSupportedExpressionWithTypeArguments(node) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; + function isSupportedExpressionWithTypeArgumentsRest(node) { + if (node.kind === 70) { + return true; + } + else if (isPropertyAccessExpression(node)) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + else { + return false; + } + } + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; + } + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; + function isEntityNameExpression(node) { + return node.kind === 70 || + node.kind === 178 && isEntityNameExpression(node.expression); + } + ts.isEntityNameExpression = isEntityNameExpression; + function isRightSideOfQualifiedNameOrPropertyAccess(node) { + return (node.parent.kind === 142 && node.parent.right === node) || + (node.parent.kind === 178 && node.parent.name === node); + } + ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 177) { + return expression.properties.length === 0; + } + if (kind === 176) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; + function getLocalSymbolForExportDefault(symbol) { + return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined; + } + ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function isExportDefaultSymbol(symbol) { + return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512); + } + ts.isExportDefaultSymbol = isExportDefaultSymbol; + function tryExtractTypeScriptExtension(fileName) { + return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); + } + ts.tryExtractTypeScriptExtension = tryExtractTypeScriptExtension; + function getExpandedCharCodes(input) { + var output = []; + var length = input.length; + for (var i = 0; i < length; i++) { + var charCode = input.charCodeAt(i); + if (charCode < 0x80) { + output.push(charCode); + } + else if (charCode < 0x800) { + output.push((charCode >> 6) | 192); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x10000) { + output.push((charCode >> 12) | 224); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x20000) { + output.push((charCode >> 18) | 240); + output.push(((charCode >> 12) & 63) | 128); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else { + ts.Debug.assert(false, "Unexpected code point"); + } + } + return output; + } + var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + function convertToBase64(input) { + var result = ""; + var charCodes = getExpandedCharCodes(input); + var i = 0; + var length = charCodes.length; + var byte1, byte2, byte3, byte4; + while (i < length) { + byte1 = charCodes[i] >> 2; + byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; + byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; + byte4 = charCodes[i + 2] & 63; + if (i + 1 >= length) { + byte3 = byte4 = 64; + } + else if (i + 2 >= length) { + byte4 = 64; + } + result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); + i += 3; + } + return result; + } + ts.convertToBase64 = convertToBase64; + var carriageReturnLineFeed = "\r\n"; + var lineFeed = "\n"; + function getNewLineCharacter(options) { + if (options.newLine === 0) { + return carriageReturnLineFeed; + } + else if (options.newLine === 1) { + return lineFeed; + } + else if (ts.sys) { + return ts.sys.newLine; + } + return carriageReturnLineFeed; + } + ts.getNewLineCharacter = getNewLineCharacter; + function isSimpleExpression(node) { + return isSimpleExpressionWorker(node, 0); + } + ts.isSimpleExpression = isSimpleExpression; + function isSimpleExpressionWorker(node, depth) { + if (depth <= 5) { + var kind = node.kind; + if (kind === 9 + || kind === 8 + || kind === 11 + || kind === 12 + || kind === 70 + || kind === 98 + || kind === 96 + || kind === 100 + || kind === 85 + || kind === 94) { + return true; + } + else if (kind === 178) { + return isSimpleExpressionWorker(node.expression, depth + 1); + } + else if (kind === 179) { + return isSimpleExpressionWorker(node.expression, depth + 1) + && isSimpleExpressionWorker(node.argumentExpression, depth + 1); + } + else if (kind === 191 + || kind === 192) { + return isSimpleExpressionWorker(node.operand, depth + 1); + } + else if (kind === 193) { + return node.operatorToken.kind !== 39 + && isSimpleExpressionWorker(node.left, depth + 1) + && isSimpleExpressionWorker(node.right, depth + 1); + } + else if (kind === 194) { + return isSimpleExpressionWorker(node.condition, depth + 1) + && isSimpleExpressionWorker(node.whenTrue, depth + 1) + && isSimpleExpressionWorker(node.whenFalse, depth + 1); + } + else if (kind === 189 + || kind === 188 + || kind === 187) { + return isSimpleExpressionWorker(node.expression, depth + 1); + } + else if (kind === 176) { + return node.elements.length === 0; + } + else if (kind === 177) { + return node.properties.length === 0; + } + else if (kind === 180) { + if (!isSimpleExpressionWorker(node.expression, depth + 1)) { + return false; + } + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var argument = _a[_i]; + if (!isSimpleExpressionWorker(argument, depth + 1)) { + return false; + } + } + return true; + } + } + return false; + } + var syntaxKindCache = []; + function formatSyntaxKind(kind) { + var syntaxKindEnum = ts.SyntaxKind; + if (syntaxKindEnum) { + var cached = syntaxKindCache[kind]; + if (cached !== undefined) { + return cached; + } + for (var name in syntaxKindEnum) { + if (syntaxKindEnum[name] === kind) { + var result = kind + " (" + name + ")"; + syntaxKindCache[kind] = result; + return result; + } + } + } + else { + return kind.toString(); + } + } + ts.formatSyntaxKind = formatSyntaxKind; + function getRangePos(range) { + return range ? range.pos : -1; + } + ts.getRangePos = getRangePos; + function getRangeEnd(range) { + return range ? range.end : -1; + } + ts.getRangeEnd = getRangeEnd; + function movePos(pos, value) { + return ts.positionIsSynthesized(pos) ? -1 : pos + value; + } + ts.movePos = movePos; + function createRange(pos, end) { + return { pos: pos, end: end }; + } + ts.createRange = createRange; + function moveRangeEnd(range, end) { + return createRange(range.pos, end); + } + ts.moveRangeEnd = moveRangeEnd; + function moveRangePos(range, pos) { + return createRange(pos, range.end); + } + ts.moveRangePos = moveRangePos; + function moveRangePastDecorators(node) { + return node.decorators && node.decorators.length > 0 + ? moveRangePos(node, node.decorators.end) + : node; + } + ts.moveRangePastDecorators = moveRangePastDecorators; + function moveRangePastModifiers(node) { + return node.modifiers && node.modifiers.length > 0 + ? moveRangePos(node, node.modifiers.end) + : moveRangePastDecorators(node); + } + ts.moveRangePastModifiers = moveRangePastModifiers; + function isCollapsedRange(range) { + return range.pos === range.end; + } + ts.isCollapsedRange = isCollapsedRange; + function collapseRangeToStart(range) { + return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); + } + ts.collapseRangeToStart = collapseRangeToStart; + function collapseRangeToEnd(range) { + return isCollapsedRange(range) ? range : moveRangePos(range, range.end); + } + ts.collapseRangeToEnd = collapseRangeToEnd; + function createTokenRange(pos, token) { + return createRange(pos, pos + ts.tokenToString(token).length); + } + ts.createTokenRange = createTokenRange; + function rangeIsOnSingleLine(range, sourceFile) { + return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile); + } + ts.rangeIsOnSingleLine = rangeIsOnSingleLine; + function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) { + return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), getStartPositionOfRange(range2, sourceFile), sourceFile); + } + ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine; + function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) { + return positionsAreOnSameLine(range1.end, range2.end, sourceFile); + } + ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine; + function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) { + return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), range2.end, sourceFile); + } + ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd; + function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) { + return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile), sourceFile); + } + ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart; + function positionsAreOnSameLine(pos1, pos2, sourceFile) { + return pos1 === pos2 || + getLineOfLocalPosition(sourceFile, pos1) === getLineOfLocalPosition(sourceFile, pos2); + } + ts.positionsAreOnSameLine = positionsAreOnSameLine; + function getStartPositionOfRange(range, sourceFile) { + return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); + } + ts.getStartPositionOfRange = getStartPositionOfRange; + function isDeclarationNameOfEnumOrNamespace(node) { + var parseNode = ts.getParseTreeNode(node); + if (parseNode) { + switch (parseNode.parent.kind) { + case 231: + case 232: + return parseNode === parseNode.parent.name; + } + } + return false; + } + ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace; + function getInitializedVariables(node) { + return ts.filter(node.declarations, isInitializedVariable); + } + ts.getInitializedVariables = getInitializedVariables; + function isInitializedVariable(node) { + return node.initializer !== undefined; + } + function isMergedWithClass(node) { + if (node.symbol) { + for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 228 && declaration !== node) { + return true; + } + } + } + return false; + } + ts.isMergedWithClass = isMergedWithClass; + function isFirstDeclarationOfKind(node, kind) { + return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; + } + ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; + function isNodeArray(array) { + return array.hasOwnProperty("pos") + && array.hasOwnProperty("end"); + } + ts.isNodeArray = isNodeArray; + function isNoSubstitutionTemplateLiteral(node) { + return node.kind === 12; + } + ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; + function isLiteralKind(kind) { + return 8 <= kind && kind <= 12; + } + ts.isLiteralKind = isLiteralKind; + function isTextualLiteralKind(kind) { + return kind === 9 || kind === 12; + } + ts.isTextualLiteralKind = isTextualLiteralKind; + function isLiteralExpression(node) { + return isLiteralKind(node.kind); + } + ts.isLiteralExpression = isLiteralExpression; + function isTemplateLiteralKind(kind) { + return 12 <= kind && kind <= 15; + } + ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isTemplateHead(node) { + return node.kind === 13; + } + ts.isTemplateHead = isTemplateHead; + function isTemplateMiddleOrTemplateTail(node) { + var kind = node.kind; + return kind === 14 + || kind === 15; + } + ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; + function isIdentifier(node) { + return node.kind === 70; + } + ts.isIdentifier = isIdentifier; + function isVoidExpression(node) { + return node.kind === 189; + } + ts.isVoidExpression = isVoidExpression; + function isGeneratedIdentifier(node) { + return isIdentifier(node) && node.autoGenerateKind > 0; + } + ts.isGeneratedIdentifier = isGeneratedIdentifier; + function isModifier(node) { + return isModifierKind(node.kind); + } + ts.isModifier = isModifier; + function isQualifiedName(node) { + return node.kind === 142; + } + ts.isQualifiedName = isQualifiedName; + function isComputedPropertyName(node) { + return node.kind === 143; + } + ts.isComputedPropertyName = isComputedPropertyName; + function isEntityName(node) { + var kind = node.kind; + return kind === 142 + || kind === 70; + } + ts.isEntityName = isEntityName; + function isPropertyName(node) { + var kind = node.kind; + return kind === 70 + || kind === 9 + || kind === 8 + || kind === 143; + } + ts.isPropertyName = isPropertyName; + function isModuleName(node) { + var kind = node.kind; + return kind === 70 + || kind === 9; + } + ts.isModuleName = isModuleName; + function isBindingName(node) { + var kind = node.kind; + return kind === 70 + || kind === 173 + || kind === 174; + } + ts.isBindingName = isBindingName; + function isTypeParameter(node) { + return node.kind === 144; + } + ts.isTypeParameter = isTypeParameter; + function isParameter(node) { + return node.kind === 145; + } + ts.isParameter = isParameter; + function isDecorator(node) { + return node.kind === 146; + } + ts.isDecorator = isDecorator; + function isMethodDeclaration(node) { + return node.kind === 150; + } + ts.isMethodDeclaration = isMethodDeclaration; + function isClassElement(node) { + var kind = node.kind; + return kind === 151 + || kind === 148 + || kind === 150 + || kind === 152 + || kind === 153 + || kind === 156 + || kind === 205; + } + ts.isClassElement = isClassElement; + function isObjectLiteralElementLike(node) { + var kind = node.kind; + return kind === 260 + || kind === 261 + || kind === 262 + || kind === 150 + || kind === 152 + || kind === 153 + || kind === 246; + } + ts.isObjectLiteralElementLike = isObjectLiteralElementLike; + function isTypeNodeKind(kind) { + return (kind >= 157 && kind <= 172) + || kind === 118 + || kind === 132 + || kind === 121 + || kind === 135 + || kind === 136 + || kind === 104 + || kind === 129 + || kind === 200; + } + function isTypeNode(node) { + return isTypeNodeKind(node.kind); + } + ts.isTypeNode = isTypeNode; + function isArrayBindingPattern(node) { + return node.kind === 174; + } + ts.isArrayBindingPattern = isArrayBindingPattern; + function isObjectBindingPattern(node) { + return node.kind === 173; + } + ts.isObjectBindingPattern = isObjectBindingPattern; + function isBindingPattern(node) { + if (node) { + var kind = node.kind; + return kind === 174 + || kind === 173; + } + return false; + } + ts.isBindingPattern = isBindingPattern; + function isAssignmentPattern(node) { + var kind = node.kind; + return kind === 176 + || kind === 177; + } + ts.isAssignmentPattern = isAssignmentPattern; + function isBindingElement(node) { + return node.kind === 175; + } + ts.isBindingElement = isBindingElement; + function isArrayBindingElement(node) { + var kind = node.kind; + return kind === 175 + || kind === 199; + } + ts.isArrayBindingElement = isArrayBindingElement; + function isDeclarationBindingElement(bindingElement) { + switch (bindingElement.kind) { + case 225: + case 145: + case 175: + return true; + } + return false; + } + ts.isDeclarationBindingElement = isDeclarationBindingElement; + function isBindingOrAssignmentPattern(node) { + return isObjectBindingOrAssignmentPattern(node) + || isArrayBindingOrAssignmentPattern(node); + } + ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; + function isObjectBindingOrAssignmentPattern(node) { + switch (node.kind) { + case 173: + case 177: + return true; + } + return false; + } + ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; + function isArrayBindingOrAssignmentPattern(node) { + switch (node.kind) { + case 174: + case 176: + return true; + } + return false; + } + ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; + function isArrayLiteralExpression(node) { + return node.kind === 176; + } + ts.isArrayLiteralExpression = isArrayLiteralExpression; + function isObjectLiteralExpression(node) { + return node.kind === 177; + } + ts.isObjectLiteralExpression = isObjectLiteralExpression; + function isPropertyAccessExpression(node) { + return node.kind === 178; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 179; + } + ts.isElementAccessExpression = isElementAccessExpression; + function isBinaryExpression(node) { + return node.kind === 193; + } + ts.isBinaryExpression = isBinaryExpression; + function isConditionalExpression(node) { + return node.kind === 194; + } + ts.isConditionalExpression = isConditionalExpression; + function isCallExpression(node) { + return node.kind === 180; + } + ts.isCallExpression = isCallExpression; + function isTemplateLiteral(node) { + var kind = node.kind; + return kind === 195 + || kind === 12; + } + ts.isTemplateLiteral = isTemplateLiteral; + function isSpreadExpression(node) { + return node.kind === 197; + } + ts.isSpreadExpression = isSpreadExpression; + function isExpressionWithTypeArguments(node) { + return node.kind === 200; + } + ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; + function isLeftHandSideExpressionKind(kind) { + return kind === 178 + || kind === 179 + || kind === 181 + || kind === 180 + || kind === 248 + || kind === 249 + || kind === 182 + || kind === 176 + || kind === 184 + || kind === 177 + || kind === 198 + || kind === 185 + || kind === 70 + || kind === 11 + || kind === 8 + || kind === 9 + || kind === 12 + || kind === 195 + || kind === 85 + || kind === 94 + || kind === 98 + || kind === 100 + || kind === 96 + || kind === 202 + || kind === 203; + } + function isLeftHandSideExpression(node) { + return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); + } + ts.isLeftHandSideExpression = isLeftHandSideExpression; + function isUnaryExpressionKind(kind) { + return kind === 191 + || kind === 192 + || kind === 187 + || kind === 188 + || kind === 189 + || kind === 190 + || kind === 183 + || isLeftHandSideExpressionKind(kind); + } + function isUnaryExpression(node) { + return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); + } + ts.isUnaryExpression = isUnaryExpression; + function isExpressionKind(kind) { + return kind === 194 + || kind === 196 + || kind === 186 + || kind === 193 + || kind === 197 + || kind === 201 + || kind === 199 + || isUnaryExpressionKind(kind); + } + function isExpression(node) { + return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); + } + ts.isExpression = isExpression; + function isAssertionExpression(node) { + var kind = node.kind; + return kind === 183 + || kind === 201; + } + ts.isAssertionExpression = isAssertionExpression; + function isPartiallyEmittedExpression(node) { + return node.kind === 298; + } + ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; + function isNotEmittedStatement(node) { + return node.kind === 297; + } + ts.isNotEmittedStatement = isNotEmittedStatement; + function isNotEmittedOrPartiallyEmittedNode(node) { + return isNotEmittedStatement(node) + || isPartiallyEmittedExpression(node); + } + ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; + function isOmittedExpression(node) { + return node.kind === 199; + } + ts.isOmittedExpression = isOmittedExpression; + function isTemplateSpan(node) { + return node.kind === 204; + } + ts.isTemplateSpan = isTemplateSpan; + function isBlock(node) { + return node.kind === 206; + } + ts.isBlock = isBlock; + function isConciseBody(node) { + return isBlock(node) + || isExpression(node); + } + ts.isConciseBody = isConciseBody; + function isFunctionBody(node) { + return isBlock(node); + } + ts.isFunctionBody = isFunctionBody; + function isForInitializer(node) { + return isVariableDeclarationList(node) + || isExpression(node); + } + ts.isForInitializer = isForInitializer; + function isVariableDeclaration(node) { + return node.kind === 225; + } + ts.isVariableDeclaration = isVariableDeclaration; + function isVariableDeclarationList(node) { + return node.kind === 226; + } + ts.isVariableDeclarationList = isVariableDeclarationList; + function isCaseBlock(node) { + return node.kind === 234; + } + ts.isCaseBlock = isCaseBlock; + function isModuleBody(node) { + var kind = node.kind; + return kind === 233 + || kind === 232 + || kind === 70; + } + ts.isModuleBody = isModuleBody; + function isNamespaceBody(node) { + var kind = node.kind; + return kind === 233 + || kind === 232; + } + ts.isNamespaceBody = isNamespaceBody; + function isJSDocNamespaceBody(node) { + var kind = node.kind; + return kind === 70 + || kind === 232; + } + ts.isJSDocNamespaceBody = isJSDocNamespaceBody; + function isImportEqualsDeclaration(node) { + return node.kind === 236; + } + ts.isImportEqualsDeclaration = isImportEqualsDeclaration; + function isImportClause(node) { + return node.kind === 238; + } + ts.isImportClause = isImportClause; + function isNamedImportBindings(node) { + var kind = node.kind; + return kind === 240 + || kind === 239; + } + ts.isNamedImportBindings = isNamedImportBindings; + function isImportSpecifier(node) { + return node.kind === 241; + } + ts.isImportSpecifier = isImportSpecifier; + function isNamedExports(node) { + return node.kind === 244; + } + ts.isNamedExports = isNamedExports; + function isExportSpecifier(node) { + return node.kind === 245; + } + ts.isExportSpecifier = isExportSpecifier; + function isModuleOrEnumDeclaration(node) { + return node.kind === 232 || node.kind === 231; + } + ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; + function isDeclarationKind(kind) { + return kind === 186 + || kind === 175 + || kind === 228 + || kind === 198 + || kind === 151 + || kind === 231 + || kind === 263 + || kind === 245 + || kind === 227 + || kind === 185 + || kind === 152 + || kind === 238 + || kind === 236 + || kind === 241 + || kind === 229 + || kind === 252 + || kind === 150 + || kind === 149 + || kind === 232 + || kind === 235 + || kind === 239 + || kind === 145 + || kind === 260 + || kind === 148 + || kind === 147 + || kind === 153 + || kind === 261 + || kind === 230 + || kind === 144 + || kind === 225 + || kind === 289; + } + function isDeclarationStatementKind(kind) { + return kind === 227 + || kind === 246 + || kind === 228 + || kind === 229 + || kind === 230 + || kind === 231 + || kind === 232 + || kind === 237 + || kind === 236 + || kind === 243 + || kind === 242 + || kind === 235; + } + function isStatementKindButNotDeclarationKind(kind) { + return kind === 217 + || kind === 216 + || kind === 224 + || kind === 211 + || kind === 209 + || kind === 208 + || kind === 214 + || kind === 215 + || kind === 213 + || kind === 210 + || kind === 221 + || kind === 218 + || kind === 220 + || kind === 222 + || kind === 223 + || kind === 207 + || kind === 212 + || kind === 219 + || kind === 297 + || kind === 300 + || kind === 299; + } + function isDeclaration(node) { + return isDeclarationKind(node.kind); + } + ts.isDeclaration = isDeclaration; + function isDeclarationStatement(node) { + return isDeclarationStatementKind(node.kind); + } + ts.isDeclarationStatement = isDeclarationStatement; + function isStatementButNotDeclaration(node) { + return isStatementKindButNotDeclarationKind(node.kind); + } + ts.isStatementButNotDeclaration = isStatementButNotDeclaration; + function isStatement(node) { + var kind = node.kind; + return isStatementKindButNotDeclarationKind(kind) + || isDeclarationStatementKind(kind) + || kind === 206; + } + ts.isStatement = isStatement; + function isModuleReference(node) { + var kind = node.kind; + return kind === 247 + || kind === 142 + || kind === 70; + } + ts.isModuleReference = isModuleReference; + function isJsxOpeningElement(node) { + return node.kind === 250; + } + ts.isJsxOpeningElement = isJsxOpeningElement; + function isJsxClosingElement(node) { + return node.kind === 251; + } + ts.isJsxClosingElement = isJsxClosingElement; + function isJsxTagNameExpression(node) { + var kind = node.kind; + return kind === 98 + || kind === 70 + || kind === 178; + } + ts.isJsxTagNameExpression = isJsxTagNameExpression; + function isJsxChild(node) { + var kind = node.kind; + return kind === 248 + || kind === 255 + || kind === 249 + || kind === 10; + } + ts.isJsxChild = isJsxChild; + function isJsxAttributes(node) { + var kind = node.kind; + return kind === 253; + } + ts.isJsxAttributes = isJsxAttributes; + function isJsxAttributeLike(node) { + var kind = node.kind; + return kind === 252 + || kind === 254; + } + ts.isJsxAttributeLike = isJsxAttributeLike; + function isJsxSpreadAttribute(node) { + return node.kind === 254; + } + ts.isJsxSpreadAttribute = isJsxSpreadAttribute; + function isJsxAttribute(node) { + return node.kind === 252; + } + ts.isJsxAttribute = isJsxAttribute; + function isJsxOpeningLikeElement(node) { + return node.kind === 250 || node.kind === 249; + } + ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; + function isStringLiteralOrJsxExpression(node) { + var kind = node.kind; + return kind === 9 + || kind === 255; + } + ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; + function isCaseOrDefaultClause(node) { + var kind = node.kind; + return kind === 256 + || kind === 257; + } + ts.isCaseOrDefaultClause = isCaseOrDefaultClause; + function isHeritageClause(node) { + return node.kind === 258; + } + ts.isHeritageClause = isHeritageClause; + function isCatchClause(node) { + return node.kind === 259; + } + ts.isCatchClause = isCatchClause; + function isPropertyAssignment(node) { + return node.kind === 260; + } + ts.isPropertyAssignment = isPropertyAssignment; + function isShorthandPropertyAssignment(node) { + return node.kind === 261; + } + ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; + function isEnumMember(node) { + return node.kind === 263; + } + ts.isEnumMember = isEnumMember; + function isSourceFile(node) { + return node.kind === 264; + } + ts.isSourceFile = isSourceFile; + function isWatchSet(options) { + return options.watch && options.hasOwnProperty("watch"); + } + ts.isWatchSet = isWatchSet; +})(ts || (ts = {})); +(function (ts) { + function getDefaultLibFileName(options) { + switch (options.target) { + case 5: + case 4: + return "lib.es2017.d.ts"; + case 3: + return "lib.es2016.d.ts"; + case 2: + return "lib.es6.d.ts"; + default: + return "lib.d.ts"; + } + } + ts.getDefaultLibFileName = getDefaultLibFileName; + function textSpanEnd(span) { + return span.start + span.length; + } + ts.textSpanEnd = textSpanEnd; + function textSpanIsEmpty(span) { + return span.length === 0; + } + ts.textSpanIsEmpty = textSpanIsEmpty; + function textSpanContainsPosition(span, position) { + return position >= span.start && position < textSpanEnd(span); + } + ts.textSpanContainsPosition = textSpanContainsPosition; + function textSpanContainsTextSpan(span, other) { + return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); + } + ts.textSpanContainsTextSpan = textSpanContainsTextSpan; + function textSpanOverlapsWith(span, other) { + var overlapStart = Math.max(span.start, other.start); + var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); + return overlapStart < overlapEnd; + } + ts.textSpanOverlapsWith = textSpanOverlapsWith; + function textSpanOverlap(span1, span2) { + var overlapStart = Math.max(span1.start, span2.start); + var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (overlapStart < overlapEnd) { + return createTextSpanFromBounds(overlapStart, overlapEnd); + } + return undefined; + } + ts.textSpanOverlap = textSpanOverlap; + function textSpanIntersectsWithTextSpan(span, other) { + return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; + } + ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; + function textSpanIntersectsWith(span, start, length) { + var end = start + length; + return start <= textSpanEnd(span) && end >= span.start; + } + ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; + } + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; + function textSpanIntersectsWithPosition(span, position) { + return position <= textSpanEnd(span) && position >= span.start; + } + ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; + function textSpanIntersection(span1, span2) { + var intersectStart = Math.max(span1.start, span2.start); + var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (intersectStart <= intersectEnd) { + return createTextSpanFromBounds(intersectStart, intersectEnd); + } + return undefined; + } + ts.textSpanIntersection = textSpanIntersection; + function createTextSpan(start, length) { + if (start < 0) { + throw new Error("start < 0"); + } + if (length < 0) { + throw new Error("length < 0"); + } + return { start: start, length: length }; + } + ts.createTextSpan = createTextSpan; + function createTextSpanFromBounds(start, end) { + return createTextSpan(start, end - start); + } + ts.createTextSpanFromBounds = createTextSpanFromBounds; + function textChangeRangeNewSpan(range) { + return createTextSpan(range.span.start, range.newLength); + } + ts.textChangeRangeNewSpan = textChangeRangeNewSpan; + function textChangeRangeIsUnchanged(range) { + return textSpanIsEmpty(range.span) && range.newLength === 0; + } + ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; + function createTextChangeRange(span, newLength) { + if (newLength < 0) { + throw new Error("newLength < 0"); + } + return { span: span, newLength: newLength }; + } + ts.createTextChangeRange = createTextChangeRange; + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + function collapseTextChangeRangesAcrossMultipleVersions(changes) { + if (changes.length === 0) { + return ts.unchangedTextChangeRange; + } + if (changes.length === 1) { + return changes[0]; + } + var change0 = changes[0]; + var oldStartN = change0.span.start; + var oldEndN = textSpanEnd(change0.span); + var newEndN = oldStartN + change0.newLength; + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + var oldStart2 = nextChange.span.start; + var oldEnd2 = textSpanEnd(nextChange.span); + var newEnd2 = oldStart2 + nextChange.newLength; + oldStartN = Math.min(oldStart1, oldStart2); + oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); + } + ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; + function getTypeParameterOwner(d) { + if (d && d.kind === 144) { + for (var current = d; current; current = current.parent) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 229) { + return current; + } + } + } + } + ts.getTypeParameterOwner = getTypeParameterOwner; + function isParameterPropertyDeclaration(node) { + return ts.hasModifier(node, 92) && node.parent.kind === 151 && ts.isClassLike(node.parent.parent); + } + ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; + function walkUpBindingElementsAndPatterns(node) { + while (node && (node.kind === 175 || ts.isBindingPattern(node))) { + node = node.parent; + } + return node; + } + function getCombinedModifierFlags(node) { + node = walkUpBindingElementsAndPatterns(node); + var flags = ts.getModifierFlags(node); + if (node.kind === 225) { + node = node.parent; + } + if (node && node.kind === 226) { + flags |= ts.getModifierFlags(node); + node = node.parent; + } + if (node && node.kind === 207) { + flags |= ts.getModifierFlags(node); + } + return flags; + } + ts.getCombinedModifierFlags = getCombinedModifierFlags; + function getCombinedNodeFlags(node) { + node = walkUpBindingElementsAndPatterns(node); + var flags = node.flags; + if (node.kind === 225) { + node = node.parent; + } + if (node && node.kind === 226) { + flags |= node.flags; + node = node.parent; + } + if (node && node.kind === 207) { + flags |= node.flags; + } + return flags; + } + ts.getCombinedNodeFlags = getCombinedNodeFlags; + function validateLocaleAndSetLanguage(locale, sys, errors) { + var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); + if (!matchResult) { + if (errors) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp")); + } + return; + } + var language = matchResult[1]; + var territory = matchResult[3]; + if (!trySetLanguageAndTerritory(language, territory, errors)) { + trySetLanguageAndTerritory(language, undefined, errors); + } + function trySetLanguageAndTerritory(language, territory, errors) { + var compilerFilePath = ts.normalizePath(sys.getExecutingFilePath()); + var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath); + var filePath = ts.combinePaths(containingDirectoryPath, language); + if (territory) { + filePath = filePath + "-" + territory; + } + filePath = sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json")); + if (!sys.fileExists(filePath)) { + return false; + } + var fileContents = ""; + try { + fileContents = sys.readFile(filePath); + } + catch (e) { + if (errors) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath)); + } + return false; + } + try { + ts.localizedDiagnosticMessages = JSON.parse(fileContents); + } + catch (e) { + if (errors) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath)); + } + return false; + } + return true; + } + } + ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage; + function getOriginalNode(node, nodeTest) { + if (node) { + while (node.original !== undefined) { + node = node.original; + } + } + return !nodeTest || nodeTest(node) ? node : undefined; + } + ts.getOriginalNode = getOriginalNode; + function isParseTreeNode(node) { + return (node.flags & 8) === 0; + } + ts.isParseTreeNode = isParseTreeNode; + function getParseTreeNode(node, nodeTest) { + if (isParseTreeNode(node)) { + return node; + } + node = getOriginalNode(node); + if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { + return node; + } + return undefined; + } + ts.getParseTreeNode = getParseTreeNode; + function unescapeIdentifier(identifier) { + return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; + } + ts.unescapeIdentifier = unescapeIdentifier; +})(ts || (ts = {})); +var ts; (function (ts) { function tokenIsIdentifierOrKeyword(token) { return token >= 70; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = ts.createMap({ + var textToToken = ts.createMapFromTemplate({ "abstract": 116, "any": 118, "as": 117, @@ -3276,7 +8855,7 @@ var ts; "false": 85, "finally": 86, "for": 87, - "from": 138, + "from": 139, "function": 88, "get": 124, "if": 89, @@ -3294,27 +8873,28 @@ var ts; "new": 93, "null": 94, "number": 132, + "object": 133, "package": 110, "private": 111, "protected": 112, "public": 113, "readonly": 130, "require": 131, - "global": 139, + "global": 140, "return": 95, - "set": 133, + "set": 134, "static": 114, - "string": 134, + "string": 135, "super": 96, "switch": 97, - "symbol": 135, + "symbol": 136, "this": 98, "throw": 99, "true": 100, "try": 101, - "type": 136, + "type": 137, "typeof": 102, - "undefined": 137, + "undefined": 138, "var": 103, "void": 104, "while": 105, @@ -3322,7 +8902,7 @@ var ts; "yield": 115, "async": 119, "await": 120, - "of": 140, + "of": 141, "{": 16, "}": 17, "(": 18, @@ -3417,9 +8997,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_4 in source) { - result[source[name_4]] = name_4; - } + source.forEach(function (value, name) { + result[value] = name; + }); return result; } var tokenStrings = makeReverseMap(textToToken); @@ -3428,7 +9008,7 @@ var ts; } ts.tokenToString = tokenToString; function stringToToken(s) { - return textToToken[s]; + return textToToken.get(s); } ts.stringToToken = stringToToken; function computeLineStarts(text) { @@ -3488,7 +9068,6 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - var hasOwnProperty = Object.prototype.hasOwnProperty; function isWhiteSpace(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } @@ -4147,8 +9726,11 @@ var ts; var len = tokenValue.length; if (len >= 2 && len <= 11) { var ch = tokenValue.charCodeAt(0); - if (ch >= 97 && ch <= 122 && hasOwnProperty.call(textToToken, tokenValue)) { - return token = textToToken[tokenValue]; + if (ch >= 97 && ch <= 122) { + token = textToToken.get(tokenValue); + if (token !== undefined) { + return token; + } } } return token = 70; @@ -4800,5816 +10382,15 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; - ts.optionDeclarations = [ - { - name: "charset", - type: "string", - }, - ts.compileOnSaveCommandLineOption, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file, - }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "diagnostics", - type: "boolean", - }, - { - name: "extendedDiagnostics", - type: "boolean", - experimental: true - }, - { - name: "emitBOM", - type: "boolean" - }, - { - name: "help", - shortName: "h", - type: "boolean", - description: ts.Diagnostics.Print_this_message, - }, - { - name: "help", - shortName: "?", - type: "boolean" - }, - { - name: "init", - type: "boolean", - description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, - }, - { - name: "inlineSourceMap", - type: "boolean", - }, - { - name: "inlineSources", - type: "boolean", - }, - { - name: "jsx", - type: ts.createMap({ - "preserve": 1, - "react": 2 - }), - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, - }, - { - name: "reactNamespace", - type: "string", - description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "jsxFactory", - type: "string", - description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h - }, - { - name: "listFiles", - type: "boolean", - }, - { - name: "locale", - type: "string", - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "module", - shortName: "m", - type: ts.createMap({ - "none": ts.ModuleKind.None, - "commonjs": ts.ModuleKind.CommonJS, - "amd": ts.ModuleKind.AMD, - "system": ts.ModuleKind.System, - "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES2015, - "es2015": ts.ModuleKind.ES2015, - }), - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND, - }, - { - name: "newLine", - type: ts.createMap({ - "crlf": 0, - "lf": 1 - }), - description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE, - }, - { - name: "noEmit", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs, - }, - { - name: "noEmitHelpers", - type: "boolean" - }, - { - name: "noEmitOnError", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, - }, - { - name: "noErrorTruncation", - type: "boolean" - }, - { - name: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, - }, - { - name: "noImplicitThis", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, - }, - { - name: "noUnusedLocals", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals, - }, - { - name: "noUnusedParameters", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters, - }, - { - name: "noLib", - type: "boolean", - }, - { - name: "noResolve", - type: "boolean", - }, - { - name: "skipDefaultLibCheck", - type: "boolean", - }, - { - name: "skipLibCheck", - type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files, - }, - { - name: "out", - type: "string", - isFilePath: false, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outFile", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outDir", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "pretty", - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, - type: "boolean" - }, - { - name: "project", - shortName: "p", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "removeComments", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output, - }, - { - name: "rootDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, - }, - { - name: "isolatedModules", - type: "boolean", - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file, - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "suppressExcessPropertyErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, - experimental: true - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, - }, - { - name: "stripInternal", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, - experimental: true - }, - { - name: "target", - shortName: "t", - type: ts.createMap({ - "es3": 0, - "es5": 1, - "es6": 2, - "es2015": 2, - "es2016": 3, - "es2017": 4, - "esnext": 5, - }), - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, - paramType: ts.Diagnostics.VERSION, - }, - { - name: "version", - shortName: "v", - type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version, - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: ts.Diagnostics.Watch_input_files, - }, - { - name: "experimentalDecorators", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators - }, - { - name: "emitDecoratorMetadata", - type: "boolean", - experimental: true, - description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - }, - { - name: "moduleResolution", - type: ts.createMap({ - "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic, - }), - description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY, - }, - { - name: "allowUnusedLabels", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "noImplicitReturns", - type: "boolean", - description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value - }, - { - name: "noFallthroughCasesInSwitch", - type: "boolean", - description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement - }, - { - name: "allowUnreachableCode", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, - { - name: "baseUrl", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names - }, - { - name: "paths", - type: "object", - isTSConfigOnly: true - }, - { - name: "rootDirs", - type: "list", - isTSConfigOnly: true, - element: { - name: "rootDirs", - type: "string", - isFilePath: true - } - }, - { - name: "typeRoots", - type: "list", - element: { - name: "typeRoots", - type: "string", - isFilePath: true - } - }, - { - name: "types", - type: "list", - element: { - name: "types", - type: "string" - }, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation - }, - { - name: "traceResolution", - type: "boolean", - description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process - }, - { - name: "allowJs", - type: "boolean", - description: ts.Diagnostics.Allow_javascript_files_to_be_compiled - }, - { - name: "allowSyntheticDefaultImports", - type: "boolean", - description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking - }, - { - name: "noImplicitUseStrict", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output - }, - { - name: "maxNodeModuleJsDepth", - type: "number", - description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files - }, - { - name: "listEmittedFiles", - type: "boolean" - }, - { - name: "lib", - type: "list", - element: { - name: "lib", - type: ts.createMap({ - "es5": "lib.es5.d.ts", - "es6": "lib.es2015.d.ts", - "es2015": "lib.es2015.d.ts", - "es7": "lib.es2016.d.ts", - "es2016": "lib.es2016.d.ts", - "es2017": "lib.es2017.d.ts", - "dom": "lib.dom.d.ts", - "dom.iterable": "lib.dom.iterable.d.ts", - "webworker": "lib.webworker.d.ts", - "scripthost": "lib.scripthost.d.ts", - "es2015.core": "lib.es2015.core.d.ts", - "es2015.collection": "lib.es2015.collection.d.ts", - "es2015.generator": "lib.es2015.generator.d.ts", - "es2015.iterable": "lib.es2015.iterable.d.ts", - "es2015.promise": "lib.es2015.promise.d.ts", - "es2015.proxy": "lib.es2015.proxy.d.ts", - "es2015.reflect": "lib.es2015.reflect.d.ts", - "es2015.symbol": "lib.es2015.symbol.d.ts", - "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", - "es2016.array.include": "lib.es2016.array.include.d.ts", - "es2017.object": "lib.es2017.object.d.ts", - "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", - "es2017.string": "lib.es2017.string.d.ts", - }), - }, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon - }, - { - name: "disableSizeLimit", - type: "boolean" - }, - { - name: "strictNullChecks", - type: "boolean", - description: ts.Diagnostics.Enable_strict_null_checks - }, - { - name: "importHelpers", - type: "boolean", - description: ts.Diagnostics.Import_emit_helpers_from_tslib - }, - { - name: "alwaysStrict", - type: "boolean", - description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file - } - ]; - ts.typeAcquisitionDeclarations = [ - { - name: "enableAutoDiscovery", - type: "boolean", - }, - { - name: "enable", - type: "boolean", - }, - { - name: "include", - type: "list", - element: { - name: "include", - type: "string" - } - }, - { - name: "exclude", - type: "list", - element: { - name: "exclude", - type: "string" - } - } - ]; - ts.defaultInitCompilerOptions = { - module: ts.ModuleKind.CommonJS, - target: 1, - noImplicitAny: false, - sourceMap: false, - }; - var optionNameMapCache; - function convertEnableAutoDiscoveryToEnable(typeAcquisition) { - if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) { - var result = { - enable: typeAcquisition.enableAutoDiscovery, - include: typeAcquisition.include || [], - exclude: typeAcquisition.exclude || [] - }; - return result; - } - return typeAcquisition; - } - ts.convertEnableAutoDiscoveryToEnable = convertEnableAutoDiscoveryToEnable; - function getOptionNameMap() { - if (optionNameMapCache) { - return optionNameMapCache; - } - var optionNameMap = ts.createMap(); - var shortOptionNames = ts.createMap(); - ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; - if (option.shortName) { - shortOptionNames[option.shortName] = option.name; - } - }); - optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; - return optionNameMapCache; - } - ts.getOptionNameMap = getOptionNameMap; - function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); - return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); - } - ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; - function parseCustomTypeOption(opt, value, errors) { - return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors); - } - ts.parseCustomTypeOption = parseCustomTypeOption; - function parseListTypeOption(opt, value, errors) { - if (value === void 0) { value = ""; } - value = trimString(value); - if (ts.startsWith(value, "-")) { - return undefined; - } - if (value === "") { - return []; - } - var values = value.split(","); - switch (opt.element.type) { - case "number": - return ts.map(values, parseInt); - case "string": - return ts.map(values, function (v) { return v || ""; }); - default: - return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); - } - } - ts.parseListTypeOption = parseListTypeOption; - function parseCommandLine(commandLine, readFile) { - var options = {}; - var fileNames = []; - var errors = []; - var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; - parseStrings(commandLine); - return { - options: options, - fileNames: fileNames, - errors: errors - }; - function parseStrings(args) { - var i = 0; - while (i < args.length) { - var s = args[i]; - i++; - if (s.charCodeAt(0) === 64) { - parseResponseFile(s.slice(1)); - } - else if (s.charCodeAt(0) === 45) { - s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); - if (s in shortOptionNames) { - s = shortOptionNames[s]; - } - if (s in optionNameMap) { - var opt = optionNameMap[s]; - if (opt.isTSConfigOnly) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); - } - else { - if (!args[i] && opt.type !== "boolean") { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); - } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - var optValue = args[i]; - options[opt.name] = optValue !== "false"; - if (optValue === "false" || optValue === "true") { - i++; - } - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - case "list": - var result = parseListTypeOption(opt, args[i], errors); - options[opt.name] = result || []; - if (result) { - i++; - } - break; - default: - options[opt.name] = parseCustomTypeOption(opt, args[i], errors); - i++; - break; - } - } - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); - } - } - else { - fileNames.push(s); - } - } - } - function parseResponseFile(fileName) { - var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); - if (!text) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); - return; - } - var args = []; - var pos = 0; - while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32) - pos++; - if (pos >= text.length) - break; - var start = pos; - if (text.charCodeAt(start) === 34) { - pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34) - pos++; - if (pos < text.length) { - args.push(text.substring(start + 1, pos)); - pos++; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName)); - } - } - else { - while (text.charCodeAt(pos) > 32) - pos++; - args.push(text.substring(start, pos)); - } - } - parseStrings(args); - } - } - ts.parseCommandLine = parseCommandLine; - function readConfigFile(fileName, readFile) { - var text = ""; - try { - text = readFile(fileName); - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; - } - return parseConfigFileTextToJson(fileName, text); - } - ts.readConfigFile = readConfigFile; - function parseConfigFileTextToJson(fileName, jsonText, stripComments) { - if (stripComments === void 0) { stripComments = true; } - try { - var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; - return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; - } - } - ts.parseConfigFileTextToJson = parseConfigFileTextToJson; - function generateTSConfig(options, fileNames) { - var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); - var configurations = { - compilerOptions: serializeCompilerOptions(compilerOptions) - }; - if (fileNames && fileNames.length) { - configurations.files = fileNames; - } - return configurations; - function getCustomTypeMapOfCommandLineOption(optionDefinition) { - if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { - return undefined; - } - else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); - } - else { - return optionDefinition.type; - } - } - function getNameOfCompilerOptionValue(value, customTypeMap) { - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { - return key; - } - } - return undefined; - } - function serializeCompilerOptions(options) { - var result = ts.createMap(); - var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_5 in options) { - if (ts.hasProperty(options, name_5)) { - switch (name_5) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - var value = options[name_5]; - var optionDefinition = optionsNameMap[name_5.toLowerCase()]; - if (optionDefinition) { - var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap) { - result[name_5] = value; - } - else { - if (optionDefinition.type === "list") { - var convertedValue = []; - for (var _i = 0, _a = value; _i < _a.length; _i++) { - var element = _a[_i]; - convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); - } - result[name_5] = convertedValue; - } - else { - result[name_5] = getNameOfCompilerOptionValue(value, customTypeMap); - } - } - } - break; - } - } - } - return result; - } - } - ts.generateTSConfig = generateTSConfig; - function removeComments(jsonText) { - var output = ""; - var scanner = ts.createScanner(1, false, 0, jsonText); - var token; - while ((token = scanner.scan()) !== 1) { - switch (token) { - case 2: - case 3: - output += scanner.getTokenText().replace(/\S/g, " "); - break; - default: - output += scanner.getTokenText(); - break; - } - } - return output; - } - function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions) { - if (existingOptions === void 0) { existingOptions = {}; } - if (resolutionStack === void 0) { resolutionStack = []; } - if (extraFileExtensions === void 0) { extraFileExtensions = []; } - var errors = []; - basePath = ts.normalizeSlashes(basePath); - var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); - if (resolutionStack.indexOf(resolvedPath) >= 0) { - return { - options: {}, - fileNames: [], - typeAcquisition: {}, - raw: json, - errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], - wildcardDirectories: {} - }; - } - var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); - var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; - var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); - if (json["extends"]) { - var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; - if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); - } - if (include && !json["include"]) { - json["include"] = include; - } - if (exclude && !json["exclude"]) { - json["exclude"] = exclude; - } - if (files && !json["files"]) { - json["files"] = files; - } - options = ts.assign({}, baseOptions, options); - } - options = ts.extend(existingOptions, options); - options.configFilePath = configFileName; - var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; - var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); - return { - options: options, - fileNames: fileNames, - typeAcquisition: typeAcquisition, - raw: json, - errors: errors, - wildcardDirectories: wildcardDirectories, - compileOnSave: compileOnSave - }; - function tryExtendsName(extendedConfig) { - if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig)); - return; - } - var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { - extendedConfigPath = extendedConfigPath + ".json"; - if (!host.fileExists(extendedConfigPath)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); - return; - } - } - var extendedResult = readConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); - if (extendedResult.error) { - errors.push(extendedResult.error); - return; - } - var extendedDirname = ts.getDirectoryPath(extendedConfigPath); - var relativeDifference = ts.convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); - var updatePath = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference, path); }; - var result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, undefined, ts.getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); - errors.push.apply(errors, result.errors); - var _a = ts.map(["include", "exclude", "files"], function (key) { - if (!json[key] && extendedResult.config[key]) { - return ts.map(extendedResult.config[key], updatePath); - } - }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; - } - function getFileNames(errors) { - var fileNames; - if (ts.hasProperty(json, "files")) { - if (ts.isArray(json["files"])) { - fileNames = json["files"]; - if (fileNames.length === 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json")); - } - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); - } - } - var includeSpecs; - if (ts.hasProperty(json, "include")) { - if (ts.isArray(json["include"])) { - includeSpecs = json["include"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array")); - } - } - var excludeSpecs; - if (ts.hasProperty(json, "exclude")) { - if (ts.isArray(json["exclude"])) { - excludeSpecs = json["exclude"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); - } - } - else if (ts.hasProperty(json, "excludes")) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); - } - else { - excludeSpecs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"]; - var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; - if (outDir) { - excludeSpecs.push(outDir); - } - } - if (fileNames === undefined && includeSpecs === undefined) { - includeSpecs = ["**/*"]; - } - var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions); - if (result.fileNames.length === 0 && !ts.hasProperty(json, "files") && resolutionStack.length === 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []))); - } - return result; - } - var _b; - } - ts.parseJsonConfigFileContent = parseJsonConfigFileContent; - function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { - if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { - return false; - } - var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); - if (typeof result === "boolean" && result) { - return result; - } - return false; - } - ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; - function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { - var errors = []; - var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); - return { options: options, errors: errors }; - } - ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; - function convertTypeAcquisitionFromJson(jsonOptions, basePath, configFileName) { - var errors = []; - var options = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); - return { options: options, errors: errors }; - } - ts.convertTypeAcquisitionFromJson = convertTypeAcquisitionFromJson; - function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } - : {}; - convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); - return options; - } - function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = { enable: ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; - var typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions); - convertOptionsFromJson(ts.typeAcquisitionDeclarations, typeAcquisition, basePath, options, ts.Diagnostics.Unknown_type_acquisition_option_0, errors); - return options; - } - function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { - if (!jsonOptions) { - return; - } - var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); - for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; - defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); - } - else { - errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id)); - } - } - } - function convertJsonOption(opt, value, basePath, errors) { - var optType = opt.type; - var expectedType = typeof optType === "string" ? optType : "string"; - if (optType === "list" && ts.isArray(value)) { - return convertJsonOptionOfListType(opt, value, basePath, errors); - } - else if (typeof value === expectedType) { - if (typeof optType !== "string") { - return convertJsonOptionOfCustomType(opt, value, errors); - } - else { - if (opt.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); - if (value === "") { - value = "."; - } - } - } - return value; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); - } - } - function convertJsonOptionOfCustomType(opt, value, errors) { - var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; - } - else { - errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); - } - } - function convertJsonOptionOfListType(option, values, basePath, errors) { - return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); - } - function trimString(s) { - return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); - } - var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; - var invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; - var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; - var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; - var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; - function matchFileNames(fileNames, include, exclude, basePath, options, host, errors, extraFileExtensions) { - basePath = ts.normalizePath(basePath); - var keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; - var literalFileMap = ts.createMap(); - var wildcardFileMap = ts.createMap(); - if (include) { - include = validateSpecs(include, errors, false); - } - if (exclude) { - exclude = validateSpecs(exclude, errors, true); - } - var wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); - var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions); - if (fileNames) { - for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { - var fileName = fileNames_1[_i]; - var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; - } - } - if (include && include.length > 0) { - for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, exclude, include); _a < _b.length; _a++) { - var file = _b[_a]; - if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) { - continue; - } - removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); - var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; - } - } - } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); - return { - fileNames: literalFiles.concat(wildcardFiles), - wildcardDirectories: wildcardDirectories - }; - } - function validateSpecs(specs, errors, allowTrailingRecursion) { - var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; - if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidMultipleRecursionPatterns.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else { - validSpecs.push(spec); - } - } - return validSpecs; - } - function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { - var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); - var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); - if (include !== undefined) { - var recursiveKeys = []; - for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { - var file = include_1[_i]; - var spec = ts.normalizePath(ts.combinePaths(path, file)); - if (excludeRegex && excludeRegex.test(spec)) { - continue; - } - var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames); - if (match) { - var key = match.key, flags = match.flags; - var existingFlags = wildcardDirectories[key]; - if (existingFlags === undefined || existingFlags < flags) { - wildcardDirectories[key] = flags; - if (flags === 1) { - recursiveKeys.push(key); - } - } - } - } - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; - } - } - } - } - return wildcardDirectories; - } - function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { - var match = wildcardDirectoryPattern.exec(spec); - if (match) { - return { - key: useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(), - flags: watchRecursivePattern.test(spec) ? 1 : 0 - }; - } - if (ts.isImplicitGlob(spec)) { - return { key: spec, flags: 1 }; - } - return undefined; - } - function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); - for (var i = 0; i < adjustedExtensionPriority; i++) { - var higherPriorityExtension = extensions[i]; - var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { - return true; - } - } - return false; - } - function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); - for (var i = nextExtensionPriority; i < extensions.length; i++) { - var lowerPriorityExtension = extensions[i]; - var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; - } - } - function addFileToOutput(output, file) { - output.push(file); - return output; - } - function caseSensitiveKeyMapper(key) { - return key; - } - function caseInsensitiveKeyMapper(key) { - return key.toLowerCase(); - } -})(ts || (ts = {})); -var ts; -(function (ts) { - var JsTyping; - (function (JsTyping) { - ; - ; - var safeList; - var EmptySafeList = ts.createMap(); - JsTyping.nodeCoreModuleList = [ - "buffer", "querystring", "events", "http", "cluster", - "zlib", "os", "https", "punycode", "repl", "readline", - "vm", "child_process", "url", "dns", "net", - "dgram", "fs", "path", "string_decoder", "tls", - "crypto", "stream", "util", "assert", "tty", "domain", - "constants", "process", "v8", "timers", "console" - ]; - var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typeAcquisition, unresolvedImports) { - var inferredTypings = ts.createMap(); - if (!typeAcquisition || !typeAcquisition.enable) { - return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; - } - fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { - var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); - return kind === 1 || kind === 2; - }); - if (!safeList) { - var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = result.config ? ts.createMap(result.config) : EmptySafeList; - } - var filesToWatch = []; - var searchDirs = []; - var exclude = []; - mergeTypings(typeAcquisition.include); - exclude = typeAcquisition.exclude || []; - var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); - if (projectRootPath) { - possibleSearchDirs.push(projectRootPath); - } - searchDirs = ts.deduplicate(possibleSearchDirs); - for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { - var searchDir = searchDirs_1[_i]; - var packageJsonPath = ts.combinePaths(searchDir, "package.json"); - getTypingNamesFromJson(packageJsonPath, filesToWatch); - var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); - getTypingNamesFromJson(bowerJsonPath, filesToWatch); - var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); - getTypingNamesFromNodeModuleFolder(nodeModulesPath); - } - getTypingNamesFromSourceFileNames(fileNames); - if (unresolvedImports) { - for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { - var moduleId = unresolvedImports_1[_a]; - var typingName = moduleId in nodeCoreModules ? "node" : moduleId; - if (!(typingName in inferredTypings)) { - inferredTypings[typingName] = undefined; - } - } - } - for (var name_6 in packageNameToTypingLocation) { - if (name_6 in inferredTypings && !inferredTypings[name_6]) { - inferredTypings[name_6] = packageNameToTypingLocation[name_6]; - } - } - for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { - var excludeTypingName = exclude_1[_b]; - delete inferredTypings[excludeTypingName]; - } - var newTypingNames = []; - var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); - } - else { - newTypingNames.push(typing); - } - } - return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; - function mergeTypings(typingNames) { - if (!typingNames) { - return; - } - for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { - var typing = typingNames_1[_i]; - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; - } - } - } - function getTypingNamesFromJson(jsonPath, filesToWatch) { - if (host.fileExists(jsonPath)) { - filesToWatch.push(jsonPath); - } - var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); - if (result.config) { - var jsonConfig = result.config; - if (jsonConfig.dependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); - } - if (jsonConfig.devDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); - } - if (jsonConfig.optionalDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); - } - if (jsonConfig.peerDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); - } - } - } - function getTypingNamesFromSourceFileNames(fileNames) { - var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); - var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); - var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); - if (safeList !== EmptySafeList) { - mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); - } - var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); - if (hasJsxFile) { - mergeTypings(["react"]); - } - } - function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { - if (!host.directoryExists(nodeModulesPath)) { - return; - } - var typingNames = []; - var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); - for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { - var fileName = fileNames_2[_i]; - var normalizedFileName = ts.normalizePath(fileName); - if (ts.getBaseFileName(normalizedFileName) !== "package.json") { - continue; - } - var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); - if (!result.config) { - continue; - } - var packageJson = result.config; - if (packageJson._requiredBy && - ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { - continue; - } - if (!packageJson.name) { - continue; - } - if (packageJson.typings) { - var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; - } - else { - typingNames.push(packageJson.name); - } - } - mergeTypings(typingNames); - } - } - JsTyping.discoverTypings = discoverTypings; - })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - server.ActionSet = "action::set"; - server.ActionInvalidate = "action::invalidate"; - server.EventBeginInstallTypes = "event::beginInstallTypes"; - server.EventEndInstallTypes = "event::endInstallTypes"; - var Arguments; - (function (Arguments) { - Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation"; - Arguments.LogFile = "--logFile"; - Arguments.EnableTelemetry = "--enableTelemetry"; - })(Arguments = server.Arguments || (server.Arguments = {})); - function hasArgument(argumentName) { - return ts.sys.args.indexOf(argumentName) >= 0; - } - server.hasArgument = hasArgument; - function findArgument(argumentName) { - var index = ts.sys.args.indexOf(argumentName); - return index >= 0 && index < ts.sys.args.length - 1 - ? ts.sys.args[index + 1] - : undefined; - } - server.findArgument = findArgument; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - function trace(host) { - host.trace(ts.formatMessage.apply(undefined, arguments)); - } - ts.trace = trace; - function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; - } - ts.isTraceEnabled = isTraceEnabled; - var Extensions; - (function (Extensions) { - Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; - Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; - Extensions[Extensions["DtsOnly"] = 2] = "DtsOnly"; - })(Extensions || (Extensions = {})); - function resolvedTypeScriptOnly(resolved) { - if (!resolved) { - return undefined; - } - ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); - return resolved.path; - } - function resolvedModuleFromResolved(_a, isExternalLibraryImport) { - var path = _a.path, extension = _a.extension; - return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; - } - function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolved && resolvedModuleFromResolved(resolved, isExternalLibraryImport), failedLookupLocations: failedLookupLocations }; - } - function moduleHasNonRelativeName(moduleName) { - return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); - } - ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); - switch (extensions) { - case Extensions.DtsOnly: - case Extensions.TypeScript: - return tryReadFromField("typings") || tryReadFromField("types"); - case Extensions.JavaScript: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; - } - function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); - } - return typesFilePath; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } - } - } - } - } - function readJson(path, host) { - try { - var jsonText = host.readFile(path); - return jsonText ? JSON.parse(jsonText) : {}; - } - catch (e) { - return {}; - } - } - function getEffectiveTypeRoots(options, host) { - if (options.typeRoots) { - return options.typeRoots; - } - var currentDirectory; - if (options.configFilePath) { - currentDirectory = ts.getDirectoryPath(options.configFilePath); - } - else if (host.getCurrentDirectory) { - currentDirectory = host.getCurrentDirectory(); - } - if (currentDirectory !== undefined) { - return getDefaultTypeRoots(currentDirectory, host); - } - } - ts.getEffectiveTypeRoots = getEffectiveTypeRoots; - function getDefaultTypeRoots(currentDirectory, host) { - if (!host.directoryExists) { - return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; - } - var typeRoots; - forEachAncestorDirectory(currentDirectory, function (directory) { - var atTypes = ts.combinePaths(directory, nodeModulesAtTypes); - if (host.directoryExists(atTypes)) { - (typeRoots || (typeRoots = [])).push(atTypes); - } - return undefined; - }); - return typeRoots; - } - var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { - var traceEnabled = isTraceEnabled(options, host); - var moduleResolutionState = { - compilerOptions: options, - host: host, - traceEnabled: traceEnabled - }; - var typeRoots = getEffectiveTypeRoots(options, host); - if (traceEnabled) { - if (containingFile === undefined) { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); - } - } - else { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); - } - } - } - var failedLookupLocations = []; - var resolved = primaryLookup(); - var primary = true; - if (!resolved) { - resolved = secondaryLookup(); - primary = false; - } - var resolvedTypeReferenceDirective; - if (resolved) { - resolved = realpath(resolved, host, traceEnabled); - if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); - } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved }; - } - return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; - function primaryLookup() { - if (typeRoots && typeRoots.length) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); - } - return ts.forEach(typeRoots, function (typeRoot) { - var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); - var candidateDirectory = ts.getDirectoryPath(candidate); - var directoryExists = directoryProbablyExists(candidateDirectory, host); - if (!directoryExists && traceEnabled) { - trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); - } - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); - }); - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); - } - } - } - function secondaryLookup() { - var resolvedFile; - var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile); - if (initialLocationForSecondaryLookup !== undefined) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); - } - var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); - resolvedFile = resolvedTypeScriptOnly(result && result.value); - if (!resolvedFile && traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); - } - return resolvedFile; - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); - } - } - } - } - ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; - function getAutomaticTypeDirectiveNames(options, host) { - if (options.types) { - return options.types; - } - var result = []; - if (host.directoryExists && host.getDirectories) { - var typeRoots = getEffectiveTypeRoots(options, host); - if (typeRoots) { - for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { - var root = typeRoots_1[_i]; - if (host.directoryExists(root)) { - for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { - var typeDirectivePath = _b[_a]; - var normalized = ts.normalizePath(typeDirectivePath); - var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); - var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; - if (!isNotNeededPackage) { - result.push(ts.getBaseFileName(normalized)); - } - } - } - } - } - } - return result; - } - ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { - var directoryToModuleNameMap = ts.createFileMap(); - var moduleNameToDirectoryMap = ts.createMap(); - return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; - function getOrCreateCacheForDirectory(directoryName) { - var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); - var perFolderCache = directoryToModuleNameMap.get(path); - if (!perFolderCache) { - perFolderCache = ts.createMap(); - directoryToModuleNameMap.set(path, perFolderCache); - } - return perFolderCache; - } - function getOrCreateCacheForModuleName(nonRelativeModuleName) { - if (!moduleHasNonRelativeName(nonRelativeModuleName)) { - return undefined; - } - var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; - if (!perModuleNameCache) { - moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); - } - return perModuleNameCache; - } - function createPerModuleNameCache() { - var directoryPathMap = ts.createFileMap(); - return { get: get, set: set }; - function get(directory) { - return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); - } - function set(directory, result) { - var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); - if (directoryPathMap.contains(path)) { - return; - } - directoryPathMap.set(path, result); - var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; - var commonPrefix = getCommonPrefix(path, resolvedFileName); - var current = path; - while (true) { - var parent_1 = ts.getDirectoryPath(current); - if (parent_1 === current || directoryPathMap.contains(parent_1)) { - break; - } - directoryPathMap.set(parent_1, result); - current = parent_1; - if (current == commonPrefix) { - break; - } - } - } - function getCommonPrefix(directory, resolution) { - if (resolution === undefined) { - return undefined; - } - var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); - var i = 0; - while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { - i++; - } - var sep = directory.lastIndexOf(ts.directorySeparator, i); - if (sep < 0) { - return undefined; - } - return directory.substr(0, sep); - } - } - } - ts.createModuleResolutionCache = createModuleResolutionCache; - function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); - } - var containingDirectory = ts.getDirectoryPath(containingFile); - var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); - var result = perFolderCache && perFolderCache[moduleName]; - if (result) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); - } - } - else { - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; - if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); - break; - } - if (perFolderCache) { - perFolderCache[moduleName] = result; - var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); - if (perModuleNameCache) { - perModuleNameCache.set(containingDirectory, result); - } - } - } - if (traceEnabled) { - if (result.resolvedModule) { - trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); - } - else { - trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); - } - } - return result; - } - ts.resolveModuleName = resolveModuleName; - function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { - if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state); - } - else { - return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); - } - } - function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { - if (!state.compilerOptions.rootDirs) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); - } - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var matchedRootDir; - var matchedNormalizedPrefix; - for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { - var rootDir = _a[_i]; - var normalizedRoot = ts.normalizePath(rootDir); - if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { - normalizedRoot += ts.directorySeparator; - } - var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && - (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); - } - if (isLongestMatchingPrefix) { - matchedNormalizedPrefix = normalizedRoot; - matchedRootDir = rootDir; - } - } - if (matchedNormalizedPrefix) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); - } - var suffix = candidate.substr(matchedNormalizedPrefix.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); - } - var resolvedFileName = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); - if (resolvedFileName) { - return resolvedFileName; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); - } - for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { - var rootDir = _c[_b]; - if (rootDir === matchedRootDir) { - continue; - } - var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); - } - var baseDirectory = ts.getDirectoryPath(candidate_1); - var resolvedFileName_1 = loader(extensions, candidate_1, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); - if (resolvedFileName_1) { - return resolvedFileName_1; - } - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); - } - } - return undefined; - } - function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state) { - if (!state.compilerOptions.baseUrl) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); - } - var matchedPattern = undefined; - if (state.compilerOptions.paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); - } - matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); - } - if (matchedPattern) { - var matchedStar_1 = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); - var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); - } - return ts.forEach(state.compilerOptions.paths[matchedPatternText], function (subst) { - var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst; - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); - } - var tsExtension = ts.tryGetExtensionFromPath(candidate); - if (tsExtension !== undefined) { - var path_1 = tryFile(candidate, failedLookupLocations, false, state); - return path_1 && { path: path_1, extension: tsExtension }; - } - return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - }); - } - else { - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); - } - return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - } - } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { - var containingDirectory = ts.getDirectoryPath(containingFile); - var traceEnabled = isTraceEnabled(compilerOptions, host); - var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); - if (result && result.value) { - var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; - return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); - } - return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - function tryResolve(extensions) { - var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); - if (resolved) { - return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); - } - if (moduleHasNonRelativeName(moduleName)) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); - } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); - return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); - return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); - } - } - } - ts.nodeModuleNameResolver = nodeModuleNameResolver; - function realpath(path, host, traceEnabled) { - if (!host.realpath) { - return path; - } - var real = ts.normalizePath(host.realpath(path)); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); - } - return real; - } - function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); - } - if (!ts.pathEndsWithDirectorySeparator(candidate)) { - if (!onlyRecordFailures) { - var parentOfCandidate = ts.getDirectoryPath(candidate); - if (!directoryProbablyExists(parentOfCandidate, state.host)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); - } - onlyRecordFailures = true; - } - } - var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - if (resolvedFromFile) { - return resolvedFromFile; - } - } - if (!onlyRecordFailures) { - var candidateExists = directoryProbablyExists(candidate, state.host); - if (!candidateExists) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); - } - onlyRecordFailures = true; - } - } - return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - } - function directoryProbablyExists(directoryName, host) { - return !host.directoryExists || host.directoryExists(directoryName); - } - ts.directoryProbablyExists = directoryProbablyExists; - function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { - var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); - if (resolvedByAddingExtension) { - return resolvedByAddingExtension; - } - if (ts.hasJavaScriptFileExtension(candidate)) { - var extensionless = ts.removeFileExtension(candidate); - if (state.traceEnabled) { - var extension = candidate.substring(extensionless.length); - trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); - } - return tryAddingExtensions(extensionless, extensions, failedLookupLocations, onlyRecordFailures, state); - } - } - function tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures) { - var directory = ts.getDirectoryPath(candidate); - if (directory) { - onlyRecordFailures = !directoryProbablyExists(directory, state.host); - } - } - switch (extensions) { - case Extensions.DtsOnly: - return tryExtension(".d.ts", ts.Extension.Dts); - case Extensions.TypeScript: - return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case Extensions.JavaScript: - return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); - } - function tryExtension(ext, extension) { - var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); - return path && { path: path, extension: extension }; - } - } - function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures) { - if (state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); - } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); - } - } - } - failedLookupLocations.push(fileName); - return undefined; - } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); - if (mainOrTypesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); - var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromExactFile) { - var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); - if (resolved_3) { - return resolved_3; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); - } - } - var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); - if (resolved) { - return resolved; - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); - } - } - } - else { - if (directoryExists && state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - failedLookupLocations.push(packageJsonPath); - } - return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); - } - function resolvedIfExtensionMatches(extensions, path) { - var extension = ts.tryGetExtensionFromPath(path); - return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; - } - function extensionIsOk(extensions, extension) { - switch (extensions) { - case Extensions.JavaScript: - return extension === ts.Extension.Js || extension === ts.Extension.Jsx; - case Extensions.TypeScript: - return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; - case Extensions.DtsOnly: - return extension === ts.Extension.Dts; - } - } - function pathToPackageJson(directory) { - return ts.combinePaths(directory, "package.json"); - } - function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { - var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || - loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); - } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); - } - function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, true, undefined); - } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { - var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); - return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { - if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); - if (resolutionFromCache) { - return resolutionFromCache; - } - return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); - } - }); - } - function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { - if (typesOnly === void 0) { typesOnly = false; } - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); - if (!nodeModulesFolderExists && state.traceEnabled) { - trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); - } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); - if (packageResult) { - return packageResult; - } - if (extensions !== Extensions.JavaScript) { - var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); - var nodeModulesAtTypesExists = nodeModulesFolderExists; - if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); - } - nodeModulesAtTypesExists = false; - } - return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); - } - } - function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { - var result = cache && cache.get(containingDirectory); - if (result) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); - } - return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; - } - } - function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var failedLookupLocations = []; - var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); - return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); - function tryResolve(extensions) { - var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); - if (resolvedUsingSettings) { - return { value: resolvedUsingSettings }; - } - var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); - if (moduleHasNonRelativeName(moduleName)) { - var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { - var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); - if (resolutionFromCache) { - return resolutionFromCache; - } - var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); - }); - if (resolved_4) { - return resolved_4; - } - if (extensions === Extensions.TypeScript) { - return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); - } - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); - } - } - } - ts.classicNameResolver = classicNameResolver; - function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - if (traceEnabled) { - trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); - } - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); - return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); - } - ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; - function toSearchResult(value) { - return value !== undefined ? { value: value } : undefined; - } - function forEachAncestorDirectory(directory, callback) { - while (true) { - var result = callback(directory); - if (result !== undefined) { - return result; - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - return undefined; - } - directory = parentPath; - } - } -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.externalHelpersModuleNameText = "tslib"; - function getDeclarationOfKind(symbol, kind) { - var declarations = symbol.declarations; - if (declarations) { - for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { - var declaration = declarations_1[_i]; - if (declaration.kind === kind) { - return declaration; - } - } - } - return undefined; - } - ts.getDeclarationOfKind = getDeclarationOfKind; - var stringWriters = []; - function getSingleLineStringWriter() { - if (stringWriters.length === 0) { - var str_1 = ""; - var writeText = function (text) { return str_1 += text; }; - return { - string: function () { return str_1; }, - writeKeyword: writeText, - writeOperator: writeText, - writePunctuation: writeText, - writeSpace: writeText, - writeStringLiteral: writeText, - writeParameter: writeText, - writeProperty: writeText, - writeSymbol: writeText, - writeLine: function () { return str_1 += " "; }, - increaseIndent: ts.noop, - decreaseIndent: ts.noop, - clear: function () { return str_1 = ""; }, - trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop - }; - } - return stringWriters.pop(); - } - ts.getSingleLineStringWriter = getSingleLineStringWriter; - function releaseStringWriter(writer) { - writer.clear(); - stringWriters.push(writer); - } - ts.releaseStringWriter = releaseStringWriter; - function getFullWidth(node) { - return node.end - node.pos; - } - ts.getFullWidth = getFullWidth; - function hasResolvedModule(sourceFile, moduleNameText) { - return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); - } - ts.hasResolvedModule = hasResolvedModule; - function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; - } - ts.getResolvedModule = getResolvedModule; - function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { - if (!sourceFile.resolvedModules) { - sourceFile.resolvedModules = ts.createMap(); - } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; - } - ts.setResolvedModule = setResolvedModule; - function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { - if (!sourceFile.resolvedTypeReferenceDirectiveNames) { - sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); - } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; - } - ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; - function moduleResolutionIsEqualTo(oldResolution, newResolution) { - return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && - oldResolution.extension === newResolution.extension && - oldResolution.resolvedFileName === newResolution.resolvedFileName; - } - ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; - function typeDirectiveIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; - } - ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; - function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { - if (names.length !== newResolutions.length) { - return false; - } - for (var i = 0; i < names.length; i++) { - var newResolution = newResolutions[i]; - var oldResolution = oldResolutions && oldResolutions[names[i]]; - var changed = oldResolution - ? !newResolution || !comparer(oldResolution, newResolution) - : newResolution; - if (changed) { - return true; - } - } - return false; - } - ts.hasChangesInResolutions = hasChangesInResolutions; - function containsParseError(node) { - aggregateChildData(node); - return (node.flags & 131072) !== 0; - } - ts.containsParseError = containsParseError; - function aggregateChildData(node) { - if (!(node.flags & 262144)) { - var thisNodeOrAnySubNodesHasError = ((node.flags & 32768) !== 0) || - ts.forEachChild(node, containsParseError); - if (thisNodeOrAnySubNodesHasError) { - node.flags |= 131072; - } - node.flags |= 262144; - } - } - function getSourceFileOfNode(node) { - while (node && node.kind !== 262) { - node = node.parent; - } - return node; - } - ts.getSourceFileOfNode = getSourceFileOfNode; - function isStatementWithLocals(node) { - switch (node.kind) { - case 205: - case 233: - case 212: - case 213: - case 214: - return true; - } - return false; - } - ts.isStatementWithLocals = isStatementWithLocals; - function getStartPositionOfLine(line, sourceFile) { - ts.Debug.assert(line >= 0); - return ts.getLineStarts(sourceFile)[line]; - } - ts.getStartPositionOfLine = getStartPositionOfLine; - function nodePosToString(node) { - var file = getSourceFileOfNode(node); - var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; - } - ts.nodePosToString = nodePosToString; - function getStartPosOfNode(node) { - return node.pos; - } - ts.getStartPosOfNode = getStartPosOfNode; - function isDefined(value) { - return value !== undefined; - } - ts.isDefined = isDefined; - function getEndLinePosition(line, sourceFile) { - ts.Debug.assert(line >= 0); - var lineStarts = ts.getLineStarts(sourceFile); - var lineIndex = line; - var sourceText = sourceFile.text; - if (lineIndex + 1 === lineStarts.length) { - return sourceText.length - 1; - } - else { - var start = lineStarts[lineIndex]; - var pos = lineStarts[lineIndex + 1] - 1; - ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos))); - while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) { - pos--; - } - return pos; - } - } - ts.getEndLinePosition = getEndLinePosition; - function nodeIsMissing(node) { - if (node === undefined) { - return true; - } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1; - } - ts.nodeIsMissing = nodeIsMissing; - function nodeIsPresent(node) { - return !nodeIsMissing(node); - } - ts.nodeIsPresent = nodeIsPresent; - function getTokenPosOfNode(node, sourceFile, includeJsDoc) { - if (nodeIsMissing(node)) { - return node.pos; - } - if (isJSDocNode(node)) { - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); - } - if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { - return getTokenPosOfNode(node.jsDoc[0]); - } - if (node.kind === 293 && node._children.length > 0) { - return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); - } - ts.getTokenPosOfNode = getTokenPosOfNode; - function isJSDocNode(node) { - return node.kind >= 263 && node.kind <= 289; - } - ts.isJSDocNode = isJSDocNode; - function isJSDocTag(node) { - return node.kind >= 279 && node.kind <= 292; - } - ts.isJSDocTag = isJSDocTag; - function getNonDecoratorTokenPosOfNode(node, sourceFile) { - if (nodeIsMissing(node) || !node.decorators) { - return getTokenPosOfNode(node, sourceFile); - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); - } - ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; - function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - if (nodeIsMissing(node)) { - return ""; - } - var text = sourceFile.text; - return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); - } - ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; - function getTextOfNodeFromSourceText(sourceText, node) { - if (nodeIsMissing(node)) { - return ""; - } - return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); - } - ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; - function getTextOfNode(node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); - } - ts.getTextOfNode = getTextOfNode; - function getLiteralText(node, sourceFile, languageVersion) { - if (languageVersion < 2 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); - } - if (!nodeIsSynthesized(node) && node.parent) { - var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { - return node.text; - } - return text; - } - switch (node.kind) { - case 9: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 12: - return getQuotedEscapedLiteralText("`", node.text, "`"); - case 13: - return getQuotedEscapedLiteralText("`", node.text, "${"); - case 14: - return getQuotedEscapedLiteralText("}", node.text, "${"); - case 15: - return getQuotedEscapedLiteralText("}", node.text, "`"); - case 8: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); - } - ts.getLiteralText = getLiteralText; - function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 && text.length > 1) { - switch (text.charCodeAt(1)) { - case 98: - case 66: - case 111: - case 79: - return true; - } - } - return false; - } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; - } - function escapeIdentifier(identifier) { - return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; - } - ts.escapeIdentifier = escapeIdentifier; - function unescapeIdentifier(identifier) { - return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; - } - ts.unescapeIdentifier = unescapeIdentifier; - function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); - } - ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; - function isBlockOrCatchScoped(declaration) { - return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 || - isCatchClauseVariableDeclarationOrBindingElement(declaration); - } - ts.isBlockOrCatchScoped = isBlockOrCatchScoped; - function isCatchClauseVariableDeclarationOrBindingElement(declaration) { - var node = getRootDeclaration(declaration); - return node.kind === 224 && node.parent.kind === 257; - } - ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; - function isAmbientModule(node) { - return node && node.kind === 231 && - (node.name.kind === 9 || isGlobalScopeAugmentation(node)); - } - ts.isAmbientModule = isAmbientModule; - function isShorthandAmbientModuleSymbol(moduleSymbol) { - return isShorthandAmbientModule(moduleSymbol.valueDeclaration); - } - ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; - function isShorthandAmbientModule(node) { - return node.kind === 231 && (!node.body); - } - function isBlockScopedContainerTopLevel(node) { - return node.kind === 262 || - node.kind === 231 || - isFunctionLike(node); - } - ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; - function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512); - } - ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; - function isExternalModuleAugmentation(node) { - if (!node || !isAmbientModule(node)) { - return false; - } - switch (node.parent.kind) { - case 262: - return ts.isExternalModule(node.parent); - case 232: - return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); - } - return false; - } - ts.isExternalModuleAugmentation = isExternalModuleAugmentation; - function isEffectiveExternalModule(node, compilerOptions) { - return ts.isExternalModule(node) || compilerOptions.isolatedModules; - } - ts.isEffectiveExternalModule = isEffectiveExternalModule; - function isBlockScope(node, parentNode) { - switch (node.kind) { - case 262: - case 233: - case 257: - case 231: - case 212: - case 213: - case 214: - case 150: - case 149: - case 151: - case 152: - case 226: - case 184: - case 185: - return true; - case 205: - return parentNode && !isFunctionLike(parentNode); - } - return false; - } - ts.isBlockScope = isBlockScope; - function getEnclosingBlockScopeContainer(node) { - var current = node.parent; - while (current) { - if (isBlockScope(current, current.parent)) { - return current; - } - current = current.parent; - } - } - ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; - function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); - } - ts.declarationNameToString = declarationNameToString; - function getTextOfPropertyName(name) { - switch (name.kind) { - case 70: - return name.text; - case 9: - case 8: - return name.text; - case 142: - if (isStringOrNumericLiteral(name.expression)) { - return name.expression.text; - } - } - return undefined; - } - ts.getTextOfPropertyName = getTextOfPropertyName; - function entityNameToString(name) { - switch (name.kind) { - case 70: - return getFullWidth(name) === 0 ? unescapeIdentifier(name.text) : getTextOfNode(name); - case 141: - return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 177: - return entityNameToString(name.expression) + "." + entityNameToString(name.name); - } - } - ts.entityNameToString = entityNameToString; - function createDiagnosticForNode(node, message, arg0, arg1, arg2) { - var sourceFile = getSourceFileOfNode(node); - return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2); - } - ts.createDiagnosticForNode = createDiagnosticForNode; - function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2) { - var span = getErrorSpanForNode(sourceFile, node); - return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); - } - ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; - function createDiagnosticForNodeFromMessageChain(node, messageChain) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return { - file: sourceFile, - start: span.start, - length: span.length, - code: messageChain.code, - category: messageChain.category, - messageText: messageChain.next ? messageChain : messageChain.messageText - }; - } - ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; - function getSpanOfTokenAtPosition(sourceFile, 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()); - } - ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; - function getErrorSpanForArrowFunction(sourceFile, node) { - var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 205) { - var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; - var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; - if (startLine < endLine) { - return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1); - } - } - return ts.createTextSpanFromBounds(pos, node.end); - } - function getErrorSpanForNode(sourceFile, node) { - var errorNode = node; - switch (node.kind) { - case 262: - 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 224: - case 174: - case 227: - case 197: - case 228: - case 231: - case 230: - case 261: - case 226: - case 184: - case 149: - case 151: - case 152: - case 229: - errorNode = node.name; - break; - case 185: - return getErrorSpanForArrowFunction(sourceFile, node); - } - if (errorNode === undefined) { - return getSpanOfTokenAtPosition(sourceFile, node.pos); - } - var pos = nodeIsMissing(errorNode) - ? errorNode.pos - : ts.skipTrivia(sourceFile.text, errorNode.pos); - return ts.createTextSpanFromBounds(pos, errorNode.end); - } - ts.getErrorSpanForNode = getErrorSpanForNode; - function isExternalOrCommonJsModule(file) { - return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; - } - ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; - function isDeclarationFile(file) { - return file.isDeclarationFile; - } - ts.isDeclarationFile = isDeclarationFile; - function isConstEnumDeclaration(node) { - return node.kind === 230 && isConst(node); - } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2) - || !!(ts.getCombinedModifierFlags(node) & 2048); - } - ts.isConst = isConst; - function isLet(node) { - return !!(ts.getCombinedNodeFlags(node) & 1); - } - ts.isLet = isLet; - function isSuperCall(n) { - return n.kind === 179 && n.expression.kind === 96; - } - ts.isSuperCall = isSuperCall; - function isPrologueDirective(node) { - return node.kind === 208 - && node.expression.kind === 9; - } - ts.isPrologueDirective = isPrologueDirective; - function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } - ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getLeadingCommentRangesOfNodeFromText(node, text) { - return ts.getLeadingCommentRanges(text, node.pos); - } - ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; - function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 144 || - node.kind === 143 || - node.kind === 184 || - node.kind === 185) ? - ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : - getLeadingCommentRangesOfNodeFromText(node, text); - return ts.filter(commentRanges, function (comment) { - return text.charCodeAt(comment.pos + 1) === 42 && - text.charCodeAt(comment.pos + 2) === 42 && - text.charCodeAt(comment.pos + 3) !== 47; - }); - } - ts.getJSDocCommentRanges = getJSDocCommentRanges; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - function isPartOfTypeNode(node) { - if (156 <= node.kind && node.kind <= 171) { - return true; - } - switch (node.kind) { - case 118: - case 132: - case 134: - case 121: - case 135: - case 137: - case 129: - return true; - case 104: - return node.parent.kind !== 188; - case 199: - return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 70: - if (node.parent.kind === 141 && node.parent.right === node) { - node = node.parent; - } - else if (node.parent.kind === 177 && node.parent.name === node) { - node = node.parent; - } - ts.Debug.assert(node.kind === 70 || node.kind === 141 || node.kind === 177, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 141: - case 177: - case 98: - var parent_2 = node.parent; - if (parent_2.kind === 160) { - return false; - } - if (156 <= parent_2.kind && parent_2.kind <= 171) { - return true; - } - switch (parent_2.kind) { - case 199: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); - case 143: - return node === parent_2.constraint; - case 147: - case 146: - case 144: - case 224: - return node === parent_2.type; - case 226: - case 184: - case 185: - case 150: - case 149: - case 148: - case 151: - case 152: - return node === parent_2.type; - case 153: - case 154: - case 155: - return node === parent_2.type; - case 182: - return node === parent_2.type; - case 179: - case 180: - return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; - case 181: - return false; - } - } - return false; - } - ts.isPartOfTypeNode = isPartOfTypeNode; - function isChildOfNodeWithKind(node, kind) { - while (node) { - if (node.kind === kind) { - return true; - } - node = node.parent; - } - return false; - } - ts.isChildOfNodeWithKind = isChildOfNodeWithKind; - function isPrefixUnaryExpression(node) { - return node.kind === 190; - } - ts.isPrefixUnaryExpression = isPrefixUnaryExpression; - function forEachReturnStatement(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 217: - return visitor(node); - case 233: - case 205: - case 209: - case 210: - case 211: - case 212: - case 213: - case 214: - case 218: - case 219: - case 254: - case 255: - case 220: - case 222: - case 257: - return ts.forEachChild(node, traverse); - } - } - } - ts.forEachReturnStatement = forEachReturnStatement; - function forEachYieldExpression(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 195: - visitor(node); - var operand = node.expression; - if (operand) { - traverse(operand); - } - case 230: - case 228: - case 231: - case 229: - case 227: - case 197: - return; - default: - if (isFunctionLike(node)) { - var name_7 = node.name; - if (name_7 && name_7.kind === 142) { - traverse(name_7.expression); - return; - } - } - else if (!isPartOfTypeNode(node)) { - ts.forEachChild(node, traverse); - } - } - } - } - ts.forEachYieldExpression = forEachYieldExpression; - function getRestParameterElementType(node) { - if (node && node.kind === 162) { - return node.elementType; - } - else if (node && node.kind === 157) { - return ts.singleOrUndefined(node.typeArguments); - } - else { - return undefined; - } - } - ts.getRestParameterElementType = getRestParameterElementType; - function isVariableLike(node) { - if (node) { - switch (node.kind) { - case 174: - case 261: - case 144: - case 258: - case 147: - case 146: - case 259: - case 224: - return true; - } - } - return false; - } - ts.isVariableLike = isVariableLike; - function isAccessor(node) { - return node && (node.kind === 151 || node.kind === 152); - } - ts.isAccessor = isAccessor; - function isClassLike(node) { - return node && (node.kind === 227 || node.kind === 197); - } - ts.isClassLike = isClassLike; - function isFunctionLike(node) { - return node && isFunctionLikeKind(node.kind); - } - ts.isFunctionLike = isFunctionLike; - function isFunctionLikeKind(kind) { - switch (kind) { - case 150: - case 184: - case 226: - case 185: - case 149: - case 148: - case 151: - case 152: - case 153: - case 154: - case 155: - case 158: - case 159: - return true; - } - return false; - } - ts.isFunctionLikeKind = isFunctionLikeKind; - function introducesArgumentsExoticObject(node) { - switch (node.kind) { - case 149: - case 148: - case 150: - case 151: - case 152: - case 226: - case 184: - return true; - } - return false; - } - ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; - function isIterationStatement(node, lookInLabeledStatements) { - switch (node.kind) { - case 212: - case 213: - case 214: - case 210: - case 211: - return true; - case 220: - return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); - } - return false; - } - ts.isIterationStatement = isIterationStatement; - function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { - while (true) { - if (beforeUnwrapLabelCallback) { - beforeUnwrapLabelCallback(node); - } - if (node.statement.kind !== 220) { - return node.statement; - } - node = node.statement; - } - } - ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; - function isFunctionBlock(node) { - return node && node.kind === 205 && isFunctionLike(node.parent); - } - ts.isFunctionBlock = isFunctionBlock; - function isObjectLiteralMethod(node) { - return node && node.kind === 149 && node.parent.kind === 176; - } - ts.isObjectLiteralMethod = isObjectLiteralMethod; - function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 149 && - (node.parent.kind === 176 || - node.parent.kind === 197); - } - ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; - function isIdentifierTypePredicate(predicate) { - return predicate && predicate.kind === 1; - } - ts.isIdentifierTypePredicate = isIdentifierTypePredicate; - function isThisTypePredicate(predicate) { - return predicate && predicate.kind === 0; - } - ts.isThisTypePredicate = isThisTypePredicate; - function getContainingFunction(node) { - while (true) { - node = node.parent; - if (!node || isFunctionLike(node)) { - return node; - } - } - } - ts.getContainingFunction = getContainingFunction; - function getContainingClass(node) { - while (true) { - node = node.parent; - if (!node || isClassLike(node)) { - return node; - } - } - } - ts.getContainingClass = getContainingClass; - function getThisContainer(node, includeArrowFunctions) { - while (true) { - node = node.parent; - if (!node) { - return undefined; - } - switch (node.kind) { - case 142: - if (isClassLike(node.parent.parent)) { - return node; - } - node = node.parent; - break; - case 145: - if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - node = node.parent; - } - break; - case 185: - if (!includeArrowFunctions) { - continue; - } - case 226: - case 184: - case 231: - case 147: - case 146: - case 149: - case 148: - case 150: - case 151: - case 152: - case 153: - case 154: - case 155: - case 230: - case 262: - return node; - } - } - } - ts.getThisContainer = getThisContainer; - function getNewTargetContainer(node) { - var container = getThisContainer(node, false); - if (container) { - switch (container.kind) { - case 150: - case 226: - case 184: - return container; - } - } - return undefined; - } - ts.getNewTargetContainer = getNewTargetContainer; - function getSuperContainer(node, stopOnFunctions) { - while (true) { - node = node.parent; - if (!node) { - return node; - } - switch (node.kind) { - case 142: - node = node.parent; - break; - case 226: - case 184: - case 185: - if (!stopOnFunctions) { - continue; - } - case 147: - case 146: - case 149: - case 148: - case 150: - case 151: - case 152: - return node; - case 145: - if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - node = node.parent; - } - break; - } - } - } - ts.getSuperContainer = getSuperContainer; - function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 184 || func.kind === 185) { - var prev = func; - var parent_3 = func.parent; - while (parent_3.kind === 183) { - prev = parent_3; - parent_3 = parent_3.parent; - } - if (parent_3.kind === 179 && parent_3.expression === prev) { - return parent_3; - } - } - } - ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; - function isSuperProperty(node) { - var kind = node.kind; - return (kind === 177 || kind === 178) - && node.expression.kind === 96; - } - ts.isSuperProperty = isSuperProperty; - function getEntityNameFromTypeNode(node) { - switch (node.kind) { - case 157: - case 273: - return node.typeName; - case 199: - return isEntityNameExpression(node.expression) - ? node.expression - : undefined; - case 70: - case 141: - return node; - } - return undefined; - } - ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; - function isCallLikeExpression(node) { - switch (node.kind) { - case 179: - case 180: - case 181: - case 145: - return true; - default: - return false; - } - } - ts.isCallLikeExpression = isCallLikeExpression; - function getInvokedExpression(node) { - if (node.kind === 181) { - return node.tag; - } - return node.expression; - } - ts.getInvokedExpression = getInvokedExpression; - function nodeCanBeDecorated(node) { - switch (node.kind) { - case 227: - return true; - case 147: - return node.parent.kind === 227; - case 151: - case 152: - case 149: - return node.body !== undefined - && node.parent.kind === 227; - case 144: - return node.parent.body !== undefined - && (node.parent.kind === 150 - || node.parent.kind === 149 - || node.parent.kind === 152) - && node.parent.parent.kind === 227; - } - return false; - } - ts.nodeCanBeDecorated = nodeCanBeDecorated; - function nodeIsDecorated(node) { - return node.decorators !== undefined - && nodeCanBeDecorated(node); - } - ts.nodeIsDecorated = nodeIsDecorated; - function nodeOrChildIsDecorated(node) { - return nodeIsDecorated(node) || childIsDecorated(node); - } - ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; - function childIsDecorated(node) { - switch (node.kind) { - case 227: - return ts.forEach(node.members, nodeOrChildIsDecorated); - case 149: - case 152: - return ts.forEach(node.parameters, nodeIsDecorated); - } - } - ts.childIsDecorated = childIsDecorated; - function isJSXTagName(node) { - var parent = node.parent; - if (parent.kind === 249 || - parent.kind === 248 || - parent.kind === 250) { - return parent.tagName === node; - } - return false; - } - ts.isJSXTagName = isJSXTagName; - function isPartOfExpression(node) { - switch (node.kind) { - case 98: - case 96: - case 94: - case 100: - case 85: - case 11: - case 175: - case 176: - case 177: - case 178: - case 179: - case 180: - case 181: - case 200: - case 182: - case 201: - case 183: - case 184: - case 197: - case 185: - case 188: - case 186: - case 187: - case 190: - case 191: - case 192: - case 193: - case 196: - case 194: - case 12: - case 198: - case 247: - case 248: - case 195: - case 189: - case 202: - return true; - case 141: - while (node.parent.kind === 141) { - node = node.parent; - } - return node.parent.kind === 160 || isJSXTagName(node); - case 70: - if (node.parent.kind === 160 || isJSXTagName(node)) { - return true; - } - case 8: - case 9: - case 98: - var parent_4 = node.parent; - switch (parent_4.kind) { - case 224: - case 144: - case 147: - case 146: - case 261: - case 258: - case 174: - return parent_4.initializer === node; - case 208: - case 209: - case 210: - case 211: - case 217: - case 218: - case 219: - case 254: - case 221: - case 219: - return parent_4.expression === node; - case 212: - var forStatement = parent_4; - return (forStatement.initializer === node && forStatement.initializer.kind !== 225) || - forStatement.condition === node || - forStatement.incrementor === node; - case 213: - case 214: - var forInStatement = parent_4; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 225) || - forInStatement.expression === node; - case 182: - case 200: - return node === parent_4.expression; - case 203: - return node === parent_4.expression; - case 142: - return node === parent_4.expression; - case 145: - case 253: - case 252: - case 260: - return true; - case 199: - return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); - default: - if (isPartOfExpression(parent_4)) { - return true; - } - } - } - return false; - } - ts.isPartOfExpression = isPartOfExpression; - function isInstantiatedModule(node, preserveConstEnums) { - var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 || - (preserveConstEnums && moduleState === 2); - } - ts.isInstantiatedModule = isInstantiatedModule; - function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 235 && node.moduleReference.kind === 246; - } - ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; - function getExternalModuleImportEqualsDeclarationExpression(node) { - ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); - return node.moduleReference.expression; - } - ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; - function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 235 && node.moduleReference.kind !== 246; - } - ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; - function isSourceFileJavaScript(file) { - return isInJavaScriptFile(file); - } - ts.isSourceFileJavaScript = isSourceFileJavaScript; - function isInJavaScriptFile(node) { - return node && !!(node.flags & 65536); - } - ts.isInJavaScriptFile = isInJavaScriptFile; - function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 179 && - expression.expression.kind === 70 && - expression.expression.text === "require" && - expression.arguments.length === 1; - return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); - } - ts.isRequireCall = isRequireCall; - function isSingleOrDoubleQuote(charCode) { - return charCode === 39 || charCode === 34; - } - ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; - function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 224) { - var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 184; - } - return false; - } - ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; - function getSpecialPropertyAssignmentKind(expression) { - if (!isInJavaScriptFile(expression)) { - return 0; - } - if (expression.kind !== 192) { - return 0; - } - var expr = expression; - if (expr.operatorToken.kind !== 57 || expr.left.kind !== 177) { - return 0; - } - var lhs = expr.left; - if (lhs.expression.kind === 70) { - var lhsId = lhs.expression; - if (lhsId.text === "exports") { - return 1; - } - else if (lhsId.text === "module" && lhs.name.text === "exports") { - return 2; - } - } - else if (lhs.expression.kind === 98) { - return 4; - } - else if (lhs.expression.kind === 177) { - var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 70) { - var innerPropertyAccessIdentifier = innerPropertyAccess.expression; - if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { - return 1; - } - if (innerPropertyAccess.name.text === "prototype") { - return 3; - } - } - } - return 0; - } - ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; - function getExternalModuleName(node) { - if (node.kind === 236) { - return node.moduleSpecifier; - } - if (node.kind === 235) { - var reference = node.moduleReference; - if (reference.kind === 246) { - return reference.expression; - } - } - if (node.kind === 242) { - return node.moduleSpecifier; - } - if (node.kind === 231 && node.name.kind === 9) { - return node.name; - } - } - ts.getExternalModuleName = getExternalModuleName; - function getNamespaceDeclarationNode(node) { - if (node.kind === 235) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 238) { - return importClause.namedBindings; - } - } - ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; - function isDefaultImport(node) { - return node.kind === 236 - && node.importClause - && !!node.importClause.name; - } - ts.isDefaultImport = isDefaultImport; - function hasQuestionToken(node) { - if (node) { - switch (node.kind) { - case 144: - case 149: - case 148: - case 259: - case 258: - case 147: - case 146: - return node.questionToken !== undefined; - } - } - return false; - } - ts.hasQuestionToken = hasQuestionToken; - function isJSDocConstructSignature(node) { - return node.kind === 275 && - node.parameters.length > 0 && - node.parameters[0].type.kind === 277; - } - ts.isJSDocConstructSignature = isJSDocConstructSignature; - function getCommentsFromJSDoc(node) { - return ts.map(getJSDocs(node), function (doc) { return doc.comment; }); - } - ts.getCommentsFromJSDoc = getCommentsFromJSDoc; - function getJSDocTags(node, kind) { - var docs = getJSDocs(node); - if (docs) { - var result = []; - for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { - var doc = docs_1[_i]; - if (doc.kind === 282) { - if (doc.kind === kind) { - result.push(doc); - } - } - else { - result.push.apply(result, ts.filter(doc.tags, function (tag) { return tag.kind === kind; })); - } - } - return result; - } - } - function getFirstJSDocTag(node, kind) { - return node && ts.firstOrUndefined(getJSDocTags(node, kind)); - } - function getJSDocs(node) { - var cache = node.jsDocCache; - if (!cache) { - getJSDocsWorker(node); - node.jsDocCache = cache; - } - return cache; - function getJSDocsWorker(node) { - var parent = node.parent; - var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && - parent.initializer === node && - parent.parent.parent.kind === 206; - var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 206; - var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : - isVariableOfVariableDeclarationStatement ? parent.parent : - undefined; - if (variableStatementNode) { - getJSDocsWorker(variableStatementNode); - } - var isSourceOfAssignmentExpressionStatement = parent && parent.parent && - parent.kind === 192 && - parent.operatorToken.kind === 57 && - parent.parent.kind === 208; - if (isSourceOfAssignmentExpressionStatement) { - getJSDocsWorker(parent.parent); - } - var isModuleDeclaration = node.kind === 231 && - parent && parent.kind === 231; - var isPropertyAssignmentExpression = parent && parent.kind === 258; - if (isModuleDeclaration || isPropertyAssignmentExpression) { - getJSDocsWorker(parent); - } - if (node.kind === 144) { - cache = ts.concatenate(cache, getJSDocParameterTags(node)); - } - if (isVariableLike(node) && node.initializer) { - cache = ts.concatenate(cache, node.initializer.jsDoc); - } - cache = ts.concatenate(cache, node.jsDoc); - } - } - function getJSDocParameterTags(param) { - if (!isParameter(param)) { - return undefined; - } - var func = param.parent; - var tags = getJSDocTags(func, 282); - if (!param.name) { - var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 282; }); - if (paramTags && 0 <= i && i < paramTags.length) { - return [paramTags[i]]; - } - } - else if (param.name.kind === 70) { - var name_8 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 282 && tag.parameterName.text === name_8; }); - } - else { - return undefined; - } - } - ts.getJSDocParameterTags = getJSDocParameterTags; - function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 284); - if (!tag && node.kind === 144) { - var paramTags = getJSDocParameterTags(node); - if (paramTags) { - tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); - } - } - return tag && tag.typeExpression && tag.typeExpression.type; - } - ts.getJSDocType = getJSDocType; - function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 281); - } - ts.getJSDocAugmentsTag = getJSDocAugmentsTag; - function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 283); - } - ts.getJSDocReturnTag = getJSDocReturnTag; - function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 285); - } - ts.getJSDocTemplateTag = getJSDocTemplateTag; - function hasRestParameter(s) { - return isRestParameter(ts.lastOrUndefined(s.parameters)); - } - ts.hasRestParameter = hasRestParameter; - function hasDeclaredRestParameter(s) { - return isDeclaredRestParam(ts.lastOrUndefined(s.parameters)); - } - ts.hasDeclaredRestParameter = hasDeclaredRestParameter; - function isRestParameter(node) { - if (node && (node.flags & 65536)) { - if (node.type && node.type.kind === 276 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 276; })) { - return true; - } - } - return isDeclaredRestParam(node); - } - ts.isRestParameter = isRestParameter; - function isDeclaredRestParam(node) { - return node && node.dotDotDotToken !== undefined; - } - ts.isDeclaredRestParam = isDeclaredRestParam; - function getAssignmentTargetKind(node) { - var parent = node.parent; - while (true) { - switch (parent.kind) { - case 192: - var binaryOperator = parent.operatorToken.kind; - return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 57 ? 1 : 2 : - 0; - case 190: - case 191: - var unaryOperator = parent.operator; - return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; - case 213: - case 214: - return parent.initializer === node ? 1 : 0; - case 183: - case 175: - case 196: - node = parent; - break; - case 259: - if (parent.name !== node) { - return 0; - } - case 258: - node = parent.parent; - break; - default: - return 0; - } - parent = node.parent; - } - } - ts.getAssignmentTargetKind = getAssignmentTargetKind; - function isAssignmentTarget(node) { - return getAssignmentTargetKind(node) !== 0; - } - ts.isAssignmentTarget = isAssignmentTarget; - function isDeleteTarget(node) { - if (node.kind !== 177 && node.kind !== 178) { - return false; - } - node = node.parent; - while (node && node.kind === 183) { - node = node.parent; - } - return node && node.kind === 186; - } - ts.isDeleteTarget = isDeleteTarget; - function isNodeDescendantOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } - ts.isNodeDescendantOf = isNodeDescendantOf; - function isInAmbientContext(node) { - while (node) { - if (hasModifier(node, 2) || (node.kind === 262 && node.isDeclarationFile)) { - return true; - } - node = node.parent; - } - return false; - } - ts.isInAmbientContext = isInAmbientContext; - function isDeclarationName(name) { - if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { - return false; - } - var parent = name.parent; - if (parent.kind === 240 || parent.kind === 244) { - if (parent.propertyName) { - return true; - } - } - if (isDeclaration(parent)) { - return parent.name === name; - } - return false; - } - ts.isDeclarationName = isDeclarationName; - function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 142 && - isDeclaration(node.parent.parent); - } - ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; - function isIdentifierName(node) { - var parent = node.parent; - switch (parent.kind) { - case 147: - case 146: - case 149: - case 148: - case 151: - case 152: - case 261: - case 258: - case 177: - return parent.name === node; - case 141: - if (parent.right === node) { - while (parent.kind === 141) { - parent = parent.parent; - } - return parent.kind === 160; - } - return false; - case 174: - case 240: - return parent.propertyName === node; - case 244: - return true; - } - return false; - } - ts.isIdentifierName = isIdentifierName; - function isAliasSymbolDeclaration(node) { - return node.kind === 235 || - node.kind === 234 || - node.kind === 237 && !!node.name || - node.kind === 238 || - node.kind === 240 || - node.kind === 244 || - node.kind === 241 && exportAssignmentIsAlias(node); - } - ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - return isEntityNameExpression(node.expression); - } - ts.exportAssignmentIsAlias = exportAssignmentIsAlias; - function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84); - return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; - } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; - function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 107); - return heritageClause ? heritageClause.types : undefined; - } - ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; - function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84); - return heritageClause ? heritageClause.types : undefined; - } - ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; - function getHeritageClause(clauses, kind) { - if (clauses) { - for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { - var clause = clauses_1[_i]; - if (clause.token === kind) { - return clause; - } - } - } - return undefined; - } - ts.getHeritageClause = getHeritageClause; - function tryResolveScriptReference(host, sourceFile, reference) { - if (!host.getCompilerOptions().noResolve) { - var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - return host.getSourceFile(referenceFileName); - } - } - ts.tryResolveScriptReference = tryResolveScriptReference; - function getAncestor(node, kind) { - while (node) { - if (node.kind === kind) { - return node; - } - node = node.parent; - } - return undefined; - } - ts.getAncestor = getAncestor; - function getFileReferenceFromReferencePath(comment, commentRange) { - var simpleReferenceRegEx = /^\/\/\/\s*/gim; - if (simpleReferenceRegEx.test(comment)) { - if (isNoDefaultLibRegEx.test(comment)) { - return { - isNoDefaultLib: true - }; - } - else { - var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); - if (refMatchResult || refLibResult) { - var start = commentRange.pos; - var end = commentRange.end; - return { - fileReference: { - pos: start, - end: end, - fileName: (refMatchResult || refLibResult)[3] - }, - isNoDefaultLib: false, - isTypeReferenceDirective: !!refLibResult - }; - } - return { - diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, - isNoDefaultLib: false - }; - } - } - return undefined; - } - ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; - function isKeyword(token) { - return 71 <= token && token <= 140; - } - ts.isKeyword = isKeyword; - function isTrivia(token) { - return 2 <= token && token <= 7; - } - ts.isTrivia = isTrivia; - function isAsyncFunctionLike(node) { - return isFunctionLike(node) && hasModifier(node, 256) && !isAccessor(node); - } - ts.isAsyncFunctionLike = isAsyncFunctionLike; - function isStringOrNumericLiteral(node) { - var kind = node.kind; - return kind === 9 - || kind === 8; - } - ts.isStringOrNumericLiteral = isStringOrNumericLiteral; - function hasDynamicName(declaration) { - return declaration.name && isDynamicName(declaration.name); - } - ts.hasDynamicName = hasDynamicName; - function isDynamicName(name) { - return name.kind === 142 && - !isStringOrNumericLiteral(name.expression) && - !isWellKnownSymbolSyntactically(name.expression); - } - ts.isDynamicName = isDynamicName; - function isWellKnownSymbolSyntactically(node) { - return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); - } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; - function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 144) { - return name.text; - } - if (name.kind === 142) { - var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - var rightHandSideName = nameExpression.name.text; - return getPropertyNameForKnownSymbolName(rightHandSideName); - } - else if (nameExpression.kind === 9 || nameExpression.kind === 8) { - return nameExpression.text; - } - } - return undefined; - } - ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; - } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; - function isESSymbolIdentifier(node) { - return node.kind === 70 && node.text === "Symbol"; - } - ts.isESSymbolIdentifier = isESSymbolIdentifier; - function isPushOrUnshiftIdentifier(node) { - return node.text === "push" || node.text === "unshift"; - } - ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; - function isModifierKind(token) { - switch (token) { - case 116: - case 119: - case 75: - case 123: - case 78: - case 83: - case 113: - case 111: - case 112: - case 130: - case 114: - return true; - } - return false; - } - ts.isModifierKind = isModifierKind; - function isParameterDeclaration(node) { - var root = getRootDeclaration(node); - return root.kind === 144; - } - ts.isParameterDeclaration = isParameterDeclaration; - function getRootDeclaration(node) { - while (node.kind === 174) { - node = node.parent.parent; - } - return node; - } - ts.getRootDeclaration = getRootDeclaration; - function nodeStartsNewLexicalEnvironment(node) { - var kind = node.kind; - return kind === 150 - || kind === 184 - || kind === 226 - || kind === 185 - || kind === 149 - || kind === 151 - || kind === 152 - || kind === 231 - || kind === 262; - } - ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; - function nodeIsSynthesized(node) { - return ts.positionIsSynthesized(node.pos) - || ts.positionIsSynthesized(node.end); - } - ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node, nodeTest) { - if (node) { - while (node.original !== undefined) { - node = node.original; - } - } - return !nodeTest || nodeTest(node) ? node : undefined; - } - ts.getOriginalNode = getOriginalNode; - function isParseTreeNode(node) { - return (node.flags & 8) === 0; - } - ts.isParseTreeNode = isParseTreeNode; - function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { - return node; - } - node = getOriginalNode(node); - if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { - return node; - } - return undefined; - } - ts.getParseTreeNode = getParseTreeNode; - function getOriginalSourceFiles(sourceFiles) { - var originalSourceFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); - if (originalSourceFile) { - originalSourceFiles.push(originalSourceFile); - } - } - return originalSourceFiles; - } - ts.getOriginalSourceFiles = getOriginalSourceFiles; - function getOriginalNodeId(node) { - node = getOriginalNode(node); - return node ? ts.getNodeId(node) : 0; - } - ts.getOriginalNodeId = getOriginalNodeId; - function getExpressionAssociativity(expression) { - var operator = getOperator(expression); - var hasArguments = expression.kind === 180 && expression.arguments !== undefined; - return getOperatorAssociativity(expression.kind, operator, hasArguments); - } - ts.getExpressionAssociativity = getExpressionAssociativity; - function getOperatorAssociativity(kind, operator, hasArguments) { - switch (kind) { - case 180: - return hasArguments ? 0 : 1; - case 190: - case 187: - case 188: - case 186: - case 189: - case 193: - case 195: - return 1; - case 192: - switch (operator) { - case 39: - case 57: - case 58: - case 59: - case 61: - case 60: - case 62: - case 63: - case 64: - case 65: - case 66: - case 67: - case 69: - case 68: - return 1; - } - } - return 0; - } - ts.getOperatorAssociativity = getOperatorAssociativity; - function getExpressionPrecedence(expression) { - var operator = getOperator(expression); - var hasArguments = expression.kind === 180 && expression.arguments !== undefined; - return getOperatorPrecedence(expression.kind, operator, hasArguments); - } - ts.getExpressionPrecedence = getExpressionPrecedence; - function getOperator(expression) { - if (expression.kind === 192) { - return expression.operatorToken.kind; - } - else if (expression.kind === 190 || expression.kind === 191) { - return expression.operator; - } - else { - return expression.kind; - } - } - ts.getOperator = getOperator; - function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { - switch (nodeKind) { - case 98: - case 96: - case 70: - case 94: - case 100: - case 85: - case 8: - case 9: - case 175: - case 176: - case 184: - case 185: - case 197: - case 247: - case 248: - case 11: - case 12: - case 194: - case 183: - case 198: - return 19; - case 181: - case 177: - case 178: - return 18; - case 180: - return hasArguments ? 18 : 17; - case 179: - return 17; - case 191: - return 16; - case 190: - case 187: - case 188: - case 186: - case 189: - return 15; - case 192: - switch (operatorKind) { - case 50: - case 51: - return 15; - case 39: - case 38: - case 40: - case 41: - return 14; - case 36: - case 37: - return 13; - case 44: - case 45: - case 46: - return 12; - case 26: - case 29: - case 28: - case 30: - case 91: - case 92: - return 11; - case 31: - case 33: - case 32: - case 34: - return 10; - case 47: - return 9; - case 49: - return 8; - case 48: - return 7; - case 52: - return 6; - case 53: - return 5; - case 57: - case 58: - case 59: - case 61: - case 60: - case 62: - case 63: - case 64: - case 65: - case 66: - case 67: - case 69: - case 68: - return 3; - case 25: - return 0; - default: - return -1; - } - case 193: - return 4; - case 195: - return 2; - case 196: - return 1; - default: - return -1; - } - } - ts.getOperatorPrecedence = getOperatorPrecedence; - function createDiagnosticCollection() { - var nonFileDiagnostics = []; - var fileDiagnostics = ts.createMap(); - var diagnosticsModified = false; - var modificationCount = 0; - return { - add: add, - getGlobalDiagnostics: getGlobalDiagnostics, - getDiagnostics: getDiagnostics, - getModificationCount: getModificationCount, - reattachFileDiagnostics: reattachFileDiagnostics - }; - function getModificationCount() { - return modificationCount; - } - function reattachFileDiagnostics(newFile) { - if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { - var diagnostic = _a[_i]; - diagnostic.file = newFile; - } - } - function add(diagnostic) { - var diagnostics; - if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; - if (!diagnostics) { - diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; - } - } - else { - diagnostics = nonFileDiagnostics; - } - diagnostics.push(diagnostic); - diagnosticsModified = true; - modificationCount++; - } - function getGlobalDiagnostics() { - sortAndDeduplicate(); - return nonFileDiagnostics; - } - function getDiagnostics(fileName) { - sortAndDeduplicate(); - if (fileName) { - return fileDiagnostics[fileName] || []; - } - var allDiagnostics = []; - function pushDiagnostic(d) { - allDiagnostics.push(d); - } - ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function sortAndDeduplicate() { - if (!diagnosticsModified) { - return; - } - diagnosticsModified = false; - nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } - } - } - ts.createDiagnosticCollection = createDiagnosticCollection; - var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = ts.createMap({ - "\0": "\\0", - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\r": "\\r", - "\n": "\\n", - "\\": "\\\\", - "\"": "\\\"", - "\u2028": "\\u2028", - "\u2029": "\\u2029", - "\u0085": "\\u0085" - }); - function escapeString(s) { - return s.replace(escapedCharsRegExp, getReplacement); - } - ts.escapeString = escapeString; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } - 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); - return "\\u" + paddedHexCode; - } - var nonAsciiCharacters = /[^\u0000-\u007F]/g; - function escapeNonAsciiCharacters(s) { - return nonAsciiCharacters.test(s) ? - s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : - s; - } - ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; - var indentStrings = ["", " "]; - function getIndentString(level) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; - } - return indentStrings[level]; - } - ts.getIndentString = getIndentString; - function getIndentSize() { - return indentStrings[1].length; - } - ts.getIndentSize = getIndentSize; - function createTextWriter(newLine) { - var output; - var indent; - var lineStart; - var lineCount; - var linePos; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function reset() { - output = ""; - indent = 0; - lineStart = true; - lineCount = 0; - linePos = 0; - } - function rawWrite(s) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; - } - } - function writeLiteral(s) { - if (s && s.length) { - write(s); - var lineStartsOfS = ts.computeLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); - } - } - } - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; - } - } - function writeTextOfNode(text, node) { - write(getTextOfNodeFromSourceText(text, node)); - } - reset(); - return { - write: write, - rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { indent++; }, - decreaseIndent: function () { indent--; }, - getIndent: function () { return indent; }, - getTextPos: function () { return output.length; }, - getLine: function () { return lineCount + 1; }, - getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, - getText: function () { return output; }, - isAtStartOfLine: function () { return lineStart; }, - reset: reset - }; - } - ts.createTextWriter = createTextWriter; - function getResolvedExternalModuleName(host, file) { - return file.moduleName || getExternalModuleNameFromPath(host, file.fileName); - } - ts.getResolvedExternalModuleName = getResolvedExternalModuleName; - function getExternalModuleNameFromDeclaration(host, resolver, declaration) { - var file = resolver.getExternalModuleFileFromDeclaration(declaration); - if (!file || isDeclarationFile(file)) { - return undefined; - } - return getResolvedExternalModuleName(host, file); - } - ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; - function getExternalModuleNameFromPath(host, fileName) { - var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; - var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); - var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false); - return ts.removeFileExtension(relativePath); - } - ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; - function getOwnEmitOutputFilePath(sourceFile, host, extension) { - var compilerOptions = host.getCompilerOptions(); - var emitOutputFilePathWithoutExtension; - if (compilerOptions.outDir) { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); - } - else { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); - } - return emitOutputFilePathWithoutExtension + extension; - } - ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; - function getDeclarationEmitOutputFilePath(sourceFile, host) { - var options = host.getCompilerOptions(); - var outputDir = options.declarationDir || options.outDir; - var path = outputDir - ? getSourceFilePathInNewDir(sourceFile, host, outputDir) - : sourceFile.fileName; - return ts.removeFileExtension(path) + ".d.ts"; - } - ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; - function getSourceFilesToEmit(host, targetSourceFile) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - var moduleKind = ts.getEmitModuleKind(options); - var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = getAllEmittableSourceFiles(); - return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); - } - else { - var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; - return filterSourceFilesInDirectory(sourceFiles, function (file) { return host.isSourceFileFromExternalLibrary(file); }); - } - function getAllEmittableSourceFiles() { - return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); - } - } - ts.getSourceFilesToEmit = getSourceFilesToEmit; - function filterSourceFilesInDirectory(sourceFiles, isSourceFileFromExternalLibrary) { - return ts.filter(sourceFiles, function (file) { return shouldEmitInDirectory(file, isSourceFileFromExternalLibrary); }); - } - ts.filterSourceFilesInDirectory = filterSourceFilesInDirectory; - function isNonDeclarationFile(sourceFile) { - return !isDeclarationFile(sourceFile); - } - function shouldEmitInDirectory(sourceFile, isSourceFileFromExternalLibrary) { - return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); - } - function isBundleEmitNonExternalModule(sourceFile) { - return isNonDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); - } - function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - onBundledEmit(sourceFiles); - } - else { - for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { - var sourceFile = sourceFiles_2[_i]; - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } - } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); - } - function onBundledEmit(sourceFiles) { - if (sourceFiles.length) { - var jsFilePath = options.outFile || options.out; - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, true); - } - } - } - ts.forEachTransformedEmitFile = forEachTransformedEmitFile; - function getSourceMapFilePath(jsFilePath, options) { - return options.sourceMap ? jsFilePath + ".map" : undefined; - } - function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - onBundledEmit(host); - } - else { - var sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; - if (shouldEmitInDirectory(sourceFile, function (file) { return host.isSourceFileFromExternalLibrary(file); })) { - onSingleFileEmit(host, sourceFile); - } - } - } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: declarationFilePath - }; - action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); - } - function onBundledEmit(host) { - var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (!ts.isExternalModule(sourceFile) || - !!ts.getEmitModuleKind(options)); }); - if (bundledSources.length) { - var jsFilePath = options.outFile || options.out; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined - }; - action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); - } - } - } - ts.forEachExpectedEmitFile = forEachExpectedEmitFile; - function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); - var commonSourceDirectory = host.getCommonSourceDirectory(); - var isSourceFileInCommonSourceDirectory = host.getCanonicalFileName(sourceFilePath).indexOf(host.getCanonicalFileName(commonSourceDirectory)) === 0; - sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath; - return ts.combinePaths(newDirPath, sourceFilePath); - } - ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }, sourceFiles); - } - ts.writeFile = writeFile; - function getLineOfLocalPosition(currentSourceFile, pos) { - return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; - } - ts.getLineOfLocalPosition = getLineOfLocalPosition; - function getLineOfLocalPositionFromLineMap(lineMap, pos) { - return ts.computeLineAndCharacterOfPosition(lineMap, pos).line; - } - ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 150 && nodeIsPresent(member.body)) { - return member; - } - }); - } - ts.getFirstConstructorWithBody = getFirstConstructorWithBody; - function getSetAccessorTypeAnnotationNode(accessor) { - if (accessor && accessor.parameters.length > 0) { - var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); - return accessor.parameters[hasThis ? 1 : 0].type; - } - } - ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; - function getThisParameter(signature) { - if (signature.parameters.length) { - var thisParameter = signature.parameters[0]; - if (parameterIsThisKeyword(thisParameter)) { - return thisParameter; - } - } - } - ts.getThisParameter = getThisParameter; - function parameterIsThisKeyword(parameter) { - return isThisIdentifier(parameter.name); - } - ts.parameterIsThisKeyword = parameterIsThisKeyword; - function isThisIdentifier(node) { - return node && node.kind === 70 && identifierIsThisKeyword(node); - } - ts.isThisIdentifier = isThisIdentifier; - function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 98; - } - ts.identifierIsThisKeyword = identifierIsThisKeyword; - function getAllAccessorDeclarations(declarations, accessor) { - var firstAccessor; - var secondAccessor; - var getAccessor; - var setAccessor; - if (hasDynamicName(accessor)) { - firstAccessor = accessor; - if (accessor.kind === 151) { - getAccessor = accessor; - } - else if (accessor.kind === 152) { - setAccessor = accessor; - } - else { - ts.Debug.fail("Accessor has wrong kind"); - } - } - else { - ts.forEach(declarations, function (member) { - if ((member.kind === 151 || member.kind === 152) - && hasModifier(member, 32) === hasModifier(accessor, 32)) { - var memberName = getPropertyNameForPropertyNameNode(member.name); - var accessorName = getPropertyNameForPropertyNameNode(accessor.name); - if (memberName === accessorName) { - if (!firstAccessor) { - firstAccessor = member; - } - else if (!secondAccessor) { - secondAccessor = member; - } - if (member.kind === 151 && !getAccessor) { - getAccessor = member; - } - if (member.kind === 152 && !setAccessor) { - setAccessor = member; - } - } - } - }); - } - return { - firstAccessor: firstAccessor, - secondAccessor: secondAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - ts.getAllAccessorDeclarations = getAllAccessorDeclarations; - function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) { - emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments); - } - ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; - function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) { - if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos && - getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) { - writer.writeLine(); - } - } - ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition; - function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) { - if (pos !== commentPos && - getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) { - writer.writeLine(); - } - } - ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition; - function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { - if (comments && comments.length > 0) { - if (leadingSeparator) { - writer.write(" "); - } - var emitInterveningSeparator = false; - for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { - var comment = comments_1[_i]; - if (emitInterveningSeparator) { - writer.write(" "); - emitInterveningSeparator = false; - } - writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else { - emitInterveningSeparator = true; - } - } - if (emitInterveningSeparator && trailingSeparator) { - writer.write(" "); - } - } - } - ts.emitComments = emitComments; - function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) { - var leadingComments; - var currentDetachedCommentInfo; - if (removeComments) { - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); - } - } - else { - leadingComments = ts.getLeadingCommentRanges(text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment = void 0; - for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { - var comment = leadingComments_1[_i]; - if (lastComment) { - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end); - var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos); - if (commentLine >= lastCommentLine + 2) { - break; - } - } - detachedComments.push(comment); - lastComment = comment; - } - if (detachedComments.length) { - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); - var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); - emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment); - currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - } - } - } - return currentDetachedCommentInfo; - function isPinnedComment(comment) { - return text.charCodeAt(comment.pos + 1) === 42 && - text.charCodeAt(comment.pos + 2) === 33; - } - } - ts.emitDetachedComments = emitDetachedComments; - function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (text.charCodeAt(commentPos + 1) === 42) { - var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); - var lineCount = lineMap.length; - var firstCommentLineIndent = void 0; - for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) { - var nextLineStart = (currentLine + 1) === lineCount - ? text.length + 1 - : lineMap[currentLine + 1]; - if (pos !== commentPos) { - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos); - } - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart); - if (spacesToEmit > 0) { - var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - writer.rawWrite(indentSizeSpaceString); - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - writer.rawWrite(""); - } - } - writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart); - pos = nextLineStart; - } - } - else { - writer.write(text.substring(commentPos, commentEnd)); - } - } - ts.writeCommentRange = writeCommentRange; - function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { - var end = Math.min(commentEnd, nextLineStart - 1); - var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); - if (currentLineText) { - writer.write(currentLineText); - if (end !== commentEnd) { - writer.writeLine(); - } - } - else { - writer.writeLiteral(newLine); - } - } - function calculateIndent(text, pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { - if (text.charCodeAt(pos) === 9) { - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - currentLineIndent++; - } - } - return currentLineIndent; - } - function hasModifiers(node) { - return getModifierFlags(node) !== 0; - } - ts.hasModifiers = hasModifiers; - function hasModifier(node, flags) { - return (getModifierFlags(node) & flags) !== 0; - } - ts.hasModifier = hasModifier; - function getModifierFlags(node) { - if (node.modifierFlagsCache & 536870912) { - return node.modifierFlagsCache & ~536870912; - } - var flags = 0; - if (node.modifiers) { - for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { - var modifier = _a[_i]; - flags |= modifierToFlag(modifier.kind); - } - } - if (node.flags & 4 || (node.kind === 70 && node.isInJSDocNamespace)) { - flags |= 1; - } - node.modifierFlagsCache = flags | 536870912; - return flags; - } - ts.getModifierFlags = getModifierFlags; - function modifierToFlag(token) { - switch (token) { - case 114: return 32; - case 113: return 4; - case 112: return 16; - case 111: return 8; - case 116: return 128; - case 83: return 1; - case 123: return 2; - case 75: return 2048; - case 78: return 512; - case 119: return 256; - case 130: return 64; - } - return 0; - } - ts.modifierToFlag = modifierToFlag; - function isLogicalOperator(token) { - return token === 53 - || token === 52 - || token === 50; - } - ts.isLogicalOperator = isLogicalOperator; - function isAssignmentOperator(token) { - return token >= 57 && token <= 69; - } - ts.isAssignmentOperator = isAssignmentOperator; - function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 199 && - node.parent.token === 84 && - isClassLike(node.parent.parent)) { - return node.parent.parent; - } - } - ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; - function isAssignmentExpression(node, excludeCompoundAssignment) { - return isBinaryExpression(node) - && (excludeCompoundAssignment - ? node.operatorToken.kind === 57 - : isAssignmentOperator(node.operatorToken.kind)) - && isLeftHandSideExpression(node.left); - } - ts.isAssignmentExpression = isAssignmentExpression; - function isDestructuringAssignment(node) { - if (isAssignmentExpression(node, true)) { - var kind = node.left.kind; - return kind === 176 - || kind === 175; - } - return false; - } - ts.isDestructuringAssignment = isDestructuringAssignment; - function isSupportedExpressionWithTypeArguments(node) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; - function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 70) { - return true; - } - else if (isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - else { - return false; - } - } - function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; - } - ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; - function isEntityNameExpression(node) { - return node.kind === 70 || - node.kind === 177 && isEntityNameExpression(node.expression); - } - ts.isEntityNameExpression = isEntityNameExpression; - function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 141 && node.parent.right === node) || - (node.parent.kind === 177 && node.parent.name === node); - } - ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; - function isEmptyObjectLiteralOrArrayLiteral(expression) { - var kind = expression.kind; - if (kind === 176) { - return expression.properties.length === 0; - } - if (kind === 175) { - return expression.elements.length === 0; - } - return false; - } - ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; - function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; - } - ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function tryExtractTypeScriptExtension(fileName) { - return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - ts.tryExtractTypeScriptExtension = tryExtractTypeScriptExtension; - function getExpandedCharCodes(input) { - var output = []; - var length = input.length; - for (var i = 0; i < length; i++) { - var charCode = input.charCodeAt(i); - if (charCode < 0x80) { - output.push(charCode); - } - else if (charCode < 0x800) { - output.push((charCode >> 6) | 192); - output.push((charCode & 63) | 128); - } - else if (charCode < 0x10000) { - output.push((charCode >> 12) | 224); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); - } - else if (charCode < 0x20000) { - output.push((charCode >> 18) | 240); - output.push(((charCode >> 12) & 63) | 128); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); - } - else { - ts.Debug.assert(false, "Unexpected code point"); - } - } - return output; - } - var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - function convertToBase64(input) { - var result = ""; - var charCodes = getExpandedCharCodes(input); - var i = 0; - var length = charCodes.length; - var byte1, byte2, byte3, byte4; - while (i < length) { - byte1 = charCodes[i] >> 2; - byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; - byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; - byte4 = charCodes[i + 2] & 63; - if (i + 1 >= length) { - byte3 = byte4 = 64; - } - else if (i + 2 >= length) { - byte4 = 64; - } - result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); - i += 3; - } - return result; - } - ts.convertToBase64 = convertToBase64; - var carriageReturnLineFeed = "\r\n"; - var lineFeed = "\n"; - function getNewLineCharacter(options) { - if (options.newLine === 0) { - return carriageReturnLineFeed; - } - else if (options.newLine === 1) { - return lineFeed; - } - else if (ts.sys) { - return ts.sys.newLine; - } - return carriageReturnLineFeed; - } - ts.getNewLineCharacter = getNewLineCharacter; - function isSimpleExpression(node) { - return isSimpleExpressionWorker(node, 0); - } - ts.isSimpleExpression = isSimpleExpression; - function isSimpleExpressionWorker(node, depth) { - if (depth <= 5) { - var kind = node.kind; - if (kind === 9 - || kind === 8 - || kind === 11 - || kind === 12 - || kind === 70 - || kind === 98 - || kind === 96 - || kind === 100 - || kind === 85 - || kind === 94) { - return true; - } - else if (kind === 177) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 178) { - return isSimpleExpressionWorker(node.expression, depth + 1) - && isSimpleExpressionWorker(node.argumentExpression, depth + 1); - } - else if (kind === 190 - || kind === 191) { - return isSimpleExpressionWorker(node.operand, depth + 1); - } - else if (kind === 192) { - return node.operatorToken.kind !== 39 - && isSimpleExpressionWorker(node.left, depth + 1) - && isSimpleExpressionWorker(node.right, depth + 1); - } - else if (kind === 193) { - return isSimpleExpressionWorker(node.condition, depth + 1) - && isSimpleExpressionWorker(node.whenTrue, depth + 1) - && isSimpleExpressionWorker(node.whenFalse, depth + 1); - } - else if (kind === 188 - || kind === 187 - || kind === 186) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 175) { - return node.elements.length === 0; - } - else if (kind === 176) { - return node.properties.length === 0; - } - else if (kind === 179) { - if (!isSimpleExpressionWorker(node.expression, depth + 1)) { - return false; - } - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - if (!isSimpleExpressionWorker(argument, depth + 1)) { - return false; - } - } - return true; - } - } - return false; - } - var syntaxKindCache = ts.createMap(); - function formatSyntaxKind(kind) { - var syntaxKindEnum = ts.SyntaxKind; - if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; - } - for (var name_9 in syntaxKindEnum) { - if (syntaxKindEnum[name_9] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_9 + ")"; - } - } - } - else { - return kind.toString(); - } - } - ts.formatSyntaxKind = formatSyntaxKind; - function movePos(pos, value) { - return ts.positionIsSynthesized(pos) ? -1 : pos + value; - } - ts.movePos = movePos; - function createRange(pos, end) { - return { pos: pos, end: end }; - } - ts.createRange = createRange; - function moveRangeEnd(range, end) { - return createRange(range.pos, end); - } - ts.moveRangeEnd = moveRangeEnd; - function moveRangePos(range, pos) { - return createRange(pos, range.end); - } - ts.moveRangePos = moveRangePos; - function moveRangePastDecorators(node) { - return node.decorators && node.decorators.length > 0 - ? moveRangePos(node, node.decorators.end) - : node; - } - ts.moveRangePastDecorators = moveRangePastDecorators; - function moveRangePastModifiers(node) { - return node.modifiers && node.modifiers.length > 0 - ? moveRangePos(node, node.modifiers.end) - : moveRangePastDecorators(node); - } - ts.moveRangePastModifiers = moveRangePastModifiers; - function isCollapsedRange(range) { - return range.pos === range.end; - } - ts.isCollapsedRange = isCollapsedRange; - function collapseRangeToStart(range) { - return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); - } - ts.collapseRangeToStart = collapseRangeToStart; - function collapseRangeToEnd(range) { - return isCollapsedRange(range) ? range : moveRangePos(range, range.end); - } - ts.collapseRangeToEnd = collapseRangeToEnd; - function createTokenRange(pos, token) { - return createRange(pos, pos + ts.tokenToString(token).length); - } - ts.createTokenRange = createTokenRange; - function rangeIsOnSingleLine(range, sourceFile) { - return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile); - } - ts.rangeIsOnSingleLine = rangeIsOnSingleLine; - function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) { - return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), getStartPositionOfRange(range2, sourceFile), sourceFile); - } - ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine; - function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) { - return positionsAreOnSameLine(range1.end, range2.end, sourceFile); - } - ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine; - function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) { - return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), range2.end, sourceFile); - } - ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd; - function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) { - return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile), sourceFile); - } - ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart; - function positionsAreOnSameLine(pos1, pos2, sourceFile) { - return pos1 === pos2 || - getLineOfLocalPosition(sourceFile, pos1) === getLineOfLocalPosition(sourceFile, pos2); - } - ts.positionsAreOnSameLine = positionsAreOnSameLine; - function getStartPositionOfRange(range, sourceFile) { - return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); - } - ts.getStartPositionOfRange = getStartPositionOfRange; - function isDeclarationNameOfEnumOrNamespace(node) { - var parseNode = getParseTreeNode(node); - if (parseNode) { - switch (parseNode.parent.kind) { - case 230: - case 231: - return parseNode === parseNode.parent.name; - } - } - return false; - } - ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace; - function getInitializedVariables(node) { - return ts.filter(node.declarations, isInitializedVariable); - } - ts.getInitializedVariables = getInitializedVariables; - function isInitializedVariable(node) { - return node.initializer !== undefined; - } - function isMergedWithClass(node) { - if (node.symbol) { - for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 227 && declaration !== node) { - return true; - } - } - } - return false; - } - ts.isMergedWithClass = isMergedWithClass; - function isFirstDeclarationOfKind(node, kind) { - return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; - } - ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; - function isNodeArray(array) { - return array.hasOwnProperty("pos") - && array.hasOwnProperty("end"); - } - ts.isNodeArray = isNodeArray; - function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 12; - } - ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; - function isLiteralKind(kind) { - return 8 <= kind && kind <= 12; - } - ts.isLiteralKind = isLiteralKind; - function isTextualLiteralKind(kind) { - return kind === 9 || kind === 12; - } - ts.isTextualLiteralKind = isTextualLiteralKind; - function isLiteralExpression(node) { - return isLiteralKind(node.kind); - } - ts.isLiteralExpression = isLiteralExpression; - function isTemplateLiteralKind(kind) { - return 12 <= kind && kind <= 15; - } - ts.isTemplateLiteralKind = isTemplateLiteralKind; - function isTemplateHead(node) { - return node.kind === 13; - } - ts.isTemplateHead = isTemplateHead; - function isTemplateMiddleOrTemplateTail(node) { - var kind = node.kind; - return kind === 14 - || kind === 15; - } - ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; - function isIdentifier(node) { - return node.kind === 70; - } - ts.isIdentifier = isIdentifier; - function isVoidExpression(node) { - return node.kind === 188; - } - ts.isVoidExpression = isVoidExpression; - function isGeneratedIdentifier(node) { - return isIdentifier(node) && node.autoGenerateKind > 0; - } - ts.isGeneratedIdentifier = isGeneratedIdentifier; - function isModifier(node) { - return isModifierKind(node.kind); - } - ts.isModifier = isModifier; - function isQualifiedName(node) { - return node.kind === 141; - } - ts.isQualifiedName = isQualifiedName; - function isComputedPropertyName(node) { - return node.kind === 142; - } - ts.isComputedPropertyName = isComputedPropertyName; - function isEntityName(node) { - var kind = node.kind; - return kind === 141 - || kind === 70; - } - ts.isEntityName = isEntityName; - function isPropertyName(node) { - var kind = node.kind; - return kind === 70 - || kind === 9 - || kind === 8 - || kind === 142; - } - ts.isPropertyName = isPropertyName; - function isModuleName(node) { - var kind = node.kind; - return kind === 70 - || kind === 9; - } - ts.isModuleName = isModuleName; - function isBindingName(node) { - var kind = node.kind; - return kind === 70 - || kind === 172 - || kind === 173; - } - ts.isBindingName = isBindingName; - function isTypeParameter(node) { - return node.kind === 143; - } - ts.isTypeParameter = isTypeParameter; - function isParameter(node) { - return node.kind === 144; - } - ts.isParameter = isParameter; - function isDecorator(node) { - return node.kind === 145; - } - ts.isDecorator = isDecorator; - function isMethodDeclaration(node) { - return node.kind === 149; - } - ts.isMethodDeclaration = isMethodDeclaration; - function isClassElement(node) { - var kind = node.kind; - return kind === 150 - || kind === 147 - || kind === 149 - || kind === 151 - || kind === 152 - || kind === 155 - || kind === 204; - } - ts.isClassElement = isClassElement; - function isObjectLiteralElementLike(node) { - var kind = node.kind; - return kind === 258 - || kind === 259 - || kind === 260 - || kind === 149 - || kind === 151 - || kind === 152 - || kind === 245; - } - ts.isObjectLiteralElementLike = isObjectLiteralElementLike; - function isTypeNodeKind(kind) { - return (kind >= 156 && kind <= 171) - || kind === 118 - || kind === 132 - || kind === 121 - || kind === 134 - || kind === 135 - || kind === 104 - || kind === 129 - || kind === 199; - } - function isTypeNode(node) { - return isTypeNodeKind(node.kind); - } - ts.isTypeNode = isTypeNode; - function isArrayBindingPattern(node) { - return node.kind === 173; - } - ts.isArrayBindingPattern = isArrayBindingPattern; - function isObjectBindingPattern(node) { - return node.kind === 172; - } - ts.isObjectBindingPattern = isObjectBindingPattern; - function isBindingPattern(node) { - if (node) { - var kind = node.kind; - return kind === 173 - || kind === 172; - } - return false; - } - ts.isBindingPattern = isBindingPattern; - function isAssignmentPattern(node) { - var kind = node.kind; - return kind === 175 - || kind === 176; - } - ts.isAssignmentPattern = isAssignmentPattern; - function isBindingElement(node) { - return node.kind === 174; - } - ts.isBindingElement = isBindingElement; - function isArrayBindingElement(node) { - var kind = node.kind; - return kind === 174 - || kind === 198; - } - ts.isArrayBindingElement = isArrayBindingElement; - function isDeclarationBindingElement(bindingElement) { - switch (bindingElement.kind) { - case 224: - case 144: - case 174: - return true; - } - return false; - } - ts.isDeclarationBindingElement = isDeclarationBindingElement; - function isBindingOrAssignmentPattern(node) { - return isObjectBindingOrAssignmentPattern(node) - || isArrayBindingOrAssignmentPattern(node); - } - ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; - function isObjectBindingOrAssignmentPattern(node) { - switch (node.kind) { - case 172: - case 176: - return true; - } - return false; - } - ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; - function isArrayBindingOrAssignmentPattern(node) { - switch (node.kind) { - case 173: - case 175: - return true; - } - return false; - } - ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; - function isArrayLiteralExpression(node) { - return node.kind === 175; - } - ts.isArrayLiteralExpression = isArrayLiteralExpression; - function isObjectLiteralExpression(node) { - return node.kind === 176; - } - ts.isObjectLiteralExpression = isObjectLiteralExpression; - function isPropertyAccessExpression(node) { - return node.kind === 177; - } - ts.isPropertyAccessExpression = isPropertyAccessExpression; - function isElementAccessExpression(node) { - return node.kind === 178; - } - ts.isElementAccessExpression = isElementAccessExpression; - function isBinaryExpression(node) { - return node.kind === 192; - } - ts.isBinaryExpression = isBinaryExpression; - function isConditionalExpression(node) { - return node.kind === 193; - } - ts.isConditionalExpression = isConditionalExpression; - function isCallExpression(node) { - return node.kind === 179; - } - ts.isCallExpression = isCallExpression; - function isTemplateLiteral(node) { - var kind = node.kind; - return kind === 194 - || kind === 12; - } - ts.isTemplateLiteral = isTemplateLiteral; - function isSpreadExpression(node) { - return node.kind === 196; - } - ts.isSpreadExpression = isSpreadExpression; - function isExpressionWithTypeArguments(node) { - return node.kind === 199; - } - ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; - function isLeftHandSideExpressionKind(kind) { - return kind === 177 - || kind === 178 - || kind === 180 - || kind === 179 - || kind === 247 - || kind === 248 - || kind === 181 - || kind === 175 - || kind === 183 - || kind === 176 - || kind === 197 - || kind === 184 - || kind === 70 - || kind === 11 - || kind === 8 - || kind === 9 - || kind === 12 - || kind === 194 - || kind === 85 - || kind === 94 - || kind === 98 - || kind === 100 - || kind === 96 - || kind === 201 - || kind === 202; - } - function isLeftHandSideExpression(node) { - return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); - } - ts.isLeftHandSideExpression = isLeftHandSideExpression; - function isUnaryExpressionKind(kind) { - return kind === 190 - || kind === 191 - || kind === 186 - || kind === 187 - || kind === 188 - || kind === 189 - || kind === 182 - || isLeftHandSideExpressionKind(kind); - } - function isUnaryExpression(node) { - return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); - } - ts.isUnaryExpression = isUnaryExpression; - function isExpressionKind(kind) { - return kind === 193 - || kind === 195 - || kind === 185 - || kind === 192 - || kind === 196 - || kind === 200 - || kind === 198 - || isUnaryExpressionKind(kind); - } - function isExpression(node) { - return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); - } - ts.isExpression = isExpression; - function isAssertionExpression(node) { - var kind = node.kind; - return kind === 182 - || kind === 200; - } - ts.isAssertionExpression = isAssertionExpression; - function isPartiallyEmittedExpression(node) { - return node.kind === 295; - } - ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; - function isNotEmittedStatement(node) { - return node.kind === 294; - } - ts.isNotEmittedStatement = isNotEmittedStatement; - function isNotEmittedOrPartiallyEmittedNode(node) { - return isNotEmittedStatement(node) - || isPartiallyEmittedExpression(node); - } - ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; - function isOmittedExpression(node) { - return node.kind === 198; - } - ts.isOmittedExpression = isOmittedExpression; - function isTemplateSpan(node) { - return node.kind === 203; - } - ts.isTemplateSpan = isTemplateSpan; - function isBlock(node) { - return node.kind === 205; - } - ts.isBlock = isBlock; - function isConciseBody(node) { - return isBlock(node) - || isExpression(node); - } - ts.isConciseBody = isConciseBody; - function isFunctionBody(node) { - return isBlock(node); - } - ts.isFunctionBody = isFunctionBody; - function isForInitializer(node) { - return isVariableDeclarationList(node) - || isExpression(node); - } - ts.isForInitializer = isForInitializer; - function isVariableDeclaration(node) { - return node.kind === 224; - } - ts.isVariableDeclaration = isVariableDeclaration; - function isVariableDeclarationList(node) { - return node.kind === 225; - } - ts.isVariableDeclarationList = isVariableDeclarationList; - function isCaseBlock(node) { - return node.kind === 233; - } - ts.isCaseBlock = isCaseBlock; - function isModuleBody(node) { - var kind = node.kind; - return kind === 232 - || kind === 231; - } - ts.isModuleBody = isModuleBody; - function isImportEqualsDeclaration(node) { - return node.kind === 235; - } - ts.isImportEqualsDeclaration = isImportEqualsDeclaration; - function isImportClause(node) { - return node.kind === 237; - } - ts.isImportClause = isImportClause; - function isNamedImportBindings(node) { - var kind = node.kind; - return kind === 239 - || kind === 238; - } - ts.isNamedImportBindings = isNamedImportBindings; - function isImportSpecifier(node) { - return node.kind === 240; - } - ts.isImportSpecifier = isImportSpecifier; - function isNamedExports(node) { - return node.kind === 243; - } - ts.isNamedExports = isNamedExports; - function isExportSpecifier(node) { - return node.kind === 244; - } - ts.isExportSpecifier = isExportSpecifier; - function isModuleOrEnumDeclaration(node) { - return node.kind === 231 || node.kind === 230; - } - ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; - function isDeclarationKind(kind) { - return kind === 185 - || kind === 174 - || kind === 227 - || kind === 197 - || kind === 150 - || kind === 230 - || kind === 261 - || kind === 244 - || kind === 226 - || kind === 184 - || kind === 151 - || kind === 237 - || kind === 235 - || kind === 240 - || kind === 228 - || kind === 149 - || kind === 148 - || kind === 231 - || kind === 234 - || kind === 238 - || kind === 144 - || kind === 258 - || kind === 147 - || kind === 146 - || kind === 152 - || kind === 259 - || kind === 229 - || kind === 143 - || kind === 224 - || kind === 286; - } - function isDeclarationStatementKind(kind) { - return kind === 226 - || kind === 245 - || kind === 227 - || kind === 228 - || kind === 229 - || kind === 230 - || kind === 231 - || kind === 236 - || kind === 235 - || kind === 242 - || kind === 241 - || kind === 234; - } - function isStatementKindButNotDeclarationKind(kind) { - return kind === 216 - || kind === 215 - || kind === 223 - || kind === 210 - || kind === 208 - || kind === 207 - || kind === 213 - || kind === 214 - || kind === 212 - || kind === 209 - || kind === 220 - || kind === 217 - || kind === 219 - || kind === 221 - || kind === 222 - || kind === 206 - || kind === 211 - || kind === 218 - || kind === 294 - || kind === 297 - || kind === 296; - } - function isDeclaration(node) { - return isDeclarationKind(node.kind); - } - ts.isDeclaration = isDeclaration; - function isDeclarationStatement(node) { - return isDeclarationStatementKind(node.kind); - } - ts.isDeclarationStatement = isDeclarationStatement; - function isStatementButNotDeclaration(node) { - return isStatementKindButNotDeclarationKind(node.kind); - } - ts.isStatementButNotDeclaration = isStatementButNotDeclaration; - function isStatement(node) { - var kind = node.kind; - return isStatementKindButNotDeclarationKind(kind) - || isDeclarationStatementKind(kind) - || kind === 205; - } - ts.isStatement = isStatement; - function isModuleReference(node) { - var kind = node.kind; - return kind === 246 - || kind === 141 - || kind === 70; - } - ts.isModuleReference = isModuleReference; - function isJsxOpeningElement(node) { - return node.kind === 249; - } - ts.isJsxOpeningElement = isJsxOpeningElement; - function isJsxClosingElement(node) { - return node.kind === 250; - } - ts.isJsxClosingElement = isJsxClosingElement; - function isJsxTagNameExpression(node) { - var kind = node.kind; - return kind === 98 - || kind === 70 - || kind === 177; - } - ts.isJsxTagNameExpression = isJsxTagNameExpression; - function isJsxChild(node) { - var kind = node.kind; - return kind === 247 - || kind === 253 - || kind === 248 - || kind === 10; - } - ts.isJsxChild = isJsxChild; - function isJsxAttributeLike(node) { - var kind = node.kind; - return kind === 251 - || kind === 252; - } - ts.isJsxAttributeLike = isJsxAttributeLike; - function isJsxSpreadAttribute(node) { - return node.kind === 252; - } - ts.isJsxSpreadAttribute = isJsxSpreadAttribute; - function isJsxAttribute(node) { - return node.kind === 251; - } - ts.isJsxAttribute = isJsxAttribute; - function isStringLiteralOrJsxExpression(node) { - var kind = node.kind; - return kind === 9 - || kind === 253; - } - ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; - function isCaseOrDefaultClause(node) { - var kind = node.kind; - return kind === 254 - || kind === 255; - } - ts.isCaseOrDefaultClause = isCaseOrDefaultClause; - function isHeritageClause(node) { - return node.kind === 256; - } - ts.isHeritageClause = isHeritageClause; - function isCatchClause(node) { - return node.kind === 257; - } - ts.isCatchClause = isCatchClause; - function isPropertyAssignment(node) { - return node.kind === 258; - } - ts.isPropertyAssignment = isPropertyAssignment; - function isShorthandPropertyAssignment(node) { - return node.kind === 259; - } - ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; - function isEnumMember(node) { - return node.kind === 261; - } - ts.isEnumMember = isEnumMember; - function isSourceFile(node) { - return node.kind === 262; - } - ts.isSourceFile = isSourceFile; - function isWatchSet(options) { - return options.watch && options.hasOwnProperty("watch"); - } - ts.isWatchSet = isWatchSet; -})(ts || (ts = {})); -(function (ts) { - function getDefaultLibFileName(options) { - switch (options.target) { - case 5: - case 4: - return "lib.es2017.d.ts"; - case 3: - return "lib.es2016.d.ts"; - case 2: - return "lib.es6.d.ts"; - default: - return "lib.d.ts"; - } - } - ts.getDefaultLibFileName = getDefaultLibFileName; - function textSpanEnd(span) { - return span.start + span.length; - } - ts.textSpanEnd = textSpanEnd; - function textSpanIsEmpty(span) { - return span.length === 0; - } - ts.textSpanIsEmpty = textSpanIsEmpty; - function textSpanContainsPosition(span, position) { - return position >= span.start && position < textSpanEnd(span); - } - ts.textSpanContainsPosition = textSpanContainsPosition; - function textSpanContainsTextSpan(span, other) { - return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); - } - ts.textSpanContainsTextSpan = textSpanContainsTextSpan; - function textSpanOverlapsWith(span, other) { - var overlapStart = Math.max(span.start, other.start); - var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); - return overlapStart < overlapEnd; - } - ts.textSpanOverlapsWith = textSpanOverlapsWith; - function textSpanOverlap(span1, span2) { - var overlapStart = Math.max(span1.start, span2.start); - var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (overlapStart < overlapEnd) { - return createTextSpanFromBounds(overlapStart, overlapEnd); - } - return undefined; - } - ts.textSpanOverlap = textSpanOverlap; - function textSpanIntersectsWithTextSpan(span, other) { - return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; - } - ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; - function textSpanIntersectsWith(span, start, length) { - var end = start + length; - return start <= textSpanEnd(span) && end >= span.start; - } - ts.textSpanIntersectsWith = textSpanIntersectsWith; - function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { - var end1 = start1 + length1; - var end2 = start2 + length2; - return start2 <= end1 && end2 >= start1; - } - ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; - function textSpanIntersectsWithPosition(span, position) { - return position <= textSpanEnd(span) && position >= span.start; - } - ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; - function textSpanIntersection(span1, span2) { - var intersectStart = Math.max(span1.start, span2.start); - var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (intersectStart <= intersectEnd) { - return createTextSpanFromBounds(intersectStart, intersectEnd); - } - return undefined; - } - ts.textSpanIntersection = textSpanIntersection; - function createTextSpan(start, length) { - if (start < 0) { - throw new Error("start < 0"); - } - if (length < 0) { - throw new Error("length < 0"); - } - return { start: start, length: length }; - } - ts.createTextSpan = createTextSpan; - function createTextSpanFromBounds(start, end) { - return createTextSpan(start, end - start); - } - ts.createTextSpanFromBounds = createTextSpanFromBounds; - function textChangeRangeNewSpan(range) { - return createTextSpan(range.span.start, range.newLength); - } - ts.textChangeRangeNewSpan = textChangeRangeNewSpan; - function textChangeRangeIsUnchanged(range) { - return textSpanIsEmpty(range.span) && range.newLength === 0; - } - ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; - function createTextChangeRange(span, newLength) { - if (newLength < 0) { - throw new Error("newLength < 0"); - } - return { span: span, newLength: newLength }; - } - ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); - function collapseTextChangeRangesAcrossMultipleVersions(changes) { - if (changes.length === 0) { - return ts.unchangedTextChangeRange; - } - if (changes.length === 1) { - return changes[0]; - } - var change0 = changes[0]; - var oldStartN = change0.span.start; - var oldEndN = textSpanEnd(change0.span); - var newEndN = oldStartN + change0.newLength; - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - var oldStart2 = nextChange.span.start; - var oldEnd2 = textSpanEnd(nextChange.span); - var newEnd2 = oldStart2 + nextChange.newLength; - oldStartN = Math.min(oldStart1, oldStart2); - oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); - } - ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; - function getTypeParameterOwner(d) { - if (d && d.kind === 143) { - for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 228) { - return current; - } - } - } - } - ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 150 && ts.isClassLike(node.parent.parent); - } - ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 174 || ts.isBindingPattern(node))) { - node = node.parent; - } - return node; - } - function getCombinedModifierFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = ts.getModifierFlags(node); - if (node.kind === 224) { - node = node.parent; - } - if (node && node.kind === 225) { - flags |= ts.getModifierFlags(node); - node = node.parent; - } - if (node && node.kind === 206) { - flags |= ts.getModifierFlags(node); - } - return flags; - } - ts.getCombinedModifierFlags = getCombinedModifierFlags; - function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 224) { - node = node.parent; - } - if (node && node.kind === 225) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 206) { - flags |= node.flags; - } - return flags; - } - ts.getCombinedNodeFlags = getCombinedNodeFlags; - function validateLocaleAndSetLanguage(locale, sys, errors) { - var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); - if (!matchResult) { - if (errors) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp")); - } - return; - } - var language = matchResult[1]; - var territory = matchResult[3]; - if (!trySetLanguageAndTerritory(language, territory, errors)) { - trySetLanguageAndTerritory(language, undefined, errors); - } - function trySetLanguageAndTerritory(language, territory, errors) { - var compilerFilePath = ts.normalizePath(sys.getExecutingFilePath()); - var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath); - var filePath = ts.combinePaths(containingDirectoryPath, language); - if (territory) { - filePath = filePath + "-" + territory; - } - filePath = sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json")); - if (!sys.fileExists(filePath)) { - return false; - } - var fileContents = ""; - try { - fileContents = sys.readFile(filePath); - } - catch (e) { - if (errors) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath)); - } - return false; - } - try { - ts.localizedDiagnosticMessages = JSON.parse(fileContents); - } - catch (e) { - if (errors) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath)); - } - return false; - } - return true; - } - } - ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage; -})(ts || (ts = {})); -var ts; -(function (ts) { - var NodeConstructor; - var SourceFileConstructor; - function createNode(kind, location, flags) { - var ConstructorForKind = kind === 262 - ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) - : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); - var node = location - ? new ConstructorForKind(kind, location.pos, location.end) - : new ConstructorForKind(kind, -1, -1); - node.flags = flags | 8; + function createSynthesizedNode(kind) { + var node = ts.createNode(kind, -1, -1); + node.flags |= 8; return node; } function updateNode(updated, original) { if (updated !== original) { setOriginalNode(updated, original); + setTextRange(updated, original); if (original.startsOnNewLine) { updated.startsOnNewLine = true; } @@ -10618,7 +10399,7 @@ var ts; return updated; } ts.updateNode = updateNode; - function createNodeArray(elements, location, hasTrailingComma) { + function createNodeArray(elements, hasTrailingComma) { if (elements) { if (ts.isNodeArray(elements)) { return elements; @@ -10628,32 +10409,15 @@ var ts; elements = []; } var array = elements; - if (location) { - array.pos = location.pos; - array.end = location.end; - } - else { - array.pos = -1; - array.end = -1; - } - if (hasTrailingComma) { - array.hasTrailingComma = true; - } + array.pos = -1; + array.end = -1; + array.hasTrailingComma = hasTrailingComma; return array; } ts.createNodeArray = createNodeArray; - function createSynthesizedNode(kind, startsOnNewLine) { - var node = createNode(kind, undefined); - node.startsOnNewLine = startsOnNewLine; - return node; - } - ts.createSynthesizedNode = createSynthesizedNode; - function createSynthesizedNodeArray(elements) { - return createNodeArray(elements, undefined); - } - ts.createSynthesizedNodeArray = createSynthesizedNodeArray; function getSynthesizedClone(node) { - var clone = createNode(node.kind, undefined, node.flags); + var clone = createSynthesizedNode(node.kind); + clone.flags |= node.flags; setOriginalNode(clone, node); for (var key in node) { if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { @@ -10664,50 +10428,47 @@ var ts; return clone; } ts.getSynthesizedClone = getSynthesizedClone; - function getMutableClone(node) { - var clone = getSynthesizedClone(node); - clone.pos = node.pos; - clone.end = node.end; - clone.parent = node.parent; - return clone; - } - ts.getMutableClone = getMutableClone; - function createLiteral(value, location) { + function createLiteral(value) { if (typeof value === "number") { - var node = createNode(8, location, undefined); - node.text = value.toString(); - return node; + return createNumericLiteral(value + ""); } - else if (typeof value === "boolean") { - return createNode(value ? 100 : 85, location, undefined); + if (typeof value === "boolean") { + return value ? createTrue() : createFalse(); } - else if (typeof value === "string") { - var node = createNode(9, location, undefined); - node.text = value; - return node; - } - else if (value) { - var node = createNode(9, location, undefined); - node.textSourceNode = value; - node.text = value.text; - return node; + if (typeof value === "string") { + return createStringLiteral(value); } + return createLiteralFromNode(value); } ts.createLiteral = createLiteral; - var nextAutoGenerateId = 0; - function createIdentifier(text, location) { - var node = createNode(70, location); + function createNumericLiteral(value) { + var node = createSynthesizedNode(8); + node.text = value; + return node; + } + ts.createNumericLiteral = createNumericLiteral; + function createStringLiteral(text) { + var node = createSynthesizedNode(9); + node.text = text; + return node; + } + function createLiteralFromNode(sourceNode) { + var node = createStringLiteral(sourceNode.text); + node.textSourceNode = sourceNode; + return node; + } + function createIdentifier(text) { + var node = createSynthesizedNode(70); node.text = ts.escapeIdentifier(text); - node.originalKeywordKind = ts.stringToToken(text); + node.originalKeywordKind = text ? ts.stringToToken(text) : 0; node.autoGenerateKind = 0; node.autoGenerateId = 0; return node; } ts.createIdentifier = createIdentifier; - function createTempVariable(recordTempVariable, location) { - var name = createNode(70, location); - name.text = ""; - name.originalKeywordKind = 0; + var nextAutoGenerateId = 0; + function createTempVariable(recordTempVariable) { + var name = createIdentifier(""); name.autoGenerateKind = 1; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; @@ -10717,93 +10478,121 @@ var ts; return name; } ts.createTempVariable = createTempVariable; - function createLoopVariable(location) { - var name = createNode(70, location); - name.text = ""; - name.originalKeywordKind = 0; + function createLoopVariable() { + var name = createIdentifier(""); name.autoGenerateKind = 2; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createLoopVariable = createLoopVariable; - function createUniqueName(text, location) { - var name = createNode(70, location); - name.text = text; - name.originalKeywordKind = 0; + function createUniqueName(text) { + var name = createIdentifier(text); name.autoGenerateKind = 3; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createUniqueName = createUniqueName; - function getGeneratedNameForNode(node, location) { - var name = createNode(70, location); - name.original = node; - name.text = ""; - name.originalKeywordKind = 0; + function getGeneratedNameForNode(node) { + var name = createIdentifier(""); name.autoGenerateKind = 4; name.autoGenerateId = nextAutoGenerateId; + name.original = node; nextAutoGenerateId++; return name; } ts.getGeneratedNameForNode = getGeneratedNameForNode; function createToken(token) { - return createNode(token); + return createSynthesizedNode(token); } ts.createToken = createToken; function createSuper() { - var node = createNode(96); - return node; + return createSynthesizedNode(96); } ts.createSuper = createSuper; - function createThis(location) { - var node = createNode(98, location); - return node; + function createThis() { + return createSynthesizedNode(98); } ts.createThis = createThis; function createNull() { - var node = createNode(94); - return node; + return createSynthesizedNode(94); } ts.createNull = createNull; - function createComputedPropertyName(expression, location) { - var node = createNode(142, location); + function createTrue() { + return createSynthesizedNode(100); + } + ts.createTrue = createTrue; + function createFalse() { + return createSynthesizedNode(85); + } + ts.createFalse = createFalse; + function createQualifiedName(left, right) { + var node = createSynthesizedNode(142); + node.left = left; + node.right = asName(right); + return node; + } + ts.createQualifiedName = createQualifiedName; + function updateQualifiedName(node, left, right) { + return node.left !== left + || node.right !== right + ? updateNode(createQualifiedName(left, right), node) + : node; + } + ts.updateQualifiedName = updateQualifiedName; + function createComputedPropertyName(expression) { + var node = createSynthesizedNode(143); node.expression = expression; return node; } ts.createComputedPropertyName = createComputedPropertyName; function updateComputedPropertyName(node, expression) { - if (node.expression !== expression) { - return updateNode(createComputedPropertyName(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createComputedPropertyName(expression), node) + : node; } ts.updateComputedPropertyName = updateComputedPropertyName; - function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(144, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { + var node = createSynthesizedNode(145); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.questionToken = questionToken; node.type = type; - node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createParameter = createParameter; function updateParameter(node, decorators, modifiers, dotDotDotToken, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + : node; } ts.updateParameter = updateParameter; - function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(147, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createDecorator(expression) { + var node = createSynthesizedNode(146); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createDecorator = createDecorator; + function updateDecorator(node, expression) { + return node.expression !== expression + ? updateNode(createDecorator(expression), node) + : node; + } + ts.updateDecorator = updateDecorator; + function createProperty(decorators, modifiers, name, questionToken, type, initializer) { + var node = createSynthesizedNode(148); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.questionToken = questionToken; node.type = type; node.initializer = initializer; @@ -10811,19 +10600,22 @@ var ts; } ts.createProperty = createProperty; function updateProperty(node, decorators, modifiers, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer), node) + : node; } ts.updateProperty = updateProperty; - function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(149, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(150); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -10831,16 +10623,21 @@ var ts; } ts.createMethod = createMethod; function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateMethod = updateMethod; - function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(150, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createConstructor(decorators, modifiers, parameters, body) { + var node = createSynthesizedNode(151); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = undefined; @@ -10849,17 +10646,19 @@ var ts; } ts.createConstructor = createConstructor; function updateConstructor(node, decorators, modifiers, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.parameters !== parameters || node.body !== body) { - return updateNode(createConstructor(decorators, modifiers, parameters, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.parameters !== parameters + || node.body !== body + ? updateNode(createConstructor(decorators, modifiers, parameters, body), node) + : node; } ts.updateConstructor = updateConstructor; - function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(151, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createGetAccessor(decorators, modifiers, name, parameters, type, body) { + var node = createSynthesizedNode(152); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = type; @@ -10868,17 +10667,21 @@ var ts; } ts.createGetAccessor = createGetAccessor; function updateGetAccessor(node, decorators, modifiers, name, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body), node) + : node; } ts.updateGetAccessor = updateGetAccessor; - function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(152, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createSetAccessor(decorators, modifiers, name, parameters, body) { + var node = createSynthesizedNode(153); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.body = body; @@ -10886,57 +10689,60 @@ var ts; } ts.createSetAccessor = createSetAccessor; function updateSetAccessor(node, decorators, modifiers, name, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.body !== body) { - return updateNode(createSetAccessor(decorators, modifiers, name, parameters, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.body !== body + ? updateNode(createSetAccessor(decorators, modifiers, name, parameters, body), node) + : node; } ts.updateSetAccessor = updateSetAccessor; - function createObjectBindingPattern(elements, location) { - var node = createNode(172, location); + function createObjectBindingPattern(elements) { + var node = createSynthesizedNode(173); node.elements = createNodeArray(elements); return node; } ts.createObjectBindingPattern = createObjectBindingPattern; function updateObjectBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createObjectBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createObjectBindingPattern(elements), node) + : node; } ts.updateObjectBindingPattern = updateObjectBindingPattern; - function createArrayBindingPattern(elements, location) { - var node = createNode(173, location); + function createArrayBindingPattern(elements) { + var node = createSynthesizedNode(174); node.elements = createNodeArray(elements); return node; } ts.createArrayBindingPattern = createArrayBindingPattern; function updateArrayBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayBindingPattern(elements), node) + : node; } ts.updateArrayBindingPattern = updateArrayBindingPattern; - function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(174, location); - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createBindingElement(propertyName, dotDotDotToken, name, initializer) { + var node = createSynthesizedNode(175); + node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.initializer = initializer; return node; } ts.createBindingElement = createBindingElement; function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) { - if (node.propertyName !== propertyName || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer) { - return updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer, node), node); - } - return node; + return node.propertyName !== propertyName + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.initializer !== initializer + ? updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer), node) + : node; } ts.updateBindingElement = updateBindingElement; - function createArrayLiteral(elements, location, multiLine) { - var node = createNode(175, location); - node.elements = parenthesizeListElements(createNodeArray(elements)); + function createArrayLiteral(elements, multiLine) { + var node = createSynthesizedNode(176); + node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; } @@ -10944,14 +10750,13 @@ var ts; } ts.createArrayLiteral = createArrayLiteral; function updateArrayLiteral(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayLiteral(elements, node, node.multiLine), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayLiteral(elements, node.multiLine), node) + : node; } ts.updateArrayLiteral = updateArrayLiteral; - function createObjectLiteral(properties, location, multiLine) { - var node = createNode(176, location); + function createObjectLiteral(properties, multiLine) { + var node = createSynthesizedNode(177); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10960,108 +10765,118 @@ var ts; } ts.createObjectLiteral = createObjectLiteral; function updateObjectLiteral(node, properties) { - if (node.properties !== properties) { - return updateNode(createObjectLiteral(properties, node, node.multiLine), node); - } - return node; + return node.properties !== properties + ? updateNode(createObjectLiteral(properties, node.multiLine), node) + : node; } ts.updateObjectLiteral = updateObjectLiteral; - function createPropertyAccess(expression, name, location, flags) { - var node = createNode(177, location, flags); - node.expression = parenthesizeForAccess(expression); - (node.emitNode || (node.emitNode = {})).flags |= 65536; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAccess(expression, name) { + var node = createSynthesizedNode(178); + node.expression = ts.parenthesizeForAccess(expression); + node.name = asName(name); + setEmitFlags(node, 65536); return node; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { - if (node.expression !== expression || node.name !== name) { - var propertyAccess = createPropertyAccess(expression, name, node, node.flags); - (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); - return updateNode(propertyAccess, node); - } - return node; + return node.expression !== expression + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccess(expression, name), getEmitFlags(node)), node) + : node; } ts.updatePropertyAccess = updatePropertyAccess; - function createElementAccess(expression, index, location) { - var node = createNode(178, location); - node.expression = parenthesizeForAccess(expression); - node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; + function createElementAccess(expression, index) { + var node = createSynthesizedNode(179); + node.expression = ts.parenthesizeForAccess(expression); + node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { - if (node.expression !== expression || node.argumentExpression !== argumentExpression) { - return updateNode(createElementAccess(expression, argumentExpression, node), node); - } - return node; + return node.expression !== expression + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccess(expression, argumentExpression), node) + : node; } ts.updateElementAccess = updateElementAccess; - function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(179, location, flags); - node.expression = parenthesizeForAccess(expression); - if (typeArguments) { - node.typeArguments = createNodeArray(typeArguments); - } - node.arguments = parenthesizeListElements(createNodeArray(argumentsArray)); + function createCall(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(180); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); return node; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { - if (expression !== node.expression || typeArguments !== node.typeArguments || argumentsArray !== node.arguments) { - return updateNode(createCall(expression, typeArguments, argumentsArray, node, node.flags), node); - } - return node; + return expression !== node.expression + || typeArguments !== node.typeArguments + || argumentsArray !== node.arguments + ? updateNode(createCall(expression, typeArguments, argumentsArray), node) + : node; } ts.updateCall = updateCall; - function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(180, location, flags); - node.expression = parenthesizeForNew(expression); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; + function createNew(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(181); + node.expression = ts.parenthesizeForNew(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; return node; } ts.createNew = createNew; function updateNew(node, expression, typeArguments, argumentsArray) { - if (node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray) { - return updateNode(createNew(expression, typeArguments, argumentsArray, node, node.flags), node); - } - return node; + return node.expression !== expression + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createNew(expression, typeArguments, argumentsArray), node) + : node; } ts.updateNew = updateNew; - function createTaggedTemplate(tag, template, location) { - var node = createNode(181, location); - node.tag = parenthesizeForAccess(tag); + function createTaggedTemplate(tag, template) { + var node = createSynthesizedNode(182); + node.tag = ts.parenthesizeForAccess(tag); node.template = template; return node; } ts.createTaggedTemplate = createTaggedTemplate; function updateTaggedTemplate(node, tag, template) { - if (node.tag !== tag || node.template !== template) { - return updateNode(createTaggedTemplate(tag, template, node), node); - } - return node; + return node.tag !== tag + || node.template !== template + ? updateNode(createTaggedTemplate(tag, template), node) + : node; } ts.updateTaggedTemplate = updateTaggedTemplate; - function createParen(expression, location) { - var node = createNode(183, location); + function createTypeAssertion(type, expression) { + var node = createSynthesizedNode(183); + node.type = type; + node.expression = ts.parenthesizePrefixOperand(expression); + return node; + } + ts.createTypeAssertion = createTypeAssertion; + function updateTypeAssertion(node, type, expression) { + return node.type !== type + || node.expression !== expression + ? updateNode(createTypeAssertion(type, expression), node) + : node; + } + ts.updateTypeAssertion = updateTypeAssertion; + function createParen(expression) { + var node = createSynthesizedNode(184); node.expression = expression; return node; } ts.createParen = createParen; function updateParen(node, expression) { - if (node.expression !== expression) { - return updateNode(createParen(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createParen(expression), node) + : node; } ts.updateParen = updateParen; - function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(184, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(185); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -11069,322 +10884,340 @@ var ts; } ts.createFunctionExpression = createFunctionExpression; function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.name !== name + || node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionExpression = updateFunctionExpression; - function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(185, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { + var node = createSynthesizedNode(186); + node.modifiers = asNodeArray(modifiers); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35); - node.body = parenthesizeConciseBody(body); + node.body = ts.parenthesizeConciseBody(body); return node; } ts.createArrowFunction = createArrowFunction; function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { - if (node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body, node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + : node; } ts.updateArrowFunction = updateArrowFunction; - function createDelete(expression, location) { - var node = createNode(186, location); - node.expression = parenthesizePrefixOperand(expression); + function createDelete(expression) { + var node = createSynthesizedNode(187); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createDelete = createDelete; function updateDelete(node, expression) { - if (node.expression !== expression) { - return updateNode(createDelete(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createDelete(expression), node) + : node; } ts.updateDelete = updateDelete; - function createTypeOf(expression, location) { - var node = createNode(187, location); - node.expression = parenthesizePrefixOperand(expression); + function createTypeOf(expression) { + var node = createSynthesizedNode(188); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createTypeOf = createTypeOf; function updateTypeOf(node, expression) { - if (node.expression !== expression) { - return updateNode(createTypeOf(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createTypeOf(expression), node) + : node; } ts.updateTypeOf = updateTypeOf; - function createVoid(expression, location) { - var node = createNode(188, location); - node.expression = parenthesizePrefixOperand(expression); + function createVoid(expression) { + var node = createSynthesizedNode(189); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createVoid = createVoid; function updateVoid(node, expression) { - if (node.expression !== expression) { - return updateNode(createVoid(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createVoid(expression), node) + : node; } ts.updateVoid = updateVoid; - function createAwait(expression, location) { - var node = createNode(189, location); - node.expression = parenthesizePrefixOperand(expression); + function createAwait(expression) { + var node = createSynthesizedNode(190); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createAwait = createAwait; function updateAwait(node, expression) { - if (node.expression !== expression) { - return updateNode(createAwait(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createAwait(expression), node) + : node; } ts.updateAwait = updateAwait; - function createPrefix(operator, operand, location) { - var node = createNode(190, location); + function createPrefix(operator, operand) { + var node = createSynthesizedNode(191); node.operator = operator; - node.operand = parenthesizePrefixOperand(operand); + node.operand = ts.parenthesizePrefixOperand(operand); return node; } ts.createPrefix = createPrefix; function updatePrefix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPrefix(node.operator, operand, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPrefix(node.operator, operand), node) + : node; } ts.updatePrefix = updatePrefix; - function createPostfix(operand, operator, location) { - var node = createNode(191, location); - node.operand = parenthesizePostfixOperand(operand); + function createPostfix(operand, operator) { + var node = createSynthesizedNode(192); + node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; } ts.createPostfix = createPostfix; function updatePostfix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPostfix(operand, node.operator, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPostfix(operand, node.operator), node) + : node; } ts.updatePostfix = updatePostfix; - function createBinary(left, operator, right, location) { - var operatorToken = typeof operator === "number" ? createToken(operator) : operator; + function createBinary(left, operator, right) { + var node = createSynthesizedNode(193); + var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; - var node = createNode(192, location); - node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); + node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; - node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); + node.right = ts.parenthesizeBinaryOperand(operatorKind, right, false, node.left); return node; } ts.createBinary = createBinary; function updateBinary(node, left, right) { - if (node.left !== left || node.right !== right) { - return updateNode(createBinary(left, node.operatorToken, right, node), node); - } - return node; + return node.left !== left + || node.right !== right + ? updateNode(createBinary(left, node.operatorToken, right), node) + : node; } ts.updateBinary = updateBinary; - function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonTokenOrLocation, whenFalse, location) { - var node = createNode(193, whenFalse ? location : colonTokenOrLocation); - node.condition = parenthesizeForConditionalHead(condition); - if (whenFalse) { - node.questionToken = questionTokenOrWhenTrue; - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - node.colonToken = colonTokenOrLocation; - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenFalse); - } - else { - node.questionToken = createToken(54); - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(questionTokenOrWhenTrue); - node.colonToken = createToken(55); - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - } + function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { + var node = createSynthesizedNode(194); + node.condition = ts.parenthesizeForConditionalHead(condition); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(54); + node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); + node.colonToken = whenFalse ? colonToken : createToken(55); + node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } ts.createConditional = createConditional; function updateConditional(node, condition, whenTrue, whenFalse) { - if (node.condition !== condition || node.whenTrue !== whenTrue || node.whenFalse !== whenFalse) { - return updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse, node), node); - } - return node; + return node.condition !== condition + || node.whenTrue !== whenTrue + || node.whenFalse !== whenFalse + ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + : node; } ts.updateConditional = updateConditional; - function createTemplateExpression(head, templateSpans, location) { - var node = createNode(194, location); + function createTemplateExpression(head, templateSpans) { + var node = createSynthesizedNode(195); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; } ts.createTemplateExpression = createTemplateExpression; function updateTemplateExpression(node, head, templateSpans) { - if (node.head !== head || node.templateSpans !== templateSpans) { - return updateNode(createTemplateExpression(head, templateSpans, node), node); - } - return node; + return node.head !== head + || node.templateSpans !== templateSpans + ? updateNode(createTemplateExpression(head, templateSpans), node) + : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createYield(asteriskToken, expression, location) { - var node = createNode(195, location); - node.asteriskToken = asteriskToken; - node.expression = expression; + function createYield(asteriskTokenOrExpression, expression) { + var node = createSynthesizedNode(196); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 38 ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 38 ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; function updateYield(node, expression) { - if (node.expression !== expression) { - return updateNode(createYield(node.asteriskToken, expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createYield(node.asteriskToken, expression), node) + : node; } ts.updateYield = updateYield; - function createSpread(expression, location) { - var node = createNode(196, location); - node.expression = parenthesizeExpressionForList(expression); + function createSpread(expression) { + var node = createSynthesizedNode(197); + node.expression = ts.parenthesizeExpressionForList(expression); return node; } ts.createSpread = createSpread; function updateSpread(node, expression) { - if (node.expression !== expression) { - return updateNode(createSpread(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createSpread(expression), node) + : node; } ts.updateSpread = updateSpread; - function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(197, location); + function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(198); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassExpression = createClassExpression; function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) { - if (node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassExpression = updateClassExpression; - function createOmittedExpression(location) { - var node = createNode(198, location); - return node; + function createOmittedExpression() { + return createSynthesizedNode(199); } ts.createOmittedExpression = createOmittedExpression; - function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(199, location); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.expression = parenthesizeForAccess(expression); + function createExpressionWithTypeArguments(typeArguments, expression) { + var node = createSynthesizedNode(200); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); return node; } ts.createExpressionWithTypeArguments = createExpressionWithTypeArguments; function updateExpressionWithTypeArguments(node, typeArguments, expression) { - if (node.typeArguments !== typeArguments || node.expression !== expression) { - return updateNode(createExpressionWithTypeArguments(typeArguments, expression, node), node); - } - return node; + return node.typeArguments !== typeArguments + || node.expression !== expression + ? updateNode(createExpressionWithTypeArguments(typeArguments, expression), node) + : node; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; - function createTemplateSpan(expression, literal, location) { - var node = createNode(203, location); + function createAsExpression(expression, type) { + var node = createSynthesizedNode(201); + node.expression = expression; + node.type = type; + return node; + } + ts.createAsExpression = createAsExpression; + function updateAsExpression(node, expression, type) { + return node.expression !== expression + || node.type !== type + ? updateNode(createAsExpression(expression, type), node) + : node; + } + ts.updateAsExpression = updateAsExpression; + function createNonNullExpression(expression) { + var node = createSynthesizedNode(202); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createNonNullExpression = createNonNullExpression; + function updateNonNullExpression(node, expression) { + return node.expression !== expression + ? updateNode(createNonNullExpression(expression), node) + : node; + } + ts.updateNonNullExpression = updateNonNullExpression; + function createTemplateSpan(expression, literal) { + var node = createSynthesizedNode(204); node.expression = expression; node.literal = literal; return node; } ts.createTemplateSpan = createTemplateSpan; function updateTemplateSpan(node, expression, literal) { - if (node.expression !== expression || node.literal !== literal) { - return updateNode(createTemplateSpan(expression, literal, node), node); - } - return node; + return node.expression !== expression + || node.literal !== literal + ? updateNode(createTemplateSpan(expression, literal), node) + : node; } ts.updateTemplateSpan = updateTemplateSpan; - function createBlock(statements, location, multiLine, flags) { - var block = createNode(205, location, flags); + function createBlock(statements, multiLine) { + var block = createSynthesizedNode(206); block.statements = createNodeArray(statements); - if (multiLine) { - block.multiLine = true; - } + if (multiLine) + block.multiLine = multiLine; return block; } ts.createBlock = createBlock; function updateBlock(node, statements) { - if (statements !== node.statements) { - return updateNode(createBlock(statements, node, node.multiLine, node.flags), node); - } - return node; + return statements !== node.statements + ? updateNode(createBlock(statements, node.multiLine), node) + : node; } ts.updateBlock = updateBlock; - function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(206, location, flags); + function createVariableStatement(modifiers, declarationList) { + var node = createSynthesizedNode(207); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; return node; } ts.createVariableStatement = createVariableStatement; function updateVariableStatement(node, modifiers, declarationList) { - if (node.modifiers !== modifiers || node.declarationList !== declarationList) { - return updateNode(createVariableStatement(modifiers, declarationList, node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.declarationList !== declarationList + ? updateNode(createVariableStatement(modifiers, declarationList), node) + : node; } ts.updateVariableStatement = updateVariableStatement; - function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(225, location, flags); + function createVariableDeclarationList(declarations, flags) { + var node = createSynthesizedNode(226); + node.flags |= flags; node.declarations = createNodeArray(declarations); return node; } ts.createVariableDeclarationList = createVariableDeclarationList; function updateVariableDeclarationList(node, declarations) { - if (node.declarations !== declarations) { - return updateNode(createVariableDeclarationList(declarations, node, node.flags), node); - } - return node; + return node.declarations !== declarations + ? updateNode(createVariableDeclarationList(declarations, node.flags), node) + : node; } ts.updateVariableDeclarationList = updateVariableDeclarationList; - function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(224, location, flags); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createVariableDeclaration(name, type, initializer) { + var node = createSynthesizedNode(225); + node.name = asName(name); node.type = type; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createVariableDeclaration = createVariableDeclaration; function updateVariableDeclaration(node, name, type, initializer) { - if (node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createVariableDeclaration(name, type, initializer, node, node.flags), node); - } - return node; + return node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createVariableDeclaration(name, type, initializer), node) + : node; } ts.updateVariableDeclaration = updateVariableDeclaration; - function createEmptyStatement(location) { - return createNode(207, location); + function createEmptyStatement() { + return createSynthesizedNode(208); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression, location, flags) { - var node = createNode(208, location, flags); - node.expression = parenthesizeExpressionForExpressionStatement(expression); + function createStatement(expression) { + var node = createSynthesizedNode(209); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } ts.createStatement = createStatement; function updateStatement(node, expression) { - if (node.expression !== expression) { - return updateNode(createStatement(expression, node, node.flags), node); - } - return node; + return node.expression !== expression + ? updateNode(createStatement(expression), node) + : node; } ts.updateStatement = updateStatement; - function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(209, location); + function createIf(expression, thenStatement, elseStatement) { + var node = createSynthesizedNode(210); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11392,42 +11225,43 @@ var ts; } ts.createIf = createIf; function updateIf(node, expression, thenStatement, elseStatement) { - if (node.expression !== expression || node.thenStatement !== thenStatement || node.elseStatement !== elseStatement) { - return updateNode(createIf(expression, thenStatement, elseStatement, node), node); - } - return node; + return node.expression !== expression + || node.thenStatement !== thenStatement + || node.elseStatement !== elseStatement + ? updateNode(createIf(expression, thenStatement, elseStatement), node) + : node; } ts.updateIf = updateIf; - function createDo(statement, expression, location) { - var node = createNode(210, location); + function createDo(statement, expression) { + var node = createSynthesizedNode(211); node.statement = statement; node.expression = expression; return node; } ts.createDo = createDo; function updateDo(node, statement, expression) { - if (node.statement !== statement || node.expression !== expression) { - return updateNode(createDo(statement, expression, node), node); - } - return node; + return node.statement !== statement + || node.expression !== expression + ? updateNode(createDo(statement, expression), node) + : node; } ts.updateDo = updateDo; - function createWhile(expression, statement, location) { - var node = createNode(211, location); + function createWhile(expression, statement) { + var node = createSynthesizedNode(212); node.expression = expression; node.statement = statement; return node; } ts.createWhile = createWhile; function updateWhile(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWhile(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWhile(expression, statement), node) + : node; } ts.updateWhile = updateWhile; - function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(212, location, undefined); + function createFor(initializer, condition, incrementor, statement) { + var node = createSynthesizedNode(213); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11436,14 +11270,16 @@ var ts; } ts.createFor = createFor; function updateFor(node, initializer, condition, incrementor, statement) { - if (node.initializer !== initializer || node.condition !== condition || node.incrementor !== incrementor || node.statement !== statement) { - return updateNode(createFor(initializer, condition, incrementor, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.condition !== condition + || node.incrementor !== incrementor + || node.statement !== statement + ? updateNode(createFor(initializer, condition, incrementor, statement), node) + : node; } ts.updateFor = updateFor; - function createForIn(initializer, expression, statement, location) { - var node = createNode(213, location); + function createForIn(initializer, expression, statement) { + var node = createSynthesizedNode(214); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11451,14 +11287,15 @@ var ts; } ts.createForIn = createForIn; function updateForIn(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForIn(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForIn(initializer, expression, statement), node) + : node; } ts.updateForIn = updateForIn; - function createForOf(initializer, expression, statement, location) { - var node = createNode(214, location); + function createForOf(initializer, expression, statement) { + var node = createSynthesizedNode(215); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11466,112 +11303,105 @@ var ts; } ts.createForOf = createForOf; function updateForOf(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForOf(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForOf(initializer, expression, statement), node) + : node; } ts.updateForOf = updateForOf; - function createContinue(label, location) { - var node = createNode(215, location); - if (label) { - node.label = label; - } + function createContinue(label) { + var node = createSynthesizedNode(216); + node.label = asName(label); return node; } ts.createContinue = createContinue; function updateContinue(node, label) { - if (node.label !== label) { - return updateNode(createContinue(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createContinue(label), node) + : node; } ts.updateContinue = updateContinue; - function createBreak(label, location) { - var node = createNode(216, location); - if (label) { - node.label = label; - } + function createBreak(label) { + var node = createSynthesizedNode(217); + node.label = asName(label); return node; } ts.createBreak = createBreak; function updateBreak(node, label) { - if (node.label !== label) { - return updateNode(createBreak(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createBreak(label), node) + : node; } ts.updateBreak = updateBreak; - function createReturn(expression, location) { - var node = createNode(217, location); + function createReturn(expression) { + var node = createSynthesizedNode(218); node.expression = expression; return node; } ts.createReturn = createReturn; function updateReturn(node, expression) { - if (node.expression !== expression) { - return updateNode(createReturn(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createReturn(expression), node) + : node; } ts.updateReturn = updateReturn; - function createWith(expression, statement, location) { - var node = createNode(218, location); + function createWith(expression, statement) { + var node = createSynthesizedNode(219); node.expression = expression; node.statement = statement; return node; } ts.createWith = createWith; function updateWith(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWith(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWith(expression, statement), node) + : node; } ts.updateWith = updateWith; - function createSwitch(expression, caseBlock, location) { - var node = createNode(219, location); - node.expression = parenthesizeExpressionForList(expression); + function createSwitch(expression, caseBlock) { + var node = createSynthesizedNode(220); + node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; } ts.createSwitch = createSwitch; function updateSwitch(node, expression, caseBlock) { - if (node.expression !== expression || node.caseBlock !== caseBlock) { - return updateNode(createSwitch(expression, caseBlock, node), node); - } - return node; + return node.expression !== expression + || node.caseBlock !== caseBlock + ? updateNode(createSwitch(expression, caseBlock), node) + : node; } ts.updateSwitch = updateSwitch; - function createLabel(label, statement, location) { - var node = createNode(220, location); - node.label = typeof label === "string" ? createIdentifier(label) : label; + function createLabel(label, statement) { + var node = createSynthesizedNode(221); + node.label = asName(label); node.statement = statement; return node; } ts.createLabel = createLabel; function updateLabel(node, label, statement) { - if (node.label !== label || node.statement !== statement) { - return updateNode(createLabel(label, statement, node), node); - } - return node; + return node.label !== label + || node.statement !== statement + ? updateNode(createLabel(label, statement), node) + : node; } ts.updateLabel = updateLabel; - function createThrow(expression, location) { - var node = createNode(221, location); + function createThrow(expression) { + var node = createSynthesizedNode(222); node.expression = expression; return node; } ts.createThrow = createThrow; function updateThrow(node, expression) { - if (node.expression !== expression) { - return updateNode(createThrow(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createThrow(expression), node) + : node; } ts.updateThrow = updateThrow; - function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(222, location); + function createTry(tryBlock, catchClause, finallyBlock) { + var node = createSynthesizedNode(223); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11579,32 +11409,20 @@ var ts; } ts.createTry = createTry; function updateTry(node, tryBlock, catchClause, finallyBlock) { - if (node.tryBlock !== tryBlock || node.catchClause !== catchClause || node.finallyBlock !== finallyBlock) { - return updateNode(createTry(tryBlock, catchClause, finallyBlock, node), node); - } - return node; + return node.tryBlock !== tryBlock + || node.catchClause !== catchClause + || node.finallyBlock !== finallyBlock + ? updateNode(createTry(tryBlock, catchClause, finallyBlock), node) + : node; } ts.updateTry = updateTry; - function createCaseBlock(clauses, location) { - var node = createNode(233, location); - node.clauses = createNodeArray(clauses); - return node; - } - ts.createCaseBlock = createCaseBlock; - function updateCaseBlock(node, clauses) { - if (node.clauses !== clauses) { - return updateNode(createCaseBlock(clauses, node), node); - } - return node; - } - ts.updateCaseBlock = updateCaseBlock; - function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(226, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(227); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -11612,161 +11430,261 @@ var ts; } ts.createFunctionDeclaration = createFunctionDeclaration; function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionDeclaration = updateFunctionDeclaration; - function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(227, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(228); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassDeclaration = createClassDeclaration; function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassDeclaration = updateClassDeclaration; - function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(236, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createEnumDeclaration(decorators, modifiers, name, members) { + var node = createSynthesizedNode(231); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.members = createNodeArray(members); + return node; + } + ts.createEnumDeclaration = createEnumDeclaration; + function updateEnumDeclaration(node, decorators, modifiers, name, members) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.members !== members + ? updateNode(createEnumDeclaration(decorators, modifiers, name, members), node) + : node; + } + ts.updateEnumDeclaration = updateEnumDeclaration; + function createModuleDeclaration(decorators, modifiers, name, body, flags) { + var node = createSynthesizedNode(232); + node.flags |= flags; + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = name; + node.body = body; + return node; + } + ts.createModuleDeclaration = createModuleDeclaration; + function updateModuleDeclaration(node, decorators, modifiers, name, body) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.body !== body + ? updateNode(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node) + : node; + } + ts.updateModuleDeclaration = updateModuleDeclaration; + function createModuleBlock(statements) { + var node = createSynthesizedNode(234); + node.statements = createNodeArray(statements); + return node; + } + ts.createModuleBlock = createModuleBlock; + function updateModuleBlock(node, statements) { + return node.statements !== statements + ? updateNode(createModuleBlock(statements), node) + : node; + } + ts.updateModuleBlock = updateModuleBlock; + function createCaseBlock(clauses) { + var node = createSynthesizedNode(234); + node.clauses = createNodeArray(clauses); + return node; + } + ts.createCaseBlock = createCaseBlock; + function updateCaseBlock(node, clauses) { + return node.clauses !== clauses + ? updateNode(createCaseBlock(clauses), node) + : node; + } + ts.updateCaseBlock = updateCaseBlock; + function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { + var node = createSynthesizedNode(236); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.moduleReference = moduleReference; + return node; + } + ts.createImportEqualsDeclaration = createImportEqualsDeclaration; + function updateImportEqualsDeclaration(node, decorators, modifiers, name, moduleReference) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.moduleReference !== moduleReference + ? updateNode(createImportEqualsDeclaration(decorators, modifiers, name, moduleReference), node) + : node; + } + ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; + function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { + var node = createSynthesizedNode(237); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createImportDeclaration = createImportDeclaration; function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node) + : node; } ts.updateImportDeclaration = updateImportDeclaration; - function createImportClause(name, namedBindings, location) { - var node = createNode(237, location); + function createImportClause(name, namedBindings) { + var node = createSynthesizedNode(238); node.name = name; node.namedBindings = namedBindings; return node; } ts.createImportClause = createImportClause; function updateImportClause(node, name, namedBindings) { - if (node.name !== name || node.namedBindings !== namedBindings) { - return updateNode(createImportClause(name, namedBindings, node), node); - } - return node; + return node.name !== name + || node.namedBindings !== namedBindings + ? updateNode(createImportClause(name, namedBindings), node) + : node; } ts.updateImportClause = updateImportClause; - function createNamespaceImport(name, location) { - var node = createNode(238, location); + function createNamespaceImport(name) { + var node = createSynthesizedNode(239); node.name = name; return node; } ts.createNamespaceImport = createNamespaceImport; function updateNamespaceImport(node, name) { - if (node.name !== name) { - return updateNode(createNamespaceImport(name, node), node); - } - return node; + return node.name !== name + ? updateNode(createNamespaceImport(name), node) + : node; } ts.updateNamespaceImport = updateNamespaceImport; - function createNamedImports(elements, location) { - var node = createNode(239, location); + function createNamedImports(elements) { + var node = createSynthesizedNode(240); node.elements = createNodeArray(elements); return node; } ts.createNamedImports = createNamedImports; function updateNamedImports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedImports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedImports(elements), node) + : node; } ts.updateNamedImports = updateNamedImports; - function createImportSpecifier(propertyName, name, location) { - var node = createNode(240, location); + function createImportSpecifier(propertyName, name) { + var node = createSynthesizedNode(241); node.propertyName = propertyName; node.name = name; return node; } ts.createImportSpecifier = createImportSpecifier; function updateImportSpecifier(node, propertyName, name) { - if (node.propertyName !== propertyName || node.name !== name) { - return updateNode(createImportSpecifier(propertyName, name, node), node); - } - return node; + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createImportSpecifier(propertyName, name), node) + : node; } ts.updateImportSpecifier = updateImportSpecifier; - function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(241, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportAssignment(decorators, modifiers, isExportEquals, expression) { + var node = createSynthesizedNode(242); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = expression; return node; } ts.createExportAssignment = createExportAssignment; function updateExportAssignment(node, decorators, modifiers, expression) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.expression !== expression) { - return updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.expression !== expression + ? updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node) + : node; } ts.updateExportAssignment = updateExportAssignment; - function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(242, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { + var node = createSynthesizedNode(243); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createExportDeclaration = createExportDeclaration; function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.exportClause !== exportClause + || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier), node) + : node; } ts.updateExportDeclaration = updateExportDeclaration; - function createNamedExports(elements, location) { - var node = createNode(243, location); + function createNamedExports(elements) { + var node = createSynthesizedNode(244); node.elements = createNodeArray(elements); return node; } ts.createNamedExports = createNamedExports; function updateNamedExports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedExports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedExports(elements), node) + : node; } ts.updateNamedExports = updateNamedExports; - function createExportSpecifier(name, propertyName, location) { - var node = createNode(244, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createExportSpecifier(name, propertyName) { + var node = createSynthesizedNode(245); + node.name = asName(name); + node.propertyName = asName(propertyName); return node; } ts.createExportSpecifier = createExportSpecifier; function updateExportSpecifier(node, name, propertyName) { - if (node.name !== name || node.propertyName !== propertyName) { - return updateNode(createExportSpecifier(name, propertyName, node), node); - } - return node; + return node.name !== name || node.propertyName !== propertyName + ? updateNode(createExportSpecifier(name, propertyName), node) + : node; } ts.updateExportSpecifier = updateExportSpecifier; - function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(247, location); + function createExternalModuleReference(expression) { + var node = createSynthesizedNode(247); + node.expression = expression; + return node; + } + ts.createExternalModuleReference = createExternalModuleReference; + function updateExternalModuleReference(node, expression) { + return node.expression !== expression + ? updateNode(createExternalModuleReference(expression), node) + : node; + } + ts.updateExternalModuleReference = updateExternalModuleReference; + function createJsxElement(openingElement, children, closingElement) { + var node = createSynthesizedNode(248); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11774,96 +11692,107 @@ var ts; } ts.createJsxElement = createJsxElement; function updateJsxElement(node, openingElement, children, closingElement) { - if (node.openingElement !== openingElement || node.children !== children || node.closingElement !== closingElement) { - return updateNode(createJsxElement(openingElement, children, closingElement, node), node); - } - return node; + return node.openingElement !== openingElement + || node.children !== children + || node.closingElement !== closingElement + ? updateNode(createJsxElement(openingElement, children, closingElement), node) + : node; } ts.updateJsxElement = updateJsxElement; - function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(248, location); + function createJsxSelfClosingElement(tagName, attributes) { + var node = createSynthesizedNode(249); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxSelfClosingElement = createJsxSelfClosingElement; function updateJsxSelfClosingElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxSelfClosingElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxSelfClosingElement(tagName, attributes), node) + : node; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; - function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(249, location); + function createJsxOpeningElement(tagName, attributes) { + var node = createSynthesizedNode(250); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxOpeningElement = createJsxOpeningElement; function updateJsxOpeningElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxOpeningElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxOpeningElement(tagName, attributes), node) + : node; } ts.updateJsxOpeningElement = updateJsxOpeningElement; - function createJsxClosingElement(tagName, location) { - var node = createNode(250, location); + function createJsxClosingElement(tagName) { + var node = createSynthesizedNode(251); node.tagName = tagName; return node; } ts.createJsxClosingElement = createJsxClosingElement; function updateJsxClosingElement(node, tagName) { - if (node.tagName !== tagName) { - return updateNode(createJsxClosingElement(tagName, node), node); - } - return node; + return node.tagName !== tagName + ? updateNode(createJsxClosingElement(tagName), node) + : node; } ts.updateJsxClosingElement = updateJsxClosingElement; - function createJsxAttribute(name, initializer, location) { - var node = createNode(251, location); + function createJsxAttributes(properties) { + var jsxAttributes = createSynthesizedNode(253); + jsxAttributes.properties = createNodeArray(properties); + return jsxAttributes; + } + ts.createJsxAttributes = createJsxAttributes; + function updateJsxAttributes(jsxAttributes, properties) { + if (jsxAttributes.properties !== properties) { + return updateNode(createJsxAttributes(properties), jsxAttributes); + } + return jsxAttributes; + } + ts.updateJsxAttributes = updateJsxAttributes; + function createJsxAttribute(name, initializer) { + var node = createSynthesizedNode(252); node.name = name; node.initializer = initializer; return node; } ts.createJsxAttribute = createJsxAttribute; function updateJsxAttribute(node, name, initializer) { - if (node.name !== name || node.initializer !== initializer) { - return updateNode(createJsxAttribute(name, initializer, node), node); - } - return node; + return node.name !== name + || node.initializer !== initializer + ? updateNode(createJsxAttribute(name, initializer), node) + : node; } ts.updateJsxAttribute = updateJsxAttribute; - function createJsxSpreadAttribute(expression, location) { - var node = createNode(252, location); + function createJsxSpreadAttribute(expression) { + var node = createSynthesizedNode(254); node.expression = expression; return node; } ts.createJsxSpreadAttribute = createJsxSpreadAttribute; function updateJsxSpreadAttribute(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxSpreadAttribute(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxSpreadAttribute(expression), node) + : node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, dotDotDotToken, location) { - var node = createNode(253, location); + function createJsxExpression(expression, dotDotDotToken) { + var node = createSynthesizedNode(255); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxExpression(expression, node.dotDotDotToken), node) + : node; } ts.updateJsxExpression = updateJsxExpression; - function createHeritageClause(token, types, location) { - var node = createNode(256, location); + function createHeritageClause(token, types) { + var node = createSynthesizedNode(258); node.token = token; node.types = createNodeArray(types); return node; @@ -11871,40 +11800,40 @@ var ts; ts.createHeritageClause = createHeritageClause; function updateHeritageClause(node, types) { if (node.types !== types) { - return updateNode(createHeritageClause(node.token, types, node), node); + return updateNode(createHeritageClause(node.token, types), node); } return node; } ts.updateHeritageClause = updateHeritageClause; - function createCaseClause(expression, statements, location) { - var node = createNode(254, location); - node.expression = parenthesizeExpressionForList(expression); + function createCaseClause(expression, statements) { + var node = createSynthesizedNode(256); + node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; } ts.createCaseClause = createCaseClause; function updateCaseClause(node, expression, statements) { if (node.expression !== expression || node.statements !== statements) { - return updateNode(createCaseClause(expression, statements, node), node); + return updateNode(createCaseClause(expression, statements), node); } return node; } ts.updateCaseClause = updateCaseClause; - function createDefaultClause(statements, location) { - var node = createNode(255, location); + function createDefaultClause(statements) { + var node = createSynthesizedNode(257); node.statements = createNodeArray(statements); return node; } ts.createDefaultClause = createDefaultClause; function updateDefaultClause(node, statements) { if (node.statements !== statements) { - return updateNode(createDefaultClause(statements, node), node); + return updateNode(createDefaultClause(statements), node); } return node; } ts.updateDefaultClause = updateDefaultClause; - function createCatchClause(variableDeclaration, block, location) { - var node = createNode(257, location); + function createCatchClause(variableDeclaration, block) { + var node = createSynthesizedNode(259); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11912,56 +11841,71 @@ var ts; ts.createCatchClause = createCatchClause; function updateCatchClause(node, variableDeclaration, block) { if (node.variableDeclaration !== variableDeclaration || node.block !== block) { - return updateNode(createCatchClause(variableDeclaration, block, node), node); + return updateNode(createCatchClause(variableDeclaration, block), node); } return node; } ts.updateCatchClause = updateCatchClause; - function createPropertyAssignment(name, initializer, location) { - var node = createNode(258, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAssignment(name, initializer) { + var node = createSynthesizedNode(260); + node.name = asName(name); node.questionToken = undefined; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createPropertyAssignment = createPropertyAssignment; function updatePropertyAssignment(node, name, initializer) { if (node.name !== name || node.initializer !== initializer) { - return updateNode(createPropertyAssignment(name, initializer, node), node); + return updateNode(createPropertyAssignment(name, initializer), node); } return node; } ts.updatePropertyAssignment = updatePropertyAssignment; - function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(259, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; + function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { + var node = createSynthesizedNode(261); + node.name = asName(name); + node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; - function createSpreadAssignment(expression, location) { - var node = createNode(260, location); - node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; + function createSpreadAssignment(expression) { + var node = createSynthesizedNode(262); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; return node; } ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { - return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); + return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); } return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function updateSpreadAssignment(node, expression) { if (node.expression !== expression) { - return updateNode(createSpreadAssignment(expression, node), node); + return updateNode(createSpreadAssignment(expression), node); } return node; } ts.updateSpreadAssignment = updateSpreadAssignment; + function createEnumMember(name, initializer) { + var node = createSynthesizedNode(263); + node.name = asName(name); + node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); + return node; + } + ts.createEnumMember = createEnumMember; + function updateEnumMember(node, name, initializer) { + return node.name !== name + || node.initializer !== initializer + ? updateNode(createEnumMember(name, initializer), node) + : node; + } + ts.updateEnumMember = updateEnumMember; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(262, node, node.flags); + var updated = createSynthesizedNode(264); + updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -12020,50 +11964,73 @@ var ts; return node; } ts.updateSourceFileNode = updateSourceFileNode; + function getMutableClone(node) { + var clone = getSynthesizedClone(node); + clone.pos = node.pos; + clone.end = node.end; + clone.parent = node.parent; + return clone; + } + ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createNode(294, original); + var node = createSynthesizedNode(297); node.original = original; + setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createNode(297); + var node = createSynthesizedNode(300); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createNode(296); + var node = createSynthesizedNode(299); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; - function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(295, location || original); + function createPartiallyEmittedExpression(expression, original) { + var node = createSynthesizedNode(298); node.expression = expression; node.original = original; + setTextRange(node, original); return node; } ts.createPartiallyEmittedExpression = createPartiallyEmittedExpression; function updatePartiallyEmittedExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createPartiallyEmittedExpression(expression, node.original, node), node); + return updateNode(createPartiallyEmittedExpression(expression, node.original), node); } return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; + function createBundle(sourceFiles) { + var node = ts.createNode(265); + node.sourceFiles = sourceFiles; + return node; + } + ts.createBundle = createBundle; + function updateBundle(node, sourceFiles) { + if (node.sourceFiles !== sourceFiles) { + return createBundle(sourceFiles); + } + return node; + } + ts.updateBundle = updateBundle; function createComma(left, right) { return createBinary(left, 25, right); } ts.createComma = createComma; - function createLessThan(left, right, location) { - return createBinary(left, 26, right, location); + function createLessThan(left, right) { + return createBinary(left, 26, right); } ts.createLessThan = createLessThan; - function createAssignment(left, right, location) { - return createBinary(left, 57, right, location); + function createAssignment(left, right) { + return createBinary(left, 57, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { @@ -12082,8 +12049,8 @@ var ts; return createBinary(left, 37, right); } ts.createSubtract = createSubtract; - function createPostfixIncrement(operand, location) { - return createPostfix(operand, 42, location); + function createPostfixIncrement(operand) { + return createPostfix(operand, 42); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { @@ -12102,97 +12069,6 @@ var ts; return createVoid(createLiteral(0)); } ts.createVoidZero = createVoidZero; - function createTypeCheck(value, tag) { - return tag === "undefined" - ? createStrictEquality(value, createVoidZero()) - : createStrictEquality(createTypeOf(value), createLiteral(tag)); - } - ts.createTypeCheck = createTypeCheck; - function createMemberAccessForPropertyName(target, memberName, location) { - if (ts.isComputedPropertyName(memberName)) { - return createElementAccess(target, memberName.expression, location); - } - else { - var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - (expression.emitNode || (expression.emitNode = {})).flags |= 64; - return expression; - } - } - ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; - function createFunctionCall(func, thisArg, argumentsList, location) { - return createCall(createPropertyAccess(func, "call"), undefined, [ - thisArg - ].concat(argumentsList), location); - } - ts.createFunctionCall = createFunctionCall; - function createFunctionApply(func, thisArg, argumentsExpression, location) { - return createCall(createPropertyAccess(func, "apply"), undefined, [ - thisArg, - argumentsExpression - ], location); - } - ts.createFunctionApply = createFunctionApply; - function createArraySlice(array, start) { - var argumentsList = []; - if (start !== undefined) { - argumentsList.push(typeof start === "number" ? createLiteral(start) : start); - } - return createCall(createPropertyAccess(array, "slice"), undefined, argumentsList); - } - ts.createArraySlice = createArraySlice; - function createArrayConcat(array, values) { - return createCall(createPropertyAccess(array, "concat"), undefined, values); - } - ts.createArrayConcat = createArrayConcat; - function createMathPow(left, right, location) { - return createCall(createPropertyAccess(createIdentifier("Math"), "pow"), undefined, [left, right], location); - } - ts.createMathPow = createMathPow; - function createReactNamespace(reactNamespace, parent) { - var react = createIdentifier(reactNamespace || "React"); - react.flags &= ~8; - react.parent = ts.getParseTreeNode(parent); - return react; - } - function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { - if (ts.isQualifiedName(jsxFactory)) { - var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); - var right = createSynthesizedNode(70); - right.text = jsxFactory.right.text; - return createPropertyAccess(left, right); - } - else { - return createReactNamespace(jsxFactory.text, parent); - } - } - function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { - return jsxFactoryEntity ? - createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : - createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); - } - function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { - var argumentsList = [tagName]; - if (props) { - argumentsList.push(props); - } - if (children && children.length > 0) { - if (!props) { - argumentsList.push(createNull()); - } - if (children.length > 1) { - for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { - var child = children_1[_i]; - child.startsOnNewLine = true; - argumentsList.push(child); - } - } - else { - argumentsList.push(children[0]); - } - } - return createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList, location); - } - ts.createExpressionForJsxElement = createExpressionForJsxElement; function createExportDefault(expression) { return createExportAssignment(undefined, undefined, false, expression); } @@ -12201,586 +12077,17 @@ var ts; return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(exportName)])); } ts.createExternalModuleExport = createExternalModuleExport; - function createLetStatement(name, initializer, location) { - return createVariableStatement(undefined, createLetDeclarationList([createVariableDeclaration(name, undefined, initializer)]), location); + function asName(name) { + return typeof name === "string" ? createIdentifier(name) : name; } - ts.createLetStatement = createLetStatement; - function createLetDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 1); + function asExpression(value) { + return typeof value === "string" || typeof value === "number" ? createLiteral(value) : value; } - ts.createLetDeclarationList = createLetDeclarationList; - function createConstDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 2); + function asNodeArray(array) { + return array ? createNodeArray(array) : undefined; } - ts.createConstDeclarationList = createConstDeclarationList; - function getHelperName(name) { - return setEmitFlags(createIdentifier(name), 4096 | 2); - } - ts.getHelperName = getHelperName; - function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { - if (!outermostLabeledStatement) { - return node; - } - var updated = updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 220 - ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) - : node); - if (afterRestoreLabelCallback) { - afterRestoreLabelCallback(outermostLabeledStatement); - } - return updated; - } - ts.restoreEnclosingLabel = restoreEnclosingLabel; - function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { - var target = skipParentheses(node); - switch (target.kind) { - case 70: - return cacheIdentifiers; - case 98: - case 8: - case 9: - return false; - case 175: - var elements = target.elements; - if (elements.length === 0) { - return false; - } - return true; - case 176: - return target.properties.length > 0; - default: - return true; - } - } - function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { - var callee = skipOuterExpressions(expression, 7); - var thisArg; - var target; - if (ts.isSuperProperty(callee)) { - thisArg = createThis(); - target = callee; - } - else if (callee.kind === 96) { - thisArg = createThis(); - target = languageVersion < 2 ? createIdentifier("_super", callee) : callee; - } - else { - switch (callee.kind) { - case 177: { - if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { - thisArg = createTempVariable(recordTempVariable); - target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); - } - else { - thisArg = callee.expression; - target = callee; - } - break; - } - case 178: { - if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { - thisArg = createTempVariable(recordTempVariable); - target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); - } - else { - thisArg = callee.expression; - target = callee; - } - break; - } - default: { - thisArg = createVoidZero(); - target = parenthesizeForAccess(expression); - break; - } - } - } - return { target: target, thisArg: thisArg }; - } - ts.createCallBinding = createCallBinding; - function inlineExpressions(expressions) { - return ts.reduceLeft(expressions, createComma); - } - ts.inlineExpressions = inlineExpressions; - function createExpressionFromEntityName(node) { - if (ts.isQualifiedName(node)) { - var left = createExpressionFromEntityName(node.left); - var right = getMutableClone(node.right); - return createPropertyAccess(left, right, node); - } - else { - return getMutableClone(node); - } - } - ts.createExpressionFromEntityName = createExpressionFromEntityName; - function createExpressionForPropertyName(memberName) { - if (ts.isIdentifier(memberName)) { - return createLiteral(memberName, undefined); - } - else if (ts.isComputedPropertyName(memberName)) { - return getMutableClone(memberName.expression); - } - else { - return getMutableClone(memberName); - } - } - ts.createExpressionForPropertyName = createExpressionForPropertyName; - function createExpressionForObjectLiteralElementLike(node, property, receiver) { - switch (property.kind) { - case 151: - case 152: - return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 258: - return createExpressionForPropertyAssignment(property, receiver); - case 259: - return createExpressionForShorthandPropertyAssignment(property, receiver); - case 149: - return createExpressionForMethodDeclaration(property, receiver); - } - } - ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike; - function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { - var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; - if (property === firstAccessor) { - var properties_1 = []; - if (getAccessor) { - var getterFunction = createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); - setOriginalNode(getterFunction, getAccessor); - var getter = createPropertyAssignment("get", getterFunction); - properties_1.push(getter); - } - if (setAccessor) { - var setterFunction = createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); - setOriginalNode(setterFunction, setAccessor); - var setter = createPropertyAssignment("set", setterFunction); - properties_1.push(setter); - } - properties_1.push(createPropertyAssignment("enumerable", createLiteral(true))); - properties_1.push(createPropertyAssignment("configurable", createLiteral(true))); - var expression = createCall(createPropertyAccess(createIdentifier("Object"), "defineProperty"), undefined, [ - receiver, - createExpressionForPropertyName(property.name), - createObjectLiteral(properties_1, undefined, multiLine) - ], firstAccessor); - return ts.aggregateTransformFlags(expression); - } - return undefined; - } - function createExpressionForPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer, property), property)); - } - function createExpressionForShorthandPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), getSynthesizedClone(property.name), property), property)); - } - function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); - } - function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384); - } - ts.getLocalName = getLocalName; - function isLocalName(node) { - return (getEmitFlags(node) & 16384) !== 0; - } - ts.isLocalName = isLocalName; - function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 8192); - } - ts.getExportName = getExportName; - function isExportName(node) { - return (getEmitFlags(node) & 8192) !== 0; - } - ts.isExportName = isExportName; - function getDeclarationName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps); - } - ts.getDeclarationName = getDeclarationName; - function getName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { - var name_10 = getMutableClone(node.name); - emitFlags |= getEmitFlags(node.name); - if (!allowSourceMaps) - emitFlags |= 48; - if (!allowComments) - emitFlags |= 1536; - if (emitFlags) - setEmitFlags(name_10, emitFlags); - return name_10; - } - return getGeneratedNameForNode(node); - } - function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && ts.hasModifier(node, 1)) { - return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); - } - return getExportName(node, allowComments, allowSourceMaps); - } - ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; - function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { - var qualifiedName = createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : getSynthesizedClone(name), name); - var emitFlags; - if (!allowSourceMaps) - emitFlags |= 48; - if (!allowComments) - emitFlags |= 1536; - if (emitFlags) - setEmitFlags(qualifiedName, emitFlags); - return qualifiedName; - } - ts.getNamespaceMemberName = getNamespaceMemberName; - function convertToFunctionBody(node, multiLine) { - return ts.isBlock(node) ? node : createBlock([createReturn(node, node)], node, multiLine); - } - ts.convertToFunctionBody = convertToFunctionBody; - function isUseStrictPrologue(node) { - return node.expression.text === "use strict"; - } - function addPrologueDirectives(target, source, ensureUseStrict, visitor) { - ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); - var foundUseStrict = false; - var statementOffset = 0; - var numStatements = source.length; - while (statementOffset < numStatements) { - var statement = source[statementOffset]; - if (ts.isPrologueDirective(statement)) { - if (isUseStrictPrologue(statement)) { - foundUseStrict = true; - } - target.push(statement); - } - else { - break; - } - statementOffset++; - } - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - } - while (statementOffset < numStatements) { - var statement = source[statementOffset]; - if (getEmitFlags(statement) & 524288) { - target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); - } - else { - break; - } - statementOffset++; - } - return statementOffset; - } - ts.addPrologueDirectives = addPrologueDirectives; - function startsWithUseStrict(statements) { - var firstStatement = ts.firstOrUndefined(statements); - return firstStatement !== undefined - && ts.isPrologueDirective(firstStatement) - && isUseStrictPrologue(firstStatement); - } - ts.startsWithUseStrict = startsWithUseStrict; - function ensureUseStrict(statements) { - var foundUseStrict = false; - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; - if (ts.isPrologueDirective(statement)) { - if (isUseStrictPrologue(statement)) { - foundUseStrict = true; - break; - } - } - else { - break; - } - } - if (!foundUseStrict) { - return createNodeArray([ - startOnNewLine(createStatement(createLiteral("use strict"))) - ].concat(statements), statements); - } - return statements; - } - ts.ensureUseStrict = ensureUseStrict; - function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 183) { - return operand; - } - return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) - ? createParen(operand) - : operand; - } - ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; - function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(192, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(192, binaryOperator); - var emittedOperand = skipPartiallyEmittedExpressions(operand); - var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); - switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1: - if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 - && operand.kind === 195) { - return false; - } - return true; - case 1: - return false; - case 0: - if (isLeftSideOfBinary) { - return binaryOperatorAssociativity === 1; - } - else { - if (ts.isBinaryExpression(emittedOperand) - && emittedOperand.operatorToken.kind === binaryOperator) { - if (operatorHasAssociativeProperty(binaryOperator)) { - return false; - } - if (binaryOperator === 36) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; - if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { - return false; - } - } - } - var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0; - } - } - } - function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 38 - || binaryOperator === 48 - || binaryOperator === 47 - || binaryOperator === 49; - } - function getLiteralKindOfBinaryPlusOperand(node) { - node = skipPartiallyEmittedExpressions(node); - if (ts.isLiteralKind(node.kind)) { - return node.kind; - } - if (node.kind === 192 && node.operatorToken.kind === 36) { - if (node.cachedLiteralKind !== undefined) { - return node.cachedLiteralKind; - } - var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0; - node.cachedLiteralKind = literalKind; - return literalKind; - } - return 0; - } - function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(193, 54); - var emittedCondition = skipPartiallyEmittedExpressions(condition); - var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { - return createParen(condition); - } - return condition; - } - ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; - function parenthesizeSubexpressionOfConditionalExpression(e) { - return e.kind === 192 && e.operatorToken.kind === 25 - ? createParen(e) - : e; - } - function parenthesizeForNew(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - switch (emittedExpression.kind) { - case 179: - return createParen(expression); - case 180: - return emittedExpression.arguments - ? expression - : createParen(expression); - } - return parenthesizeForAccess(expression); - } - ts.parenthesizeForNew = parenthesizeForNew; - function parenthesizeForAccess(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 180 || emittedExpression.arguments) - && emittedExpression.kind !== 8) { - return expression; - } - return createParen(expression, expression); - } - ts.parenthesizeForAccess = parenthesizeForAccess; - function parenthesizePostfixOperand(operand) { - return ts.isLeftHandSideExpression(operand) - ? operand - : createParen(operand, operand); - } - ts.parenthesizePostfixOperand = parenthesizePostfixOperand; - function parenthesizePrefixOperand(operand) { - return ts.isUnaryExpression(operand) - ? operand - : createParen(operand, operand); - } - ts.parenthesizePrefixOperand = parenthesizePrefixOperand; - function parenthesizeListElements(elements) { - var result; - for (var i = 0; i < elements.length; i++) { - var element = parenthesizeExpressionForList(elements[i]); - if (result !== undefined || element !== elements[i]) { - if (result === undefined) { - result = elements.slice(0, i); - } - result.push(element); - } - } - if (result !== undefined) { - return createNodeArray(result, elements, elements.hasTrailingComma); - } - return elements; - } - function parenthesizeExpressionForList(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(192, 25); - return expressionPrecedence > commaPrecedence - ? expression - : createParen(expression, expression); - } - ts.parenthesizeExpressionForList = parenthesizeExpressionForList; - function parenthesizeExpressionForExpressionStatement(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - if (ts.isCallExpression(emittedExpression)) { - var callee = emittedExpression.expression; - var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 184 || kind === 185) { - var mutableCall = getMutableClone(emittedExpression); - mutableCall.expression = createParen(callee, callee); - return recreatePartiallyEmittedExpressions(expression, mutableCall); - } - } - else { - var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 176 || leftmostExpressionKind === 184) { - return createParen(expression, expression); - } - } - return expression; - } - ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; - function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { - if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { - var clone_1 = getMutableClone(originalOuterExpression); - clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); - return clone_1; - } - return newInnerExpression; - } - function getLeftmostExpression(node) { - while (true) { - switch (node.kind) { - case 191: - node = node.operand; - continue; - case 192: - node = node.left; - continue; - case 193: - node = node.condition; - continue; - case 179: - case 178: - case 177: - node = node.expression; - continue; - case 295: - node = node.expression; - continue; - } - return node; - } - } - function parenthesizeConciseBody(body) { - var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 176) { - return createParen(body, body); - } - return body; - } - ts.parenthesizeConciseBody = parenthesizeConciseBody; - function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 7; } - var previousNode; - do { - previousNode = node; - if (kinds & 1) { - node = skipParentheses(node); - } - if (kinds & 2) { - node = skipAssertions(node); - } - if (kinds & 4) { - node = skipPartiallyEmittedExpressions(node); - } - } while (previousNode !== node); - return node; - } - ts.skipOuterExpressions = skipOuterExpressions; - function skipParentheses(node) { - while (node.kind === 183) { - node = node.expression; - } - return node; - } - ts.skipParentheses = skipParentheses; - function skipAssertions(node) { - while (ts.isAssertionExpression(node)) { - node = node.expression; - } - return node; - } - ts.skipAssertions = skipAssertions; - function skipPartiallyEmittedExpressions(node) { - while (node.kind === 295) { - node = node.expression; - } - return node; - } - ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; - function startOnNewLine(node) { - node.startsOnNewLine = true; - return node; - } - ts.startOnNewLine = startOnNewLine; - function setOriginalNode(node, original) { - node.original = original; - if (original) { - var emitNode = original.emitNode; - if (emitNode) - node.emitNode = mergeEmitNode(emitNode, node.emitNode); - } - return node; - } - ts.setOriginalNode = setOriginalNode; - function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; - if (!destEmitNode) - destEmitNode = {}; - if (flags) - destEmitNode.flags = flags; - if (commentRange) - destEmitNode.commentRange = commentRange; - if (sourceMapRange) - destEmitNode.sourceMapRange = sourceMapRange; - if (tokenSourceMapRanges) - destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); - if (constantValue !== undefined) - destEmitNode.constantValue = constantValue; - if (helpers) - destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); - return destEmitNode; - } - function mergeTokenSourceMapRanges(sourceRanges, destRanges) { - if (!destRanges) - destRanges = ts.createMap(); - ts.copyProperties(sourceRanges, destRanges); - return destRanges; + function asToken(value) { + return typeof value === "number" ? createToken(value) : value; } function disposeEmitNodes(sourceFile) { sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); @@ -12797,7 +12104,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 262) { + if (node.kind === 264) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12808,6 +12115,14 @@ var ts; return node.emitNode; } ts.getOrCreateEmitNode = getOrCreateEmitNode; + function setTextRange(range, location) { + if (location) { + range.pos = location.pos; + range.end = location.end; + } + return range; + } + ts.setTextRange = setTextRange; function getEmitFlags(node) { var emitNode = node.emitNode; return emitNode && emitNode.flags; @@ -12836,7 +12151,7 @@ var ts; ts.getTokenSourceMapRange = getTokenSourceMapRange; function setTokenSourceMapRange(node, token, range) { var emitNode = getOrCreateEmitNode(node); - var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); + var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []); tokenSourceMapRanges[token] = range; return node; } @@ -12862,32 +12177,6 @@ var ts; return node; } ts.setConstantValue = setConstantValue; - function getExternalHelpersModuleName(node) { - var parseNode = ts.getOriginalNode(node, ts.isSourceFile); - var emitNode = parseNode && parseNode.emitNode; - return emitNode && emitNode.externalHelpersModuleName; - } - ts.getExternalHelpersModuleName = getExternalHelpersModuleName; - function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions) { - if (compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { - var externalHelpersModuleName = getExternalHelpersModuleName(node); - if (externalHelpersModuleName) { - return externalHelpersModuleName; - } - var helpers = getEmitHelpers(node); - if (helpers) { - for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { - var helper = helpers_1[_i]; - if (!helper.scoped) { - var parseNode = ts.getOriginalNode(node, ts.isSourceFile); - var emitNode = getOrCreateEmitNode(parseNode); - return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = createUniqueName(ts.externalHelpersModuleNameText)); - } - } - } - } - } - ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; function addEmitHelper(node, helper) { var emitNode = getOrCreateEmitNode(node); emitNode.helpers = ts.append(emitNode.helpers, helper); @@ -12897,8 +12186,8 @@ var ts; function addEmitHelpers(node, helpers) { if (ts.some(helpers)) { var emitNode = getOrCreateEmitNode(node); - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { + var helper = helpers_1[_i]; if (!ts.contains(emitNode.helpers, helper)) { emitNode.helpers = ts.append(emitNode.helpers, helper); } @@ -12959,40 +12248,725 @@ var ts; return ts.compareValues(x.priority, y.priority); } ts.compareEmitHelpers = compareEmitHelpers; - function setTextRange(node, location) { - if (location) { - node.pos = location.pos; - node.end = location.end; + function setOriginalNode(node, original) { + node.original = original; + if (original) { + var emitNode = original.emitNode; + if (emitNode) + node.emitNode = mergeEmitNode(emitNode, node.emitNode); } return node; } - ts.setTextRange = setTextRange; - function setNodeFlags(node, flags) { - node.flags = flags; + ts.setOriginalNode = setOriginalNode; + function mergeEmitNode(sourceEmitNode, destEmitNode) { + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; + if (!destEmitNode) + destEmitNode = {}; + if (flags) + destEmitNode.flags = flags; + if (commentRange) + destEmitNode.commentRange = commentRange; + if (sourceMapRange) + destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + if (constantValue !== undefined) + destEmitNode.constantValue = constantValue; + if (helpers) + destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); + return destEmitNode; + } + function mergeTokenSourceMapRanges(sourceRanges, destRanges) { + if (!destRanges) + destRanges = []; + for (var key in sourceRanges) { + destRanges[key] = sourceRanges[key]; + } + return destRanges; + } +})(ts || (ts = {})); +(function (ts) { + function createTypeCheck(value, tag) { + return tag === "undefined" + ? ts.createStrictEquality(value, ts.createVoidZero()) + : ts.createStrictEquality(ts.createTypeOf(value), ts.createLiteral(tag)); + } + ts.createTypeCheck = createTypeCheck; + function createMemberAccessForPropertyName(target, memberName, location) { + if (ts.isComputedPropertyName(memberName)) { + return ts.setTextRange(ts.createElementAccess(target, memberName.expression), location); + } + else { + var expression = ts.setTextRange(ts.isIdentifier(memberName) + ? ts.createPropertyAccess(target, memberName) + : ts.createElementAccess(target, memberName), memberName); + ts.getOrCreateEmitNode(expression).flags |= 64; + return expression; + } + } + ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; + function createFunctionCall(func, thisArg, argumentsList, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), undefined, [ + thisArg + ].concat(argumentsList)), location); + } + ts.createFunctionCall = createFunctionCall; + function createFunctionApply(func, thisArg, argumentsExpression, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "apply"), undefined, [ + thisArg, + argumentsExpression + ]), location); + } + ts.createFunctionApply = createFunctionApply; + function createArraySlice(array, start) { + var argumentsList = []; + if (start !== undefined) { + argumentsList.push(typeof start === "number" ? ts.createLiteral(start) : start); + } + return ts.createCall(ts.createPropertyAccess(array, "slice"), undefined, argumentsList); + } + ts.createArraySlice = createArraySlice; + function createArrayConcat(array, values) { + return ts.createCall(ts.createPropertyAccess(array, "concat"), undefined, values); + } + ts.createArrayConcat = createArrayConcat; + function createMathPow(left, right, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Math"), "pow"), undefined, [left, right]), location); + } + ts.createMathPow = createMathPow; + function createReactNamespace(reactNamespace, parent) { + var react = ts.createIdentifier(reactNamespace || "React"); + react.flags &= ~8; + react.parent = ts.getParseTreeNode(parent); + return react; + } + function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { + if (ts.isQualifiedName(jsxFactory)) { + var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); + var right = ts.createIdentifier(jsxFactory.right.text); + right.text = jsxFactory.right.text; + return ts.createPropertyAccess(left, right); + } + else { + return createReactNamespace(jsxFactory.text, parent); + } + } + function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { + return jsxFactoryEntity ? + createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : + ts.createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); + } + function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { + var argumentsList = [tagName]; + if (props) { + argumentsList.push(props); + } + if (children && children.length > 0) { + if (!props) { + argumentsList.push(ts.createNull()); + } + if (children.length > 1) { + for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { + var child = children_1[_i]; + child.startsOnNewLine = true; + argumentsList.push(child); + } + } + else { + argumentsList.push(children[0]); + } + } + return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location); + } + ts.createExpressionForJsxElement = createExpressionForJsxElement; + function getHelperName(name) { + return ts.setEmitFlags(ts.createIdentifier(name), 4096 | 2); + } + ts.getHelperName = getHelperName; + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 221 + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; + function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { + var target = skipParentheses(node); + switch (target.kind) { + case 70: + return cacheIdentifiers; + case 98: + case 8: + case 9: + return false; + case 176: + var elements = target.elements; + if (elements.length === 0) { + return false; + } + return true; + case 177: + return target.properties.length > 0; + default: + return true; + } + } + function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { + var callee = skipOuterExpressions(expression, 7); + var thisArg; + var target; + if (ts.isSuperProperty(callee)) { + thisArg = ts.createThis(); + target = callee; + } + else if (callee.kind === 96) { + thisArg = ts.createThis(); + target = languageVersion < 2 + ? ts.setTextRange(ts.createIdentifier("_super"), callee) + : callee; + } + else { + switch (callee.kind) { + case 178: { + if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); + ts.setTextRange(target, callee); + } + else { + thisArg = callee.expression; + target = callee; + } + break; + } + case 179: { + if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); + ts.setTextRange(target, callee); + } + else { + thisArg = callee.expression; + target = callee; + } + break; + } + default: { + thisArg = ts.createVoidZero(); + target = parenthesizeForAccess(expression); + break; + } + } + } + return { target: target, thisArg: thisArg }; + } + ts.createCallBinding = createCallBinding; + function inlineExpressions(expressions) { + return ts.reduceLeft(expressions, ts.createComma); + } + ts.inlineExpressions = inlineExpressions; + function createExpressionFromEntityName(node) { + if (ts.isQualifiedName(node)) { + var left = createExpressionFromEntityName(node.left); + var right = ts.getMutableClone(node.right); + return ts.setTextRange(ts.createPropertyAccess(left, right), node); + } + else { + return ts.getMutableClone(node); + } + } + ts.createExpressionFromEntityName = createExpressionFromEntityName; + function createExpressionForPropertyName(memberName) { + if (ts.isIdentifier(memberName)) { + return ts.createLiteral(memberName); + } + else if (ts.isComputedPropertyName(memberName)) { + return ts.getMutableClone(memberName.expression); + } + else { + return ts.getMutableClone(memberName); + } + } + ts.createExpressionForPropertyName = createExpressionForPropertyName; + function createExpressionForObjectLiteralElementLike(node, property, receiver) { + switch (property.kind) { + case 152: + case 153: + return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); + case 260: + return createExpressionForPropertyAssignment(property, receiver); + case 261: + return createExpressionForShorthandPropertyAssignment(property, receiver); + case 150: + return createExpressionForMethodDeclaration(property, receiver); + } + } + ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike; + function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { + var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + if (property === firstAccessor) { + var properties_1 = []; + if (getAccessor) { + var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body); + ts.setTextRange(getterFunction, getAccessor); + ts.setOriginalNode(getterFunction, getAccessor); + var getter = ts.createPropertyAssignment("get", getterFunction); + properties_1.push(getter); + } + if (setAccessor) { + var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body); + ts.setTextRange(setterFunction, setAccessor); + ts.setOriginalNode(setterFunction, setAccessor); + var setter = ts.createPropertyAssignment("set", setterFunction); + properties_1.push(setter); + } + properties_1.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_1.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + receiver, + createExpressionForPropertyName(property.name), + ts.createObjectLiteral(properties_1, multiLine) + ]), firstAccessor); + return ts.aggregateTransformFlags(expression); + } + return undefined; + } + function createExpressionForPropertyAssignment(property, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer), property), property)); + } + function createExpressionForShorthandPropertyAssignment(property, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), ts.getSynthesizedClone(property.name)), property), property)); + } + function createExpressionForMethodDeclaration(method, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body), method), method)), method), method)); + } + function getLocalName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 16384); + } + ts.getLocalName = getLocalName; + function isLocalName(node) { + return (ts.getEmitFlags(node) & 16384) !== 0; + } + ts.isLocalName = isLocalName; + function getExportName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 8192); + } + ts.getExportName = getExportName; + function isExportName(node) { + return (ts.getEmitFlags(node) & 8192) !== 0; + } + ts.isExportName = isExportName; + function getDeclarationName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps); + } + ts.getDeclarationName = getDeclarationName; + function getName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { + var name = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); + if (!allowSourceMaps) + emitFlags |= 48; + if (!allowComments) + emitFlags |= 1536; + if (emitFlags) + ts.setEmitFlags(name, emitFlags); + return name; + } + return ts.getGeneratedNameForNode(node); + } + function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { + if (ns && ts.hasModifier(node, 1)) { + return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); + } + return getExportName(node, allowComments, allowSourceMaps); + } + ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; + function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { + var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name)); + ts.setTextRange(qualifiedName, name); + var emitFlags; + if (!allowSourceMaps) + emitFlags |= 48; + if (!allowComments) + emitFlags |= 1536; + if (emitFlags) + ts.setEmitFlags(qualifiedName, emitFlags); + return qualifiedName; + } + ts.getNamespaceMemberName = getNamespaceMemberName; + function convertToFunctionBody(node, multiLine) { + return ts.isBlock(node) ? node : ts.setTextRange(ts.createBlock([ts.setTextRange(ts.createReturn(node), node)], multiLine), node); + } + ts.convertToFunctionBody = convertToFunctionBody; + function isUseStrictPrologue(node) { + return node.expression.text === "use strict"; + } + function addPrologueDirectives(target, source, ensureUseStrict, visitor) { + ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); + var foundUseStrict = false; + var statementOffset = 0; + var numStatements = source.length; + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + } + target.push(statement); + } + else { + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (ts.getEmitFlags(statement) & 524288) { + target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); + } + else { + break; + } + statementOffset++; + } + return statementOffset; + } + ts.addPrologueDirectives = addPrologueDirectives; + function startsWithUseStrict(statements) { + var firstStatement = ts.firstOrUndefined(statements); + return firstStatement !== undefined + && ts.isPrologueDirective(firstStatement) + && isUseStrictPrologue(firstStatement); + } + ts.startsWithUseStrict = startsWithUseStrict; + function ensureUseStrict(statements) { + var foundUseStrict = false; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + break; + } + } + else { + break; + } + } + if (!foundUseStrict) { + return ts.setTextRange(ts.createNodeArray([ + startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) + ].concat(statements)), statements); + } + return statements; + } + ts.ensureUseStrict = ensureUseStrict; + function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { + var skipped = skipPartiallyEmittedExpressions(operand); + if (skipped.kind === 184) { + return operand; + } + return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) + ? ts.createParen(operand) + : operand; + } + ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; + function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { + var binaryOperatorPrecedence = ts.getOperatorPrecedence(193, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(193, binaryOperator); + var emittedOperand = skipPartiallyEmittedExpressions(operand); + var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); + switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { + case -1: + if (!isLeftSideOfBinary + && binaryOperatorAssociativity === 1 + && operand.kind === 196) { + return false; + } + return true; + case 1: + return false; + case 0: + if (isLeftSideOfBinary) { + return binaryOperatorAssociativity === 1; + } + else { + if (ts.isBinaryExpression(emittedOperand) + && emittedOperand.operatorToken.kind === binaryOperator) { + if (operatorHasAssociativeProperty(binaryOperator)) { + return false; + } + if (binaryOperator === 36) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; + if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { + return false; + } + } + } + var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); + return operandAssociativity === 0; + } + } + } + function operatorHasAssociativeProperty(binaryOperator) { + return binaryOperator === 38 + || binaryOperator === 48 + || binaryOperator === 47 + || binaryOperator === 49; + } + function getLiteralKindOfBinaryPlusOperand(node) { + node = skipPartiallyEmittedExpressions(node); + if (ts.isLiteralKind(node.kind)) { + return node.kind; + } + if (node.kind === 193 && node.operatorToken.kind === 36) { + if (node.cachedLiteralKind !== undefined) { + return node.cachedLiteralKind; + } + var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); + var literalKind = ts.isLiteralKind(leftKind) + && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) + ? leftKind + : 0; + node.cachedLiteralKind = literalKind; + return literalKind; + } + return 0; + } + function parenthesizeForConditionalHead(condition) { + var conditionalPrecedence = ts.getOperatorPrecedence(194, 54); + var emittedCondition = skipPartiallyEmittedExpressions(condition); + var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { + return ts.createParen(condition); + } + return condition; + } + ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; + function parenthesizeSubexpressionOfConditionalExpression(e) { + return e.kind === 193 && e.operatorToken.kind === 25 + ? ts.createParen(e) + : e; + } + ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression; + function parenthesizeForNew(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + switch (emittedExpression.kind) { + case 180: + return ts.createParen(expression); + case 181: + return emittedExpression.arguments + ? expression + : ts.createParen(expression); + } + return parenthesizeForAccess(expression); + } + ts.parenthesizeForNew = parenthesizeForNew; + function parenthesizeForAccess(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + if (ts.isLeftHandSideExpression(emittedExpression) + && (emittedExpression.kind !== 181 || emittedExpression.arguments) + && emittedExpression.kind !== 8) { + return expression; + } + return ts.setTextRange(ts.createParen(expression), expression); + } + ts.parenthesizeForAccess = parenthesizeForAccess; + function parenthesizePostfixOperand(operand) { + return ts.isLeftHandSideExpression(operand) + ? operand + : ts.setTextRange(ts.createParen(operand), operand); + } + ts.parenthesizePostfixOperand = parenthesizePostfixOperand; + function parenthesizePrefixOperand(operand) { + return ts.isUnaryExpression(operand) + ? operand + : ts.setTextRange(ts.createParen(operand), operand); + } + ts.parenthesizePrefixOperand = parenthesizePrefixOperand; + function parenthesizeListElements(elements) { + var result; + for (var i = 0; i < elements.length; i++) { + var element = parenthesizeExpressionForList(elements[i]); + if (result !== undefined || element !== elements[i]) { + if (result === undefined) { + result = elements.slice(0, i); + } + result.push(element); + } + } + if (result !== undefined) { + return ts.setTextRange(ts.createNodeArray(result, elements.hasTrailingComma), elements); + } + return elements; + } + ts.parenthesizeListElements = parenthesizeListElements; + function parenthesizeExpressionForList(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); + var commaPrecedence = ts.getOperatorPrecedence(193, 25); + return expressionPrecedence > commaPrecedence + ? expression + : ts.setTextRange(ts.createParen(expression), expression); + } + ts.parenthesizeExpressionForList = parenthesizeExpressionForList; + function parenthesizeExpressionForExpressionStatement(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + if (ts.isCallExpression(emittedExpression)) { + var callee = emittedExpression.expression; + var kind = skipPartiallyEmittedExpressions(callee).kind; + if (kind === 185 || kind === 186) { + var mutableCall = ts.getMutableClone(emittedExpression); + mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); + return recreatePartiallyEmittedExpressions(expression, mutableCall); + } + } + else { + var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; + if (leftmostExpressionKind === 177 || leftmostExpressionKind === 185) { + return ts.setTextRange(ts.createParen(expression), expression); + } + } + return expression; + } + ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; + function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { + if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { + var clone_1 = ts.getMutableClone(originalOuterExpression); + clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); + return clone_1; + } + return newInnerExpression; + } + function getLeftmostExpression(node) { + while (true) { + switch (node.kind) { + case 192: + node = node.operand; + continue; + case 193: + node = node.left; + continue; + case 194: + node = node.condition; + continue; + case 180: + case 179: + case 178: + node = node.expression; + continue; + case 298: + node = node.expression; + continue; + } + return node; + } + } + function parenthesizeConciseBody(body) { + var emittedBody = skipPartiallyEmittedExpressions(body); + if (emittedBody.kind === 177) { + return ts.setTextRange(ts.createParen(body), body); + } + return body; + } + ts.parenthesizeConciseBody = parenthesizeConciseBody; + var OuterExpressionKinds; + (function (OuterExpressionKinds) { + OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; + OuterExpressionKinds[OuterExpressionKinds["Assertions"] = 2] = "Assertions"; + OuterExpressionKinds[OuterExpressionKinds["PartiallyEmittedExpressions"] = 4] = "PartiallyEmittedExpressions"; + OuterExpressionKinds[OuterExpressionKinds["All"] = 7] = "All"; + })(OuterExpressionKinds = ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); + function skipOuterExpressions(node, kinds) { + if (kinds === void 0) { kinds = 7; } + var previousNode; + do { + previousNode = node; + if (kinds & 1) { + node = skipParentheses(node); + } + if (kinds & 2) { + node = skipAssertions(node); + } + if (kinds & 4) { + node = skipPartiallyEmittedExpressions(node); + } + } while (previousNode !== node); return node; } - ts.setNodeFlags = setNodeFlags; - function setMultiLine(node, multiLine) { - node.multiLine = multiLine; + ts.skipOuterExpressions = skipOuterExpressions; + function skipParentheses(node) { + while (node.kind === 184) { + node = node.expression; + } return node; } - ts.setMultiLine = setMultiLine; - function setHasTrailingComma(nodes, hasTrailingComma) { - nodes.hasTrailingComma = hasTrailingComma; - return nodes; + ts.skipParentheses = skipParentheses; + function skipAssertions(node) { + while (ts.isAssertionExpression(node)) { + node = node.expression; + } + return node; } - ts.setHasTrailingComma = setHasTrailingComma; + ts.skipAssertions = skipAssertions; + function skipPartiallyEmittedExpressions(node) { + while (node.kind === 298) { + node = node.expression; + } + return node; + } + ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; + function startOnNewLine(node) { + node.startsOnNewLine = true; + return node; + } + ts.startOnNewLine = startOnNewLine; + function getExternalHelpersModuleName(node) { + var parseNode = ts.getOriginalNode(node, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return emitNode && emitNode.externalHelpersModuleName; + } + ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions) { + if (compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { + var externalHelpersModuleName = getExternalHelpersModuleName(node); + if (externalHelpersModuleName) { + return externalHelpersModuleName; + } + var helpers = ts.getEmitHelpers(node); + if (helpers) { + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var parseNode = ts.getOriginalNode(node, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = ts.createUniqueName(ts.externalHelpersModuleNameText)); + } + } + } + } + } + ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_11 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_11) ? name_11 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 236 && node.importClause) { - return getGeneratedNameForNode(node); + if (node.kind === 237 && node.importClause) { + return ts.getGeneratedNameForNode(node); } - if (node.kind === 242 && node.moduleSpecifier) { - return getGeneratedNameForNode(node); + if (node.kind === 243 && node.moduleSpecifier) { + return ts.getGeneratedNameForNode(node); } return undefined; } @@ -13002,26 +12976,24 @@ var ts; if (moduleName.kind === 9) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) - || getSynthesizedClone(moduleName); + || ts.getSynthesizedClone(moduleName); } return undefined; } ts.getExternalModuleNameLiteral = getExternalModuleNameLiteral; function tryRenameExternalModule(moduleName, sourceFile) { - if (sourceFile.renamedDependencies && ts.hasProperty(sourceFile.renamedDependencies, moduleName.text)) { - return createLiteral(sourceFile.renamedDependencies[moduleName.text]); - } - return undefined; + var rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text); + return rename && ts.createLiteral(rename); } function tryGetModuleNameFromFile(file, host, options) { if (!file) { return undefined; } if (file.moduleName) { - return createLiteral(file.moduleName); + return ts.createLiteral(file.moduleName); } if (!ts.isDeclarationFile(file) && (options.out || options.outFile)) { - return createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); + return ts.createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); } return undefined; } @@ -13055,11 +13027,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 258: - return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 259: - return bindingElement.name; case 260: + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); + case 261: + return bindingElement.name; + case 262: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -13075,11 +13047,11 @@ var ts; ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 144: - case 174: + case 145: + case 175: return bindingElement.dotDotDotToken; - case 196: - case 260: + case 197: + case 262: return bindingElement; } return undefined; @@ -13087,7 +13059,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 174: + case 175: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -13095,7 +13067,7 @@ var ts; : propertyName; } break; - case 258: + case 260: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -13103,7 +13075,7 @@ var ts; : propertyName; } break; - case 260: + case 262: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -13117,11 +13089,11 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 172: case 173: - case 175: - return name.elements; + case 174: case 176: + return name.elements; + case 177: return name.properties; } } @@ -13130,10 +13102,12 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpread(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpread(element.name), element), element); } var expression = convertToAssignmentElementTarget(element.name); - return element.initializer ? setOriginalNode(createAssignment(expression, element.initializer, element), element) : expression; + return element.initializer + ? ts.setOriginalNode(ts.setTextRange(ts.createAssignment(expression, element.initializer), element), element) + : expression; } ts.Debug.assertNode(element, ts.isExpression); return element; @@ -13143,14 +13117,14 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpreadAssignment(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpreadAssignment(element.name), element), element); } if (element.propertyName) { var expression = convertToAssignmentElementTarget(element.name); - return setOriginalNode(createPropertyAssignment(element.propertyName, element.initializer ? createAssignment(expression, element.initializer) : expression, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createPropertyAssignment(element.propertyName, element.initializer ? ts.createAssignment(expression, element.initializer) : expression), element), element); } ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createShorthandPropertyAssignment(element.name, element.initializer, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createShorthandPropertyAssignment(element.name, element.initializer), element), element); } ts.Debug.assertNode(element, ts.isObjectLiteralElementLike); return element; @@ -13158,18 +13132,18 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 173: - case 175: - return convertToArrayAssignmentPattern(node); - case 172: + case 174: case 176: + return convertToArrayAssignmentPattern(node); + case 173: + case 177: return convertToObjectAssignmentPattern(node); } } ts.convertToAssignmentPattern = convertToAssignmentPattern; function convertToObjectAssignmentPattern(node) { if (ts.isObjectBindingPattern(node)) { - return setOriginalNode(createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isObjectLiteralExpression); return node; @@ -13177,7 +13151,7 @@ var ts; ts.convertToObjectAssignmentPattern = convertToObjectAssignmentPattern; function convertToArrayAssignmentPattern(node) { if (ts.isArrayBindingPattern(node)) { - return setOriginalNode(createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isArrayLiteralExpression); return node; @@ -13193,30 +13167,30 @@ var ts; ts.convertToAssignmentElementTarget = convertToAssignmentElementTarget; function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) { var externalImports = []; - var exportSpecifiers = ts.createMap(); - var exportedBindings = ts.createMap(); + var exportSpecifiers = ts.createMultiMap(); + var exportedBindings = []; var uniqueExports = ts.createMap(); var exportedNames; var hasExportDefault = false; var exportEquals = undefined; var hasExportStarsToExportValues = false; var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions); - var externalHelpersImportDeclaration = externalHelpersModuleName && createImportDeclaration(undefined, undefined, createImportClause(undefined, createNamespaceImport(externalHelpersModuleName)), createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); if (externalHelpersImportDeclaration) { externalImports.push(externalHelpersImportDeclaration); } for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 236: + case 237: externalImports.push(node); break; - case 235: - if (node.moduleReference.kind === 246) { + case 236: + if (node.moduleReference.kind === 247) { externalImports.push(node); } break; - case 242: + case 243: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -13229,26 +13203,26 @@ var ts; else { for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - if (!uniqueExports[specifier.name.text]) { - var name_12 = specifier.propertyName || specifier.name; - ts.multiMapAdd(exportSpecifiers, name_12.text, specifier); - var decl = resolver.getReferencedImportDeclaration(name_12) - || resolver.getReferencedValueDeclaration(name_12); + if (!uniqueExports.get(specifier.name.text)) { + var name = specifier.propertyName || specifier.name; + exportSpecifiers.add(name.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); if (decl) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); } - uniqueExports[specifier.name.text] = true; + uniqueExports.set(specifier.name.text, true); exportedNames = ts.append(exportedNames, specifier.name); } } } break; - case 241: + case 242: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 206: + case 207: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13256,38 +13230,38 @@ var ts; } } break; - case 226: - if (ts.hasModifier(node, 1)) { - if (ts.hasModifier(node, 512)) { - if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); - hasExportDefault = true; - } - } - else { - var name_13 = node.name; - if (!uniqueExports[name_13.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_13); - uniqueExports[name_13.text] = true; - exportedNames = ts.append(exportedNames, name_13); - } - } - } - break; case 227: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { - var name_14 = node.name; - if (!uniqueExports[name_14.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_14); - uniqueExports[name_14.text] = true; - exportedNames = ts.append(exportedNames, name_14); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); + } + } + } + break; + case 228: + if (ts.hasModifier(node, 1)) { + if (ts.hasModifier(node, 512)) { + if (!hasExportDefault) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + hasExportDefault = true; + } + } + else { + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } @@ -13307,13 +13281,23 @@ var ts; } } else if (!ts.isGeneratedIdentifier(decl.name)) { - if (!uniqueExports[decl.name.text]) { - uniqueExports[decl.name.text] = true; + if (!uniqueExports.get(decl.name.text)) { + uniqueExports.set(decl.name.text, true); exportedNames = ts.append(exportedNames, decl.name); } } return exportedNames; } + function multiMapSparseArrayAdd(map, key, value) { + var values = map[key]; + if (values) { + values.push(value); + } + else { + map[key] = values = [value]; + } + return values; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -13322,13 +13306,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 262) { + if (kind === 264) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 141) { + else if (kind < 142) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -13364,28 +13348,29 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 141: + case 142: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 143: + case 144: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || + visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 259: + case 261: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 260: + case 262: return visitNode(cbNode, node.expression); - case 144: + case 145: + case 148: case 147: - case 146: - case 258: - case 224: - case 174: + case 260: + case 225: + case 175: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -13394,24 +13379,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 158: case 159: - case 153: + case 160: case 154: case 155: + case 156: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 184: - case 226: + case 153: case 185: + case 227: + case 186: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -13422,174 +13407,167 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 157: + case 158: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 156: + case 157: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 160: - return visitNode(cbNode, node.exprName); case 161: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 162: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 163: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 164: + return visitNodes(cbNodes, node.elementTypes); case 165: - return visitNodes(cbNodes, node.types); case 166: - case 168: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); + case 167: case 169: + return visitNode(cbNode, node.type); + case 170: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 170: + case 171: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 171: - return visitNode(cbNode, node.literal); case 172: + return visitNode(cbNode, node.literal); case 173: - return visitNodes(cbNodes, node.elements); - case 175: + case 174: return visitNodes(cbNodes, node.elements); case 176: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 177: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.name); + return visitNodes(cbNodes, node.properties); case 178: return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); + visitNode(cbNode, node.name); case 179: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); case 180: + case 181: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 181: + case 182: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 182: + case 183: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 183: - return visitNode(cbNode, node.expression); - case 186: + case 184: return visitNode(cbNode, node.expression); case 187: return visitNode(cbNode, node.expression); case 188: return visitNode(cbNode, node.expression); - case 190: - return visitNode(cbNode, node.operand); - case 195: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 189: return visitNode(cbNode, node.expression); case 191: return visitNode(cbNode, node.operand); + case 196: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 190: + return visitNode(cbNode, node.expression); case 192: + return visitNode(cbNode, node.operand); + case 193: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 200: + case 201: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 201: - return visitNode(cbNode, node.expression); case 202: + return visitNode(cbNode, node.expression); + case 203: return visitNode(cbNode, node.name); - case 193: + case 194: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 196: + case 197: return visitNode(cbNode, node.expression); - case 205: - case 232: + case 206: + case 233: return visitNodes(cbNodes, node.statements); - case 262: + case 264: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 206: + case 207: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 225: + case 226: return visitNodes(cbNodes, node.declarations); - case 208: - return visitNode(cbNode, node.expression); case 209: + return visitNode(cbNode, node.expression); + case 210: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 210: + case 211: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 211: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 212: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 213: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 214: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 215: - case 216: - return visitNode(cbNode, node.label); - case 217: - return visitNode(cbNode, node.expression); - case 218: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 216: + case 217: + return visitNode(cbNode, node.label); + case 218: + return visitNode(cbNode, node.expression); case 219: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 220: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 233: + case 234: return visitNodes(cbNodes, node.clauses); - case 254: + case 256: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 255: + case 257: return visitNodes(cbNodes, node.statements); - case 220: + case 221: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 221: - return visitNode(cbNode, node.expression); case 222: + return visitNode(cbNode, node.expression); + case 223: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 257: + case 259: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 145: + case 146: return visitNode(cbNode, node.expression); - case 227: - case 197: - 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 228: + case 198: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13601,144 +13579,153 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 230: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 261: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 231: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 263: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 232: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 235: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 236: + case 237: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 237: + case 238: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 234: - return visitNode(cbNode, node.name); - case 238: + case 235: return visitNode(cbNode, node.name); case 239: - case 243: + return visitNode(cbNode, node.name); + case 240: + case 244: return visitNodes(cbNodes, node.elements); - case 242: + case 243: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 240: - case 244: + case 241: + case 245: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 241: + case 242: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 194: + case 195: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 203: + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 142: + case 143: return visitNode(cbNode, node.expression); - case 256: + case 258: return visitNodes(cbNodes, node.types); - case 199: + case 200: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 246: - return visitNode(cbNode, node.expression); - case 245: - return visitNodes(cbNodes, node.decorators); case 247: + return visitNode(cbNode, node.expression); + case 246: + return visitNodes(cbNodes, node.decorators); + case 248: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 248: case 249: + case 250: return visitNode(cbNode, node.tagName) || - visitNodes(cbNodes, node.attributes); - case 251: + visitNode(cbNode, node.attributes); + case 253: + return visitNodes(cbNodes, node.properties); + case 252: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 252: + case 254: return visitNode(cbNode, node.expression); - case 253: + case 255: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 250: + case 251: return visitNode(cbNode, node.tagName); - case 263: - return visitNode(cbNode, node.type); - case 267: - return visitNodes(cbNodes, node.types); - case 268: - return visitNodes(cbNodes, node.types); case 266: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.type); case 270: - return visitNode(cbNode, node.type); - case 269: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); case 271: - return visitNode(cbNode, node.literal); + return visitNodes(cbNodes, node.types); + case 269: + return visitNode(cbNode, node.elementType); case 273: + return visitNode(cbNode, node.type); + case 272: + return visitNode(cbNode, node.type); + case 274: + return visitNode(cbNode, node.literal); + case 276: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 274: - return visitNode(cbNode, node.type); - case 275: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 276: - return visitNode(cbNode, node.type); case 277: return visitNode(cbNode, node.type); case 278: - return visitNode(cbNode, node.type); - case 272: - return visitNode(cbNode, node.name) || + return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); case 279: - return visitNodes(cbNodes, node.tags); + return visitNode(cbNode, node.type); + case 280: + return visitNode(cbNode, node.type); + case 281: + return visitNode(cbNode, node.type); + case 275: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.type); case 282: + return visitNodes(cbNodes, node.tags); + case 285: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 283: + case 286: + return visitNode(cbNode, node.typeExpression); + case 287: return visitNode(cbNode, node.typeExpression); case 284: return visitNode(cbNode, node.typeExpression); - case 281: - return visitNode(cbNode, node.typeExpression); - case 285: + case 288: return visitNodes(cbNodes, node.typeParameters); - case 286: + case 289: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 288: + case 291: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 287: + case 290: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 295: + case 298: return visitNode(cbNode, node.expression); - case 289: + case 292: return visitNode(cbNode, node.literal); } } @@ -13902,7 +13889,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(262, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(264, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -14129,7 +14116,7 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 141 ? new NodeConstructor(kind, pos, pos) : + return kind >= 142 ? new NodeConstructor(kind, pos, pos) : kind === 70 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } @@ -14166,7 +14153,11 @@ var ts; } function internIdentifier(text) { text = ts.escapeIdentifier(text); - return identifiers[text] || (identifiers[text] = text); + var identifier = identifiers.get(text); + if (identifier === undefined) { + identifiers.set(text, identifier = text); + } + return identifier; } function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; @@ -14211,7 +14202,7 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(142); + var node = createNode(143); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); @@ -14516,14 +14507,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 150: - case 155: case 151: + case 156: case 152: - case 147: - case 204: + case 153: + case 148: + case 205: return true; - case 149: + case 150: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 70 && methodDeclaration.name.originalKeywordKind === 122; @@ -14535,8 +14526,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 254: - case 255: + case 256: + case 257: return true; } } @@ -14545,65 +14536,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 226: + case 227: + case 207: case 206: - case 205: + case 210: case 209: - case 208: - case 221: + case 222: + case 218: + case 220: case 217: - case 219: case 216: + case 214: case 215: case 213: - case 214: case 212: - case 211: - case 218: - case 207: - case 222: - case 220: - case 210: + case 219: + case 208: case 223: + case 221: + case 211: + case 224: + case 237: case 236: - case 235: + case 243: case 242: - case 241: - case 231: - case 227: + case 232: case 228: - case 230: case 229: + case 231: + case 230: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 261; + return node.kind === 263; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 154: - case 148: case 155: - case 146: - case 153: + case 149: + case 156: + case 147: + case 154: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 224) { + if (node.kind !== 225) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 144) { + if (node.kind !== 145) { return false; } var parameter = node; @@ -14699,7 +14690,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(22)) { - var node = createNode(141, entity.pos); + var node = createNode(142, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -14716,7 +14707,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(194); + var template = createNode(195); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -14728,7 +14719,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(203); + var span = createNode(204); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -14776,7 +14767,7 @@ var ts; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(157, typeName.pos); + var node = createNode(158, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token() === 26) { node.typeArguments = parseBracketedList(19, parseType, 26, 28); @@ -14785,24 +14776,24 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(156, lhs.pos); + var node = createNode(157, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(167); + var node = createNode(168); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(160); + var node = createNode(161); parseExpected(102); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(143); + var node = createNode(144); node.name = parseIdentifier(); if (parseOptional(84)) { if (isStartOfType() || !isStartOfExpression()) { @@ -14812,6 +14803,9 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } + if (parseOptional(57)) { + node.default = parseType(); + } return finishNode(node); } function parseTypeParameters() { @@ -14829,7 +14823,7 @@ var ts; return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; } function parseParameter() { - var node = createNode(144); + var node = createNode(145); if (token() === 98) { node.name = createIdentifier(true, undefined); node.type = parseParameterType(); @@ -14889,7 +14883,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 154) { + if (kind === 155) { parseExpected(93); } fillSignature(55, false, false, false, node); @@ -14929,7 +14923,7 @@ var ts; return token() === 55 || token() === 25 || token() === 21; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(155, fullStart); + var node = createNode(156, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.parameters = parseBracketedList(16, parseParameter, 20, 21); @@ -14941,7 +14935,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(54); if (token() === 18 || token() === 26) { - var method = createNode(148, fullStart); + var method = createNode(149, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; @@ -14950,7 +14944,7 @@ var ts; return addJSDocComment(finishNode(method)); } else { - var property = createNode(146, fullStart); + var property = createNode(147, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; @@ -14990,10 +14984,10 @@ var ts; } function parseTypeMember() { if (token() === 18 || token() === 26) { - return parseSignatureMember(153); + return parseSignatureMember(154); } if (token() === 93 && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(154); + return parseSignatureMember(155); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -15007,7 +15001,7 @@ var ts; return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(161); + var node = createNode(162); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -15030,14 +15024,14 @@ var ts; return token() === 20 && nextTokenIsIdentifier() && nextToken() === 91; } function parseMappedTypeParameter() { - var node = createNode(143); + var node = createNode(144); node.name = parseIdentifier(); parseExpected(91); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(170); + var node = createNode(171); parseExpected(16); node.readonlyToken = parseOptionalToken(130); parseExpected(20); @@ -15050,12 +15044,12 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(163); + var node = createNode(164); node.elementTypes = parseBracketedList(20, parseType, 20, 21); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(166); + var node = createNode(167); parseExpected(18); node.type = parseType(); parseExpected(19); @@ -15063,7 +15057,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 159) { + if (kind === 160) { parseExpected(93); } fillSignature(35, false, false, false, node); @@ -15074,7 +15068,7 @@ var ts; return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(171); + var node = createNode(172); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -15085,12 +15079,13 @@ var ts; function parseNonArrayType() { switch (token()) { case 118: - case 134: + case 135: case 132: case 121: - case 135: - case 137: + case 136: + case 138: case 129: + case 133: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: @@ -15127,12 +15122,12 @@ var ts; function isStartOfType() { switch (token()) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: case 104: - case 137: + case 138: case 94: case 98: case 102: @@ -15147,6 +15142,7 @@ var ts; case 8: case 100: case 85: + case 133: return true; case 37: return lookAhead(nextTokenIsNumericLiteral); @@ -15164,14 +15160,14 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { if (isStartOfType()) { - var node = createNode(169, type.pos); + var node = createNode(170, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(21); type = finishNode(node); } else { - var node = createNode(162, type.pos); + var node = createNode(163, type.pos); node.elementType = type; parseExpected(21); type = finishNode(node); @@ -15180,7 +15176,7 @@ var ts; return type; } function parseTypeOperator(operator) { - var node = createNode(168); + var node = createNode(169); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); @@ -15209,10 +15205,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(165, parseTypeOperatorOrHigher, 47); + return parseUnionOrIntersectionType(166, parseTypeOperatorOrHigher, 47); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(164, parseIntersectionTypeOrHigher, 48); + return parseUnionOrIntersectionType(165, parseIntersectionTypeOrHigher, 48); } function isStartOfFunctionType() { if (token() === 26) { @@ -15258,7 +15254,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(156, typePredicateVariable.pos); + var node = createNode(157, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -15279,10 +15275,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(158); + return parseFunctionOrConstructorType(159); } if (token() === 93) { - return parseFunctionOrConstructorType(159); + return parseFunctionOrConstructorType(160); } return parseUnionTypeOrHigher(); } @@ -15401,7 +15397,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(195); + var node = createNode(196); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 38 || isStartOfExpression())) { @@ -15417,13 +15413,13 @@ var ts; ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(185, asyncModifier.pos); + node = createNode(186, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(185, identifier.pos); + node = createNode(186, identifier.pos); } - var parameter = createNode(144, identifier.pos); + var parameter = createNode(145, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); @@ -15557,7 +15553,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(185); + var node = createNode(186); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); fillSignature(55, false, isAsync, !allowAmbiguity, node); @@ -15589,7 +15585,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(193, leftOperand.pos); + var node = createNode(194, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -15602,7 +15598,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 || t === 140; + return t === 91 || t === 141; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -15680,43 +15676,43 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(192, left.pos); + var node = createNode(193, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(200, left.pos); + var node = createNode(201, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(190); + var node = createNode(191); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(186); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(187); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(188); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(189); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { if (token() === 120) { if (inAwaitContext()) { @@ -15727,7 +15723,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(189); + var node = createNode(190); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15743,7 +15739,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 182) { + if (simpleUnaryExpression.kind === 183) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -15796,7 +15792,7 @@ var ts; } function parseIncrementExpression() { if (token() === 42 || token() === 43) { - var node = createNode(190); + var node = createNode(191); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -15808,7 +15804,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(191, expression.pos); + var node = createNode(192, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -15831,7 +15827,7 @@ var ts; if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(177, expression.pos); + var node = createNode(178, expression.pos); node.expression = expression; parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -15853,8 +15849,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 249) { - var node = createNode(247, opening.pos); + if (opening.kind === 250) { + var node = createNode(248, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -15864,14 +15860,14 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 248); + ts.Debug.assert(opening.kind === 249); result = opening; } if (inExpressionContext && token() === 26) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(192, result.pos); + var badNode = createNode(193, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -15917,14 +15913,19 @@ var ts; parsingContext = saveParsingContext; return result; } + function parseJsxAttributes() { + var jsxAttributes = createNode(253); + jsxAttributes.properties = parseList(13, parseJsxAttribute); + return finishNode(jsxAttributes); + } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); parseExpected(26); var tagName = parseJsxElementName(); - var attributes = parseList(13, parseJsxAttribute); + var attributes = parseJsxAttributes(); var node; if (token() === 28) { - node = createNode(249, fullStart); + node = createNode(250, fullStart); scanJsxText(); } else { @@ -15936,7 +15937,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(248, fullStart); + node = createNode(249, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -15947,7 +15948,7 @@ var ts; var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22)) { - var propertyAccess = createNode(177, expression.pos); + var propertyAccess = createNode(178, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -15955,7 +15956,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(253); + var node = createNode(255); parseExpected(16); if (token() !== 17) { node.dotDotDotToken = parseOptionalToken(23); @@ -15975,7 +15976,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(251); + var node = createNode(252); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -15990,7 +15991,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(252); + var node = createNode(254); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -15998,7 +15999,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(250); + var node = createNode(251); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -16011,7 +16012,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(182); + var node = createNode(183); parseExpected(26); node.type = parseType(); parseExpected(28); @@ -16022,7 +16023,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(177, expression.pos); + var propertyAccess = createNode(178, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -16030,13 +16031,13 @@ var ts; } if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(201, expression.pos); + var nonNullExpression = createNode(202, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(20)) { - var indexedAccess = createNode(178, expression.pos); + var indexedAccess = createNode(179, expression.pos); indexedAccess.expression = expression; if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -16050,7 +16051,7 @@ var ts; continue; } if (token() === 12 || token() === 13) { - var tagExpression = createNode(181, expression.pos); + var tagExpression = createNode(182, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 ? parseLiteralNode() @@ -16069,7 +16070,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(179, expression.pos); + var callExpr = createNode(180, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -16077,7 +16078,7 @@ var ts; continue; } else if (token() === 18) { - var callExpr = createNode(179, expression.pos); + var callExpr = createNode(180, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -16172,28 +16173,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(183); + var node = createNode(184); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(196); + var node = createNode(197); parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 ? parseSpreadElement() : - token() === 25 ? createNode(198) : + token() === 25 ? createNode(199) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(175); + var node = createNode(176); parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16204,18 +16205,18 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(124)) { - return parseAccessorDeclaration(151, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(133)) { return parseAccessorDeclaration(152, fullStart, decorators, modifiers); } + else if (parseContextualModifier(134)) { + return parseAccessorDeclaration(153, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23); if (dotDotDotToken) { - var spreadElement = createNode(260, fullStart); + var spreadElement = createNode(262, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -16234,7 +16235,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(259, fullStart); + var shorthandDeclaration = createNode(261, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -16245,7 +16246,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(258, fullStart); + var propertyAssignment = createNode(260, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -16255,7 +16256,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(176); + var node = createNode(177); parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16269,7 +16270,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(184); + var node = createNode(185); node.modifiers = parseModifiers(); parseExpected(88); node.asteriskToken = parseOptionalToken(38); @@ -16294,12 +16295,12 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(93); if (parseOptional(22)) { - var node_1 = createNode(202, fullStart); + var node_1 = createNode(203, fullStart); node_1.keywordToken = 93; node_1.name = parseIdentifierName(); return finishNode(node_1); } - var node = createNode(180, fullStart); + var node = createNode(181, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18) { @@ -16308,7 +16309,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(205); + var node = createNode(206); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16339,12 +16340,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(207); + var node = createNode(208); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(209); + var node = createNode(210); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16354,7 +16355,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(210); + var node = createNode(211); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -16365,7 +16366,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(211); + var node = createNode(212); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16388,21 +16389,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(213, pos); + var forInStatement = createNode(214, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(140)) { - var forOfStatement = createNode(214, pos); + else if (parseOptional(141)) { + var forOfStatement = createNode(215, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(212, pos); + var forStatement = createNode(213, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -16420,7 +16421,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 216 ? 71 : 76); + parseExpected(kind === 217 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16428,7 +16429,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(217); + var node = createNode(218); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -16437,7 +16438,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(218); + var node = createNode(219); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16446,7 +16447,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(254); + var node = createNode(256); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -16454,7 +16455,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(255); + var node = createNode(257); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -16464,12 +16465,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(219); + var node = createNode(220); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(233, scanner.getStartPos()); + var caseBlock = createNode(234, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -16477,14 +16478,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(221); + var node = createNode(222); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(222); + var node = createNode(223); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -16495,7 +16496,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(257); + var result = createNode(259); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -16505,7 +16506,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(223); + var node = createNode(224); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -16514,13 +16515,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(220, fullStart); + var labeledStatement = createNode(221, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(208, fullStart); + var expressionStatement = createNode(209, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16549,7 +16550,7 @@ var ts; case 82: return true; case 108: - case 136: + case 137: return nextTokenIsIdentifierOnSameLine(); case 127: case 128: @@ -16566,7 +16567,7 @@ var ts; return false; } continue; - case 139: + case 140: nextToken(); return token() === 16 || token() === 70 || token() === 83; case 90: @@ -16626,8 +16627,8 @@ var ts; case 108: case 127: case 128: - case 136: - case 139: + case 137: + case 140: return true; case 113: case 111: @@ -16672,9 +16673,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(215); - case 71: return parseBreakOrContinueStatement(216); + case 71: + return parseBreakOrContinueStatement(217); case 95: return parseReturnStatement(); case 106: @@ -16693,7 +16694,7 @@ var ts; return parseDeclaration(); case 119: case 108: - case 136: + case 137: case 127: case 128: case 123: @@ -16707,7 +16708,7 @@ var ts; case 116: case 114: case 130: - case 139: + case 140: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -16730,11 +16731,11 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 108: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 136: + case 137: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 82: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 139: + case 140: case 127: case 128: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -16753,7 +16754,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(245, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(246, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -16774,16 +16775,16 @@ var ts; } function parseArrayBindingElement() { if (token() === 25) { - return createNode(198); + return createNode(199); } - var node = createNode(174); + var node = createNode(175); node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(174); + var node = createNode(175); node.dotDotDotToken = parseOptionalToken(23); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -16799,14 +16800,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(172); + var node = createNode(173); parseExpected(16); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(173); + var node = createNode(174); parseExpected(20); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(21); @@ -16825,7 +16826,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(224); + var node = createNode(225); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -16834,7 +16835,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(225); + var node = createNode(226); switch (token()) { case 103: break; @@ -16848,7 +16849,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token() === 140 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 141 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -16863,7 +16864,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(206, fullStart); + var node = createNode(207, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -16871,7 +16872,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -16884,7 +16885,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(150, pos); + var node = createNode(151, pos); node.decorators = decorators; node.modifiers = modifiers; parseExpected(122); @@ -16893,7 +16894,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(149, fullStart); + var method = createNode(150, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -16906,7 +16907,7 @@ var ts; return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(147, fullStart); + var property = createNode(148, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -16976,7 +16977,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 133 || idToken === 124) { + if (!ts.isKeyword(idToken) || idToken === 134 || idToken === 124) { return true; } switch (token()) { @@ -16999,7 +17000,7 @@ var ts; if (!parseOptional(56)) { break; } - var decorator = createNode(145, decoratorStart); + var decorator = createNode(146, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -17056,7 +17057,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(204); + var result = createNode(205); nextToken(); return finishNode(result); } @@ -17081,16 +17082,16 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_15 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_15, undefined); + var name = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 197); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 198); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 227); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 228); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -17125,7 +17126,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 || token() === 107) { - var node = createNode(256); + var node = createNode(258); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -17134,7 +17135,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(199); + var node = createNode(200); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26) { node.typeArguments = parseBracketedList(19, parseType, 26, 28); @@ -17148,7 +17149,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228, fullStart); + var node = createNode(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -17159,10 +17160,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(136); + parseExpected(137); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57); @@ -17171,13 +17172,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(261, scanner.getStartPos()); + var node = createNode(263, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -17192,7 +17193,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(232, scanner.getStartPos()); + var node = createNode(233, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -17203,7 +17204,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(231, fullStart); + var node = createNode(232, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -17215,10 +17216,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(231, fullStart); + var node = createNode(232, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 139) { + if (token() === 140) { node.name = parseIdentifier(); node.flags |= 512; } @@ -17235,7 +17236,7 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 139) { + if (token() === 140) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } else if (parseOptional(128)) { @@ -17260,7 +17261,7 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(234, fullStart); + var exportDeclaration = createNode(235, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); @@ -17275,8 +17276,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 && token() !== 138) { - var importEqualsDeclaration = createNode(235, fullStart); + if (token() !== 25 && token() !== 139) { + var importEqualsDeclaration = createNode(236, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -17286,27 +17287,27 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(236, fullStart); + var importDeclaration = createNode(237, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || token() === 38 || token() === 16) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(138); + parseExpected(139); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(237, fullStart); + var importClause = createNode(238, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(239); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(240); } return finishNode(importClause); } @@ -17316,7 +17317,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(246); + var node = createNode(247); parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); @@ -17334,7 +17335,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(238); + var namespaceImport = createNode(239); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -17342,14 +17343,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 239 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 240 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(244); + return parseImportOrExportSpecifier(245); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(240); + return parseImportOrExportSpecifier(241); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17368,23 +17369,23 @@ var ts; else { node.name = identifierName; } - if (kind === 240 && checkIdentifierIsKeyword) { + if (kind === 241 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(242, fullStart); + var node = createNode(243, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38)) { - parseExpected(138); + parseExpected(139); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(243); - if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(138); + node.exportClause = parseNamedImportsOrExports(244); + if (token() === 139 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(139); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -17392,7 +17393,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(241, fullStart); + var node = createNode(242, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -17471,14 +17472,51 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 235 && node.moduleReference.kind === 246 - || node.kind === 236 - || node.kind === 241 + || node.kind === 236 && node.moduleReference.kind === 247 + || node.kind === 237 || node.kind === 242 + || node.kind === 243 ? node : undefined; }); } + var ParsingContext; + (function (ParsingContext) { + ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; + ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; + ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; + ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; + ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; + ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; + ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; + ParsingContext[ParsingContext["RestProperties"] = 17] = "RestProperties"; + ParsingContext[ParsingContext["TypeParameters"] = 18] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 19] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 20] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 21] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 22] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 23] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 24] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 25] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 26] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 27] = "Count"; + })(ParsingContext || (ParsingContext = {})); + var Tristate; + (function (Tristate) { + Tristate[Tristate["False"] = 0] = "False"; + Tristate[Tristate["True"] = 1] = "True"; + Tristate[Tristate["Unknown"] = 2] = "Unknown"; + })(Tristate || (Tristate = {})); var JSDocParser; (function (JSDocParser) { function isJSDocType() { @@ -17510,7 +17548,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(263, scanner.getTokenPos()); + var result = createNode(266, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -17521,12 +17559,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(267, type.pos); + var unionType = createNode(270, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(274, type.pos); + var optionalType = createNode(277, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -17537,20 +17575,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(266, type.pos); + var arrayType = createNode(269, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(269, type.pos); + var nullableType = createNode(272, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(270, type.pos); + var nonNullableType = createNode(273, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -17584,14 +17622,15 @@ var ts; case 98: return parseJSDocThisType(); case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: case 104: case 94: - case 137: + case 138: case 129: + case 133: return parseTokenNode(); case 9: case 8: @@ -17602,27 +17641,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(278); + var result = createNode(281); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(277); + var result = createNode(280); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(276); + var result = createNode(279); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(275); + var result = createNode(278); nextToken(); parseExpected(18); result.parameters = parseDelimitedList(23, parseJSDocParameter); @@ -17635,7 +17674,7 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(144); + var parameter = createNode(145); parameter.type = parseJSDocType(); if (parseOptional(57)) { parameter.questionToken = createNode(57); @@ -17643,7 +17682,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(273); + var result = createNode(276); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -17677,24 +17716,24 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(141, left.pos); + var result = createNode(142, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(271); + var result = createNode(274); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(270); + var result = createNode(273); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(268); + var result = createNode(271); nextToken(); result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); @@ -17708,7 +17747,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(267); + var result = createNode(270); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -17724,12 +17763,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(264); + var result = createNode(267); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(289); + var result = createNode(292); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -17742,11 +17781,11 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(265, pos); + var result = createNode(268, pos); return finishNode(result); } else { - var result = createNode(269, pos); + var result = createNode(272, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -17774,6 +17813,12 @@ var ts; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; + var JSDocState; + (function (JSDocState) { + JSDocState[JSDocState["BeginningOfLine"] = 0] = "BeginningOfLine"; + JSDocState[JSDocState["SawAsterisk"] = 1] = "SawAsterisk"; + JSDocState[JSDocState["SavingComments"] = 2] = "SavingComments"; + })(JSDocState || (JSDocState = {})); function parseJSDocCommentWorker(start, length) { var content = sourceText; start = start || 0; @@ -17890,7 +17935,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(279, start); + var result = createNode(282, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -18000,7 +18045,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(280, atToken.pos); + var result = createNode(283, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -18055,7 +18100,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(282, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -18066,20 +18111,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283; })) { + if (ts.forEach(tags, function (t) { return t.kind === 286; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283, atToken.pos); + var result = createNode(286, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284; })) { + if (ts.forEach(tags, function (t) { return t.kind === 287; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(284, atToken.pos); + var result = createNode(287, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -18094,7 +18139,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(287, atToken.pos); + var result = createNode(290, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -18103,7 +18148,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(281, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -18112,25 +18157,28 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(286, atToken.pos); + var typedefTag = createNode(289, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); if (typedefTag.fullName) { var rightNode = typedefTag.fullName; - while (rightNode.kind !== 70) { + while (true) { + if (rightNode.kind === 70 || !rightNode.body) { + typedefTag.name = rightNode.kind === 70 ? rightNode : rightNode.name; + break; + } rightNode = rightNode.body; } - typedefTag.name = rightNode; } typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 273) { + if (typeExpression.type.kind === 276) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { - var name_16 = jsDocTypeReference.name; - if (name_16.text === "Object") { + var name = jsDocTypeReference.name; + if (name.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -18144,7 +18192,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(288, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(291, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -18185,7 +18233,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(231, pos); + var jsDocNamespaceNode = createNode(232, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -18229,19 +18277,19 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 285; })) { + if (ts.forEach(tags, function (t) { return t.kind === 288; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); while (true) { - var name_17 = parseJSDocIdentifierName(); + var name = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_17) { + if (!name) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(143, name_17.pos); - typeParameter.name = name_17; + var typeParameter = createNode(144, name.pos); + typeParameter.name = name; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25) { @@ -18252,7 +18300,7 @@ var ts; break; } } - var result = createNode(285, atToken.pos); + var result = createNode(288, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -18566,21 +18614,31 @@ var ts; } } } + var InvalidPosition; + (function (InvalidPosition) { + InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; + })(InvalidPosition || (InvalidPosition = {})); })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); var ts; (function (ts) { + var ModuleInstanceState; + (function (ModuleInstanceState) { + ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; + ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; + ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; + })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); function getModuleInstanceState(node) { - if (node.kind === 228 || node.kind === 229) { + if (node.kind === 229 || node.kind === 230) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 236 || node.kind === 235) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 237 || node.kind === 236) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 232) { + else if (node.kind === 233) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -18596,7 +18654,7 @@ var ts; }); return state_1; } - else if (node.kind === 231) { + else if (node.kind === 232) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -18608,6 +18666,18 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; + var ContainerFlags; + (function (ContainerFlags) { + ContainerFlags[ContainerFlags["None"] = 0] = "None"; + ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; + ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; + ContainerFlags[ContainerFlags["IsControlFlowContainer"] = 4] = "IsControlFlowContainer"; + ContainerFlags[ContainerFlags["IsFunctionLike"] = 8] = "IsFunctionLike"; + ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; + ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; + ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; + ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; + })(ContainerFlags || (ContainerFlags = {})); var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -18705,7 +18775,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 231)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 232)) { symbol.valueDeclaration = node; } } @@ -18715,7 +18785,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 142) { + if (node.name.kind === 143) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression)) { return nameExpression.text; @@ -18726,21 +18796,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 150: + case 151: return "__constructor"; - case 158: - case 153: - return "__call"; case 159: case 154: - return "__new"; + return "__call"; + case 160: case 155: + return "__new"; + case 156: return "__index"; - case 242: + case 243: return "__export"; - case 241: + case 242: return node.isExportEquals ? "export=" : "default"; - case 192: + case 193: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -18752,20 +18822,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 226: case 227: + case 228: return ts.hasModifier(node, 512) ? "default" : undefined; - case 275: + case 278: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 144: - ts.Debug.assert(node.parent.kind === 275); + case 145: + ts.Debug.assert(node.parent.kind === 278); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 286: + case 289: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 206) { + if (parentNode && parentNode.kind === 207) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -18788,13 +18858,16 @@ var ts; symbol = createSymbol(0, "__missing"); } else { - symbol = symbolTable[name] || (symbolTable[name] = createSymbol(0, name)); + symbol = symbolTable.get(name); + if (!symbol) { + symbolTable.set(name, symbol = createSymbol(0, name)); + } if (name && (includes & 788448)) { - classifiableNames[name] = name; + classifiableNames.set(name, name); } if (symbol.flags & excludes) { if (symbol.isReplaceableByMethod) { - symbol = symbolTable[name] = createSymbol(0, name); + symbolTable.set(name, symbol = createSymbol(0, name)); } else { if (node.name) { @@ -18809,7 +18882,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 241 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 242 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -18829,7 +18902,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 244 || (node.kind === 235 && hasExportModifier)) { + if (node.kind === 245 || (node.kind === 236 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -18837,7 +18910,7 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 286 && + var isJSDocTypedefInJSDocNamespace = node.kind === 289 && node.name && node.name.kind === 70 && node.name.isInJSDocNamespace; @@ -18898,7 +18971,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 262) { + if (node.kind === 264) { node.flags |= emitFlags; } if (isIIFE) { @@ -18974,64 +19047,64 @@ var ts; return; } switch (node.kind) { - case 211: + case 212: bindWhileStatement(node); break; - case 210: + case 211: bindDoStatement(node); break; - case 212: + case 213: bindForStatement(node); break; - case 213: case 214: + case 215: bindForInOrForOfStatement(node); break; - case 209: + case 210: bindIfStatement(node); break; - case 217: - case 221: + case 218: + case 222: bindReturnOrThrow(node); break; + case 217: case 216: - case 215: bindBreakOrContinueStatement(node); break; - case 222: + case 223: bindTryStatement(node); break; - case 219: + case 220: bindSwitchStatement(node); break; - case 233: + case 234: bindCaseBlock(node); break; - case 254: + case 256: bindCaseClause(node); break; - case 220: + case 221: bindLabeledStatement(node); break; - case 190: + case 191: bindPrefixUnaryExpressionFlow(node); break; - case 191: + case 192: bindPostfixUnaryExpressionFlow(node); break; - case 192: + case 193: bindBinaryExpressionFlow(node); break; - case 186: + case 187: bindDeleteExpressionFlow(node); break; - case 193: + case 194: bindConditionalExpressionFlow(node); break; - case 224: + case 225: bindVariableDeclarationFlow(node); break; - case 179: + case 180: bindCallExpressionFlow(node); break; default: @@ -19043,15 +19116,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 177: + case 178: return isNarrowableReference(expr); - case 179: + case 180: return hasNarrowableArgument(expr); - case 183: + case 184: return isNarrowingExpression(expr.expression); - case 192: + case 193: return isNarrowingBinaryExpression(expr); - case 190: + case 191: return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; @@ -19059,7 +19132,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 || expr.kind === 98 || - expr.kind === 177 && isNarrowableReference(expr.expression); + expr.kind === 178 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -19070,14 +19143,14 @@ var ts; } } } - if (expr.expression.kind === 177 && + if (expr.expression.kind === 178 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 187 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 188 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -19098,9 +19171,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 183: + case 184: return isNarrowableOperand(expr.expression); - case 192: + case 193: switch (expr.operatorToken.kind) { case 57: return isNarrowableOperand(expr.left); @@ -19194,33 +19267,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 209: - case 211: case 210: - return parent.expression === node; case 212: - case 193: + case 211: + return parent.expression === node; + case 213: + case 194: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 183) { + if (node.kind === 184) { node = node.expression; } - else if (node.kind === 190 && node.operator === 50) { + else if (node.kind === 191 && node.operator === 50) { node = node.operand; } else { - return node.kind === 192 && (node.operatorToken.kind === 52 || + return node.kind === 193 && (node.operatorToken.kind === 52 || node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 183 || - node.parent.kind === 190 && + while (node.parent.kind === 184 || + node.parent.kind === 191 && node.parent.operator === 50) { node = node.parent; } @@ -19262,7 +19335,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 220 + var enclosingLabeledStatement = node.parent.kind === 221 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -19297,7 +19370,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 225) { + if (node.initializer.kind !== 226) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -19319,7 +19392,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 217) { + if (node.kind === 218) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -19339,7 +19412,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 216 ? breakTarget : continueTarget; + var flowLabel = node.kind === 217 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -19372,7 +19445,8 @@ var ts; flowAfterCatch = currentFlow; } if (node.finallyBlock) { - addAntecedent(preFinallyLabel, preTryFlow); + var preFinallyFlow = { flags: 2048, antecedent: preTryFlow, lock: {} }; + addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); if (!(currentFlow.flags & 1)) { @@ -19382,6 +19456,11 @@ var ts; : unreachableFlow; } } + if (!(currentFlow.flags & 1)) { + var afterFinallyFlow = { flags: 4096, antecedent: currentFlow }; + preFinallyFlow.lock = afterFinallyFlow; + currentFlow = afterFinallyFlow; + } } else { currentFlow = finishFlowLabel(preFinallyLabel); @@ -19396,7 +19475,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 255; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 257; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -19461,13 +19540,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 210) { + if (!node.statement || node.statement.kind !== 211) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 192 && node.operatorToken.kind === 57) { + if (node.kind === 193 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -19478,10 +19557,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 175) { + else if (node.kind === 176) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 196) { + if (e.kind === 197) { bindAssignmentTargetFlow(e.expression); } else { @@ -19489,16 +19568,16 @@ var ts; } } } - else if (node.kind === 176) { + else if (node.kind === 177) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 258) { + if (p.kind === 260) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 259) { + else if (p.kind === 261) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 260) { + else if (p.kind === 262) { bindAssignmentTargetFlow(p.expression); } } @@ -19554,7 +19633,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 57 && node.left.kind === 178) { + if (operator === 57 && node.left.kind === 179) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -19565,7 +19644,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 177) { + if (node.expression.kind === 178) { bindAssignmentTargetFlow(node.expression); } } @@ -19598,16 +19677,16 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 213 || node.parent.parent.kind === 214) { + if (node.initializer || node.parent.parent.kind === 214 || node.parent.parent.kind === 215) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 183) { + while (expr.kind === 184) { expr = expr.expression; } - if (expr.kind === 184 || expr.kind === 185) { + if (expr.kind === 185 || expr.kind === 186) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -19615,7 +19694,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 177) { + if (node.expression.kind === 178) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -19624,52 +19703,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 197: - case 227: - case 230: - case 176: - case 161: - case 288: - case 271: - return 1; + case 198: case 228: - return 1 | 64; - case 275: case 231: + case 177: + case 162: + case 291: + case 274: + case 253: + return 1; case 229: - case 170: + return 1 | 64; + case 278: + case 232: + case 230: + case 171: return 1 | 32; - case 262: + case 264: return 1 | 4 | 32; - case 149: + case 150: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 150: - case 226: - case 148: case 151: + case 227: + case 149: case 152: case 153: case 154: case 155: - case 158: + case 156: case 159: + case 160: return 1 | 4 | 32 | 8; - case 184: case 185: + case 186: return 1 | 4 | 32 | 8 | 16; - case 232: + case 233: return 4; - case 147: + case 148: return node.initializer ? 4 : 0; - case 257: - case 212: + case 259: case 213: case 214: - case 233: + case 215: + case 234: return 2; - case 205: + case 206: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -19685,37 +19765,38 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 231: + case 232: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 262: + case 264: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 197: - case 227: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 230: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 161: - case 176: + case 198: case 228: - case 271: - case 288: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 231: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 162: + case 177: + case 229: + case 274: + case 291: + case 253: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 158: case 159: - case 153: + case 160: case 154: case 155: - case 149: - case 148: + case 156: case 150: + case 149: case 151: case 152: - case 226: - case 184: + case 153: + case 227: case 185: - case 275: - case 229: - case 170: + case 186: + case 278: + case 230: + case 171: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -19730,11 +19811,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 262 ? node : node.body; - if (body && (body.kind === 262 || body.kind === 232)) { + var body = node.kind === 264 ? node : node.body; + if (body && (body.kind === 264 || body.kind === 233)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 242 || stat.kind === 241) { + if (stat.kind === 243 || stat.kind === 242) { return true; } } @@ -19756,7 +19837,7 @@ var ts; errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isExternalModuleAugmentation(node)) { - declareSymbolAndAddToSymbolTable(node, 1024, 0); + declareModuleSymbol(node); } else { var pattern = void 0; @@ -19776,12 +19857,8 @@ var ts; } } else { - var state = getModuleInstanceState(node); - if (state === 0) { - declareSymbolAndAddToSymbolTable(node, 1024, 0); - } - else { - declareSymbolAndAddToSymbolTable(node, 512, 106639); + var state = declareModuleSymbol(node); + if (state !== 0) { if (node.symbol.flags & (16 | 32 | 256)) { node.symbol.constEnumOnlyModule = false; } @@ -19797,29 +19874,40 @@ var ts; } } } + function declareModuleSymbol(node) { + var state = getModuleInstanceState(node); + var instantiated = state !== 0; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 : 1024, instantiated ? 106639 : 0); + return state; + } function bindFunctionOrConstructorType(node) { var symbol = createSymbol(131072, getDeclarationName(node)); addDeclarationToSymbol(symbol, node, 131072); var typeLiteralSymbol = createSymbol(2048, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048); typeLiteralSymbol.members = ts.createMap(); - typeLiteralSymbol.members[symbol.name] = symbol; + typeLiteralSymbol.members.set(symbol.name, symbol); } function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); if (inStrictMode) { var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 260 || prop.name.kind !== 70) { + if (prop.kind === 262 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 258 || prop.kind === 259 || prop.kind === 149 + var currentKind = prop.kind === 260 || prop.kind === 261 || prop.kind === 150 ? 1 : 2; - var existingKind = seen[identifier.text]; + var existingKind = seen.get(identifier.text); if (!existingKind) { - seen[identifier.text] = currentKind; + seen.set(identifier.text, currentKind); continue; } if (currentKind === 1 && existingKind === 1) { @@ -19830,16 +19918,22 @@ var ts; } return bindAnonymousDeclaration(node, 4096, "__object"); } + function bindJsxAttributes(node) { + return bindAnonymousDeclaration(node, 4096, "__jsxAttributes"); + } + function bindJsxAttribute(node, symbolFlags, symbolExcludes) { + return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 231: + case 232: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 262: + case 264: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -19929,8 +20023,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 262 && - blockScopeContainer.kind !== 231 && + if (blockScopeContainer.kind !== 264 && + blockScopeContainer.kind !== 232 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -19973,7 +20067,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 140) { + if (node.kind > 141) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -20013,23 +20107,23 @@ var ts; case 70: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 286) { + while (parentNode && parentNode.kind !== 289) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 259)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 261)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 177: + case 178: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 192: + case 193: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -20052,48 +20146,48 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 257: + case 259: return checkStrictModeCatchClause(node); - case 186: + case 187: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 191: + case 192: return checkStrictModePostfixUnaryExpression(node); - case 190: + case 191: return checkStrictModePrefixUnaryExpression(node); - case 218: + case 219: return checkStrictModeWithStatement(node); - case 167: + case 168: seenThisKeyword = true; return; - case 156: + case 157: return checkTypePredicate(node); - case 143: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 144: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 145: return bindParameter(node); - case 224: - case 174: + case 225: + case 175: return bindVariableDeclarationOrBindingElement(node); + case 148: case 147: - case 146: - case 272: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 287: + case 275: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 67108864 : 0), 0); + case 290: return bindJSDocProperty(node); - case 258: - case 259: - return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 261: - return bindPropertyOrMethodOrAccessor(node, 8, 900095); case 260: - case 252: + case 261: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 263: + return bindPropertyOrMethodOrAccessor(node, 8, 900095); + case 262: + case 254: var root = container; var hasRest = false; while (root.parent) { - if (root.kind === 176 && - root.parent.kind === 192 && + if (root.kind === 177 && + root.parent.kind === 193 && root.parent.operatorToken.kind === 57 && root.parent.left === root) { hasRest = true; @@ -20102,78 +20196,82 @@ var ts; root = root.parent; } return; - case 153: case 154: case 155: + case 156: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 149: - case 148: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 226: - return bindFunctionDeclaration(node); case 150: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 149: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 67108864 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); + case 227: + return bindFunctionDeclaration(node); case 151: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 152: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 153: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 158: case 159: - case 275: + case 160: + case 278: return bindFunctionOrConstructorType(node); - case 161: - case 170: - case 288: - case 271: + case 162: + case 171: + case 291: + case 274: return bindAnonymousDeclaration(node, 2048, "__type"); - case 176: + case 177: return bindObjectLiteralExpression(node); - case 184: case 185: + case 186: return bindFunctionExpression(node); - case 179: + case 180: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 197: - case 227: + case 198: + case 228: inStrictMode = true; return bindClassLikeDeclaration(node); - case 228: + case 229: return bindBlockScopedDeclaration(node, 64, 792968); - case 286: + case 289: if (!node.fullName || node.fullName.kind === 70) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 229: - return bindBlockScopedDeclaration(node, 524288, 793064); case 230: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 231: + return bindEnumDeclaration(node); + case 232: return bindModuleDeclaration(node); - case 235: - case 238: - case 240: - case 244: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 234: - return bindNamespaceExportDeclaration(node); - case 237: - return bindImportClause(node); - case 242: - return bindExportDeclaration(node); + case 253: + return bindJsxAttributes(node); + case 252: + return bindJsxAttribute(node, 4, 0); + case 236: + case 239: case 241: + case 245: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 235: + return bindNamespaceExportDeclaration(node); + case 238: + return bindImportClause(node); + case 243: + return bindExportDeclaration(node); + case 242: return bindExportAssignment(node); - case 262: + case 264: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 205: + case 206: if (!ts.isFunctionLike(node.parent)) { return; } - case 232: + case 233: return updateStrictModeStatementList(node.statements); } } @@ -20182,7 +20280,7 @@ var ts; if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 167) { + if (parameterName && parameterName.kind === 168) { seenThisKeyword = true; } bind(type); @@ -20201,7 +20299,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 241 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 242 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -20211,17 +20309,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 262) { + if (node.parent.kind !== 264) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_5 = node.parent; - if (!ts.isExternalModule(parent_5)) { + var parent_1 = node.parent; + if (!ts.isExternalModule(parent_1)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_5.isDeclarationFile) { + if (!parent_1.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -20231,10 +20329,10 @@ var ts; } function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { - bindAnonymousDeclaration(node, 1073741824, getDeclarationName(node)); + bindAnonymousDeclaration(node, 33554432, getDeclarationName(node)); } else if (!node.exportClause) { - declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); + declareSymbol(container.symbol.exports, container.symbol, node, 33554432, 0); } } function bindImportClause(node) { @@ -20260,11 +20358,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 226 || container.kind === 184) { + if (container.kind === 227 || container.kind === 185) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } - else if (container.kind === 150) { + else if (container.kind === 151) { var saveContainer = container; container = container.parent; var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); @@ -20281,7 +20379,7 @@ var ts; leftSideOfAssignment.parent = node; constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - var funcSymbol = container.locals[constructorFunction.text]; + var funcSymbol = container.locals.get(constructorFunction.text); if (!funcSymbol || !(funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { return; } @@ -20296,25 +20394,26 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 227) { + if (node.kind === 228) { bindBlockScopedDeclaration(node, 32, 899519); } else { var bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, 32, bindingName); if (node.name) { - classifiableNames[node.name.text] = node.name.text; + classifiableNames.set(node.name.text, node.name.text); } } var symbol = node.symbol; - var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); - if (symbol.exports[prototypeSymbol.name]) { + var prototypeSymbol = createSymbol(4 | 16777216, "prototype"); + var symbolExport = symbol.exports.get(prototypeSymbol.name); + if (symbolExport) { if (node.name) { node.name.parent = node; } - file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbolExport.declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; + symbol.exports.set(prototypeSymbol.name, prototypeSymbol); prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { @@ -20350,7 +20449,7 @@ var ts; } if (ts.isParameterPropertyDeclaration(node)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 536870912 : 0), 0); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 67108864 : 0), 0); } } function bindFunctionDeclaration(node) { @@ -20406,15 +20505,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 207) || - node.kind === 227 || - (node.kind === 231 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 230 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 208) || + node.kind === 228 || + (node.kind === 232 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 231 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 206 || + (node.kind !== 207 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -20428,56 +20527,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 179: - return computeCallExpression(node, subtreeFlags); case 180: + return computeCallExpression(node, subtreeFlags); + case 181: return computeNewExpression(node, subtreeFlags); - case 231: + case 232: return computeModuleDeclaration(node, subtreeFlags); - case 183: - return computeParenthesizedExpression(node, subtreeFlags); - case 192: - return computeBinaryExpression(node, subtreeFlags); - case 208: - return computeExpressionStatement(node, subtreeFlags); - case 144: - return computeParameter(node, subtreeFlags); - case 185: - return computeArrowFunction(node, subtreeFlags); case 184: + return computeParenthesizedExpression(node, subtreeFlags); + case 193: + return computeBinaryExpression(node, subtreeFlags); + case 209: + return computeExpressionStatement(node, subtreeFlags); + case 145: + return computeParameter(node, subtreeFlags); + case 186: + return computeArrowFunction(node, subtreeFlags); + case 185: return computeFunctionExpression(node, subtreeFlags); - case 226: - return computeFunctionDeclaration(node, subtreeFlags); - case 224: - return computeVariableDeclaration(node, subtreeFlags); - case 225: - return computeVariableDeclarationList(node, subtreeFlags); - case 206: - return computeVariableStatement(node, subtreeFlags); - case 220: - return computeLabeledStatement(node, subtreeFlags); case 227: + return computeFunctionDeclaration(node, subtreeFlags); + case 225: + return computeVariableDeclaration(node, subtreeFlags); + case 226: + return computeVariableDeclarationList(node, subtreeFlags); + case 207: + return computeVariableStatement(node, subtreeFlags); + case 221: + return computeLabeledStatement(node, subtreeFlags); + case 228: return computeClassDeclaration(node, subtreeFlags); - case 197: + case 198: return computeClassExpression(node, subtreeFlags); - case 256: + case 258: return computeHeritageClause(node, subtreeFlags); - case 257: + case 259: return computeCatchClause(node, subtreeFlags); - case 199: + case 200: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 150: - return computeConstructor(node, subtreeFlags); - case 147: - return computePropertyDeclaration(node, subtreeFlags); - case 149: - return computeMethod(node, subtreeFlags); case 151: + return computeConstructor(node, subtreeFlags); + case 148: + return computePropertyDeclaration(node, subtreeFlags); + case 150: + return computeMethod(node, subtreeFlags); case 152: + case 153: return computeAccessor(node, subtreeFlags); - case 235: + case 236: return computeImportEquals(node, subtreeFlags); - case 177: + case 178: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -20502,8 +20601,8 @@ var ts; switch (kind) { case 96: return true; - case 177: case 178: + case 179: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96; @@ -20525,10 +20624,10 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 && leftKind === 176) { + if (operatorTokenKind === 57 && leftKind === 177) { transformFlags |= 8 | 192 | 3072; } - else if (operatorTokenKind === 57 && leftKind === 175) { + else if (operatorTokenKind === 57 && leftKind === 176) { transformFlags |= 192 | 3072; } else if (operatorTokenKind === 39 @@ -20567,8 +20666,8 @@ var ts; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 200 - || expressionKind === 182) { + if (expressionKind === 201 + || expressionKind === 183) { transformFlags |= 3; } if (expressionTransformFlags & 1024) { @@ -20854,7 +20953,7 @@ var ts; var excludeFlags = 536872257; switch (kind) { case 119: - case 189: + case 190: transformFlags |= 16; break; case 113: @@ -20863,51 +20962,52 @@ var ts; case 116: case 123: case 75: - case 230: - case 261: - case 182: - case 200: + case 231: + case 263: + case 183: case 201: + case 202: case 130: transformFlags |= 3; break; - case 247: case 248: case 249: - case 10: case 250: + case 10: case 251: case 252: case 253: + case 254: + case 255: transformFlags |= 4; break; - case 214: + case 215: transformFlags |= 8; case 12: case 13: case 14: case 15: - case 194: - case 181: - case 259: + case 195: + case 182: + case 261: case 114: - case 202: + case 203: transformFlags |= 192; break; - case 195: + case 196: transformFlags |= 192 | 16777216; break; case 118: case 132: case 129: - case 134: - case 121: + case 133: case 135: + case 121: + case 136: case 104: - case 143: - case 146: - case 148: - case 153: + case 144: + case 147: + case 149: case 154: case 155: case 156: @@ -20921,26 +21021,27 @@ var ts; case 164: case 165: case 166: - case 228: - case 229: case 167: + case 229: + case 230: case 168: case 169: case 170: case 171: + case 172: transformFlags = 3; excludeFlags = -3; break; - case 142: + case 143: transformFlags |= 2097152; if (subtreeFlags & 16384) { transformFlags |= 65536; } break; - case 196: + case 197: transformFlags |= 192 | 524288; break; - case 260: + case 262: transformFlags |= 8 | 1048576; break; case 96: @@ -20949,27 +21050,27 @@ var ts; case 98: transformFlags |= 16384; break; - case 172: + case 173: transformFlags |= 192 | 8388608; if (subtreeFlags & 524288) { transformFlags |= 8 | 1048576; } excludeFlags = 537396545; break; - case 173: + case 174: transformFlags |= 192 | 8388608; excludeFlags = 537396545; break; - case 174: + case 175: transformFlags |= 192; if (node.dotDotDotToken) { transformFlags |= 524288; } break; - case 145: + case 146: transformFlags |= 3 | 4096; break; - case 176: + case 177: excludeFlags = 540087617; if (subtreeFlags & 2097152) { transformFlags |= 192; @@ -20981,29 +21082,29 @@ var ts; transformFlags |= 8; } break; - case 175: - case 180: + case 176: + case 181: excludeFlags = 537396545; if (subtreeFlags & 524288) { transformFlags |= 192; } break; - case 210: case 211: case 212: case 213: + case 214: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 262: + case 264: if (subtreeFlags & 32768) { transformFlags |= 192; } break; - case 217: - case 215: + case 218: case 216: + case 217: transformFlags |= 33554432; break; } @@ -21011,56 +21112,57 @@ var ts; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 156 && kind <= 171) { + if (kind >= 157 && kind <= 172) { return -3; } switch (kind) { - case 179: case 180: - case 175: + case 181: + case 176: return 537396545; - case 231: + case 232: return 574674241; - case 144: + case 145: return 536872257; - case 185: + case 186: return 601249089; - case 184: - case 226: - return 601281857; - case 225: - return 546309441; + case 185: case 227: - case 197: + return 601281857; + case 226: + return 546309441; + case 228: + case 198: return 539358529; - case 150: - return 601015617; - case 149: case 151: + return 601015617; + case 150: case 152: + case 153: return 601015617; case 118: case 132: case 129: - case 134: - case 121: case 135: + case 133: + case 121: + case 136: case 104: - case 143: - case 146: - case 148: - case 153: + case 144: + case 147: + case 149: case 154: case 155: - case 228: + case 156: case 229: + case 230: return -3; - case 176: + case 177: return 540087617; - case 257: + case 259: return 537920833; - case 172: case 173: + case 174: return 537396545; default: return 536872257; @@ -21109,9 +21211,9 @@ var ts; var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; var strictNullChecks = compilerOptions.strictNullChecks; var emitResolver = createResolver(); - var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); + var undefinedSymbol = createSymbol(4, "undefined"); undefinedSymbol.declarations = []; - var argumentsSymbol = createSymbol(4 | 67108864, "arguments"); + var argumentsSymbol = createSymbol(4, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, @@ -21132,6 +21234,7 @@ var ts; getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, getTypeFromTypeNode: getTypeFromTypeNode, + getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -21156,8 +21259,9 @@ var ts; getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getAmbientModules: getAmbientModules, - getJsxElementAttributesType: getJsxElementAttributesType, + getAllAttributesTypeFromJsxOpeningLikeElement: getAllAttributesTypeFromJsxOpeningLikeElement, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, isOptionalParameter: isOptionalParameter, tryGetMemberInModuleExports: tryGetMemberInModuleExports, @@ -21173,8 +21277,8 @@ var ts; var numericLiteralTypes = ts.createMap(); var indexedAccessTypes = ts.createMap(); var evolvingArrayTypes = []; - var unknownSymbol = createSymbol(4 | 67108864, "unknown"); - var resolvingSymbol = createSymbol(67108864, "__resolving__"); + var unknownSymbol = createSymbol(4, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__"); var anyType = createIntrinsicType(1, "any"); var autoType = createIntrinsicType(1, "any"); var unknownType = createIntrinsicType(1, "unknown"); @@ -21191,8 +21295,9 @@ var ts; var voidType = createIntrinsicType(1024, "void"); var neverType = createIntrinsicType(8192, "never"); var silentNeverType = createIntrinsicType(8192, "never"); + var nonPrimitiveType = createIntrinsicType(16777216, "object"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var emptyTypeLiteralSymbol = createSymbol(2048 | 67108864, "__type"); + var emptyTypeLiteralSymbol = createSymbol(2048, "__type"); emptyTypeLiteralSymbol.members = ts.createMap(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -21200,6 +21305,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); anyFunctionType.flags |= 8388608; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); @@ -21261,7 +21367,67 @@ var ts; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - var typeofEQFacts = ts.createMap({ + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; + TypeFacts[TypeFacts["Discriminatable"] = 4194304] = "Discriminatable"; + TypeFacts[TypeFacts["All"] = 8388607] = "All"; + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; + TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; + TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; + TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 6166480] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 8378320] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 6164448] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 8376288] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; + })(TypeFacts || (TypeFacts = {})); + var typeofEQFacts = ts.createMapFromTemplate({ "string": 1, "number": 2, "boolean": 4, @@ -21270,7 +21436,7 @@ var ts; "object": 16, "function": 32 }); - var typeofNEFacts = ts.createMap({ + var typeofNEFacts = ts.createMapFromTemplate({ "string": 128, "number": 256, "boolean": 512, @@ -21279,13 +21445,14 @@ var ts; "object": 2048, "function": 4096 }); - var typeofTypesByName = ts.createMap({ + var typeofTypesByName = ts.createMapFromTemplate({ "string": stringType, "number": numberType, "boolean": booleanType, "symbol": esSymbolType, "undefined": undefinedType }); + var typeofType = createTypeofType(); var jsxElementType; var _jsxNamespace; var _jsxFactoryEntity; @@ -21305,8 +21472,15 @@ var ts; var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); - builtinGlobals[undefinedSymbol.name] = undefinedSymbol; + builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); return checker; function getJsxNamespace() { @@ -21336,7 +21510,9 @@ var ts; } function createSymbol(flags, name) { symbolCount++; - return new Symbol(flags, name); + var symbol = (new Symbol(flags | 134217728, name)); + symbol.checkFlags = 0; + return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; @@ -21382,7 +21558,7 @@ var ts; mergedSymbols[source.mergeId] = target; } function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 33554432, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) @@ -21404,7 +21580,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 231 && source.valueDeclaration.kind !== 231))) { + (target.valueDeclaration.kind === 232 && source.valueDeclaration.kind !== 232))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -21420,6 +21596,9 @@ var ts; } recordMergedSymbol(target, source); } + else if (target.flags & 1024) { + error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + } else { var message_2 = target.flags & 2 || source.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -21432,18 +21611,19 @@ var ts; } } function mergeSymbolTable(target, source) { - for (var id in source) { - var targetSymbol = target[id]; + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); if (!targetSymbol) { - target[id] = source[id]; + target.set(id, sourceSymbol); } else { - if (!(targetSymbol.flags & 33554432)) { - target[id] = targetSymbol = cloneSymbol(targetSymbol); + if (!(targetSymbol.flags & 134217728)) { + targetSymbol = cloneSymbol(targetSymbol); + target.set(id, targetSymbol); } - mergeSymbol(targetSymbol, source[id]); + mergeSymbol(targetSymbol, sourceSymbol); } - } + }); } function mergeModuleAugmentation(moduleName) { var moduleAugmentation = moduleName.parent; @@ -21464,7 +21644,7 @@ var ts; } mainModule = resolveExternalModuleSymbol(mainModule); if (mainModule.flags & 1920) { - mainModule = mainModule.flags & 33554432 ? mainModule : cloneSymbol(mainModule); + mainModule = mainModule.flags & 134217728 ? mainModule : cloneSymbol(mainModule); mergeSymbol(mainModule, moduleAugmentation.symbol); } else { @@ -21473,20 +21653,21 @@ var ts; } } function addToSymbolTable(target, source, message) { - for (var id in source) { - if (target[id]) { - ts.forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); + if (targetSymbol) { + ts.forEach(targetSymbol.declarations, addDeclarationDiagnostic(id, message)); } else { - target[id] = source[id]; + target.set(id, sourceSymbol); } - } + }); function addDeclarationDiagnostic(id, message) { return function (declaration) { return diagnostics.add(ts.createDiagnosticForNode(declaration, message, id)); }; } } function getSymbolLinks(symbol) { - if (symbol.flags & 67108864) + if (symbol.flags & 134217728) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = {}); @@ -21498,14 +21679,17 @@ var ts; function getObjectFlags(type) { return type.flags & 32768 ? type.objectFlags : 0; } + function getCheckFlags(symbol) { + return symbol.flags & 134217728 ? symbol.checkFlags : 0; + } function isGlobalSourceFile(node) { - return node.kind === 262 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 264 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { - var symbol = symbols[name]; + var symbol = symbols.get(name); if (symbol) { - ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } @@ -21536,49 +21720,50 @@ var ts; (!compilerOptions.outFile && !compilerOptions.out)) { return true; } - if (isUsedInFunctionOrNonStaticProperty(usage)) { + if (isUsedInFunctionOrInstanceProperty(usage)) { return true; } var sourceFiles = host.getSourceFiles(); return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - if (declaration.kind === 174) { - var errorBindingElement = ts.getAncestor(usage, 174); + if (declaration.kind === 175) { + var errorBindingElement = ts.getAncestor(usage, 175); if (errorBindingElement) { return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || declaration.pos < errorBindingElement.pos; } - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 224), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 225), usage); } - else if (declaration.kind === 224) { + else if (declaration.kind === 225) { return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return isUsedInFunctionOrNonStaticProperty(usage, container); + var isInstanceProperty = declaration.kind === 148 && !(ts.getModifierFlags(declaration) & 32); + return isUsedInFunctionOrInstanceProperty(usage, isInstanceProperty, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 206: - case 212: - case 214: + case 207: + case 213: + case 215: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 213: case 214: + case 215: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } } return false; } - function isUsedInFunctionOrNonStaticProperty(usage, container) { + function isUsedInFunctionOrInstanceProperty(usage, isDeclarationInstanceProperty, container) { var current = usage; while (current) { if (current === container) { @@ -21587,12 +21772,12 @@ var ts; if (ts.isFunctionLike(current)) { return true; } - var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 147 && + var initializerOfInstanceProperty = current.parent && + current.parent.kind === 148 && (ts.getModifierFlags(current.parent) & 32) === 0 && current.parent.initializer === current; - if (initializerOfNonStaticProperty) { - return true; + if (initializerOfInstanceProperty) { + return !isDeclarationInstanceProperty; } current = current.parent; } @@ -21620,18 +21805,18 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793064 && lastLocation.kind !== 279) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 282) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 144 || - lastLocation.kind === 143 + lastLocation.kind === 145 || + lastLocation.kind === 144 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 144 || + lastLocation.kind === 145 || (lastLocation === location.type && - result.valueDeclaration.kind === 144); + result.valueDeclaration.kind === 145); } } if (useResult) { @@ -21643,23 +21828,24 @@ var ts; } } switch (location.kind) { - case 262: + case 264: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 231: + case 232: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 262 || ts.isAmbientModule(location)) { - if (result = moduleExports["default"]) { + if (location.kind === 264 || ts.isAmbientModule(location)) { + if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } - if (moduleExports[name] && - moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 244)) { + var moduleExport = moduleExports.get(name); + if (moduleExport && + moduleExport.flags === 8388608 && + ts.getDeclarationOfKind(moduleExport, 245)) { break; } } @@ -21667,13 +21853,13 @@ var ts; break loop; } break; - case 230: + case 231: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 148: case 147: - case 146: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -21683,17 +21869,21 @@ var ts; } } break; - case 227: - case 197: case 228: + case 198: + case 229: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { + if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { + result = undefined; + break; + } if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; } break loop; } - if (location.kind === 197 && meaning & 32) { + if (location.kind === 198 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -21701,28 +21891,28 @@ var ts; } } break; - case 142: + case 143: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 228) { + if (ts.isClassLike(grandparent) || grandparent.kind === 229) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 226: - case 185: + case 153: + case 227: + case 186: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 184: + case 185: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -21735,8 +21925,8 @@ var ts; } } break; - case 145: - if (location.parent && location.parent.kind === 144) { + case 146: + if (location.parent && location.parent.kind === 145) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -21779,13 +21969,22 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 234) { + if (decls && decls.length === 1 && decls[0].kind === 235) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } } return result; } + function isTypeParameterSymbolDeclaredInContainer(symbol, container) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 144 && decl.parent === container) { + return true; + } + } + return false; + } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { if ((errorLocation.kind === 70 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; @@ -21826,9 +22025,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70: - case 177: + case 178: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 199: + case 200: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -21876,10 +22075,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 235) { + if (node.kind === 236) { return node; } - while (node && node.kind !== 236) { + while (node && node.kind !== 237) { node = node.parent; } return node; @@ -21889,7 +22088,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 246) { + if (node.moduleReference.kind === 247) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -21897,11 +22096,16 @@ var ts; function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { - var exportDefaultSymbol = ts.isShorthandAmbientModuleSymbol(moduleSymbol) ? - moduleSymbol : - moduleSymbol.exports["export="] ? - getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") : - resolveSymbol(moduleSymbol.exports["default"]); + var exportDefaultSymbol = void 0; + if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { + exportDefaultSymbol = moduleSymbol; + } + else { + var exportValue = moduleSymbol.exports.get("export="); + exportDefaultSymbol = exportValue + ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") + : resolveSymbol(moduleSymbol.exports.get("default")); + } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } @@ -21932,7 +22136,7 @@ var ts; } function getExportOfModule(symbol, name) { if (symbol.flags & 1536) { - var exportedSymbol = getExportsOfSymbol(symbol)[name]; + var exportedSymbol = getExportsOfSymbol(symbol).get(name); if (exportedSymbol) { return resolveSymbol(exportedSymbol); } @@ -21950,28 +22154,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_18 = specifier.propertyName || specifier.name; - if (name_18.text) { + var name = specifier.propertyName || specifier.name; + if (name.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_18.text); + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) { + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_18.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_18.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_18.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_18, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_18)); + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name)); } return symbol; } @@ -21993,19 +22197,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 235: + case 236: return getTargetOfImportEqualsDeclaration(node); - case 237: - return getTargetOfImportClause(node); case 238: + return getTargetOfImportClause(node); + case 239: return getTargetOfNamespaceImport(node); - case 240: - return getTargetOfImportSpecifier(node); - case 244: - return getTargetOfExportSpecifier(node); case 241: + return getTargetOfImportSpecifier(node); + case 245: + return getTargetOfExportSpecifier(node); + case 242: return getTargetOfExportAssignment(node); - case 234: + case 235: return getTargetOfNamespaceExportDeclaration(node); } } @@ -22049,10 +22253,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 241) { + if (node.kind === 242) { checkExpressionCached(node.expression); } - else if (node.kind === 244) { + else if (node.kind === 245) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -22064,11 +22268,11 @@ var ts; if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 70 || entityName.parent.kind === 141) { + if (entityName.kind === 70 || entityName.parent.kind === 142) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 235); + ts.Debug.assert(entityName.parent.kind === 236); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -22087,9 +22291,9 @@ var ts; return undefined; } } - else if (name.kind === 141 || name.kind === 177) { - var left = name.kind === 141 ? name.left : name.expression; - var right = name.kind === 141 ? name.right : name.name; + else if (name.kind === 142 || name.kind === 178) { + var left = name.kind === 142 ? name.left : name.expression; + var right = name.kind === 142 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -22108,7 +22312,7 @@ var ts; else { ts.Debug.fail("Unknown entity name kind."); } - ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); } function resolveExternalModuleName(location, moduleReferenceExpression) { @@ -22179,7 +22383,7 @@ var ts; return undefined; } function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="))) || moduleSymbol; } function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { var symbol = resolveExternalModuleSymbol(moduleSymbol); @@ -22190,15 +22394,23 @@ var ts; return symbol; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="] !== undefined; + return moduleSymbol.exports.get("export=") !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); } + function getExportsAndPropertiesOfModule(moduleSymbol) { + var exports = getExportsOfModuleAsArray(moduleSymbol); + var exportEquals = resolveExternalModuleSymbol(moduleSymbol); + if (exportEquals !== moduleSymbol) { + ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + } + return exports; + } function tryGetMemberInModuleExports(memberName, moduleSymbol) { var symbolTable = getExportsOfModule(moduleSymbol); if (symbolTable) { - return symbolTable[memberName]; + return symbolTable.get(memberName); } } function getExportsOfSymbol(symbol) { @@ -22209,24 +22421,28 @@ var ts; return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol)); } function extendExportSymbols(target, source, lookupTable, exportNode) { - for (var id in source) { - if (id !== "default" && !target[id]) { - target[id] = source[id]; + source && source.forEach(function (sourceSymbol, id) { + if (id === "default") + return; + var targetSymbol = target.get(id); + if (!targetSymbol) { + target.set(id, sourceSymbol); if (lookupTable && exportNode) { - lookupTable[id] = { + lookupTable.set(id, { specifierText: ts.getTextOfNode(exportNode.moduleSpecifier) - }; + }); } } - else if (lookupTable && exportNode && id !== "default" && target[id] && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { - if (!lookupTable[id].exportsWithDuplicate) { - lookupTable[id].exportsWithDuplicate = [exportNode]; + else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) { + var collisionTracker = lookupTable.get(id); + if (!collisionTracker.exportsWithDuplicate) { + collisionTracker.exportsWithDuplicate = [exportNode]; } else { - lookupTable[id].exportsWithDuplicate.push(exportNode); + collisionTracker.exportsWithDuplicate.push(exportNode); } } - } + }); } function getExportsForModule(moduleSymbol) { var visitedSymbols = []; @@ -22238,26 +22454,26 @@ var ts; } visitedSymbols.push(symbol); var symbols = ts.cloneMap(symbol.exports); - var exportStars = symbol.exports["__export"]; + var exportStars = symbol.exports.get("__export"); if (exportStars) { var nestedSymbols = ts.createMap(); - var lookupTable = ts.createMap(); + var lookupTable_1 = ts.createMap(); for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { var node = _a[_i]; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable, node); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); } - for (var id in lookupTable) { - var exportsWithDuplicate = lookupTable[id].exportsWithDuplicate; - if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols[id]) { - continue; + lookupTable_1.forEach(function (_a, id) { + var exportsWithDuplicate = _a.exportsWithDuplicate; + if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) { + return; } - for (var _b = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _b < exportsWithDuplicate_1.length; _b++) { - var node = exportsWithDuplicate_1[_b]; - diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable[id].specifierText, id)); + for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) { + var node = exportsWithDuplicate_1[_i]; + diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable_1.get(id).specifierText, id)); } - } + }); extendExportSymbols(symbols, nestedSymbols); } return symbols; @@ -22279,22 +22495,13 @@ var ts; : symbol; } function symbolIsValue(symbol) { - if (symbol.flags & 16777216) { - return symbolIsValue(getSymbolLinks(symbol).target); - } - if (symbol.flags & 107455) { - return true; - } - if (symbol.flags & 8388608) { - return (resolveAlias(symbol).flags & 107455) !== 0; - } - return false; + return !!(symbol.flags & 107455 || symbol.flags & 8388608 && resolveAlias(symbol).flags & 107455); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 150 && ts.nodeIsPresent(member.body)) { + if (member.kind === 151 && ts.nodeIsPresent(member.body)) { return member; } } @@ -22322,6 +22529,9 @@ var ts; type.symbol = symbol; return type; } + function createTypeofType() { + return getUnionType(ts.convertToArray(typeofEQFacts.keys(), function (s) { return getLiteralTypeForText(32, s); })); + } function isReservedMemberName(name) { return name.charCodeAt(0) === 95 && name.charCodeAt(1) === 95 && @@ -22330,16 +22540,15 @@ var ts; } function getNamedMembers(members) { var result; - for (var id in members) { + members.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { if (!result) result = []; - var symbol = members[id]; if (symbolIsValue(symbol)) { result.push(symbol); } } - } + }); return result || emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -22358,19 +22567,19 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { - if (location_1.locals && !isGlobalSourceFile(location_1)) { - if (result = callback(location_1.locals)) { + for (var location = enclosingDeclaration; location; location = location.parent) { + if (location.locals && !isGlobalSourceFile(location)) { + if (result = callback(location.locals)) { return result; } } - switch (location_1.kind) { - case 262: - if (!ts.isExternalOrCommonJsModule(location_1)) { + switch (location.kind) { + case 264: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 231: - if (result = callback(getSymbolOfNode(location_1).exports)) { + case 232: + if (result = callback(getSymbolOfNode(location).exports)) { return result; } break; @@ -22407,13 +22616,13 @@ var ts; } } function trySymbolTable(symbols) { - if (isAccessible(symbols[symbol.name])) { + if (isAccessible(symbols.get(symbol.name))) { return [symbol]; } - return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { + return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -22438,14 +22647,14 @@ var ts; function needsQualification(symbol, enclosingDeclaration, meaning) { var qualify = false; forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { - var symbolFromSymbolTable = symbolTable[symbol.name]; + var symbolFromSymbolTable = symbolTable.get(symbol.name); if (!symbolFromSymbolTable) { return false; } if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -22459,10 +22668,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 147: - case 149: - case 151: + case 148: + case 150: case 152: + case 153: continue; default: return false; @@ -22518,7 +22727,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 262 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 264 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -22552,11 +22761,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 160 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 161 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 141 || entityName.kind === 177 || - entityName.parent.kind === 235) { + else if (entityName.kind === 142 || entityName.kind === 178 || + entityName.parent.kind === 236) { meaning = 1920; } else { @@ -22648,10 +22857,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 166) { + while (node.kind === 167) { node = node.parent; } - if (node.kind === 229) { + if (node.kind === 230) { return getSymbolOfNode(node); } } @@ -22659,29 +22868,29 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 232 && + node.parent.kind === 233 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { return type.flags & 32 ? "\"" + ts.escapeString(type.text) + "\"" : type.text; } - function getSymbolDisplayBuilder() { - function getNameOfSymbol(symbol) { - if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - if (declaration.name) { - return ts.declarationNameToString(declaration.name); - } - switch (declaration.kind) { - case 197: - return "(Anonymous class)"; - case 184: - case 185: - return "(Anonymous function)"; - } + function getNameOfSymbol(symbol) { + if (symbol.declarations && symbol.declarations.length) { + var declaration = symbol.declarations[0]; + if (declaration.name) { + return ts.declarationNameToString(declaration.name); + } + switch (declaration.kind) { + case 198: + return "(Anonymous class)"; + case 185: + case 186: + return "(Anonymous function)"; } - return symbol.name; } + return symbol.name; + } + function getSymbolDisplayBuilder() { function appendSymbolNameOnly(symbol, writer) { writer.writeSymbol(getNameOfSymbol(symbol), symbol); } @@ -22709,7 +22918,7 @@ var ts; function appendParentTypeArgumentsAndSymbolName(symbol) { if (parentSymbol) { if (flags & 1) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); } else { @@ -22728,9 +22937,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_6) { - walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), false); + var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + walkSymbol(parent, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -22760,7 +22969,7 @@ var ts; return writeType(type, globalFlags); function writeType(type, flags) { var nextFlags = flags & ~512; - if (type.flags & 16015) { + if (type.flags & 16793231) { writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) ? "any" : type.intrinsicName); @@ -22785,7 +22994,7 @@ var ts; else if (!(flags & 512) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { var typeArguments = type.aliasTypeArguments; - writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); + writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, ts.length(typeArguments), nextFlags); } else if (type.flags & 196608) { writeUnionOrIntersectionType(type, nextFlags); @@ -22863,12 +23072,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); + writeSymbolTypeReference(parent, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -22894,7 +23103,8 @@ var ts; function writeAnonymousType(type, flags) { var symbol = type.symbol; if (symbol) { - if (symbol.flags & (32 | 384 | 512)) { + if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (384 | 512)) { writeTypeOfSymbol(type, flags); } else if (shouldWriteTypeOfFunctionSymbol()) { @@ -22927,7 +23137,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 262 || declaration.parent.kind === 232; + return declaration.parent.kind === 264 || declaration.parent.kind === 233; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -22946,7 +23156,7 @@ var ts; writeSpace(writer); } buildSymbolDisplay(prop, writer); - if (prop.flags & 536870912) { + if (prop.flags & 67108864) { writePunctuation(writer, 54); } } @@ -23089,6 +23299,13 @@ var ts; writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } + var defaultType = getDefaultFromTypeParameter(tp); + if (defaultType) { + writeSpace(writer); + writePunctuation(writer, 57); + writeSpace(writer); + buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack); + } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; @@ -23106,15 +23323,19 @@ var ts; } writePunctuation(writer, 55); writeSpace(writer); - buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); + var type = getTypeOfSymbol(p); + if (isRequiredInitializedParameter(parameterNode)) { + type = includeFalsyTypes(type, 2048); + } + buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 172) { + if (bindingPattern.kind === 173) { writePunctuation(writer, 16); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); writePunctuation(writer, 17); } - else if (bindingPattern.kind === 173) { + else if (bindingPattern.kind === 174) { writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -23128,7 +23349,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 174); + ts.Debug.assert(bindingElement.kind === 175); if (bindingElement.propertyName) { writer.writeProperty(ts.getTextOfNode(bindingElement.propertyName)); writePunctuation(writer, 55); @@ -23250,7 +23471,7 @@ var ts; writeKeyword(writer, 132); break; case 0: - writeKeyword(writer, 134); + writeKeyword(writer, 135); break; } writePunctuation(writer, 21); @@ -23286,64 +23507,64 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 174: + case 175: return isDeclarationVisible(node.parent.parent); - case 224: + case 225: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 231: - case 227: + case 232: case 228: case 229: - case 226: case 230: - case 235: + case 227: + case 231: + case 236: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_8 = getDeclarationContainer(node); + var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 235 && parent_8.kind !== 262 && ts.isInAmbientContext(parent_8))) { - return isGlobalSourceFile(parent_8); + !(node.kind !== 236 && parent.kind !== 264 && ts.isInAmbientContext(parent))) { + return isGlobalSourceFile(parent); } - return isDeclarationVisible(parent_8); - case 147: - case 146: - case 151: - case 152: - case 149: + return isDeclarationVisible(parent); case 148: + case 147: + case 152: + case 153: + case 150: + case 149: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 150: - case 154: - case 153: + case 151: case 155: - case 144: - case 232: - case 158: + case 154: + case 156: + case 145: + case 233: case 159: - case 161: - case 157: + case 160: case 162: + case 158: case 163: case 164: case 165: case 166: + case 167: return isDeclarationVisible(node.parent); - case 237: case 238: - case 240: - return false; - case 143: - case 262: - case 234: - return true; + case 239: case 241: return false; + case 144: + case 264: + case 235: + return true; + case 242: + return false; default: return false; } @@ -23351,10 +23572,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 241) { + if (node.parent && node.parent.kind === 242) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 244) { + else if (node.parent.kind === 245) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -23432,12 +23653,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 224: case 225: + case 226: + case 241: case 240: case 239: case 238: - case 237: node = node.parent; break; default: @@ -23461,7 +23682,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } function isComputedNonLiteralName(name) { - return name.kind === 142 && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 143 && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 6144); }); @@ -23474,17 +23695,16 @@ var ts; var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name_19 = properties_2[_i]; - names[ts.getTextOfPropertyName(name_19)] = true; + var name = properties_2[_i]; + names.set(ts.getTextOfPropertyName(name), true); } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - var inNamesToRemove = prop.name in names; + var inNamesToRemove = names.has(prop.name); var isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16); - var isMethod = prop.flags & 8192; var isSetOnlyAccessor = prop.flags & 65536 && !(prop.flags & 32768); - if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { - members[prop.name] = prop; + if (!inNamesToRemove && !isPrivate && !isClassMethod(prop) && !isSetOnlyAccessor) { + members.set(prop.name, prop); } } var stringIndexInfo = getIndexInfoOfType(source, 0); @@ -23504,7 +23724,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 172) { + if (pattern.kind === 173) { if (declaration.dotDotDotToken) { if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -23520,19 +23740,19 @@ var ts; type = getRestType(parentType, literalMembers, declaration.symbol); } else { - var name_20 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_20)) { + var name = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name)) { return anyType; } if (declaration.initializer) { getContextualType(declaration.initializer); } - var text = ts.getTextOfPropertyName(name_20); + var text = ts.getTextOfPropertyName(name); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_20)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); return unknownType; } } @@ -23565,7 +23785,7 @@ var ts; getUnionType([type, checkExpressionCached(declaration.initializer)], true) : type; } - function getTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); if (jsdocType) { return getTypeFromTypeNode(jsdocType); @@ -23578,33 +23798,42 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 175 && expr.elements.length === 0; + return expr.kind === 176 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } + function removeOptionalityFromAnnotation(annotatedType, declaration) { + var annotationIncludesUndefined = strictNullChecks && + declaration.kind === 145 && + declaration.initializer && + getFalsyFlags(annotatedType) & 2048 && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048); + return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; + } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { if (declaration.flags & 65536) { - var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); + var type = getTypeForDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } } - if (declaration.parent.parent.kind === 213) { + if (declaration.parent.parent.kind === 214) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 | 262144) ? indexType : stringType; } - if (declaration.parent.parent.kind === 214) { + if (declaration.parent.parent.kind === 215) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } if (declaration.type) { - return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); + var declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + return addOptionality(declaredType, declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && - declaration.kind === 224 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 225 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -23613,10 +23842,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 144) { + if (declaration.kind === 145) { var func = declaration.parent; - if (func.kind === 152 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 151); + if (func.kind === 153 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 152); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -23642,7 +23871,10 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 259) { + if (ts.isJsxAttribute(declaration)) { + return trueType; + } + if (declaration.kind === 261) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -23650,6 +23882,21 @@ var ts; } return undefined; } + function getTypeForJSSpecialPropertyDeclaration(declaration) { + var expression = declaration.kind === 193 ? declaration : + declaration.kind === 178 ? ts.getAncestor(declaration, 193) : + undefined; + if (!expression) { + return unknownType; + } + if (expression.flags & 65536) { + var type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + return getWidenedType(type); + } + } + return getWidenedLiteralType(checkExpressionCached(expression.right)); + } function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { return checkDeclarationInitializer(element); @@ -23677,11 +23924,11 @@ var ts; return; } var text = ts.getTextOfPropertyName(name); - var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); + var flags = 4 | (e.initializer ? 67108864 : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; - members[symbol.name] = symbol; + members.set(symbol.name, symbol); }); var result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { @@ -23707,7 +23954,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 172 + return pattern.kind === 173 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -23717,7 +23964,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 258) { + if (declaration.kind === 260) { return type; } return getWidenedType(type); @@ -23732,41 +23979,32 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 144 ? root.parent : root; + var memberDeclaration = root.kind === 145 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.flags & 134217728) { + if (symbol.flags & 16777216) { return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 241) { + if (declaration.kind === 242) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 && declaration.kind === 287 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 290 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = void 0; - if (declaration.kind === 192 || - declaration.kind === 177 && declaration.parent.kind === 192) { - if (declaration.flags & 65536) { - var jsdocType = ts.getJSDocType(declaration.parent); - if (jsdocType) { - return links.type = getTypeFromTypeNode(jsdocType); - } - } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 192 ? - checkExpressionCached(decl.right) : - checkExpressionCached(decl.parent.right); }); - type = getUnionType(declaredTypes, true); + if (declaration.kind === 193 || + declaration.kind === 178 && declaration.parent.kind === 193) { + type = getWidenedType(getUnionType(ts.map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), true)); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -23780,7 +24018,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 151) { + if (accessor.kind === 152) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -23800,10 +24038,10 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 151); - var setter = ts.getDeclarationOfKind(symbol, 152); + var getter = ts.getDeclarationOfKind(symbol, 152); + var setter = ts.getDeclarationOfKind(symbol, 153); if (getter && getter.flags & 65536) { - var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); + var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; } @@ -23842,7 +24080,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 151); + var getter_1 = ts.getDeclarationOfKind(symbol, 152); 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)); } } @@ -23850,6 +24088,10 @@ var ts; } return links.type; } + function getBaseTypeVariableOfClass(symbol) { + var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); + return baseConstructorType.flags & 540672 ? baseConstructorType : undefined; + } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { @@ -23858,8 +24100,13 @@ var ts; } else { var type = createObjectType(16, symbol); - links.type = strictNullChecks && symbol.flags & 536870912 ? - includeFalsyTypes(type, 2048) : type; + if (symbol.flags & 32) { + var baseTypeVariable = getBaseTypeVariableOfClass(symbol); + links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; + } + else { + links.type = strictNullChecks && symbol.flags & 67108864 ? includeFalsyTypes(type, 2048) : type; + } } } return links.type; @@ -23906,7 +24153,7 @@ var ts; return anyType; } function getTypeOfSymbol(symbol) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { return getTypeOfInstantiatedSymbol(symbol); } if (symbol.flags & (3 | 4)) { @@ -23932,13 +24179,18 @@ var ts; function hasBaseType(type, checkBase) { return check(type); function check(type) { - var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); + if (getObjectFlags(type) & (3 | 4)) { + var target = getTargetType(type); + return target === checkBase || ts.forEach(getBaseTypes(target), check); + } + else if (type.flags & 131072) { + return ts.forEach(type.types, check); + } } } function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { - var declaration = declarations_2[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -23955,9 +24207,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 227 || node.kind === 197 || - node.kind === 226 || node.kind === 184 || - node.kind === 149 || node.kind === 185) { + if (node.kind === 228 || node.kind === 198 || + node.kind === 227 || node.kind === 185 || + node.kind === 150 || node.kind === 186) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -23966,15 +24218,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 228); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 229); 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 === 228 || node.kind === 227 || - node.kind === 197 || node.kind === 229) { + if (node.kind === 229 || node.kind === 228 || + node.kind === 198 || node.kind === 230) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -23986,15 +24238,30 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } + function isMixinConstructorType(type) { + var signatures = getSignaturesOfType(type, 1); + if (signatures.length === 1) { + var s = signatures[0]; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + } + return false; + } function isConstructorType(type) { - return type.flags & 32768 && getSignaturesOfType(type, 1).length > 0; + if (isValidBaseType(type) && getSignaturesOfType(type, 1).length > 0) { + return true; + } + if (type.flags & 540672) { + var constraint = getBaseConstraintOfType(type); + return isValidBaseType(constraint) && isMixinConstructorType(constraint); + } + return false; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); } function getConstructorsForTypeArguments(type, typeArgumentNodes) { - var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; - return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + var typeArgCount = ts.length(typeArgumentNodes); + return ts.filter(getSignaturesOfType(type, 1), function (sig) { return typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); @@ -24014,7 +24281,7 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 32768) { + if (baseConstructorType.flags & (32768 | 131072)) { resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { @@ -24050,8 +24317,8 @@ var ts; } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - var baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & 32768)) { + var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); + if (!(baseConstructorType.flags & (32768 | 131072))) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -24079,7 +24346,7 @@ var ts; if (baseType === unknownType) { return; } - if (!(getObjectFlags(getTargetType(baseType)) & 3)) { + if (!isValidBaseType(baseType)) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -24103,16 +24370,20 @@ var ts; } return true; } + function isValidBaseType(type) { + return type.flags & (32768 | 16777216) && !isGenericMappedType(type) || + type.flags & 131072 && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); + } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 228 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 229 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { - if (getObjectFlags(getTargetType(baseType)) & 3) { + if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -24136,7 +24407,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 228) { + if (declaration.kind === 229) { if (declaration.flags & 64) { return false; } @@ -24169,7 +24440,7 @@ var ts; type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384); @@ -24186,7 +24457,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 286); + var declaration = ts.getDeclarationOfKind(symbol, 289); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -24197,7 +24468,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 229); + declaration = ts.getDeclarationOfKind(symbol, 230); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -24205,7 +24476,7 @@ var ts; if (typeParameters) { links.typeParameters = typeParameters; links.instantiations = ts.createMap(); - links.instantiations[getTypeListId(typeParameters)] = type; + links.instantiations.set(getTypeListId(typeParameters), type); } } else { @@ -24222,14 +24493,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 190 && expr.operator === 37 && + expr.kind === 191 && expr.operator === 37 && expr.operand.kind === 8 || - expr.kind === 70 && !!symbol.exports[expr.text]; + expr.kind === 70 && !!symbol.exports.get(expr.text); } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 230) { + if (declaration.kind === 231) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -24254,10 +24525,10 @@ var ts; enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { var memberTypeList = []; - var memberTypes = ts.createMap(); + var memberTypes = []; for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 230) { + if (declaration.kind === 231) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -24274,7 +24545,7 @@ var ts; if (memberTypeList.length > 1) { enumType.flags |= 65536; enumType.types = memberTypeList; - unionTypes[getTypeListId(memberTypeList)] = enumType; + unionTypes.set(getTypeListId(memberTypeList), enumType); } } } @@ -24295,9 +24566,6 @@ var ts; if (!links.declaredType) { var type = createType(16384); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 143).constraint) { - type.constraint = noConstraintType; - } links.declaredType = type; } return links.declaredType; @@ -24310,7 +24578,6 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 16777216) === 0); if (symbol.flags & (32 | 64)) { return getDeclaredTypeOfClassOrInterface(symbol); } @@ -24345,19 +24612,20 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: + case 133: case 104: - case 137: + case 138: case 94: case 129: - case 171: + case 172: return true; - case 162: + case 163: return isIndependentType(node.elementType); - case 157: + case 158: return isIndependentTypeReference(node); } return false; @@ -24366,7 +24634,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 150 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 151 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -24382,12 +24650,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 147: - case 146: - return isIndependentVariableLikeDeclaration(declaration); - case 149: case 148: + case 147: + return isIndependentVariableLikeDeclaration(declaration); case 150: + case 149: + case 151: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -24398,7 +24666,7 @@ var ts; var result = ts.createMap(); for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { var symbol = symbols_1[_i]; - result[symbol.name] = symbol; + result.set(symbol.name, symbol); } return result; } @@ -24406,15 +24674,15 @@ var ts; var result = ts.createMap(); for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { var symbol = symbols_2[_i]; - result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); + result.set(symbol.name, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } function addInheritedMembers(symbols, baseSymbols) { for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { var s = baseSymbols_1[_i]; - if (!symbols[s.name]) { - symbols[s.name] = s; + if (!symbols.has(s.name)) { + symbols.set(s.name, s); } } } @@ -24422,8 +24690,8 @@ var ts; if (!type.declaredProperties) { var symbol = type.symbol; type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members.get("__call")); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members.get("__new")); type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0); type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1); } @@ -24431,7 +24699,14 @@ var ts; } function getTypeWithThisArgument(type, thisArgument) { if (getObjectFlags(type) & 4) { - return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + var target = type.target; + var typeArguments = type.typeArguments; + if (ts.length(target.typeParameters) === ts.length(typeArguments)) { + return createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); + } + } + else if (type.flags & 131072) { + return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument); })); } return type; } @@ -24467,7 +24742,7 @@ var ts; for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) { var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0); @@ -24510,13 +24785,14 @@ var ts; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); - var typeArgCount = typeArguments ? typeArguments.length : 0; + var typeArgCount = ts.length(typeArguments); var result = []; for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { var baseSig = baseSignatures_1[_i]; - var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; - if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); + var typeParamCount = ts.length(baseSig.typeParameters); + if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -24570,7 +24846,7 @@ var ts; s = cloneSignature(signature); if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return getTypeOfSymbol(sig.thisParameter) || anyType; }), true); - s.thisParameter = createTransientSymbol(signature.thisParameter, thisType); + s.thisParameter = createSymbolWithType(signature.thisParameter, thisType); } s.resolvedReturnType = undefined; s.unionSignatures = unionSignatures; @@ -24612,17 +24888,44 @@ var ts; function unionSpreadIndexInfos(info1, info2) { return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); } + function includeMixinType(type, types, index) { + var mixedTypes = []; + for (var i = 0; i < types.length; i++) { + if (i === index) { + mixedTypes.push(type); + } + else if (isMixinConstructorType(types[i])) { + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1)[0])); + } + } + return getIntersectionType(mixedTypes); + } function resolveIntersectionTypeMembers(type) { var callSignatures = emptyArray; var constructSignatures = emptyArray; - var stringIndexInfo = undefined; - var numberIndexInfo = undefined; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + var stringIndexInfo; + var numberIndexInfo; + var types = type.types; + var mixinCount = ts.countWhere(types, isMixinConstructorType); + var _loop_3 = function (i) { + var t = type.types[i]; + if (mixinCount === 0 || mixinCount === types.length && i === 0 || !isMixinConstructorType(t)) { + var signatures = getSignaturesOfType(t, 1); + if (signatures.length && mixinCount > 0) { + signatures = ts.map(signatures, function (s) { + var clone = cloneSignature(s); + clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, i); + return clone; + }); + } + constructSignatures = ts.concatenate(constructSignatures, signatures); + } callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1)); stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1)); + }; + for (var i = 0; i < types.length; i++) { + _loop_3(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } @@ -24638,8 +24941,8 @@ var ts; } else if (symbol.flags & 2048) { var members = symbol.members; - var callSignatures = getSignaturesOfSymbol(members["__call"]); - var constructSignatures = getSignaturesOfSymbol(members["__new"]); + var callSignatures = getSignaturesOfSymbol(members.get("__call")); + var constructSignatures = getSignaturesOfSymbol(members.get("__new")); var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0); var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -24652,14 +24955,14 @@ var ts; } if (symbol.flags & 32) { var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 32768) { + if (baseConstructorType.flags & (32768 | 131072 | 540672)) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); + addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } } var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; @@ -24679,8 +24982,11 @@ var ts; var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); var templateReadonly = !!type.declaration.readonlyToken; var templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === 168) { - forEachType(getLiteralTypeFromPropertyNames(modifiersType), addMemberForKeyType); + if (type.declaration.typeParameter.constraint.kind === 169) { + for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { + var propertySymbol = _a[_i]; + addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); + } if (getIndexInfoOfType(modifiersType, 0)) { addMemberForKeyType(stringType); } @@ -24691,18 +24997,21 @@ var ts; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t) { - var iterationMapper = createUnaryTypeMapper(typeParameter, t); + function addMemberForKeyType(t, propertySymbol) { + var iterationMapper = createTypeMapper([typeParameter], [t]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; var propType = instantiateType(templateType, templateMapper); if (t.flags & 32) { var propName = t.text; var modifiersProp = getPropertyOfType(modifiersType, propName); - var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 536870912); - var prop = createSymbol(4 | 67108864 | (isOptional ? 536870912 : 0), propName); + var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 67108864); + var prop = createSymbol(4 | (isOptional ? 67108864 : 0), propName); + prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 4 : 0; prop.type = propType; - prop.isReadonly = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp); - members[propName] = prop; + if (propertySymbol) { + prop.mappedTypeOrigin = propertySymbol; + } + members.set(propName, prop); } else if (t.flags & 2) { stringIndexInfo = createIndexInfo(propType, templateReadonly); @@ -24726,7 +25035,7 @@ var ts; function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { var constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === 168) { + if (constraintDeclaration.kind === 169) { type.modifiersType = instantiateType(getTypeFromTypeNode(constraintDeclaration.type), type.mapper || identityMapper); } else { @@ -24738,9 +25047,6 @@ var ts; } return type.modifiersType; } - function getErasedTemplateTypeFromMappedType(type) { - return instantiateType(getTemplateTypeFromMappedType(type), createUnaryTypeMapper(getTypeParameterFromMappedType(type), anyType)); - } function isGenericMappedType(type) { if (getObjectFlags(type) & 32) { var constraintType = getConstraintTypeFromMappedType(type); @@ -24782,35 +25088,33 @@ var ts; function getPropertyOfObjectType(type, name) { if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } } } 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]; - getUnionOrIntersectionProperty(type, prop.name); - } - if (type.flags & 65536) { - break; - } - } - var props = type.resolvedProperties; - if (props) { - var result = []; - for (var key in props) { - var prop = props[key]; - if (!(prop.flags & 268435456 && prop.isPartial)) { - result.push(prop); + if (!type.resolvedProperties) { + var members = ts.createMap(); + 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]; + if (!members.has(prop.name)) { + var combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.name); + if (combinedProp) { + members.set(prop.name, combinedProp); + } + } + } + if (type.flags & 65536) { + break; } } - return result; + type.resolvedProperties = getNamedMembers(members); } - return emptyArray; + return type.resolvedProperties; } function getPropertiesOfType(type) { type = getApparentType(type); @@ -24818,36 +25122,110 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } - function getApparentTypeOfTypeVariable(type) { - if (!type.resolvedApparentType) { - var constraintType = getConstraintOfTypeVariable(type); - while (constraintType && constraintType.flags & 16384) { - constraintType = getConstraintOfTypeVariable(constraintType); - } - type.resolvedApparentType = getTypeWithThisArgument(constraintType || emptyObjectType, type); + function getConstraintOfType(type) { + return type.flags & 16384 ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + } + function getConstraintOfTypeParameter(typeParameter) { + return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; + } + function getBaseConstraintOfType(type) { + var constraint = getResolvedBaseConstraint(type); + return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + } + function hasNonCircularBaseConstraint(type) { + return getResolvedBaseConstraint(type) !== circularConstraintType; + } + function getResolvedBaseConstraint(type) { + var typeStack; + var circular; + if (!type.resolvedBaseConstraint) { + typeStack = []; + var constraint = getBaseConstraint(type); + type.resolvedBaseConstraint = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type); } - return type.resolvedApparentType; + return type.resolvedBaseConstraint; + function getBaseConstraint(t) { + if (ts.contains(typeStack, t)) { + circular = true; + return undefined; + } + typeStack.push(t); + var result = computeBaseConstraint(t); + typeStack.pop(); + return result; + } + function computeBaseConstraint(t) { + if (t.flags & 16384) { + var constraint = getConstraintFromTypeParameter(t); + return t.isThisType ? constraint : + constraint ? getBaseConstraint(constraint) : undefined; + } + if (t.flags & 196608) { + var types = t.types; + var baseTypes = []; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var type_1 = types_2[_i]; + var baseType = getBaseConstraint(type_1); + if (baseType) { + baseTypes.push(baseType); + } + } + return t.flags & 65536 && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 131072 && baseTypes.length ? getIntersectionType(baseTypes) : + undefined; + } + if (t.flags & 262144) { + return stringType; + } + if (t.flags & 524288) { + var baseObjectType = getBaseConstraint(t.objectType); + var baseIndexType = getBaseConstraint(t.indexType); + var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; + return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + } + return t; + } + } + function getApparentTypeOfIntersectionType(type) { + return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type)); + } + function getDefaultFromTypeParameter(typeParameter) { + if (!typeParameter.default) { + if (typeParameter.target) { + var targetDefault = getDefaultFromTypeParameter(typeParameter.target); + typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType; + } + else { + var defaultDeclaration = typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameter(decl) && decl.default; }); + typeParameter.default = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType; + } + } + return typeParameter.default === noConstraintType ? undefined : typeParameter.default; } function getApparentType(type) { - var t = type.flags & 540672 ? getApparentTypeOfTypeVariable(type) : type; - return t.flags & 262178 ? globalStringType : - t.flags & 340 ? globalNumberType : - t.flags & 136 ? globalBooleanType : - t.flags & 512 ? getGlobalESSymbolType() : - t; + var t = type.flags & 540672 ? getBaseConstraintOfType(type) || emptyObjectType : type; + return t.flags & 131072 ? getApparentTypeOfIntersectionType(t) : + t.flags & 262178 ? globalStringType : + t.flags & 340 ? globalNumberType : + t.flags & 136 ? globalBooleanType : + t.flags & 512 ? getGlobalESSymbolType() : + t.flags & 16777216 ? emptyObjectType : + t; } function createUnionOrIntersectionProperty(containingType, name) { - var types = containingType.types; var props; - var commonFlags = (containingType.flags & 131072) ? 536870912 : 0; - var isReadonly = false; - var isPartial = false; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var current = types_2[_i]; + var types = containingType.types; + var isUnion = containingType.flags & 65536; + var excludeModifiers = isUnion ? 24 : 0; + var commonFlags = isUnion ? 0 : 67108864; + var checkFlags = 2; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var current = types_3[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16))) { + var modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0; + if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; if (!props) { props = [prop]; @@ -24855,25 +25233,26 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } - if (isReadonlySymbol(prop)) { - isReadonly = true; - } + checkFlags |= (isReadonlySymbol(prop) ? 4 : 0) | + (!(modifiers & 24) ? 32 : 0) | + (modifiers & 16 ? 64 : 0) | + (modifiers & 8 ? 128 : 0) | + (modifiers & 32 ? 256 : 0); } - else if (containingType.flags & 65536) { - isPartial = true; + else if (isUnion) { + checkFlags |= 8; } } } if (!props) { return undefined; } - if (props.length === 1 && !isPartial) { + if (props.length === 1 && !(checkFlags & 8)) { return props[0]; } var propTypes = []; var declarations = []; var commonType = undefined; - var hasNonUniformType = false; for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; if (prop.declarations) { @@ -24884,39 +25263,37 @@ var ts; commonType = type; } else if (type !== commonType) { - hasNonUniformType = true; + checkFlags |= 16; } propTypes.push(type); } - var result = createSymbol(4 | 67108864 | 268435456 | commonFlags, name); + var result = createSymbol(4 | commonFlags, name); + result.checkFlags = checkFlags; result.containingType = containingType; - result.hasNonUniformType = hasNonUniformType; - result.isPartial = isPartial; result.declarations = declarations; - result.isReadonly = isReadonly; - result.type = containingType.flags & 65536 ? getUnionType(propTypes) : getIntersectionType(propTypes); + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } function getUnionOrIntersectionProperty(type, name) { - var properties = type.resolvedProperties || (type.resolvedProperties = ts.createMap()); - var property = properties[name]; + var properties = type.propertyCache || (type.propertyCache = ts.createMap()); + var property = properties.get(name); if (!property) { property = createUnionOrIntersectionProperty(type, name); if (property) { - properties[name] = property; + properties.set(name, property); } } return property; } function getPropertyOfUnionOrIntersectionType(type, name) { var property = getUnionOrIntersectionProperty(type, name); - return property && !(property.flags & 268435456 && property.isPartial) ? property : undefined; + return property && !(getCheckFlags(property) & 8) ? property : undefined; } function getPropertyOfType(type, name) { type = getApparentType(type); if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } @@ -24995,16 +25372,16 @@ var ts; } function symbolsToArray(symbols) { var result = []; - for (var id in symbols) { + symbols.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { - result.push(symbols[id]); + result.push(symbol); } - } + }); return result; } function isJSDocOptionalParameter(node) { if (node.flags & 65536) { - if (node.type && node.type.kind === 274) { + if (node.type && node.type.kind === 277) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -25015,7 +25392,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 274; + return paramTag.typeExpression.type.kind === 277; } } } @@ -25039,6 +25416,12 @@ var ts; ts.Debug.assert(parameterIndex >= 0); return parameterIndex >= signature.minArgumentCount; } + var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); + if (iife) { + return !node.type && + !node.dotDotDotToken && + ts.indexOf(node.parent.parameters, node) >= iife.arguments.length; + } return false; } function createTypePredicateFromTypePredicateNode(node) { @@ -25058,15 +25441,48 @@ var ts; }; } } + function getMinTypeArgumentCount(typeParameters) { + var minTypeArgumentCount = 0; + if (typeParameters) { + for (var i = 0; i < typeParameters.length; i++) { + if (!getDefaultFromTypeParameter(typeParameters[i])) { + minTypeArgumentCount = i + 1; + } + } + } + return minTypeArgumentCount; + } + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount) { + var numTypeParameters = ts.length(typeParameters); + if (numTypeParameters) { + var numTypeArguments = ts.length(typeArguments); + if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + if (!typeArguments) { + typeArguments = []; + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + typeArguments[i] = emptyObjectType; + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + var mapper = createTypeMapper(typeParameters, typeArguments); + var defaultType = getDefaultFromTypeParameter(typeParameters[i]); + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + } + } + } + return typeArguments; + } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; var hasLiteralTypes = false; - var minArgumentCount = -1; + var minArgumentCount = 0; var thisParameter = undefined; var hasThisParameter = void 0; + var iife = ts.getImmediatelyInvokedFunctionExpression(declaration); var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); + var isUntypedSignatureInJSFile = !iife && !isJSConstructSignature && ts.isInJavaScriptFile(declaration) && !ts.hasJSDocParameterTags(declaration); for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; @@ -25081,41 +25497,34 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 171) { + if (param.type && param.type.kind === 172) { hasLiteralTypes = true; } - if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { - if (minArgumentCount < 0) { - minArgumentCount = i - (hasThisParameter ? 1 : 0); - } - } - else { - minArgumentCount = -1; + var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken || + iife && parameters.length > iife.arguments.length && !param.type || + isJSDocOptionalParameter(param) || + isUntypedSignatureInJSFile; + if (!isOptionalParameter_1) { + minArgumentCount = parameters.length; } } - if ((declaration.kind === 151 || declaration.kind === 152) && + if ((declaration.kind === 152 || declaration.kind === 153) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 151 ? 152 : 151; + var otherKind = declaration.kind === 152 ? 153 : 152; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); - } - if (isJSConstructSignature) { - minArgumentCount--; - } - var classType = declaration.kind === 150 ? + var classType = declaration.kind === 151 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 156 ? + var typePredicate = declaration.type && declaration.type.kind === 157 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -25138,8 +25547,8 @@ var ts; return type; } } - if (declaration.kind === 151 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 152); + if (declaration.kind === 152 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 153); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -25153,20 +25562,20 @@ var ts; for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 158: case 159: - case 226: - case 149: - case 148: + case 160: + case 227: case 150: - case 153: + case 149: + case 151: case 154: case 155: - case 151: + case 156: case 152: - case 184: + case 153: case 185: - case 275: + case 186: + case 278: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -25234,9 +25643,14 @@ var ts; return anyType; } function getSignatureInstantiation(signature, typeArguments) { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); - return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + var instantiation = instantiations.get(id); + if (!instantiation) { + instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments)); + } + return instantiation; } function createSignatureInstantiation(signature, typeArguments) { return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); @@ -25251,7 +25665,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 150 || signature.declaration.kind === 154; + var isConstructor = signature.declaration.kind === 151 || signature.declaration.kind === 155; var type = createObjectType(16); type.members = emptySymbols; type.properties = emptyArray; @@ -25262,10 +25676,10 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members["__index"]; + return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 132 : 134; + var syntaxKind = kind === 1 ? 132 : 135; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -25292,21 +25706,9 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 143).constraint; + return ts.getDeclarationOfKind(type.symbol, 144).constraint; } - function hasConstraintReferenceTo(type, target) { - var checked; - while (type && type.flags & 16384 && !(type.isThisType) && !ts.contains(checked, type)) { - if (type === target) { - return true; - } - (checked || (checked = [])).push(type); - var constraintDeclaration = getConstraintDeclaration(type); - type = constraintDeclaration && getTypeFromTypeNode(constraintDeclaration); - } - return false; - } - function getConstraintOfTypeParameter(typeParameter) { + function getConstraintFromTypeParameter(typeParameter) { if (!typeParameter.constraint) { if (typeParameter.target) { var targetConstraint = getConstraintOfTypeParameter(typeParameter.target); @@ -25314,23 +25716,13 @@ var ts; } else { var constraintDeclaration = getConstraintDeclaration(typeParameter); - var constraint = getTypeFromTypeNode(constraintDeclaration); - if (hasConstraintReferenceTo(constraint, typeParameter)) { - error(constraintDeclaration, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); - constraint = unknownType; - } - typeParameter.constraint = constraint; + typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : noConstraintType; } } return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } - function getConstraintOfTypeVariable(type) { - return type.flags & 16384 ? getConstraintOfTypeParameter(type) : - type.flags & 524288 ? type.constraint : - undefined; - } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 143).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 144).parent); } function getTypeListId(types) { var result = ""; @@ -25357,8 +25749,8 @@ var ts; } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var type = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -25367,9 +25759,10 @@ var ts; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); - var type = target.instantiations[id]; + var type = target.instantiations.get(id); if (!type) { - type = target.instantiations[id] = createObjectType(4, target.symbol); + type = createObjectType(4, target.symbol); + target.instantiations.set(id, type); type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0; type.target = target; type.typeArguments = typeArguments; @@ -25385,17 +25778,22 @@ var ts; return type; } function getTypeReferenceArity(type) { - return type.target.typeParameters ? type.target.typeParameters.length : 0; + return ts.length(type.target.typeParameters); } function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), typeParameters.length); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, undefined, 1), minTypeArgumentCount, typeParameters.length); return unknownType; } - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + return createTypeReference(type, typeArguments); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -25408,14 +25806,22 @@ var ts; var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + var instantiation = links.instantiations.get(id); + if (!instantiation) { + links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + } + return instantiation; } function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return unknownType; } var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); @@ -25436,11 +25842,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 157: + case 158: return node.typeName; - case 273: + case 276: return node.name; - case 199: + case 200: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -25464,7 +25870,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 273) { + if (symbol.flags & 107455 && node.kind === 276) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -25474,13 +25880,13 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 273) { + if (node.kind === 276) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { - var typeNameOrExpression = node.kind === 157 + var typeNameOrExpression = node.kind === 158 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -25506,12 +25912,12 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var declaration = declarations_4[_i]; switch (declaration.kind) { - case 227: case 228: - case 230: + case 229: + case 231: return declaration; } } @@ -25524,7 +25930,7 @@ var ts; error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return arity ? emptyGenericType : emptyObjectType; } - if ((type.typeParameters ? type.typeParameters.length : 0) !== arity) { + if (ts.length(type.typeParameters) !== arity) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); return arity ? emptyGenericType : emptyObjectType; } @@ -25579,7 +25985,7 @@ var ts; for (var i = 0; i < arity; i++) { var typeParameter = createType(16384); typeParameters.push(typeParameter); - var property = createSymbol(4 | 67108864, "" + i); + var property = createSymbol(4, "" + i); property.type = typeParameter; properties.push(property); } @@ -25588,7 +25994,7 @@ var ts; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384); @@ -25670,14 +26076,14 @@ var ts; } } function addTypesToUnion(typeSet, types) { - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var t = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var t = types_6[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -25685,8 +26091,8 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } @@ -25765,10 +26171,11 @@ var ts; return types[0]; } var id = getTypeListId(types); - var type = unionTypes[id]; + var type = unionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(types, 6144); - type = unionTypes[id] = createType(65536 | propagatedFlags); + type = createType(65536 | propagatedFlags); + unionTypes.set(id, type); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -25793,12 +26200,15 @@ var ts; if (type.flags & 65536 && typeSet.unionIndex === undefined) { typeSet.unionIndex = typeSet.length; } - typeSet.push(type); + if (!(type.flags & 32768 && type.objectFlags & 16 && + type.symbol && type.symbol.flags & (16 | 8192) && containsIdenticalType(typeSet, type))) { + typeSet.push(type); + } } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; addTypeToIntersection(typeSet, type); } } @@ -25820,10 +26230,11 @@ var ts; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex, t)); }), false, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); - var type = intersectionTypes[id]; + var type = intersectionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, 6144); - type = intersectionTypes[id] = createType(131072 | propagatedFlags); + type = createType(131072 | propagatedFlags); + intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -25873,21 +26284,10 @@ var ts; var type = createType(524288); type.objectType = objectType; type.indexType = indexType; - if (type.objectType.flags & 229376) { - type.constraint = getIndexTypeOfType(type.objectType, 0); - } - else if (type.objectType.flags & 540672) { - var apparentType = getApparentTypeOfTypeVariable(type.objectType); - if (apparentType !== emptyObjectType) { - type.constraint = isTypeOfKind(type.indexType, 262178) ? - getIndexedAccessType(apparentType, type.indexType) : - getIndexTypeOfType(apparentType, 0); - } - } return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 178 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; var propName = indexType.flags & (32 | 64 | 256) ? indexType.text : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? @@ -25935,7 +26335,7 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 178 ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 179 ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (32 | 64)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); } @@ -25949,33 +26349,31 @@ var ts; return unknownType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 178 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; } - var mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); + var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } function getIndexedAccessType(objectType, indexType, accessNode) { if (maybeTypeOfKind(indexType, 540672 | 262144) || - maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 178) || + maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 179) || isGenericMappedType(objectType)) { if (objectType.flags & 1) { return objectType; } - if (accessNode) { - if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { - error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); - return unknownType; - } - } if (isGenericMappedType(objectType)) { return getIndexedAccessForMappedType(objectType, indexType, accessNode); } var id = objectType.id + "," + indexType.id; - return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType)); + var type = indexedAccessTypes.get(id); + if (!type) { + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType)); + } + return type; } var apparentObjectType = getApparentType(objectType); if (indexType.flags & 65536 && !(indexType.flags & 8190)) { @@ -26015,7 +26413,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - if (ts.isEmpty(node.symbol.members) && !aliasSymbol) { + if (node.symbol.members.size === 0 && !aliasSymbol) { links.resolvedType = emptyTypeLiteralType; } else { @@ -26028,13 +26426,13 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 229 ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 230 ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } - function getSpreadType(left, right, isFromObjectLiteral) { + function getSpreadType(left, right) { if (left.flags & 1 || right.flags & 1) { return anyType; } @@ -26047,10 +26445,13 @@ var ts; return left; } if (left.flags & 65536) { - return mapType(left, function (t) { return getSpreadType(t, right, isFromObjectLiteral); }); + return mapType(left, function (t) { return getSpreadType(t, right); }); } if (right.flags & 65536) { - return mapType(right, function (t) { return getSpreadType(left, t, isFromObjectLiteral); }); + return mapType(right, function (t) { return getSpreadType(left, t); }); + } + if (right.flags & 16777216) { + return emptyObjectType; } var members = ts.createMap(); var skippedPrivateMembers = ts.createMap(); @@ -26066,42 +26467,45 @@ var ts; } for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; - var isOwnProperty = !(rightProp.flags & 8192) || isFromObjectLiteral; var isSetterWithoutGetter = rightProp.flags & 65536 && !(rightProp.flags & 32768); if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 | 16)) { - skippedPrivateMembers[rightProp.name] = true; + skippedPrivateMembers.set(rightProp.name, true); } - else if (isOwnProperty && !isSetterWithoutGetter) { - members[rightProp.name] = rightProp; + else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { + members.set(rightProp.name, rightProp); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { var leftProp = _c[_b]; if (leftProp.flags & 65536 && !(leftProp.flags & 32768) - || leftProp.name in skippedPrivateMembers) { + || skippedPrivateMembers.has(leftProp.name) + || isClassMethod(leftProp)) { continue; } - if (leftProp.name in members) { - var rightProp = members[leftProp.name]; + if (members.has(leftProp.name)) { + var rightProp = members.get(leftProp.name); var rightType = getTypeOfSymbol(rightProp); - if (maybeTypeOfKind(rightType, 2048) || rightProp.flags & 536870912) { + if (maybeTypeOfKind(rightType, 2048) || rightProp.flags & 67108864) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 | 67108864 | (leftProp.flags & 536870912); + var flags = 4 | (leftProp.flags & 67108864); var result = createSymbol(flags, leftProp.name); + result.checkFlags = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp) ? 4 : 0; result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; - result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); - members[leftProp.name] = result; + members.set(leftProp.name, result); } } else { - members[leftProp.name] = leftProp; + members.set(leftProp.name, leftProp); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function isClassMethod(prop) { + return prop.flags & 8192 && ts.find(prop.declarations, function (decl) { return ts.isClassLike(decl.parent); }); + } function createLiteralType(flags, text) { var type = createType(flags); type.text = text; @@ -26123,7 +26527,11 @@ var ts; } function getLiteralTypeForText(flags, text) { var map = flags & 32 ? stringLiteralTypes : numericLiteralTypes; - return map[text] || (map[text] = createLiteralType(flags, text)); + var type = map.get(text); + if (!type) { + map.set(text, type = createLiteralType(flags, text)); + } + return type; } function getTypeFromLiteralTypeNode(node) { var links = getNodeLinks(node); @@ -26151,9 +26559,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 228)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 229)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 150 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 151 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -26170,85 +26578,87 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118: - case 264: - case 265: + case 267: + case 268: return anyType; - case 134: + case 135: return stringType; case 132: return numberType; case 121: return booleanType; - case 135: + case 136: return esSymbolType; case 104: return voidType; - case 137: + case 138: return undefinedType; case 94: return nullType; case 129: return neverType; - case 290: + case 133: + return nonPrimitiveType; + case 293: return nullType; - case 291: + case 294: return undefinedType; - case 292: + case 295: return neverType; - case 167: + case 168: case 98: return getTypeFromThisTypeNode(node); - case 171: + case 172: return getTypeFromLiteralTypeNode(node); - case 289: + case 292: return getTypeFromLiteralTypeNode(node.literal); - case 157: - case 273: - return getTypeFromTypeReference(node); - case 156: - return booleanType; - case 199: - return getTypeFromTypeReference(node); - case 160: - return getTypeFromTypeQueryNode(node); - case 162: - case 266: - return getTypeFromArrayTypeNode(node); - case 163: - return getTypeFromTupleTypeNode(node); - case 164: - case 267: - return getTypeFromUnionTypeNode(node); - case 165: - return getTypeFromIntersectionTypeNode(node); - case 166: - case 269: - case 270: - case 277: - case 278: - case 274: - return getTypeFromTypeNode(node.type); - case 271: - return getTypeFromTypeNode(node.literal); case 158: - case 159: + case 276: + return getTypeFromTypeReference(node); + case 157: + return booleanType; + case 200: + return getTypeFromTypeReference(node); case 161: - case 288: - case 275: + return getTypeFromTypeQueryNode(node); + case 163: + case 269: + return getTypeFromArrayTypeNode(node); + case 164: + return getTypeFromTupleTypeNode(node); + case 165: + case 270: + return getTypeFromUnionTypeNode(node); + case 166: + return getTypeFromIntersectionTypeNode(node); + case 167: + case 272: + case 273: + case 280: + case 281: + case 277: + return getTypeFromTypeNode(node.type); + case 274: + return getTypeFromTypeNode(node.literal); + case 159: + case 160: + case 162: + case 291: + case 278: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 168: - return getTypeFromTypeOperatorNode(node); case 169: - return getTypeFromIndexedAccessTypeNode(node); + return getTypeFromTypeOperatorNode(node); case 170: + return getTypeFromIndexedAccessTypeNode(node); + case 171: return getTypeFromMappedTypeNode(node); case 70: - case 141: + case 142: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 268: + case 271: return getTypeFromJSDocTupleType(node); - case 276: + case 279: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -26275,13 +26685,13 @@ var ts; var instantiations = mapper.instantiations || (mapper.instantiations = []); return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); } - function createUnaryTypeMapper(source, target) { + function makeUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } - function createBinaryTypeMapper(source1, target1, source2, target2) { + function makeBinaryTypeMapper(source1, target1, source2, target2) { return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; } - function createArrayTypeMapper(sources, targets) { + function makeArrayTypeMapper(sources, targets) { return function (t) { for (var i = 0; i < sources.length; i++) { if (t === sources[i]) { @@ -26292,16 +26702,20 @@ var ts; }; } function createTypeMapper(sources, targets) { - var count = sources.length; - var mapper = count == 1 ? createUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : - count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - createArrayTypeMapper(sources, targets); + var mapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : + makeArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; return mapper; } function createTypeEraser(sources) { return createTypeMapper(sources, undefined); } + function createBackreferenceMapper(typeParameters, index) { + var mapper = function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; + mapper.mappedTypes = typeParameters; + return mapper; + } function getInferenceMapper(context) { if (!context.mapper) { var mapper = function (t) { @@ -26325,7 +26739,12 @@ var ts; } function combineTypeMappers(mapper1, mapper2) { var mapper = function (t) { return instantiateType(mapper1(t), mapper2); }; - mapper.mappedTypes = mapper1.mappedTypes; + mapper.mappedTypes = ts.concatenate(mapper1.mappedTypes, mapper2.mappedTypes); + return mapper; + } + function createReplacementMapper(source, target, baseMapper) { + var mapper = function (t) { return t === source ? target : baseMapper(t); }; + mapper.mappedTypes = baseMapper.mappedTypes; return mapper; } function cloneTypeParameter(typeParameter) { @@ -26370,12 +26789,13 @@ var ts; return result; } function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { var links = getSymbolLinks(symbol); symbol = links.target; mapper = combineTypeMappers(links.mapper, mapper); } - var result = createSymbol(16777216 | 67108864 | symbol.flags, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); + result.checkFlags = 1; result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -26402,10 +26822,7 @@ var ts; if (typeVariable_1 !== mappedTypeVariable) { return mapType(mappedTypeVariable, function (t) { if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); + return instantiateMappedObjectType(type, createReplacementMapper(typeVariable_1, t, mapper)); } return t; }); @@ -26433,23 +26850,23 @@ var ts; var node = symbol.declarations[0]; while (node) { switch (node.kind) { - case 158: case 159: - case 226: - case 149: - case 148: + case 160: + case 227: case 150: - case 153: + case 149: + case 151: case 154: case 155: - case 151: + case 156: case 152: - case 184: + case 153: case 185: - case 227: - case 197: + case 186: case 228: + case 198: case 229: + case 230: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -26459,14 +26876,19 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 228) { + if (ts.isClassLike(node) || node.kind === 229) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 275: + case 171: + if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { + return true; + } + break; + case 278: var func = node; for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { var p = _c[_b]; @@ -26475,8 +26897,8 @@ var ts; } } break; - case 231: - case 262: + case 232: + case 264: return false; } node = node.parent; @@ -26486,7 +26908,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 262 || parentKind === 232; + return parentKind === 264 || parentKind === 233; } return false; } @@ -26538,28 +26960,34 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 184: case 185: + case 186: return isContextSensitiveFunctionLikeDeclaration(node); - case 176: + case 177: return ts.forEach(node.properties, isContextSensitive); - case 175: + case 176: return ts.forEach(node.elements, isContextSensitive); - case 193: + case 194: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 192: + case 193: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 258: + case 260: return isContextSensitive(node.initializer); + case 150: case 149: - case 148: return isContextSensitiveFunctionLikeDeclaration(node); - case 183: + case 184: return isContextSensitive(node.expression); + case 253: + return ts.forEach(node.properties, isContextSensitive); + case 252: + return node.initializer && isContextSensitive(node.initializer); + case 255: + return node.expression && isContextSensitive(node.expression); } return false; } @@ -26570,7 +26998,7 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !p.type; })) { return true; } - if (node.kind === 185) { + if (node.kind === 186) { return false; } var parameter = ts.firstOrUndefined(node.parameters); @@ -26588,9 +27016,12 @@ var ts; result.properties = resolved.properties; result.callSignatures = emptyArray; result.constructSignatures = emptyArray; - type = result; + return result; } } + else if (type.flags & 131072) { + return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); + } return type; } function isTypeIdenticalTo(source, target) { @@ -26757,13 +27188,15 @@ var ts; return true; } var id = source.id + "," + target.id; - if (enumRelation[id] !== undefined) { - return enumRelation[id]; + var relation = enumRelation.get(id); + if (relation !== undefined) { + return relation; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & 256) || !(target.symbol.flags & 256) || (source.flags & 65536) !== (target.flags & 65536)) { - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } var targetEnumType = getTypeOfSymbol(target.symbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(source.symbol)); _i < _a.length; _i++) { @@ -26774,11 +27207,13 @@ var ts; if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, property.name, typeToString(target, undefined, 128)); } - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } } } - return enumRelation[id] = true; + enumRelation.set(id, true); + return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { if (target.flags & 8192) @@ -26799,6 +27234,8 @@ var ts; return true; if (source.flags & 4096 && (!strictNullChecks || target.flags & 4096)) return true; + if (source.flags & 32768 && target.flags & 16777216) + return true; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & 1) return true; @@ -26830,12 +27267,12 @@ var ts; } if (source.flags & 32768 && target.flags & 32768) { var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { return related === 1; } } - if (source.flags & 507904 || target.flags & 507904) { + if (source.flags & 1032192 || target.flags & 1032192) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -26974,14 +27411,6 @@ var ts; } } } - else { - var constraint = getConstraintOfTypeParameter(target); - if (constraint && constraint.flags & 262144) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - return result; - } - } - } } else if (target.flags & 262144) { if (source.flags & 262144) { @@ -26989,12 +27418,10 @@ var ts; return result; } } - if (target.type.flags & 540672) { - var constraint = getConstraintOfTypeVariable(target.type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } + var constraint = getConstraintOfType(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; } } } @@ -27004,8 +27431,9 @@ var ts; return result; } } - if (target.constraint) { - if (result = isRelatedTo(source, target.constraint, reportErrors)) { + var constraint = getBaseConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -27022,20 +27450,23 @@ var ts; } else { var constraint = getConstraintOfTypeParameter(source); - if (!constraint || constraint.flags & 1) { - constraint = emptyObjectType; - } - constraint = getTypeWithThisArgument(constraint, source); - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; + if (constraint || !(target.flags & 16777216)) { + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + constraint = getTypeWithThisArgument(constraint, source); + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } } else if (source.flags & 524288) { - if (source.constraint) { - if (result = isRelatedTo(source.constraint, target, reportErrors)) { + var constraint = getBaseConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -27087,42 +27518,55 @@ var ts; } return 0; } - function isKnownProperty(type, name) { + function isKnownProperty(type, name, isComparingJsxAttributes) { if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || - resolved.stringIndexInfo || - (resolved.numberIndexInfo && isNumericLiteralName(name)) || - getPropertyOfType(type, name)) { + if ((relation === assignableRelation || relation === comparableRelation) && + (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) { + return true; + } + else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) { + return true; + } + else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) { return true; } } else if (type.flags & 196608) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (isKnownProperty(t, name)) { + if (isKnownProperty(t, name, isComparingJsxAttributes)) { return true; } } } return false; } - function isEmptyObjectType(t) { + function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && !t.stringIndexInfo && !t.numberIndexInfo; } + function isEmptyObjectType(type) { + return type.flags & 32768 && isEmptyResolvedType(resolveStructuredTypeMembers(type)); + } function hasExcessProperties(source, target, reportErrors) { if (maybeTypeOfKind(target, 32768) && !(getObjectFlags(target) & 512)) { + var isComparingJsxAttributes = !!(source.flags & 33554432); for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; - if (!isKnownProperty(target, prop.name)) { + if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { if (reportErrors) { ts.Debug.assert(!!errorNode); - errorNode = prop.valueDeclaration; - reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + if (ts.isJsxAttributes(errorNode)) { + reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); + } + else { + errorNode = prop.valueDeclaration; + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } } return true; } @@ -27148,20 +27592,42 @@ var ts; if (target.flags & 65536 && containsType(targetTypes, source)) { return -1; } - var len = targetTypes.length; - for (var i = 0; i < len; i++) { - var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var type = targetTypes_1[_i]; + var related = isRelatedTo(source, type, false); if (related) { return related; } } + if (reportErrors) { + var discriminantType = findMatchingDiscriminantType(source, target); + isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], true); + } return 0; } + function findMatchingDiscriminantType(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProperty = sourceProperties_1[_i]; + if (isDiscriminantProperty(target, sourceProperty.name)) { + var sourceType = getTypeOfSymbol(sourceProperty); + for (var _a = 0, _b = target.types; _a < _b.length; _a++) { + var type = _b[_a]; + var targetType = getTypeOfPropertyOfType(type, sourceProperty.name); + if (targetType && isRelatedTo(sourceType, targetType)) { + return type; + } + } + } + } + } + } function typeRelatedToEachType(source, target, reportErrors) { var result = -1; var targetTypes = target.types; - for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { - var targetType = targetTypes_1[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var targetType = targetTypes_2[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0; @@ -27219,10 +27685,10 @@ var ts; return 0; } var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2) { - relation[id] = 3; + relation.set(id, 3); } else { return related === 1 ? -1 : 0; @@ -27230,7 +27696,7 @@ var ts; } if (depth > 0) { for (var i = 0; i < depth; i++) { - if (maybeStack[i][id]) { + if (maybeStack[i].get(id)) { return 1; } } @@ -27248,7 +27714,7 @@ var ts; sourceStack[depth] = source; targetStack[depth] = target; maybeStack[depth] = ts.createMap(); - maybeStack[depth][id] = 1; + maybeStack[depth].set(id, 1); depth++; var saveExpandingFlags = expandingFlags; if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) @@ -27282,38 +27748,38 @@ var ts; if (result) { var maybeCache = maybeStack[depth]; var destinationCache = (result === -1 || depth === 0) ? relation : maybeStack[depth - 1]; - ts.copyProperties(maybeCache, destinationCache); + ts.copyEntries(maybeCache, destinationCache); } else { - relation[id] = reportErrors ? 3 : 2; + relation.set(id, reportErrors ? 3 : 2); } return result; } function mappedTypeRelatedTo(source, target, reportErrors) { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { - var result_2; - if (relation === identityRelation) { - var readonlyMatches = !source.declaration.readonlyToken === !target.declaration.readonlyToken; - var optionalMatches = !source.declaration.questionToken === !target.declaration.questionToken; - if (readonlyMatches && optionalMatches) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getErasedTemplateTypeFromMappedType(source), getErasedTemplateTypeFromMappedType(target), reportErrors); - } - } - } - else { - if (relation === comparableRelation || !source.declaration.questionToken || target.declaration.questionToken) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors); - } + var sourceReadonly = !!source.declaration.readonlyToken; + var sourceOptional = !!source.declaration.questionToken; + var targetReadonly = !!target.declaration.readonlyToken; + var targetOptional = !!target.declaration.questionToken; + var modifiersRelated = relation === identityRelation ? + sourceReadonly === targetReadonly && sourceOptional === targetOptional : + relation === comparableRelation || !sourceOptional || targetOptional; + if (modifiersRelated) { + var result_2; + if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { + var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); + return result_2 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } + else if (target.declaration.questionToken && isEmptyObjectType(source)) { + return -1; + } } else if (relation !== identityRelation) { var resolved = resolveStructuredTypeMembers(target); - if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1) { + if (isEmptyResolvedType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1) { return -1; } } @@ -27331,17 +27797,23 @@ var ts; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { - if (!(targetProp.flags & 536870912) || requireOptionalProperties) { + if (!(targetProp.flags & 67108864) || requireOptionalProperties) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); } return 0; } } - else if (!(targetProp.flags & 134217728)) { + else if (!(targetProp.flags & 16777216)) { var sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 || targetPropFlags & 8) { + if (getCheckFlags(sourceProp) & 128) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); + } + return 0; + } if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { if (sourcePropFlags & 8 && targetPropFlags & 8) { @@ -27355,12 +27827,9 @@ var ts; } } else if (targetPropFlags & 16) { - var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(getParentOfSymbol(sourceProp)) : undefined; - var targetClass = getDeclaredTypeOfSymbol(getParentOfSymbol(targetProp)); - if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { + if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); + reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } return 0; } @@ -27379,7 +27848,7 @@ var ts; return 0; } result &= related; - if (relation !== comparableRelation && sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { + if (relation !== comparableRelation && sourceProp.flags & 67108864 && !(targetProp.flags & 67108864)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -27400,8 +27869,8 @@ var ts; return 0; } var result = -1; - for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { - var sourceProp = sourceProperties_1[_i]; + for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { + var sourceProp = sourceProperties_2[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0; @@ -27562,6 +28031,37 @@ var ts; return false; } } + function forEachProperty(prop, callback) { + if (getCheckFlags(prop) & 2) { + for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var p = getPropertyOfType(t, prop.name); + var result = p && forEachProperty(p, callback); + if (result) { + return result; + } + } + return undefined; + } + return callback(prop); + } + function getDeclaringClass(prop) { + return prop.parent && prop.parent.flags & 32 ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + } + function isPropertyInClassDerivedFrom(prop, baseClass) { + return forEachProperty(prop, function (sp) { + var sourceClass = getDeclaringClass(sp); + return sourceClass ? hasBaseType(sourceClass, baseClass) : false; + }); + } + function isValidOverrideOf(sourceProp, targetProp) { + return !forEachProperty(targetProp, function (tp) { return getDeclarationModifierFlagsFromSymbol(tp) & 16 ? + !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); + } + function isClassDerivedFromDeclaringClasses(checkClass, prop) { + return forEachProperty(prop, function (p) { return getDeclarationModifierFlagsFromSymbol(p) & 16 ? + !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; + } function isAbstractConstructorType(type) { if (getObjectFlags(type) & 16) { var symbol = type.symbol; @@ -27607,7 +28107,7 @@ var ts; } } else { - if ((sourceProp.flags & 536870912) !== (targetProp.flags & 536870912)) { + if ((sourceProp.flags & 67108864) !== (targetProp.flags & 67108864)) { return 0; } } @@ -27637,7 +28137,7 @@ var ts; if (!(isMatchingSignature(source, target, partialMatch))) { return 0; } - if ((source.typeParameters ? source.typeParameters.length : 0) !== (target.typeParameters ? target.typeParameters.length : 0)) { + if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { return 0; } source = getErasedSignature(source); @@ -27675,8 +28175,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -27684,8 +28184,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -27776,8 +28276,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getFalsyFlags(t); } return result; @@ -27806,7 +28306,7 @@ var ts; types.push(undefinedType); if (flags & 4096) types.push(nullType); - return getUnionType(types, true); + return getUnionType(types); } function removeDefinitelyFalsyTypes(type) { return getFalsyFlags(type) & 7392 ? @@ -27821,8 +28321,8 @@ var ts; getSignaturesOfType(type, 0).length === 0 && getSignaturesOfType(type, 1).length === 0; } - function createTransientSymbol(source, type) { - var symbol = createSymbol(source.flags | 67108864, source.name); + function createSymbolWithType(source, type) { + var symbol = createSymbol(source.flags, source.name); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -27838,7 +28338,7 @@ var ts; var property = _a[_i]; var original = getTypeOfSymbol(property); var updated = f(original); - members[property.name] = updated === original ? property : createTransientSymbol(property, updated); + members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); } ; return members; @@ -27924,25 +28424,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 148: case 147: - case 146: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 144: + case 145: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 174: + case 175: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 226: + case 227: + case 150: case 149: - case 148: - case 151: case 152: - case 184: + case 153: case 185: + case 186: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -28027,7 +28527,7 @@ var ts; var typeInferencesArray = [typeInferences]; var templateType = getTemplateTypeFromMappedType(target); var readonlyMask = target.declaration.readonlyToken ? false : true; - var optionalMask = target.declaration.questionToken ? 0 : 536870912; + var optionalMask = target.declaration.questionToken ? 0 : 67108864; var members = createSymbolTable(properties); for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var prop = properties_4[_i]; @@ -28035,11 +28535,11 @@ var ts; if (!inferredPropType) { return undefined; } - var inferredProp = createSymbol(4 | 67108864 | prop.flags & optionalMask, prop.name); + var inferredProp = createSymbol(4 | prop.flags & optionalMask, prop.name); + inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 4 : 0; inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; - inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); - members[prop.name] = inferredProp; + members.set(prop.name, inferredProp); } if (indexInfo) { var inferredIndexType = inferTargetType(indexInfo.type); @@ -28149,8 +28649,8 @@ var ts; var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; - for (var _d = 0, targetTypes_2 = targetTypes; _d < targetTypes_2.length; _d++) { - var t = targetTypes_2[_d]; + for (var _d = 0, targetTypes_3 = targetTypes; _d < targetTypes_3.length; _d++) { + var t = targetTypes_3[_d]; if (t.flags & 540672 && ts.contains(typeVariables, t)) { typeVariable = t; typeVariableCount++; @@ -28182,10 +28682,10 @@ var ts; return; } var key = source.id + "," + target.id; - if (visited[key]) { + if (visited.get(key)) { return; } - visited[key] = true; + visited.set(key, true); if (depth === 0) { sourceStack = []; targetStack = []; @@ -28277,8 +28777,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -28319,7 +28819,13 @@ var ts; inferenceSucceeded = !!unionOrSuperType; } else { - inferredType = emptyObjectType; + var defaultType = getDefaultFromTypeParameter(context.signature.typeParameters[index]); + if (defaultType) { + inferredType = instantiateType(defaultType, combineTypeMappers(createBackreferenceMapper(context.signature.typeParameters, index), getInferenceMapper(context))); + } + else { + inferredType = emptyObjectType; + } inferenceSucceeded = true; } context.inferredTypes[index] = inferredType; @@ -28354,10 +28860,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 160: + case 161: return true; case 70: - case 141: + case 142: node = node.parent; continue; default: @@ -28374,7 +28880,7 @@ var ts; if (node.kind === 98) { return "0"; } - if (node.kind === 177) { + if (node.kind === 178) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -28385,7 +28891,7 @@ var ts; case 70: case 98: return node; - case 177: + case 178: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -28394,19 +28900,19 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 224 || target.kind === 174) && + (target.kind === 225 || target.kind === 175) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; - case 177: - return target.kind === 177 && + case 178: + return target.kind === 178 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 177) { + while (source.kind === 178) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -28415,7 +28921,7 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 177 && + return target.kind === 178 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -28423,7 +28929,7 @@ var ts; if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 177) { + if (expr.kind === 178) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -28432,9 +28938,9 @@ var ts; function isDiscriminantProperty(type, name) { if (type && type.flags & 65536) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && prop.flags & 268435456) { + if (prop && getCheckFlags(prop) & 2) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.hasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.checkFlags & 16 && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -28453,7 +28959,7 @@ var ts; } } } - if (callExpression.expression.kind === 177 && + if (callExpression.expression.kind === 178 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -28492,8 +28998,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -28501,7 +29007,7 @@ var ts; function isFunctionObjectType(type) { var resolved = resolveStructuredTypeMembers(type); return !!(resolved.callSignatures.length || resolved.constructSignatures.length || - resolved.members["bind"] && isTypeSubtypeOf(type, globalFunctionType)); + resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type) { var flags = type.flags; @@ -28544,6 +29050,9 @@ var ts; if (flags & 512) { return strictNullChecks ? 1981320 : 4193160; } + if (flags & 16777216) { + return strictNullChecks ? 6166480 : 8378320; + } if (flags & 16384) { var constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); @@ -28579,10 +29088,16 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 || node.parent.kind === 258 ? + var isDestructuringDefaultAssignment = node.parent.kind === 176 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 260 && isDestructuringAssignmentTarget(node.parent.parent); + return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } + function isDestructuringAssignmentTarget(parent) { + return parent.parent.kind === 193 && parent.parent.left === parent || + parent.parent.kind === 215 && parent.parent.initializer === parent; + } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); } @@ -28598,21 +29113,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 213: - return stringType; case 214: + return stringType; + case 215: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 192: + case 193: return getAssignedTypeOfBinaryExpression(parent); - case 186: + case 187: return undefinedType; - case 175: + case 176: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 196: + case 197: return getAssignedTypeOfSpreadExpression(parent); - case 258: + case 260: return getAssignedTypeOfPropertyAssignment(parent); - case 259: + case 261: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -28620,7 +29135,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 172 ? + var type = pattern.kind === 173 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -28635,35 +29150,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 213) { + if (node.parent.parent.kind === 214) { return stringType; } - if (node.parent.parent.kind === 214) { + if (node.parent.parent.kind === 215) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 224 ? + return node.kind === 225 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 224 || node.kind === 174 ? + return node.kind === 225 || node.kind === 175 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 224 && node.initializer && + return node.kind === 225 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 174 && node.parent.kind === 192 && + node.kind !== 175 && node.parent.kind === 193 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 183: + case 184: return getReferenceCandidate(node.expression); - case 192: + case 193: switch (node.operatorToken.kind) { case 57: return getReferenceCandidate(node.left); @@ -28675,13 +29190,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 183 || - parent.kind === 192 && parent.operatorToken.kind === 57 && parent.left === node || - parent.kind === 192 && parent.operatorToken.kind === 25 && parent.right === node ? + return parent.kind === 184 || + parent.kind === 193 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 193 && parent.operatorToken.kind === 25 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 254) { + if (clause.kind === 256) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -28783,8 +29298,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -28802,11 +29317,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 177 && (parent.name.text === "length" || - parent.parent.kind === 179 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 178 && + var isLengthPushOrUnshift = parent.kind === 178 && (parent.name.text === "length" || + parent.parent.kind === 180 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 179 && parent.expression === root && - parent.parent.kind === 192 && + parent.parent.kind === 193 && parent.parent.operatorToken.kind === 57 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -28835,7 +29350,7 @@ var ts; } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 17810431)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -28845,7 +29360,7 @@ var ts; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; var resultType = getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 201 && getTypeWithFacts(resultType, 524288).flags & 8192) { + if (reference.parent.kind === 202 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; @@ -28859,7 +29374,16 @@ var ts; } } var type = void 0; - if (flow.flags & 16) { + if (flow.flags & 4096) { + flow.locked = true; + type = getTypeAtFlowNode(flow.antecedent); + flow.locked = false; + } + else if (flow.flags & 2048) { + flow = flow.antecedent; + continue; + } + else if (flow.flags & 16) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; @@ -28890,7 +29414,7 @@ var ts; } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 177) { + if (container && container !== flowContainer && reference.kind !== 178) { flow = container.flowNode; continue; } @@ -28933,7 +29457,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 179 ? + var expr = node.kind === 180 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -28941,7 +29465,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 179) { + if (node.kind === 180) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -28993,6 +29517,9 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; + if (antecedent.flags & 2048 && antecedent.lock.locked) { + continue; + } var flowType = getTypeAtFlowNode(antecedent); var type = getTypeFromFlowType(flowType); if (type === declaredType && declaredType === initialType) { @@ -29016,8 +29543,9 @@ var ts; if (!key) { key = getFlowCacheKey(reference); } - if (cache[key]) { - return cache[key]; + var cached = cache.get(key); + if (cached) { + return cached; } for (var i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { @@ -29039,8 +29567,9 @@ var ts; firstAntecedentType = flowType; } var type = getTypeFromFlowType(flowType); - if (cache[key]) { - return cache[key]; + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; } if (!ts.contains(antecedentTypes, type)) { antecedentTypes.push(type); @@ -29056,10 +29585,11 @@ var ts; if (isIncomplete(firstAntecedentType)) { return createFlowType(result, true); } - return cache[key] = result; + cache.set(key, result); + return result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 177 && + return expr.kind === 178 && declaredType.flags & 65536 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -29093,10 +29623,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 187 && right_1.kind === 9) { + if (left_1.kind === 188 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 187 && left_1.kind === 9) { + if (right_1.kind === 188 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -29142,7 +29672,7 @@ var ts; assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); } - if (type.flags & 33281) { + if (type.flags & 16810497) { return type; } if (assumeTrue) { @@ -29167,14 +29697,14 @@ var ts; assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 65536)) { - var targetType = typeofTypesByName[literal.text]; + var targetType = typeofTypesByName.get(literal.text); if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; } } var facts = assumeTrue ? - typeofEQFacts[literal.text] || 64 : - typeofNEFacts[literal.text] || 8192; + typeofEQFacts.get(literal.text) || 64 : + typeofNEFacts.get(literal.text) || 8192; return getTypeWithFacts(type, facts); } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { @@ -29274,7 +29804,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 178 || invokedExpression.kind === 177) { + if (invokedExpression.kind === 179 || invokedExpression.kind === 178) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -29291,15 +29821,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 177: + case 178: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 179: + case 180: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 183: + case 184: return narrowType(type, expr.expression, assumeTrue); - case 192: + case 193: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 190: + case 191: if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } @@ -29326,9 +29856,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 232 || - node.kind === 262 || - node.kind === 147) { + node.kind === 233 || + node.kind === 264 || + node.kind === 148) { return node; } } @@ -29359,7 +29889,7 @@ var ts; if (node.kind === 70) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 144) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 145) { symbol.isAssigned = true; } } @@ -29379,7 +29909,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 185) { + if (container.kind === 186) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { @@ -29397,7 +29927,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; - if (declaration_1.kind === 227 + if (declaration_1.kind === 228 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -29409,11 +29939,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 197) { + else if (declaration_1.kind === 198) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 147 && ts.hasModifier(container, 32)) { + if (container.kind === 148 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -29443,12 +29973,12 @@ var ts; if (!(localOrExportSymbol.flags & 3) || assignmentKind === 1 || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 144; + var isParameter = ts.getRootDeclaration(declaration).kind === 145; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && (flowContainer.kind === 184 || - flowContainer.kind === 185 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 185 || + flowContainer.kind === 186 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -29484,7 +30014,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 257) { + symbol.valueDeclaration.parent.kind === 259) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -29502,8 +30032,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 212 && - ts.getAncestor(symbol.valueDeclaration, 225).parent === container && + if (container.kind === 213 && + ts.getAncestor(symbol.valueDeclaration, 226).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -29515,14 +30045,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 183) { + while (current.parent.kind === 184) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 190 || current.parent.kind === 191)) { + else if ((current.parent.kind === 191 || current.parent.kind === 192)) { var expr = current.parent; isAssigned = expr.operator === 42 || expr.operator === 43; } @@ -29541,7 +30071,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 147 || container.kind === 150) { + if (container.kind === 148 || container.kind === 151) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -29585,32 +30115,32 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 150) { + if (container.kind === 151) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 185) { + if (container.kind === 186) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 231: + case 232: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 230: + case 231: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 150: + case 151: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 148: case 147: - case 146: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 142: + case 143: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -29619,7 +30149,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 184 && + if (container.kind === 185 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -29654,27 +30184,27 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 275) { + if (jsdocType && jsdocType.kind === 278) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 278) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 281) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 144) { + if (n.kind === 145) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 179 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 180 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 185) { + while (container && container.kind === 186) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -29683,16 +30213,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 142) { + while (current && current !== container && current.kind !== 143) { current = current.parent; } - if (current && current.kind === 142) { + if (current && current.kind === 143) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 176)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 177)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -29700,7 +30230,7 @@ var ts; } return unknownType; } - if (!isCallExpression && container.kind === 150) { + if (!isCallExpression && container.kind === 151) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if ((ts.getModifierFlags(container) & 32) || isCallExpression) { @@ -29710,7 +30240,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 149 && ts.getModifierFlags(container) & 256) { + if (container.kind === 150 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -29721,7 +30251,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 176) { + if (container.parent.kind === 177) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -29739,7 +30269,7 @@ var ts; } return unknownType; } - if (container.kind === 150 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 151 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -29751,24 +30281,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 150; + return container.kind === 151; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 176) { + if (ts.isClassLike(container.parent) || container.parent.kind === 177) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 149 || - container.kind === 148 || - container.kind === 151 || - container.kind === 152; + return container.kind === 150 || + container.kind === 149 || + container.kind === 152 || + container.kind === 153; } else { - return container.kind === 149 || - container.kind === 148 || - container.kind === 151 || + return container.kind === 150 || + container.kind === 149 || container.kind === 152 || + container.kind === 153 || + container.kind === 148 || container.kind === 147 || - container.kind === 146 || - container.kind === 150; + container.kind === 151; } } } @@ -29776,7 +30306,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 185) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 186) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -29791,23 +30321,23 @@ var ts; var func = parameter.parent; if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { var iife = ts.getImmediatelyInvokedFunctionExpression(func); - if (iife) { + if (iife && iife.arguments) { var indexOfParameter = ts.indexOf(func.parameters, parameter); - if (iife.arguments && indexOfParameter < iife.arguments.length) { - if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return createArrayType(getUnionType(restTypes)); + if (parameter.dotDotDotToken) { + var restTypes = []; + for (var i = indexOfParameter; i < iife.arguments.length; i++) { + restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); } - var links = getNodeLinks(iife); - var cached = links.resolvedSignature; - links.resolvedSignature = anySignature; - var type = getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])); - links.resolvedSignature = cached; - return type; + return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; } + var links = getNodeLinks(iife); + var cached = links.resolvedSignature; + links.resolvedSignature = anySignature; + var type = indexOfParameter < iife.arguments.length ? + getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + parameter.initializer ? undefined : undefinedWideningType; + links.resolvedSignature = cached; + return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -29832,7 +30362,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 144) { + if (declaration.kind === 145) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -29843,11 +30373,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_21 = declaration.propertyName || declaration.name; + var name = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_21)) { - var text = ts.getTextOfPropertyName(name_21); + !ts.isBindingPattern(name)) { + var text = ts.getTextOfPropertyName(name); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -29884,7 +30414,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 144 && node.parent.initializer === node) { + if (node.parent.kind === 145 && node.parent.initializer === node) { return true; } node = node.parent; @@ -29893,8 +30423,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 150 || - functionDecl.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 152))) { + functionDecl.kind === 151 || + functionDecl.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 153))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -29913,7 +30443,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 181) { + if (template.parent.kind === 182) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -29950,8 +30480,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -30018,19 +30548,16 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxAttribute(attribute) { - var kind = attribute.kind; - var jsxElement = attribute.parent; - var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 251) { - if (!attrsType || isTypeAny(attrsType)) { + var attributesType = getContextualType(attribute.parent); + if (ts.isJsxAttribute(attribute)) { + if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attrsType, attribute.name.text); + return getTypeOfPropertyOfType(attributesType, attribute.name.text); } - else if (attribute.kind === 252) { - return attrsType; + else { + return attributesType; } - ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); } function getApparentTypeOfContextualType(node) { var type = getContextualType(node); @@ -30045,42 +30572,45 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 224: - case 144: + case 225: + case 145: + case 148: case 147: - case 146: - case 174: - return getContextualTypeForInitializerExpression(node); - case 185: - case 217: - return getContextualTypeForReturnExpression(node); - case 195: - return getContextualTypeForYieldOperand(parent); - case 179: - case 180: - return getContextualTypeForArgument(parent, node); - case 182: - case 200: - return getTypeFromTypeNode(parent.type); - case 192: - return getContextualTypeForBinaryOperand(node); - case 258: - case 259: - return getContextualTypeForObjectLiteralElement(parent); case 175: - return getContextualTypeForElementExpression(node); - case 193: - return getContextualTypeForConditionalOperand(node); - case 203: - ts.Debug.assert(parent.parent.kind === 194); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 186: + case 218: + return getContextualTypeForReturnExpression(node); + case 196: + return getContextualTypeForYieldOperand(parent); + case 180: + case 181: + return getContextualTypeForArgument(parent, node); case 183: + case 201: + return getTypeFromTypeNode(parent.type); + case 193: + return getContextualTypeForBinaryOperand(node); + case 260: + case 261: + return getContextualTypeForObjectLiteralElement(parent); + case 176: + return getContextualTypeForElementExpression(node); + case 194: + return getContextualTypeForConditionalOperand(node); + case 204: + ts.Debug.assert(parent.parent.kind === 195); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 184: return getContextualType(parent); - case 253: + case 255: return getContextualType(parent); - case 251: case 252: + case 254: return getContextualTypeForJsxAttribute(parent); + case 250: + case 249: + return getAttributesTypeFromJsxOpeningLikeElement(parent); } return undefined; } @@ -30108,7 +30638,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 184 || node.kind === 185; + return node.kind === 185 || node.kind === 186; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -30121,7 +30651,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -30131,8 +30661,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var current = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -30162,8 +30692,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 174 && !!node.initializer) || - (node.kind === 192 && node.operatorToken.kind === 57); + return (node.kind === 175 && !!node.initializer) || + (node.kind === 193 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -30172,7 +30702,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 196) { + if (inDestructuringPattern && e.kind === 197) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -30184,7 +30714,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 196; + hasSpreadElement = hasSpreadElement || e.kind === 197; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -30195,7 +30725,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 173 || pattern.kind === 175)) { + if (pattern && (pattern.kind === 174 || pattern.kind === 176)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -30203,7 +30733,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 198) { + if (patternElement.kind !== 199) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -30220,7 +30750,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 142 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 143 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -30266,7 +30796,7 @@ var ts; var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 172 || contextualType.pattern.kind === 176); + (contextualType.pattern.kind === 173 || contextualType.pattern.kind === 177); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -30275,27 +30805,27 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 258 || - memberDecl.kind === 259 || + if (memberDecl.kind === 260 || + memberDecl.kind === 261 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 258) { + if (memberDecl.kind === 260) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 149) { + else if (memberDecl.kind === 150) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 259); + ts.Debug.assert(memberDecl.kind === 261); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; - var prop = createSymbol(4 | 67108864 | member.flags, member.name); + var prop = createSymbol(4 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 258 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 259 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 260 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 261 && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 536870912; + prop.flags |= 67108864; } if (ts.hasDynamicName(memberDecl)) { patternWithComputedProperties = true; @@ -30304,7 +30834,7 @@ var ts; else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & 512)) { var impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { - prop.flags |= impliedProp.flags & 536870912; + prop.flags |= impliedProp.flags & 67108864; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -30319,12 +30849,12 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 260) { - if (languageVersion < 5) { + else if (memberDecl.kind === 262) { + if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), true); + spread = getSpreadType(spread, createObjectLiteralType()); propertiesArray = []; propertiesTable = ts.createMap(); hasComputedStringProperty = false; @@ -30336,12 +30866,12 @@ var ts; error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } - spread = getSpreadType(spread, type, false); + spread = getSpreadType(spread, type); offset = i + 1; continue; } else { - ts.Debug.assert(memberDecl.kind === 151 || memberDecl.kind === 152); + ts.Debug.assert(memberDecl.kind === 152 || memberDecl.kind === 153); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -30353,25 +30883,25 @@ var ts; } } else { - propertiesTable[member.name] = member; + propertiesTable.set(member.name, member); } propertiesArray.push(member); } if (contextualTypeHasPattern) { for (var _i = 0, _a = getPropertiesOfType(contextualType); _i < _a.length; _i++) { var prop = _a[_i]; - if (!propertiesTable[prop.name]) { - if (!(prop.flags & 536870912)) { + if (!propertiesTable.get(prop.name)) { + if (!(prop.flags & 67108864)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } - propertiesTable[prop.name] = prop; + propertiesTable.set(prop.name, prop); propertiesArray.push(prop); } } } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), true); + spread = getSpreadType(spread, createObjectLiteralType()); } if (spread.flags & 32768) { spread.flags |= propagatedFlags; @@ -30400,7 +30930,7 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (1 | 4096 | 2048) || + return !!(type.flags & (1 | 4096 | 2048 | 16777216) || type.flags & 32768 && !isGenericMappedType(type) || type.flags & 196608 && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } @@ -30419,13 +30949,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 253: + case 255: checkJsxExpression(child); break; - case 247: + case 248: checkJsxElement(child); break; - case 248: + case 249: checkJsxSelfClosingElement(child); break; } @@ -30436,71 +30966,88 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 177 || tagName.kind === 98) { + if (tagName.kind === 178 || tagName.kind === 98) { 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 (isUnhyphenatedJsxName(node.name.text)) { - var attributeType = getTypeOfPropertyOfType(elementAttributesType, ts.getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0); - if (attributeType) { - correspondingPropType = attributeType; + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, contextualMapper) { + var attributes = openingLikeElement.attributes; + var attributesTable = ts.createMap(); + var spread = emptyObjectType; + var attributesArray = []; + for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { + var attributeDecl = _a[_i]; + var member = attributeDecl.symbol; + if (ts.isJsxAttribute(attributeDecl)) { + var exprType = attributeDecl.initializer ? + checkExpression(attributeDecl.initializer, contextualMapper) : + trueType; + var attributeSymbol = createSymbol(4 | 134217728 | member.flags, member.name); + attributeSymbol.declarations = member.declarations; + attributeSymbol.parent = member.parent; + if (member.valueDeclaration) { + attributeSymbol.valueDeclaration = member.valueDeclaration; } - else { - if (!correspondingPropType) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; - } + attributeSymbol.type = exprType; + attributeSymbol.target = member; + attributesTable.set(attributeSymbol.name, attributeSymbol); + attributesArray.push(attributeSymbol); + } + else { + ts.Debug.assert(attributeDecl.kind === 254); + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); } + var exprType = checkExpression(attributeDecl.expression); + if (!(exprType.flags & (32768 | 1))) { + error(attributeDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + return anyType; + } + if (isTypeAny(exprType)) { + return anyType; + } + spread = getSpreadType(spread, exprType); } } - var exprType; - if (node.initializer) { - exprType = checkExpression(node.initializer); + if (spread !== emptyObjectType) { + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); + } + attributesArray = getPropertiesOfType(spread); } - else { - exprType = booleanType; + attributesTable = ts.createMap(); + if (attributesArray) { + ts.forEach(attributesArray, function (attr) { + if (!filter || filter(attr)) { + attributesTable.set(attr.name, attr); + } + }); } - if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, node); + return createJsxAttributesType(attributes.symbol, attributesTable); + function createJsxAttributesType(symbol, attributesTable) { + var result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, undefined, undefined); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; + result.flags |= 33554432 | 4194304 | freshObjectLiteralFlag; + result.objectFlags |= 128; + return result; } - nameTable[node.name.text] = true; - return exprType; } - function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { - if (compilerOptions.jsx === 2) { - checkExternalEmitHelpers(node, 2); - } - var type = checkExpression(node.expression); - var props = getPropertiesOfType(type); - for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { - var prop = props_2[_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 checkJsxAttributes(node, contextualMapper) { + return createJsxAttributesTypeFromAttributesProperty(node.parent, undefined, contextualMapper); } function getJsxType(name) { - if (jsxTypes[name] === undefined) { - return jsxTypes[name] = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType; + var jsxType = jsxTypes.get(name); + if (jsxType === undefined) { + jsxTypes.set(name, jsxType = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType); } - return jsxTypes[name]; + return jsxType; } function getIntrinsicTagSymbol(node) { var links = getNodeLinks(node); @@ -30565,23 +31112,84 @@ var ts; return undefined; } } - function getResolvedJsxType(node, elemType, elemClassType) { - if (!elemType) { - elemType = checkExpression(node.tagName); + function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, undefined); + if (callSignature !== unknownSignature) { + var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); + var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + paramType = intersectTypes(intrinsicAttributes, paramType); + } + return paramType; + } + } + } } - if (elemType.flags & 65536) { - var types = elemType.types; - return getUnionType(ts.map(types, function (type) { - return getResolvedJsxType(node, type, elemClassType); + return undefined; + } + function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + var candidatesOutArray = []; + getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); + var result = void 0; + var allMatchingAttributesType = void 0; + for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { + var candidate = candidatesOutArray_1[_i]; + var callReturnType = getReturnTypeOfSignature(candidate); + var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var shouldBeCandidate = true; + for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { + var attribute = _b[_a]; + if (ts.isJsxAttribute(attribute) && + isUnhyphenatedJsxName(attribute.name.text) && + !getPropertyOfType(paramType, attribute.name.text)) { + shouldBeCandidate = false; + break; + } + } + if (shouldBeCandidate) { + result = intersectTypes(result, paramType); + } + allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); + } + } + if (!result) { + result = allMatchingAttributesType; + } + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + result = intersectTypes(intrinsicAttributes, result); + } + return result; + } + } + return undefined; + } + function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { + if (!elementType) { + elementType = checkExpression(openingLikeElement.tagName); + } + if (elementType.flags & 65536) { + var types = elementType.types; + return getUnionType(types.map(function (type) { + return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); }), true); } - if (elemType.flags & 2) { + if (elementType.flags & 2) { return anyType; } - else if (elemType.flags & 32) { + else if (elementType.flags & 32) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { - var stringLiteralTypeName = elemType.text; + var stringLiteralTypeName = elementType.text; var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); if (intrinsicProp) { return getTypeOfSymbol(intrinsicProp); @@ -30590,28 +31198,19 @@ var ts; if (indexSignatureType) { return indexSignatureType; } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + error(openingLikeElement, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); } return anyType; } - var elemInstanceType = getJsxElementInstanceType(node, elemType); - if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { - if (jsxElementType) { - var callSignatures = elemType && getSignaturesOfType(elemType, 0); - var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); - if (intrinsicAttributes !== unknownType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } + var elemInstanceType = getJsxElementInstanceType(openingLikeElement, elementType); + var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? + tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : + defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); + if (statelessAttributesType) { + return statelessAttributesType; } - if (elemClassType) { - checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + if (elementClassType) { + checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } if (isTypeAny(elemInstanceType)) { return elemInstanceType; @@ -30632,7 +31231,7 @@ var ts; return attributesType; } else if (attributesType.flags & 65536) { - error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); + error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); return anyType; } else { @@ -30657,30 +31256,49 @@ var ts; } } } - function getJsxElementAttributesType(node) { + function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) { + ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName)); var links = getNodeLinks(node); - if (!links.resolvedJsxType) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1) { - return links.resolvedJsxType = getTypeOfSymbol(symbol); - } - else if (links.jsxFlags & 2) { - return links.resolvedJsxType = getIndexInfoOfSymbol(symbol, 0).type; - } - else { - return links.resolvedJsxType = unknownType; - } + if (!links.resolvedJsxElementAttributesType) { + var symbol = getIntrinsicTagSymbol(node); + if (links.jsxFlags & 1) { + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + } + else if (links.jsxFlags & 2) { + return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, 0).type; } else { - var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxType = getResolvedJsxType(node, undefined, elemClassType); + return links.resolvedJsxElementAttributesType = unknownType; } } - return links.resolvedJsxType; + return links.resolvedJsxElementAttributesType; + } + function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { + var links = getNodeLinks(node); + if (!links.resolvedJsxElementAttributesType) { + var elemClassType = getJsxGlobalElementClassType(); + return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); + } + return links.resolvedJsxElementAttributesType; + } + function getAllAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, true); + } + } + function getAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, false); + } } function getJsxAttributePropertySymbol(attrib) { - var attributesType = getJsxElementAttributesType(attrib.parent); + var attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent); var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } @@ -30716,34 +31334,25 @@ var ts; markAliasSymbolAsReferenced(reactSym); } } - var targetAttributesType = getJsxElementAttributesType(node); - var nameTable = ts.createMap(); - var sawSpreadedAny = false; - for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 251) { - checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); - } - else { - ts.Debug.assert(node.attributes[i].kind === 252); - var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if (isTypeAny(spreadType)) { - sawSpreadedAny = true; - } - } + checkJsxAttributesAssignableToTagNameAttributes(node); + } + function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement) { + var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? + getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : + getCustomJsxElementAttributesType(openingLikeElement, false); + var sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, function (attribute) { + return isUnhyphenatedJsxName(attribute.name) || !!(getPropertyOfType(targetAttributesType, attribute.name)); + }); + if (targetAttributesType === emptyObjectType && (isTypeAny(sourceAttributesType) || sourceAttributesType.properties.length > 0)) { + error(openingLikeElement, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); } - if (targetAttributesType && !sawSpreadedAny) { - var targetProperties = getPropertiesOfType(targetAttributesType); - for (var i = 0; i < targetProperties.length; i++) { - if (!(targetProperties[i].flags & 536870912) && - !nameTable[targetProperties[i].name]) { - error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); - } - } + else { + checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); } } - function checkJsxExpression(node) { + function checkJsxExpression(node, contextualMapper) { if (node.expression) { - var type = checkExpression(node.expression); + var type = checkExpression(node.expression, contextualMapper); if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); } @@ -30754,27 +31363,48 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 147; + return s.valueDeclaration ? s.valueDeclaration.kind : 148; } function getDeclarationModifierFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; + if (s.valueDeclaration) { + var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + return s.parent && s.parent.flags & 32 ? flags : flags & ~28; + } + if (getCheckFlags(s) & 2) { + var checkFlags = s.checkFlags; + var accessModifier = checkFlags & 128 ? 8 : + checkFlags & 32 ? 4 : + 16; + var staticModifier = checkFlags & 256 ? 32 : 0; + return accessModifier | staticModifier; + } + if (s.flags & 16777216) { + return 4 | 32; + } + return 0; } function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; } - function checkClassPropertyAccess(node, left, type, prop) { + function checkPropertyAccessibility(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 || node.kind === 224 ? + var errorNode = node.kind === 178 || node.kind === 225 ? node.name : node.right; + if (getCheckFlags(prop) & 128) { + error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); + return false; + } if (left.kind === 96) { - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 149) { - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - return false; + if (languageVersion < 2) { + var propKind = getDeclarationKindFromSymbol(prop); + if (propKind !== 150 && propKind !== 149) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } } if (flags & 128) { - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } } @@ -30784,7 +31414,7 @@ var ts; if (flags & 8) { var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } return true; @@ -30794,10 +31424,10 @@ var ts; } var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return hasBaseType(enclosingClass, declaringClass) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; }); if (!enclosingClass) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); return false; } if (flags & 32) { @@ -30813,16 +31443,17 @@ var ts; return true; } function checkNonNullExpression(node) { - var type = checkExpression(node); - if (strictNullChecks) { - var kind = getFalsyFlags(type) & 6144; - if (kind) { - error(node, kind & 2048 ? kind & 4096 ? - ts.Diagnostics.Object_is_possibly_null_or_undefined : - ts.Diagnostics.Object_is_possibly_undefined : - ts.Diagnostics.Object_is_possibly_null); - } - return getNonNullableType(type); + return checkNonNullType(checkExpression(node), node); + } + function checkNonNullType(type, errorNode) { + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 6144; + if (kind) { + error(errorNode, kind & 2048 ? kind & 4096 ? + ts.Diagnostics.Object_is_possibly_null_or_undefined : + ts.Diagnostics.Object_is_possibly_undefined : + ts.Diagnostics.Object_is_possibly_null); + var t = getNonNullableType(type); + return t.flags & (6144 | 8192) ? unknownType : t; } return type; } @@ -30851,7 +31482,7 @@ var ts; noUnusedIdentifiers && (prop.flags & 106500) && prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8)) { - if (prop.flags & 16777216) { + if (getCheckFlags(prop) & 1) { getSymbolLinks(prop).target.isReferenced = true; } else { @@ -30859,6 +31490,15 @@ var ts; } } } + function isInPropertyInitializer(node) { + while (node) { + if (node.parent && node.parent.kind === 148 && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { var type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -30870,16 +31510,23 @@ var ts; } var prop = getPropertyOfType(apparentType, right.text); if (!prop) { + var stringIndexType = getIndexTypeOfType(apparentType, 0); + if (stringIndexType) { + return stringIndexType; + } if (right.text && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & 16384 && type.isThisType ? apparentType : type); } return unknownType; } + if (prop.valueDeclaration && + isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; - if (prop.parent && prop.parent.flags & 32) { - checkClassPropertyAccess(node, left, apparentType, prop); - } + checkPropertyAccessibility(node, left, apparentType, prop); var propType = getTypeOfSymbol(prop); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { @@ -30888,7 +31535,7 @@ var ts; return unknownType; } } - if (node.kind !== 177 || assignmentKind === 1 || + if (node.kind !== 178 || assignmentKind === 1 || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 65536)) { return propType; @@ -30897,21 +31544,21 @@ var ts; return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 177 + var left = node.kind === 178 ? 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) { - return checkClassPropertyAccess(node, left, type, prop); + if (prop) { + return checkPropertyAccessibility(node, left, type, prop); } } return true; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 225) { + if (initializer.kind === 226) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -30933,7 +31580,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 213 && + if (node.kind === 214 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -30951,7 +31598,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 180 && node.parent.expression === node) { + if (node.parent.kind === 181 && 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); @@ -30971,7 +31618,7 @@ var ts; error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } - return getIndexedAccessType(objectType, indexType, node); + return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === unknownType) { @@ -31004,10 +31651,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 181) { + if (node.kind === 182) { checkExpression(node.template); } - else if (node.kind !== 145) { + else if (node.kind !== 146) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -31029,19 +31676,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_9 = signature.declaration && signature.declaration.parent; + var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_9 === lastParent) { + if (lastParent && parent === lastParent) { index++; } else { - lastParent = parent_9; + lastParent = parent; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_9; + lastParent = parent; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -31058,7 +31705,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 196) { + if (arg && arg.kind === 197) { return i; } } @@ -31071,11 +31718,14 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 181) { + if (ts.isJsxOpeningLikeElement(node)) { + return true; + } + if (node.kind === 182) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 194) { + if (tagExpression.template.kind === 195) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -31087,7 +31737,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 145) { + else if (node.kind === 146) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -31095,7 +31745,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 180); + ts.Debug.assert(callExpression.kind === 181); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -31103,8 +31753,10 @@ var ts; typeArguments = callExpression.typeArguments; spreadArgIndex = getSpreadArgumentIndex(args); } + var numTypeParameters = ts.length(signature.typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters); var hasRightNumberOfTypeArgs = !typeArguments || - (signature.typeParameters && typeArguments.length === signature.typeParameters.length); + (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters); if (!hasRightNumberOfTypeArgs) { return false; } @@ -31154,7 +31806,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 !== 198) { + if (arg === undefined || arg.kind !== 199) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -31179,7 +31831,7 @@ var ts; var typeParameters = signature.typeParameters; var typeArgumentsAreAssignable = true; var mapper; - for (var i = 0; i < typeParameters.length; i++) { + for (var i = 0; i < typeArgumentNodes.length; i++) { if (typeArgumentsAreAssignable) { var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { @@ -31199,9 +31851,29 @@ var ts; } return typeArgumentsAreAssignable; } + function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { + var callIsIncomplete = node.attributes.end === node.end; + if (callIsIncomplete) { + return true; + } + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + var paramType = getTypeAtPosition(signature, 0); + var attributesType = checkExpressionWithContextualType(node.attributes, paramType, undefined); + var argProperties = getPropertiesOfType(attributesType); + for (var _i = 0, argProperties_1 = argProperties; _i < argProperties_1.length; _i++) { + var arg = argProperties_1[_i]; + if (!getPropertyOfType(paramType, arg.name) && isUnhyphenatedJsxName(arg.name)) { + return false; + } + } + return checkTypeRelatedTo(attributesType, paramType, relation, undefined, headMessage); + } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { + if (ts.isJsxOpeningLikeElement(node)) { + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 180) { + if (thisType && thisType !== voidType && node.kind !== 181) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -31214,7 +31886,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 !== 198) { + if (arg === undefined || arg.kind !== 199) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -31229,51 +31901,54 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 179) { + if (node.kind === 180) { var callee = node.expression; - if (callee.kind === 177) { + if (callee.kind === 178) { return callee.expression; } - else if (callee.kind === 178) { + else if (callee.kind === 179) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 181) { + if (node.kind === 182) { var template = node.template; args = [undefined]; - if (template.kind === 194) { + if (template.kind === 195) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 145) { + else if (node.kind === 146) { return undefined; } + else if (ts.isJsxOpeningLikeElement(node)) { + args = node.attributes.properties.length > 0 ? [node.attributes] : emptyArray; + } else { args = node.arguments || emptyArray; } return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 145) { + if (node.kind === 146) { switch (node.parent.kind) { - case 227: - case 197: + case 228: + case 198: return 1; - case 147: + case 148: return 2; - case 149: - case 151: + case 150: case 152: + case 153: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 144: + case 145: return 3; } } @@ -31282,48 +31957,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 227) { + if (node.kind === 228) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 144) { + if (node.kind === 145) { node = node.parent; - if (node.kind === 150) { + if (node.kind === 151) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 152 || + node.kind === 153) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 227) { + if (node.kind === 228) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 144) { + if (node.kind === 145) { node = node.parent; - if (node.kind === 150) { + if (node.kind === 151) { return anyType; } } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 152 || + node.kind === 153) { var element = node; switch (element.name.kind) { case 70: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 142: + case 143: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -31340,20 +32015,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 227) { + if (node.kind === 228) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 144) { + if (node.kind === 145) { return numberType; } - if (node.kind === 147) { + if (node.kind === 148) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 150 || + node.kind === 152 || + node.kind === 153) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -31374,26 +32049,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex) { - if (node.kind === 145) { + if (node.kind === 146) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 181) { + else if (argIndex === 0 && node.kind === 182) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 145 || - (argIndex === 0 && node.kind === 181)) { + if (node.kind === 146 || + (argIndex === 0 && node.kind === 182)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 145) { + if (node.kind === 146) { return node.expression; } - else if (argIndex === 0 && node.kind === 181) { + else if (argIndex === 0 && node.kind === 182) { return node.template; } else { @@ -31401,10 +32076,11 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 181; - var isDecorator = node.kind === 145; + var isTaggedTemplate = node.kind === 182; + var isDecorator = node.kind === 146; + var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; - if (!isTaggedTemplate && !isDecorator) { + if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) { typeArguments = node.typeArguments; if (node.expression.kind !== 96) { ts.forEach(typeArguments, checkSourceElement); @@ -31432,7 +32108,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 179 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 180 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -31446,6 +32122,9 @@ var ts; return result; } if (candidateForArgumentError) { + if (isJsxOpeningOrSelfClosingElement) { + return candidateForArgumentError; + } checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); } else if (candidateForTypeArgumentError) { @@ -31461,7 +32140,7 @@ var ts; if (headMessage) { diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); } - reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); + reportNoCommonSupertypeError(inferenceCandidates, node.tagName || node.expression || node.tag, diagnosticChainHead); } } else { @@ -31504,13 +32183,13 @@ var ts; if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNode); + typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); - typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; } if (!typeArgumentsAreValid) { break; @@ -31701,16 +32380,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 227: - case 197: + case 228: + case 198: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 144: + case 145: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 147: + case 148: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 149: - case 151: + case 150: case 152: + case 153: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -31735,16 +32414,42 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray, headMessage); } + function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray) { + ts.Debug.assert(!(elementType.flags & 65536)); + var callSignature = resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray); + return callSignature; + } + function resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray) { + if (elementType.flags & 65536) { + var types = elementType.types; + var result = void 0; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); + } + return result; + } + var callSignatures = elementType && getSignaturesOfType(elementType, 0); + if (callSignatures && callSignatures.length > 0) { + var callSignature = void 0; + callSignature = resolveCall(openingLikeElement, callSignatures, candidatesOutArray); + return callSignature; + } + return undefined; + } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 179: - return resolveCallExpression(node, candidatesOutArray); case 180: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 181: + return resolveNewExpression(node, candidatesOutArray); + case 182: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 145: + case 146: return resolveDecorator(node, candidatesOutArray); + case 250: + case 249: + return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); } @@ -31775,12 +32480,12 @@ var ts; if (node.expression.kind === 96) { return voidType; } - if (node.kind === 180) { + if (node.kind === 181) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 150 && - declaration.kind !== 154 && - declaration.kind !== 159 && + declaration.kind !== 151 && + declaration.kind !== 155 && + declaration.kind !== 160 && !ts.isJSDocConstructSignature(declaration)) { var funcSymbol = node.expression.kind === 70 ? getResolvedSymbol(node.expression) : @@ -31811,9 +32516,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 226 + ? 227 : resolvedRequire.flags & 3 - ? 224 + ? 225 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -31847,7 +32552,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return unknownType; } - else if (container.kind === 150) { + else if (container.kind === 151) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -31885,7 +32590,7 @@ var ts; var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { if (!parameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); } assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } @@ -31923,8 +32628,8 @@ var ts; if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 172 || - parameter.valueDeclaration.name.kind === 173)) { + (parameter.valueDeclaration.name.kind === 173 || + parameter.valueDeclaration.name.kind === 174)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -31954,6 +32659,9 @@ var ts; error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } + else if (!getGlobalPromiseConstructorSymbol()) { + error(func, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } return promiseType; } function getReturnTypeFromBody(func, contextualMapper) { @@ -31963,7 +32671,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 205) { + if (func.body.kind !== 206) { 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); @@ -32042,7 +32750,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 219 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 220 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -32071,7 +32779,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 184 || func.kind === 185)) { + func.kind === 185 || func.kind === 186)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -32088,7 +32796,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 205 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 206 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -32115,9 +32823,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 184) { + if (!hasGrammarError && node.kind === 185) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -32151,7 +32859,7 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 149) { + if (produceDiagnostics && node.kind !== 150) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithCapturedNewTargetVariable(node, node.name); @@ -32159,7 +32867,7 @@ var ts; return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -32169,7 +32877,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 205) { + if (node.body.kind === 206) { checkSourceElement(node.body); } else { @@ -32195,19 +32903,19 @@ var ts; return true; } function isReadonlySymbol(symbol) { - return symbol.isReadonly || - symbol.flags & 4 && (getDeclarationModifierFlagsFromSymbol(symbol) & 64) !== 0 || - symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 || + return !!(getCheckFlags(symbol) & 4 || + symbol.flags & 4 && getDeclarationModifierFlagsFromSymbol(symbol) & 64 || + symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 || symbol.flags & 98304 && !(symbol.flags & 65536) || - (symbol.flags & 8) !== 0; + symbol.flags & 8); } function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 177 || expr.kind === 178) && + (expr.kind === 178 || expr.kind === 179) && expr.expression.kind === 98) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 150)) + if (!(func && func.kind === 151)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -32216,13 +32924,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 177 || expr.kind === 178) { + if (expr.kind === 178 || expr.kind === 179) { var node = ts.skipParentheses(expr.expression); if (node.kind === 70) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 238; + return declaration && declaration.kind === 239; } } } @@ -32230,7 +32938,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage) { var node = ts.skipParentheses(expr); - if (node.kind !== 70 && node.kind !== 177 && node.kind !== 178) { + if (node.kind !== 70 && node.kind !== 178 && node.kind !== 179) { error(expr, invalidReferenceMessage); return false; } @@ -32239,7 +32947,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 177 && expr.kind !== 178) { + if (expr.kind !== 178 && expr.kind !== 179) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -32252,7 +32960,7 @@ var ts; } function checkTypeOfExpression(node) { checkExpression(node.expression); - return stringType; + return typeofType; } function checkVoidExpression(node) { checkExpression(node.expression); @@ -32282,6 +32990,7 @@ var ts; case 36: case 37: case 51: + checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 512)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } @@ -32293,7 +33002,7 @@ var ts; booleanType; case 42: case 43: - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); } @@ -32306,7 +33015,7 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); } @@ -32318,8 +33027,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -32333,8 +33042,8 @@ var ts; } if (type.flags & 65536) { var types = type.types; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var t = types_19[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -32343,8 +33052,8 @@ var ts; } if (type.flags & 131072) { var types = type.types; - for (var _a = 0, types_18 = types; _a < types_18.length; _a++) { - var t = types_18[_a]; + for (var _a = 0, types_20 = types; _a < types_20.length; _a++) { + var t = types_20[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -32365,7 +33074,10 @@ var ts; if (isTypeOfKind(leftType, 8190)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } - if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { + if (!(isTypeAny(rightType) || + getSignaturesOfType(rightType, 0).length || + getSignaturesOfType(rightType, 1).length || + isTypeSubtypeOf(rightType, globalFunctionType))) { error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; @@ -32374,6 +33086,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 | 512))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } @@ -32391,22 +33105,22 @@ var ts; return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 258 || property.kind === 259) { - var name_22 = property.name; - if (name_22.kind === 142) { - checkComputedPropertyName(name_22); + if (property.kind === 260 || property.kind === 261) { + var name = property.name; + if (name.kind === 143) { + checkComputedPropertyName(name); } - if (isComputedNonLiteralName(name_22)) { + if (isComputedNonLiteralName(name)) { return undefined; } - var text = ts.getTextOfPropertyName(name_22); + var text = ts.getTextOfPropertyName(name); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 259) { + if (property.kind === 261) { return checkDestructuringAssignment(property, type); } else { @@ -32414,10 +33128,10 @@ var ts; } } else { - error(name_22, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_22)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 260) { + else if (property.kind === 262) { if (languageVersion < 5) { checkExternalEmitHelpers(property, 4); } @@ -32445,8 +33159,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 198) { - if (element.kind !== 196) { + if (element.kind !== 199) { + if (element.kind !== 197) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -32472,7 +33186,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 192 && restExpression.operatorToken.kind === 57) { + if (restExpression.kind === 193 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -32485,7 +33199,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 259) { + if (exprOrAssignment.kind === 261) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -32499,21 +33213,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 192 && target.operatorToken.kind === 57) { + if (target.kind === 193 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 176) { + if (target.kind === 177) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 175) { + if (target.kind === 176) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 260 ? + var error = target.parent.kind === 262 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -32527,35 +33241,35 @@ var ts; case 70: case 9: case 11: - case 181: - case 194: + case 182: + case 195: case 12: case 8: case 100: case 85: case 94: - case 137: - case 184: - case 197: + case 138: case 185: - case 175: + case 198: + case 186: case 176: - case 187: - case 201: + case 177: + case 188: + case 202: + case 249: case 248: - case 247: return true; - case 193: + case 194: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 192: + case 193: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 190: case 191: + case 192: switch (node.operator) { case 50: case 36: @@ -32564,9 +33278,9 @@ var ts; return true; } return false; - case 188: - case 182: - case 200: + case 189: + case 183: + case 201: default: return false; } @@ -32586,7 +33300,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 57 && (left.kind === 176 || left.kind === 175)) { + if (operator === 57 && (left.kind === 177 || left.kind === 176)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -32617,12 +33331,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (leftType.flags & 6144) - leftType = rightType; - if (rightType.flags & 6144) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); var suggestedOperator = void 0; if ((leftType.flags & 136) && (rightType.flags & 136) && @@ -32642,12 +33352,10 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (leftType.flags & 6144) - leftType = rightType; - if (rightType.flags & 6144) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + if (!isTypeOfKind(leftType, 1 | 262178) && !isTypeOfKind(rightType, 1 | 262178)) { + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); + } var resultType = void 0; if (isTypeOfKind(leftType, 340) && isTypeOfKind(rightType, 340)) { resultType = numberType; @@ -32676,8 +33384,8 @@ var ts; case 29: case 30: if (checkForDisallowedESSymbolOperand(operator)) { - leftType = getBaseTypeOfLiteralType(leftType); - rightType = getBaseTypeOfLiteralType(rightType); + leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); + rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } @@ -32846,7 +33554,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 182 || node.kind === 200; + return node.kind === 183 || node.kind === 201; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -32857,11 +33565,11 @@ var ts; function isLiteralContextualType(contextualType) { if (contextualType) { if (contextualType.flags & 540672) { - var apparentType = getApparentTypeOfTypeVariable(contextualType); - if (apparentType.flags & (2 | 4 | 8 | 16)) { + var constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; + if (constraint.flags & (2 | 4 | 8 | 16)) { return true; } - contextualType = apparentType; + contextualType = constraint; } return maybeTypeOfKind(contextualType, (480 | 262144)); } @@ -32872,14 +33580,14 @@ var ts; return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -32901,7 +33609,7 @@ var ts; return type; } function getTypeOfExpression(node) { - if (node.kind === 179 && node.expression.kind !== 96) { + if (node.kind === 180 && node.expression.kind !== 96) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -32912,7 +33620,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 141) { + if (node.kind === 142) { type = checkQualifiedName(node); } else { @@ -32920,9 +33628,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 177 && node.parent.expression === node) || - (node.parent.kind === 178 && node.parent.expression === node) || - ((node.kind === 70 || node.kind === 141) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 178 && node.parent.expression === node) || + (node.parent.kind === 179 && node.parent.expression === node) || + ((node.kind === 70 || node.kind === 142) && 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); } @@ -32944,68 +33652,70 @@ var ts; case 100: case 85: return checkLiteralExpression(node); - case 194: + case 195: return checkTemplateExpression(node); case 12: return stringType; case 11: return globalRegExpType; - case 175: - return checkArrayLiteral(node, contextualMapper); case 176: - return checkObjectLiteral(node, contextualMapper); + return checkArrayLiteral(node, contextualMapper); case 177: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, contextualMapper); case 178: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 179: + return checkIndexedAccess(node); case 180: - return checkCallExpression(node); case 181: - return checkTaggedTemplateExpression(node); - case 183: - return checkExpression(node.expression, contextualMapper); - case 197: - return checkClassExpression(node); - case 184: - case 185: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 187: - return checkTypeOfExpression(node); + return checkCallExpression(node); case 182: - case 200: - return checkAssertion(node); - case 201: - return checkNonNullAssertion(node); - case 202: - return checkMetaProperty(node); - case 186: - return checkDeleteExpression(node); - case 188: - return checkVoidExpression(node); - case 189: - return checkAwaitExpression(node); - case 190: - return checkPrefixUnaryExpression(node); - case 191: - return checkPostfixUnaryExpression(node); - case 192: - return checkBinaryExpression(node, contextualMapper); - case 193: - return checkConditionalExpression(node, contextualMapper); - case 196: - return checkSpreadExpression(node, contextualMapper); + return checkTaggedTemplateExpression(node); + case 184: + return checkExpression(node.expression, contextualMapper); case 198: + return checkClassExpression(node); + case 185: + case 186: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 188: + return checkTypeOfExpression(node); + case 183: + case 201: + return checkAssertion(node); + case 202: + return checkNonNullAssertion(node); + case 203: + return checkMetaProperty(node); + case 187: + return checkDeleteExpression(node); + case 189: + return checkVoidExpression(node); + case 190: + return checkAwaitExpression(node); + case 191: + return checkPrefixUnaryExpression(node); + case 192: + return checkPostfixUnaryExpression(node); + case 193: + return checkBinaryExpression(node, contextualMapper); + case 194: + return checkConditionalExpression(node, contextualMapper); + case 197: + return checkSpreadExpression(node, contextualMapper); + case 199: return undefinedWideningType; - case 195: + case 196: return checkYieldExpression(node); - case 253: - return checkJsxExpression(node); - case 247: - return checkJsxElement(node); + case 255: + return checkJsxExpression(node, contextualMapper); case 248: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 249: + return checkJsxSelfClosingElement(node); + case 253: + return checkJsxAttributes(node, contextualMapper); + case 250: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -33015,7 +33725,16 @@ var ts; grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } checkSourceElement(node.constraint); - getConstraintOfTypeParameter(getDeclaredTypeOfTypeParameter(getSymbolOfNode(node))); + checkSourceElement(node.default); + var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); + if (!hasNonCircularBaseConstraint(typeParameter)) { + error(node.constraint, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); + } + var constraintType = getConstraintOfTypeParameter(typeParameter); + var defaultType = getDefaultFromTypeParameter(typeParameter); + if (constraintType && defaultType) { + checkTypeAssignableTo(defaultType, getTypeWithThisArgument(constraintType, defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } @@ -33026,7 +33745,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 150 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 151 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -33037,7 +33756,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 150 || func.kind === 154 || func.kind === 159) { + if (func.kind === 151 || func.kind === 155 || func.kind === 160) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -33049,9 +33768,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 149 || - node.kind === 226 || - node.kind === 184; + return node.kind === 150 || + node.kind === 227 || + node.kind === 185; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -33092,9 +33811,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_23 = _a[_i].name; - if (ts.isBindingPattern(name_23) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_23, parameterName, typePredicate.parameterName)) { + var name = _a[_i].name; + if (ts.isBindingPattern(name) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -33107,16 +33826,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 186: + case 154: + case 227: case 185: - case 153: - case 226: - case 184: - case 158: + case 159: + case 150: case 149: - case 148: - var parent_10 = node.parent; - if (node === parent_10.type) { - return parent_10; + var parent = node.parent; + if (node === parent.type) { + return parent; } } } @@ -33126,27 +33845,27 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_24 = element.name; - if (name_24.kind === 70 && - name_24.text === predicateVariableName) { + var name = element.name; + if (name.kind === 70 && + name.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_24.kind === 173 || - name_24.kind === 172) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_24, predicateVariableNode, predicateVariableName)) { + else if (name.kind === 174 || + name.kind === 173) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } } } } function checkSignatureDeclaration(node) { - if (node.kind === 155) { + if (node.kind === 156) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 || node.kind === 226 || node.kind === 159 || - node.kind === 153 || node.kind === 150 || - node.kind === 154) { + else if (node.kind === 159 || node.kind === 227 || node.kind === 160 || + node.kind === 154 || node.kind === 151 || + node.kind === 155) { checkGrammarFunctionLikeDeclaration(node); } if (ts.isAsyncFunctionLike(node) && languageVersion < 4) { @@ -33164,10 +33883,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 154: + case 155: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 153: + case 154: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -33194,11 +33913,18 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { + var Declaration; + (function (Declaration) { + Declaration[Declaration["Getter"] = 1] = "Getter"; + Declaration[Declaration["Setter"] = 2] = "Setter"; + Declaration[Declaration["Method"] = 4] = "Method"; + Declaration[Declaration["Property"] = 3] = "Property"; + })(Declaration || (Declaration = {})); var instanceNames = ts.createMap(); var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150) { + if (member.kind === 151) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -33207,36 +33933,65 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114; }); + var isStatic = ts.getModifierFlags(member) & 32; var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 151: + case 152: addName(names, member.name, memberName, 1); break; - case 152: + case 153: addName(names, member.name, memberName, 2); break; - case 147: + case 148: addName(names, member.name, memberName, 3); break; + case 150: + addName(names, member.name, memberName, 4); + break; } } } } function addName(names, location, name, meaning) { - var prev = names[name]; + var prev = names.get(name); if (prev) { - if (prev & meaning) { + if (prev & 4) { + if (meaning !== 4) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + } + else if (prev & meaning) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { - names[name] = prev | meaning; + names.set(name, prev | meaning); } } else { - names[name] = meaning; + names.set(name, meaning); + } + } + } + function checkClassForStaticPropertyNameConflicts(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + var memberNameNode = member.name; + var isStatic = ts.getModifierFlags(member) & 32; + if (isStatic && memberNameNode) { + var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode); + switch (memberName) { + case "name": + case "length": + case "caller": + case "arguments": + case "prototype": + var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; + var className = getNameOfSymbol(getSymbolOfNode(node)); + error(memberNameNode, message, memberName, className); + break; + } } } } @@ -33244,7 +33999,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 146) { + if (member.kind == 147) { var memberName = void 0; switch (member.name.kind) { case 9: @@ -33255,18 +34010,18 @@ var ts; default: continue; } - if (names[memberName]) { + if (names.get(memberName)) { error(member.symbol.valueDeclaration.name, ts.Diagnostics.Duplicate_identifier_0, memberName); error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName); } else { - names[memberName] = true; + names.set(memberName, true); } } } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 228) { + if (node.kind === 229) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -33281,7 +34036,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 134: + case 135: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -33348,12 +34103,12 @@ var ts; if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 && n.kind !== 226) { + else if (n.kind !== 185 && n.kind !== 227) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 147 && + return n.kind === 148 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -33373,7 +34128,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -33396,18 +34151,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 151) { + if (node.kind === 152) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 151 ? 152 : 151; + var otherKind = node.kind === 152 ? 153 : 152; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -33421,11 +34176,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 151) { + if (node.kind === 152) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 176) { + if (node.parent.kind !== 177) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -33448,6 +34203,7 @@ var ts; checkDecorators(node); } function checkTypeArgumentConstraints(typeParameters, typeArgumentNodes) { + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); var typeArguments; var mapper; var result = true; @@ -33455,7 +34211,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -33506,25 +34262,42 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessIndexType(type, accessNode) { + if (!(type.flags & 524288)) { + return type; + } + var objectType = type.objectType; + var indexType = type.indexType; + if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + return type; + } + if (maybeTypeOfKind(objectType, 540672) && isTypeOfKind(indexType, 340)) { + var constraint = getBaseConstraintOfType(objectType); + if (constraint && getIndexInfoOfType(constraint, 1)) { + return type; + } + } + error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); + return type; + } function checkIndexedAccessType(node) { - getTypeFromIndexedAccessTypeNode(node); + checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node) { checkSourceElement(node.typeParameter); checkSourceElement(node.type); var type = getTypeFromMappedTypeNode(node); var constraintType = getConstraintTypeFromMappedType(type); - var keyType = constraintType.flags & 540672 ? getApparentTypeOfTypeVariable(constraintType) : constraintType; - checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint); + checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 228 && - n.parent.kind !== 227 && - n.parent.kind !== 197 && + if (n.parent.kind !== 229 && + n.parent.kind !== 228 && + n.parent.kind !== 198 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -33601,7 +34374,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) { - var reportError = (node.kind === 149 || node.kind === 148) && + var reportError = (node.kind === 150 || node.kind === 149) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -33630,15 +34403,15 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var current = declarations_5[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 228 || node.parent.kind === 161 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 229 || node.parent.kind === 162 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 226 || node.kind === 149 || node.kind === 148 || node.kind === 150) { + if (node.kind === 227 || node.kind === 150 || node.kind === 149 || node.kind === 151) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -33749,16 +34522,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 228: + case 229: return 2097152; - case 231: + case 232: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 227: - case 230: + case 228: + case 231: return 2097152 | 1048576; - case 235: + case 236: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -33876,7 +34649,12 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455, true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; if (promiseConstructorType === unknownType) { - error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + if (promiseConstructorName.kind === 70 && promiseConstructorName.text === "Promise" && getTargetType(returnType) === tryGetGlobalPromiseType()) { + error(node.type, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } + else { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + } return unknownType; } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); @@ -33906,22 +34684,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 227: + case 228: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 144: + case 145: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 147: + case 148: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 149: - case 151: + case 150: case 152: + case 153: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -33955,13 +34733,13 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8); - if (node.kind === 144) { + if (node.kind === 145) { checkExternalEmitHelpers(firstDecorator, 32); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 227: + case 228: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -33970,19 +34748,19 @@ var ts; } } break; - case 149: - case 151: + case 150: case 152: + case 153: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markTypeNodeAsReferenced(node.type); break; - case 147: + case 148: markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); break; - case 144: + case 145: markTypeNodeAsReferenced(node.type); break; } @@ -34003,7 +34781,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 142) { + if (node.name && node.name.kind === 143) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -34045,43 +34823,43 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 262: - case 231: + case 264: + case 232: checkUnusedModuleMembers(node); break; - case 227: - case 197: + case 228: + case 198: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 228: + case 229: checkUnusedTypeParameters(node); break; - case 205: - case 233: - case 212: + case 206: + case 234: case 213: case 214: + case 215: checkUnusedLocalsAndParameters(node); break; - case 150: - case 184: - case 226: - case 185: - case 149: case 151: + case 185: + case 227: + case 186: + case 150: case 152: + case 153: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 148: - case 153: + case 149: case 154: case 155: - case 158: + case 156: case 159: + case 160: checkUnusedTypeParameters(node); break; } @@ -34090,11 +34868,10 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 228 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_2 = function (key) { - var local = node.locals[key]; + if (node.parent.kind !== 229 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + node.locals.forEach(function (local) { if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 145) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -34107,10 +34884,7 @@ var ts; ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d.name || d, local.name); }); } } - }; - for (var key in node.locals) { - _loop_2(key); - } + }); } } function isRemovedPropertyFromObjectSpread(node) { @@ -34123,9 +34897,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 224 && - (declaration.parent.parent.kind === 213 || - declaration.parent.parent.kind === 214)) { + if (declaration.kind === 225 && + (declaration.parent.parent.kind === 214 || + declaration.parent.parent.kind === 215)) { return; } } @@ -34144,12 +34918,12 @@ var ts; if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149 || member.kind === 147) { + if (member.kind === 150 || member.kind === 148) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 150) { + else if (member.kind === 151) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -34180,8 +34954,7 @@ var ts; } function checkUnusedModuleMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { - for (var key in node.locals) { - var local = node.locals[key]; + node.locals.forEach(function (local) { if (!local.isReferenced && !local.exportSymbol) { for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; @@ -34190,11 +34963,11 @@ var ts; } } } - } + }); } } function checkBlock(node) { - if (node.kind === 205) { + if (node.kind === 206) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -34216,19 +34989,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 147 || - node.kind === 146 || + if (node.kind === 148 || + node.kind === 147 || + node.kind === 150 || node.kind === 149 || - node.kind === 148 || - node.kind === 151 || - node.kind === 152) { + node.kind === 152 || + node.kind === 153) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 144 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 145 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -34300,11 +35073,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 262 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 264 && ts.isExternalOrCommonJsModule(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)); } } @@ -34312,11 +35085,11 @@ var ts; if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 262 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 264 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -34324,7 +35097,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 224 && !node.initializer) { + if (node.kind === 225 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -34334,25 +35107,25 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 225); - var container = varDeclList.parent.kind === 206 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 226); + var container = varDeclList.parent.kind === 207 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 205 && ts.isFunctionLike(container.parent) || + (container.kind === 206 && ts.isFunctionLike(container.parent) || + container.kind === 233 || container.kind === 232 || - container.kind === 231 || - container.kind === 262); + container.kind === 264); if (!namesShareScope) { - var name_25 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_25, name_25); + var name = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 144) { + if (ts.getRootDeclaration(node).kind !== 145) { return; } var func = ts.getContainingFunction(node); @@ -34361,7 +35134,7 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 177) { + if (n.kind === 178) { return visit(n.expression); } else if (n.kind === 70) { @@ -34375,8 +35148,8 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144 || - symbol.valueDeclaration.kind === 174) { + if (symbol.valueDeclaration.kind === 145 || + symbol.valueDeclaration.kind === 175) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -34385,7 +35158,7 @@ var ts; if (ts.isFunctionLike(current.parent)) { return; } - if (current.parent.kind === 147 && + if (current.parent.kind === 148 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)) { return; @@ -34407,37 +35180,37 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 174) { - if (node.parent.kind === 172 && languageVersion < 5 && !ts.isInAmbientContext(node)) { + if (node.kind === 175) { + if (node.parent.kind === 173 && languageVersion < 5 && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4); } - if (node.propertyName && node.propertyName.kind === 142) { + if (node.propertyName && node.propertyName.kind === 143) { checkComputedPropertyName(node.propertyName); } - var parent_11 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_11); - var name_26 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_26)); + var parent = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent); + var name = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); markPropertyAsReferenced(property); - if (parent_11.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); + if (parent.initializer && property) { + checkPropertyAccessibility(parent, parent.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 144 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 145 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 213) { + if (node.initializer && node.parent.parent.kind !== 214) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -34446,7 +35219,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 213) { + if (node.initializer && node.parent.parent.kind !== 214) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -34464,9 +35237,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 147 && node.kind !== 146) { + if (node.kind !== 148 && node.kind !== 147) { checkExportsOnMergedDeclarations(node); - if (node.kind === 224 || node.kind === 174) { + if (node.kind === 225 || node.kind === 175) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -34477,8 +35250,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 && right.kind === 224) || - (left.kind === 224 && right.kind === 144)) { + if ((left.kind === 145 && right.kind === 225) || + (left.kind === 225 && right.kind === 145)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -34505,7 +35278,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 176) { + if (node.modifiers && node.parent.kind === 177) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -34524,7 +35297,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 207) { + if (node.thenStatement.kind === 208) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -34541,12 +35314,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 225) { + if (node.initializer && node.initializer.kind === 226) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 225) { + if (node.initializer.kind === 226) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -34564,13 +35337,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 225) { + if (node.initializer.kind === 226) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 175 || varExpr.kind === 176) { + if (varExpr.kind === 176 || varExpr.kind === 177) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -34589,7 +35362,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 225) { + if (node.initializer.kind === 226) { 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); @@ -34599,7 +35372,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 175 || varExpr.kind === 176) { + if (varExpr.kind === 176 || varExpr.kind === 177) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -34775,7 +35548,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 152))); + return !!(node.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 153))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -34797,30 +35570,30 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 152) { + if (func.kind === 153) { if (node.expression) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); + error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 150) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { - error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + else if (func.kind === 151) { + if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node.expression || node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); if (promisedType) { - checkTypeAssignableTo(awaitedType, promisedType, node.expression || node); + checkTypeAssignableTo(awaitedType, promisedType, node); } } else { - checkTypeAssignableTo(exprType, returnType, node.expression || node); + checkTypeAssignableTo(exprType, returnType, node); } } } - else if (func.kind !== 150 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 151 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -34846,7 +35619,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 255 && !hasDuplicateDefaultClause) { + if (clause.kind === 257 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -34858,7 +35631,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 254) { + if (produceDiagnostics && clause.kind === 256) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var caseIsLiteral = isLiteralType(caseType); @@ -34884,7 +35657,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 220 && current.label.text === node.label.text) { + if (current.kind === 221 && 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; @@ -34917,14 +35690,14 @@ var ts; grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - var blockLocals = catchClause.block.locals; - if (blockLocals) { - for (var caughtName in catchClause.locals) { - var blockLocal = blockLocals[caughtName]; + var blockLocals_1 = catchClause.block.locals; + if (blockLocals_1) { + ts.forEachKey(catchClause.locals, function (caughtName) { + var blockLocal = blockLocals_1.get(caughtName); if (blockLocal && (blockLocal.flags & 2) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } - } + }); } } } @@ -34972,12 +35745,13 @@ var ts; if (!indexType) { return; } - if (indexKind === 1 && !isNumericName(prop.valueDeclaration.name)) { + var propDeclaration = prop.valueDeclaration; + if (indexKind === 1 && !(propDeclaration ? isNumericName(propDeclaration.name) : isNumericLiteralName(prop.name))) { return; } var errorNode; - if (prop.valueDeclaration.name.kind === 142 || prop.parent === containingType.symbol) { - errorNode = prop.valueDeclaration; + if (propDeclaration && (propDeclaration.name.kind === 143 || prop.parent === containingType.symbol)) { + errorNode = propDeclaration; } else if (indexDeclaration) { errorNode = indexDeclaration; @@ -35002,15 +35776,23 @@ var ts; case "string": case "symbol": case "void": + case "object": error(name, message, name.text); } } function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { + var seenDefault = false; for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { + if (node.default) { + seenDefault = true; + } + else if (seenDefault) { + error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters); + } for (var j = 0; j < i; j++) { if (typeParameterDeclarations[j].symbol === node.symbol) { error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name)); @@ -35020,23 +35802,57 @@ var ts; } } } - function checkTypeParameterListsIdentical(node, symbol) { + function checkTypeParameterListsIdentical(symbol) { if (symbol.declarations.length === 1) { return; } - var firstDecl; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 227 || declaration.kind === 228) { - if (!firstDecl) { - firstDecl = declaration; - } - else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); + var links = getSymbolLinks(symbol); + if (!links.typeParametersChecked) { + links.typeParametersChecked = true; + var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); + if (declarations.length <= 1) { + return; + } + var type = getDeclaredTypeOfSymbol(symbol); + if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { + var name = symbolToString(symbol); + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; + error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } } } + function areTypeParametersIdentical(declarations, typeParameters) { + var maxTypeArgumentCount = ts.length(typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; + var numTypeParameters = ts.length(declaration.typeParameters); + if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { + return false; + } + for (var i = 0; i < numTypeParameters; i++) { + var source = declaration.typeParameters[i]; + var target = typeParameters[i]; + if (source.name.text !== target.symbol.name) { + return false; + } + var sourceConstraint = source.constraint && getTypeFromTypeNode(source.constraint); + var targetConstraint = getConstraintFromTypeParameter(target); + if ((sourceConstraint || targetConstraint) && + (!sourceConstraint || !targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint))) { + return false; + } + var sourceDefault = source.default && getTypeFromTypeNode(source.default); + var targetDefault = getDefaultFromTypeParameter(target); + if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) { + return false; + } + } + } + return true; + } function checkClassExpression(node) { checkClassLikeDeclaration(node); checkNodeDeferred(node); @@ -35070,8 +35886,11 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); + if (!ts.isInAmbientContext(node)) { + checkClassForStaticPropertyNameConflicts(node); + } var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { if (languageVersion < 2 && !ts.isInAmbientContext(node)) { @@ -35080,7 +35899,8 @@ var ts; var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType_1 = baseTypes[0]; - var staticBaseType = getBaseConstructorTypeOfClass(type); + var baseConstructorType = getBaseConstructorTypeOfClass(type); + var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { @@ -35094,14 +35914,17 @@ var ts; } checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType_1.symbol.valueDeclaration && + if (baseConstructorType.flags & 540672 && !isMixinConstructorType(staticType)) { + error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); + } + if (baseType_1.symbol && baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 227) { + baseType_1.symbol.valueDeclaration.kind === 228) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 540672)) { var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType_1; })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); @@ -35121,8 +35944,7 @@ var ts; if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - var declaredType = getObjectFlags(t) & 4 ? t.target : t; - if (getObjectFlags(declaredType) & 3) { + if (isValidBaseType(t)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -35150,17 +35972,22 @@ var ts; } } function getTargetSymbol(s) { - return s.flags & 16777216 ? getSymbolLinks(s).target : s; + return getCheckFlags(s) & 1 ? s.target : s; } function getClassLikeDeclarationOfSymbol(symbol) { return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); } + function getClassOrInterfaceDeclarationsOfSymbol(symbol) { + return ts.filter(symbol.declarations, function (d) { + return d.kind === 228 || d.kind === 229; + }); + } function checkKindsOfPropertyMemberOverrides(type, baseType) { - var baseProperties = getPropertiesOfObjectType(baseType); + var baseProperties = getPropertiesOfType(baseType); for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); - if (base.flags & 134217728) { + if (base.flags & 16777216) { continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); @@ -35170,7 +35997,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 197) { + if (derivedClassDecl.kind === 198) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -35214,32 +36041,7 @@ var ts; } } function isAccessor(kind) { - return kind === 151 || kind === 152; - } - function areTypeParametersIdentical(list1, list2) { - if (!list1 && !list2) { - return true; - } - if (!list1 || !list2 || list1.length !== list2.length) { - return false; - } - for (var i = 0; i < list1.length; i++) { - var tp1 = list1[i]; - var tp2 = list2[i]; - if (tp1.name.text !== tp2.name.text) { - return false; - } - if (!tp1.constraint && !tp2.constraint) { - continue; - } - if (!tp1.constraint || !tp2.constraint) { - return false; - } - if (!isTypeIdenticalTo(getTypeFromTypeNode(tp1.constraint), getTypeFromTypeNode(tp2.constraint))) { - return false; - } - } - return true; + return kind === 152 || kind === 153; } function checkInheritedPropertiesAreIdentical(type, typeNode) { var baseTypes = getBaseTypes(type); @@ -35247,16 +36049,16 @@ var ts; return true; } var seen = ts.createMap(); - ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.name, { prop: p, containingType: type }); }); var ok = true; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; - var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { var prop = properties_7[_a]; - var existing = seen[prop.name]; + var existing = seen.get(prop.name); if (!existing) { - seen[prop.name] = { prop: prop, containingType: base }; + seen.set(prop.name, { prop: prop, containingType: base }); } else { var isInheritedProperty = existing.containingType !== type; @@ -35280,8 +36082,8 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 228); + checkTypeParameterListsIdentical(symbol); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 229); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -35377,7 +36179,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 190: + case 191: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -35388,7 +36190,7 @@ var ts; case 51: return ~value_1; } return undefined; - case 192: + case 193: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -35414,11 +36216,11 @@ var ts; case 8: checkGrammarNumericLiteral(e); return +e.text; - case 183: + case 184: return evalConstant(e.expression); case 70: + case 179: case 178: - case 177: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -35429,7 +36231,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 178) { + if (e.kind === 179) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -35446,7 +36248,7 @@ var ts; if (current.kind === 70) { break; } - else if (current.kind === 177) { + else if (current.kind === 178) { current = current.expression; } else { @@ -35507,7 +36309,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 230) { + if (declaration.kind !== 231) { return false; } var enumDeclaration = declaration; @@ -35528,10 +36330,10 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var declaration = declarations_5[_i]; - if ((declaration.kind === 227 || - (declaration.kind === 226 && ts.nodeIsPresent(declaration.body))) && + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 228 || + (declaration.kind === 227 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -35590,7 +36392,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 227); + var mergedClass = ts.getDeclarationOfKind(symbol, 228); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -35598,7 +36400,7 @@ var ts; } if (isAmbientExternalModule) { if (ts.isExternalModuleAugmentation(node)) { - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 134217728); if (checkBody && node.body) { for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -35633,42 +36435,42 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 206: + case 207: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 241: case 242: + case 243: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 235: case 236: + case 237: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 174: - case 224: - var name_27 = node.name; - if (ts.isBindingPattern(name_27)) { - for (var _b = 0, _c = name_27.elements; _b < _c.length; _b++) { + case 175: + case 225: + var name = node.name; + if (ts.isBindingPattern(name)) { + for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 227: - case 230: - case 226: case 228: case 231: + case 227: case 229: + case 232: + case 230: if (isGlobalAugmentation) { return; } var symbol = getSymbolOfNode(node); if (symbol) { - var reportError = !(symbol.flags & 33554432); + var reportError = !(symbol.flags & 134217728); if (!reportError) { reportError = ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } @@ -35680,12 +36482,12 @@ var ts; switch (node.kind) { case 70: return node; - case 141: + case 142: do { node = node.left; } while (node.kind !== 70); return node; - case 177: + case 178: do { node = node.expression; } while (node.kind !== 70); @@ -35698,9 +36500,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 262 && !inAmbientExternalModule) { - error(moduleName, node.kind === 242 ? + var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 264 && !inAmbientExternalModule) { + error(moduleName, node.kind === 243 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -35721,7 +36523,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 244 ? + var message = node.kind === 245 ? 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)); @@ -35748,7 +36550,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 238) { + if (importClause.namedBindings.kind === 239) { checkImportBinding(importClause.namedBindings); } else { @@ -35799,8 +36601,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 262 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 233 && + !node.moduleSpecifier && ts.isInAmbientContext(node); + if (node.parent.kind !== 264 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -35813,7 +36617,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 262 || node.parent.kind === 232 || node.parent.kind === 231; + var isInAppropriateContext = node.parent.kind === 264 || node.parent.kind === 233 || node.parent.kind === 232; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -35836,8 +36640,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 262 ? node.parent : node.parent.parent; - if (container.kind === 231 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 264 ? node.parent : node.parent.parent; + if (container.kind === 232 && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -35866,18 +36670,13 @@ var ts; } } function hasExportedMembers(moduleSymbol) { - for (var id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; + return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; }); } function checkExternalModuleExports(node) { var moduleSymbol = getSymbolOfNode(node); var links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - var exportEqualsSymbol = moduleSymbol.exports["export="]; + var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; if (!isTopLevelInExternalModuleAugmentation(declaration)) { @@ -35885,31 +36684,31 @@ var ts; } } var exports_1 = getExportsOfModule(moduleSymbol); - for (var id in exports_1) { + exports_1 && exports_1.forEach(function (_a, id) { + var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { - continue; + return; } - var _a = exports_1[id], declarations = _a.declarations, flags = _a.flags; if (flags & (1920 | 64 | 384)) { - continue; + return; } var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); if (flags & 524288 && exportedDeclarationsCount <= 2) { - continue; + return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, id)); } } } - } + }); links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 226 && declaration.kind !== 149) || + return (declaration.kind !== 227 && declaration.kind !== 150) || !!declaration.body; } } @@ -35920,123 +36719,123 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 231: - case 227: + case 232: case 228: - case 226: + case 229: + case 227: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 143: - return checkTypeParameter(node); case 144: + return checkTypeParameter(node); + case 145: return checkParameter(node); + case 148: case 147: - case 146: return checkPropertyDeclaration(node); - case 158: case 159: - case 153: + case 160: case 154: - return checkSignatureDeclaration(node); case 155: return checkSignatureDeclaration(node); - case 149: - case 148: - return checkMethodDeclaration(node); - case 150: - return checkConstructorDeclaration(node); - case 151: - case 152: - return checkAccessorDeclaration(node); - case 157: - return checkTypeReferenceNode(node); case 156: + return checkSignatureDeclaration(node); + case 150: + case 149: + return checkMethodDeclaration(node); + case 151: + return checkConstructorDeclaration(node); + case 152: + case 153: + return checkAccessorDeclaration(node); + case 158: + return checkTypeReferenceNode(node); + case 157: return checkTypePredicate(node); - case 160: - return checkTypeQuery(node); case 161: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 162: - return checkArrayType(node); + return checkTypeLiteral(node); case 163: - return checkTupleType(node); + return checkArrayType(node); case 164: + return checkTupleType(node); case 165: - return checkUnionOrIntersectionType(node); case 166: - case 168: - return checkSourceElement(node.type); + return checkUnionOrIntersectionType(node); + case 167: case 169: - return checkIndexedAccessType(node); + return checkSourceElement(node.type); case 170: + return checkIndexedAccessType(node); + case 171: return checkMappedType(node); - case 226: - return checkFunctionDeclaration(node); - case 205: - case 232: - return checkBlock(node); - case 206: - return checkVariableStatement(node); - case 208: - return checkExpressionStatement(node); - case 209: - return checkIfStatement(node); - case 210: - return checkDoStatement(node); - case 211: - return checkWhileStatement(node); - case 212: - return checkForStatement(node); - case 213: - return checkForInStatement(node); - case 214: - return checkForOfStatement(node); - case 215: - case 216: - return checkBreakOrContinueStatement(node); - case 217: - return checkReturnStatement(node); - case 218: - return checkWithStatement(node); - case 219: - return checkSwitchStatement(node); - case 220: - return checkLabeledStatement(node); - case 221: - return checkThrowStatement(node); - case 222: - return checkTryStatement(node); - case 224: - return checkVariableDeclaration(node); - case 174: - return checkBindingElement(node); case 227: - return checkClassDeclaration(node); - case 228: - return checkInterfaceDeclaration(node); - case 229: - return checkTypeAliasDeclaration(node); - case 230: - return checkEnumDeclaration(node); - case 231: - return checkModuleDeclaration(node); - case 236: - return checkImportDeclaration(node); - case 235: - return checkImportEqualsDeclaration(node); - case 242: - return checkExportDeclaration(node); - case 241: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 206: + case 233: + return checkBlock(node); case 207: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 209: + return checkExpressionStatement(node); + case 210: + return checkIfStatement(node); + case 211: + return checkDoStatement(node); + case 212: + return checkWhileStatement(node); + case 213: + return checkForStatement(node); + case 214: + return checkForInStatement(node); + case 215: + return checkForOfStatement(node); + case 216: + case 217: + return checkBreakOrContinueStatement(node); + case 218: + return checkReturnStatement(node); + case 219: + return checkWithStatement(node); + case 220: + return checkSwitchStatement(node); + case 221: + return checkLabeledStatement(node); + case 222: + return checkThrowStatement(node); case 223: + return checkTryStatement(node); + case 225: + return checkVariableDeclaration(node); + case 175: + return checkBindingElement(node); + case 228: + return checkClassDeclaration(node); + case 229: + return checkInterfaceDeclaration(node); + case 230: + return checkTypeAliasDeclaration(node); + case 231: + return checkEnumDeclaration(node); + case 232: + return checkModuleDeclaration(node); + case 237: + return checkImportDeclaration(node); + case 236: + return checkImportEqualsDeclaration(node); + case 243: + return checkExportDeclaration(node); + case 242: + return checkExportAssignment(node); + case 208: checkGrammarStatementInAmbientContext(node); return; - case 245: + case 224: + checkGrammarStatementInAmbientContext(node); + return; + case 246: return checkMissingDeclaration(node); } } @@ -36049,17 +36848,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 184: case 185: + case 186: + case 150: case 149: - case 148: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 151: case 152: + case 153: checkAccessorDeferred(node); break; - case 197: + case 198: checkClassExpressionDeferred(node); break; } @@ -36147,7 +36946,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 218 && node.parent.statement === node) { + if (node.parent.kind === 219 && node.parent.statement === node) { return true; } node = node.parent; @@ -36169,28 +36968,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 262: + case 264: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 231: + case 232: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 230: + case 231: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 197: + case 198: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 227: case 228: + case 229: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 184: + case 185: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -36208,17 +37007,16 @@ var ts; function copySymbol(symbol, meaning) { if (symbol.flags & meaning) { var id = symbol.name; - if (!symbols[id]) { - symbols[id] = symbol; + if (!symbols.has(id)) { + symbols.set(id, symbol); } } } function copySymbols(source, meaning) { if (meaning) { - for (var id in source) { - var symbol = source[id]; + source.forEach(function (symbol) { copySymbol(symbol, meaning); - } + }); } } } @@ -36229,27 +37027,27 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 143: - case 227: + case 144: case 228: case 229: case 230: + case 231: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 141) { + while (node.parent && node.parent.kind === 142) { node = node.parent; } - return node.parent && (node.parent.kind === 157 || node.parent.kind === 273); + return node.parent && (node.parent.kind === 158 || node.parent.kind === 276); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 177) { + while (node.parent && node.parent.kind === 178) { node = node.parent; } - return node.parent && node.parent.kind === 199; + return node.parent && node.parent.kind === 200; } function forEachEnclosingClass(node, callback) { var result; @@ -36266,13 +37064,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 141) { + while (nodeOnRightSide.parent.kind === 142) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 235) { + if (nodeOnRightSide.parent.kind === 236) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 241) { + if (nodeOnRightSide.parent.kind === 242) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -36284,7 +37082,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 177) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 178) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -36296,11 +37094,11 @@ var ts; default: } } - if (entityName.parent.kind === 241 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 242 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 177 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 235); + if (entityName.kind !== 178 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 236); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -36309,7 +37107,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 199) { + if (entityName.parent.kind === 200) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -36331,14 +37129,14 @@ var ts; } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 177) { + else if (entityName.kind === 178) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 141) { + else if (entityName.kind === 142) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -36347,19 +37145,19 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 273) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 158 || entityName.parent.kind === 276) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 251) { + else if (entityName.parent.kind === 252) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 156) { + if (entityName.parent.kind === 157) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 262) { + if (node.kind === 264) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -36375,8 +37173,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 174 && - node.parent.parent.kind === 172 && + else if (node.parent.kind === 175 && + node.parent.parent.kind === 173 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -36387,8 +37185,8 @@ var ts; } switch (node.kind) { case 70: - case 177: - case 141: + case 178: + case 142: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98: var container = ts.getThisContainer(node, false); @@ -36401,18 +37199,18 @@ var ts; case 96: var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 167: + case 168: return getTypeFromTypeNode(node).symbol; case 122: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 150) { + if (constructorDeclaration && constructorDeclaration.kind === 151) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 236 || node.parent.kind === 242) && + ((node.parent.kind === 237 || node.parent.kind === 243) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -36420,7 +37218,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 178 && node.parent.argumentExpression === node) { + if (node.parent.kind === 179 && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -36434,7 +37232,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 259) { + if (location && location.kind === 261) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -36484,20 +37282,20 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 176 || expr.kind === 175); - if (expr.parent.kind === 214) { + ts.Debug.assert(expr.kind === 177 || expr.kind === 176); + if (expr.parent.kind === 215) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 192) { + if (expr.parent.kind === 193) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 258) { + if (expr.parent.kind === 260) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 175); + ts.Debug.assert(expr.parent.kind === 176); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); @@ -36523,30 +37321,33 @@ var ts; var propsByName = createSymbolTable(getPropertiesOfType(type)); if (getSignaturesOfType(type, 0).length || getSignaturesOfType(type, 1).length) { ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { - if (!propsByName[p.name]) { - propsByName[p.name] = p; + if (!propsByName.has(p.name)) { + propsByName.set(p.name, p); } }); } return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (symbol.flags & 268435456) { + if (getCheckFlags(symbol) & 2) { var symbols_3 = []; - var name_28 = symbol.name; + var name_2 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_28); + var symbol = getPropertyOfType(t, name_2); if (symbol) { symbols_3.push(symbol); } }); return symbols_3; } - else if (symbol.flags & 67108864) { + else if (symbol.flags & 134217728) { if (symbol.leftSpread) { var links = symbol; return [links.leftSpread, links.rightSpread]; } + if (symbol.mappedTypeOrigin) { + return getRootSymbols(symbol.mappedTypeOrigin); + } var target = void 0; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -36562,7 +37363,8 @@ var ts; if (!ts.isGeneratedIdentifier(node)) { node = ts.getParseTreeNode(node, ts.isIdentifier); if (node) { - return getReferencedValueSymbol(node) === argumentsSymbol; + var isPropertyName_1 = node.parent.kind === 178 && node.parent.name === node; + return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } return false; @@ -36578,7 +37380,7 @@ var ts; if (symbolLinks.exportsSomeValue === undefined) { symbolLinks.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & 107455) - : ts.forEachProperty(getExportsOfModule(moduleSymbol), isValue); + : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { @@ -36604,7 +37406,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 262) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 264) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -36642,7 +37444,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 205 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 206 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -36682,16 +37484,16 @@ var ts; return true; } switch (node.kind) { - case 235: - case 237: + case 236: case 238: - case 240: - case 244: + case 239: + case 241: + case 245: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 242: + case 243: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 241: + case 242: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -36701,7 +37503,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 262 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 264 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -36743,6 +37545,12 @@ var ts; } return false; } + function isRequiredInitializedParameter(parameter) { + return strictNullChecks && + !isOptionalParameter(parameter) && + parameter.initializer && + !(ts.getModifierFlags(parameter) & 92); + } function getNodeCheckFlags(node) { node = ts.getParseTreeNode(node); return node ? getNodeLinks(node).flags : undefined; @@ -36752,7 +37560,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 261) { + if (node.kind === 263) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -36768,15 +37576,17 @@ var ts; } function getTypeReferenceSerializationKind(typeName, location) { var valueSymbol = resolveEntityName(typeName, 107455, true, false, location); - var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); - if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { - return ts.TypeReferenceSerializationKind.Promise; - } - var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; - if (constructorType && isConstructorType(constructorType)) { - return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; - } var typeSymbol = resolveEntityName(typeName, 793064, true, false, location); + if (valueSymbol && valueSymbol === typeSymbol) { + var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); + if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { + return ts.TypeReferenceSerializationKind.Promise; + } + var constructorType = getTypeOfSymbol(valueSymbol); + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + } if (!typeSymbol) { return ts.TypeReferenceSerializationKind.ObjectType; } @@ -36820,6 +37630,9 @@ var ts; var type = symbol && !(symbol.flags & (2048 | 131072)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : unknownType; + if (flags & 4096) { + type = includeFalsyTypes(type, 2048); + } getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { @@ -36834,10 +37647,13 @@ var ts; var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(node)); resolveBaseTypesOfClass(classType); var baseType = classType.resolvedBaseTypes.length ? classType.resolvedBaseTypes[0] : unknownType; + if (!baseType.symbol) { + writer.reportIllegalExtends(); + } getSymbolDisplayBuilder().buildTypeDisplay(baseType, writer, enclosingDeclaration, flags); } function hasGlobalName(name) { - return !!globals[name]; + return globals.has(name); } function getReferencedValueSymbol(reference, startInDeclarationContainer) { var resolvedSymbol = getNodeLinks(reference).resolvedSymbol; @@ -36846,9 +37662,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_12 = reference.parent; - if (ts.isDeclaration(parent_12) && reference === parent_12.name) { - location = getDeclarationContainer(parent_12); + var parent = reference.parent; + if (ts.isDeclaration(parent) && reference === parent.name) { + location = getDeclarationContainer(parent); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -36881,14 +37697,13 @@ var ts; var fileToDirective; if (resolvedTypeReferenceDirectives) { fileToDirective = ts.createFileMap(); - for (var key in resolvedTypeReferenceDirectives) { - var resolvedDirective = resolvedTypeReferenceDirectives[key]; + resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) { if (!resolvedDirective) { - continue; + return; } var file = host.getSourceFile(resolvedDirective.resolvedFileName); fileToDirective.set(file.path, key); - } + }); } return { getReferencedExportContainer: getReferencedExportContainer, @@ -36902,6 +37717,7 @@ var ts; isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, + isRequiredInitializedParameter: isRequiredInitializedParameter, writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, writeTypeOfExpression: writeTypeOfExpression, @@ -36926,7 +37742,7 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 177) || (node.kind === 70 && isInTypeQuery(node)) + var meaning = (node.kind === 178) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -36961,15 +37777,15 @@ var ts; } var current = symbol; while (true) { - var parent_13 = getParentOfSymbol(current); - if (parent_13) { - current = parent_13; + var parent = getParentOfSymbol(current); + if (parent) { + current = parent; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 262 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 264 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -36988,7 +37804,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 262); + return ts.getDeclarationOfKind(moduleSymbol, 264); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -37009,11 +37825,11 @@ var ts; } if (file.symbol && file.symbol.globalExports) { var source = file.symbol.globalExports; - for (var id in source) { - if (!(id in globals)) { - globals[id] = source[id]; + source.forEach(function (sourceSymbol, id) { + if (!globals.has(id)) { + globals.set(id, sourceSymbol); } - } + }); } } if (augmentations) { @@ -37079,10 +37895,10 @@ var ts; var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1; helper <= 128; helper <<= 1) { if (uncheckedHelpers & helper) { - var name_29 = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_29), 107455); + var name = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name), 107455); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_29); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); } } } @@ -37117,7 +37933,7 @@ var ts; return emptyObjectType; } function createThenableType() { - var thenPropertySymbol = createSymbol(67108864 | 4, "then"); + var thenPropertySymbol = createSymbol(4, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; var thenableType = createObjectType(16); thenableType.properties = [thenPropertySymbol]; @@ -37131,14 +37947,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 149 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 150 && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 151 || node.kind === 152) { + else if (node.kind === 152 || node.kind === 153) { 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); @@ -37156,16 +37972,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 130) { - if (node.kind === 146 || node.kind === 148) { + if (node.kind === 147 || node.kind === 149) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 155) { + if (node.kind === 156) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 75: - if (node.kind !== 230 && node.parent.kind === 227) { + if (node.kind !== 231 && node.parent.kind === 228) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -37191,7 +38007,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 232 || node.parent.kind === 262) { + else if (node.parent.kind === 233 || node.parent.kind === 264) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -37214,10 +38030,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 232 || node.parent.kind === 262) { + else if (node.parent.kind === 233 || node.parent.kind === 264) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -37230,7 +38046,7 @@ var ts; if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 147 && node.kind !== 146 && node.kind !== 155 && node.kind !== 144) { + else if (node.kind !== 148 && node.kind !== 147 && node.kind !== 156 && node.kind !== 145) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; @@ -37249,10 +38065,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 228) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; @@ -37264,13 +38080,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 228) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 232) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 233) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -37280,14 +38096,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 227) { - if (node.kind !== 149 && - node.kind !== 147 && - node.kind !== 151 && - node.kind !== 152) { + if (node.kind !== 228) { + if (node.kind !== 150 && + node.kind !== 148 && + node.kind !== 152 && + node.kind !== 153) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 227 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 228 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -37306,7 +38122,7 @@ var ts; 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 === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -37314,7 +38130,7 @@ var ts; break; } } - if (node.kind === 150) { + if (node.kind === 151) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -37329,13 +38145,13 @@ var ts; } return; } - else if ((node.kind === 236 || node.kind === 235) && flags & 2) { + else if ((node.kind === 237 || node.kind === 236) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 144 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 145 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 144 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 145 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -37351,37 +38167,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 151: case 152: - case 150: - case 147: - case 146: - case 149: + case 153: + case 151: case 148: - case 155: - case 231: + case 147: + case 150: + case 149: + case 156: + case 232: + case 237: case 236: - case 235: + case 243: case 242: - case 241: - case 184: case 185: - case 144: + case 186: + case 145: return false; default: - if (node.parent.kind === 232 || node.parent.kind === 262) { + if (node.parent.kind === 233 || node.parent.kind === 264) { return false; } switch (node.kind) { - case 226: - return nodeHasAnyModifiersExcept(node, 119); case 227: - return nodeHasAnyModifiersExcept(node, 116); + return nodeHasAnyModifiersExcept(node, 119); case 228: - case 206: + return nodeHasAnyModifiersExcept(node, 116); case 229: - return true; + case 207: case 230: + return true; + case 231: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -37394,10 +38210,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 149: - case 226: - case 184: + case 150: + case 227: case 185: + case 186: if (!node.asteriskToken) { return false; } @@ -37459,7 +38275,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 185) { + if (node.kind === 186) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -37494,7 +38310,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 !== 134 && parameter.type.kind !== 132) { + if (parameter.type.kind !== 135 && parameter.type.kind !== 132) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -37521,7 +38337,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 198) { + if (arg.kind === 199) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -37591,19 +38407,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 142) { + if (node.kind !== 143) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 192 && computedPropertyName.expression.operatorToken.kind === 25) { + if (computedPropertyName.expression.kind === 193 && computedPropertyName.expression.operatorToken.kind === 25) { 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 === 226 || - node.kind === 184 || - node.kind === 149); + ts.Debug.assert(node.kind === 227 || + node.kind === 185 || + node.kind === 150); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -37628,87 +38444,87 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 260) { + if (prop.kind === 262) { continue; } - var name_30 = prop.name; - if (name_30.kind === 142) { - checkGrammarComputedPropertyName(name_30); + var name = prop.name; + if (name.kind === 143) { + checkGrammarComputedPropertyName(name); } - if (prop.kind === 259 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 261 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 || prop.kind !== 149) { + if (mod.kind !== 119 || prop.kind !== 150) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; - if (prop.kind === 258 || prop.kind === 259) { + if (prop.kind === 260 || prop.kind === 261) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_30.kind === 8) { - checkGrammarNumericLiteral(name_30); + if (name.kind === 8) { + checkGrammarNumericLiteral(name); } currentKind = Property; } - else if (prop.kind === 149) { + else if (prop.kind === 150) { currentKind = Property; } - else if (prop.kind === 151) { + else if (prop.kind === 152) { currentKind = GetAccessor; } - else if (prop.kind === 152) { + else if (prop.kind === 153) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_30); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { continue; } - if (!seen[effectiveName]) { - seen[effectiveName] = currentKind; + var existingKind = seen.get(effectiveName); + if (!existingKind) { + seen.set(effectiveName, currentKind); } else { - var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_30, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_30)); + grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[effectiveName] = currentKind | existingKind; + seen.set(effectiveName, currentKind | existingKind); } else { - return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } } function checkGrammarJsxElement(node) { var seen = ts.createMap(); - for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 252) { + if (attr.kind === 254) { continue; } var jsxAttr = attr; - var name_31 = jsxAttr.name; - if (!seen[name_31.text]) { - seen[name_31.text] = true; + var name = jsxAttr.name; + if (!seen.get(name.text)) { + seen.set(name.text, true); } else { - return grammarErrorOnNode(name_31, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 253 && !initializer.expression) { + if (initializer && initializer.kind === 255 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -37717,7 +38533,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 225) { + if (forInOrOfStatement.initializer.kind === 226) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -37725,20 +38541,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 213 + var diagnostic = forInOrOfStatement.kind === 214 ? 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 = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 213 + var diagnostic = forInOrOfStatement.kind === 214 ? 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 === 213 + var diagnostic = forInOrOfStatement.kind === 214 ? 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); @@ -37765,11 +38581,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 151 ? + return grammarErrorOnNode(accessor.name, kind === 152 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 152) { + else if (kind === 153) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -37788,10 +38604,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 151 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 152 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 151 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 152 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -37806,7 +38622,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 176) { + if (node.parent.kind === 177) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -37822,10 +38638,10 @@ 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 === 228) { + else if (node.parent.kind === 229) { 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 === 161) { + else if (node.parent.kind === 162) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -37836,9 +38652,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 220: + case 221: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 215 + var isMisplacedContinueLabel = node.kind === 216 && !ts.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); @@ -37846,8 +38662,8 @@ var ts; return false; } break; - case 219: - if (node.kind === 216 && !node.label) { + case 220: + if (node.kind === 217 && !node.label) { return false; } break; @@ -37860,13 +38676,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 216 + var message = node.kind === 217 ? 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 === 216 + var message = node.kind === 217 ? 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); @@ -37878,7 +38694,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 173 || node.name.kind === 172) { + if (node.name.kind === 174 || node.name.kind === 173) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -37888,11 +38704,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 190 && expr.operator === 37 && + expr.kind === 191 && expr.operator === 37 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 213 && node.parent.parent.kind !== 214) { + if (node.parent.parent.kind !== 214 && node.parent.parent.kind !== 215) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -37919,9 +38735,29 @@ var ts; } } } + if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && + !ts.isInAmbientContext(node.parent.parent) && ts.hasModifier(node.parent.parent, 1)) { + checkESModuleMarker(node.name); + } var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } + function checkESModuleMarker(name) { + if (name.kind === 70) { + if (ts.unescapeIdentifier(name.text) === "__esModule") { + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); + } + } + else { + var elements = name.elements; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; + if (!ts.isOmittedExpression(element)) { + return checkESModuleMarker(element.name); + } + } + } + } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 70) { if (name.originalKeywordKind === 109) { @@ -37930,8 +38766,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { - var element = elements_2[_i]; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var element = elements_3[_i]; if (!ts.isOmittedExpression(element)) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -37949,15 +38785,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 209: case 210: case 211: - case 218: case 212: + case 219: case 213: case 214: + case 215: return false; - case 220: + case 221: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -38019,7 +38855,7 @@ var ts; return true; } } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 229) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -38027,7 +38863,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 161) { + else if (node.parent.kind === 162) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -38040,13 +38876,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 228 || - node.kind === 229 || + if (node.kind === 229 || + node.kind === 230 || + node.kind === 237 || node.kind === 236 || - node.kind === 235 || + node.kind === 243 || node.kind === 242 || - node.kind === 241 || - node.kind === 234 || + node.kind === 235 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -38055,7 +38891,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 === 206) { + if (ts.isDeclaration(decl) || decl.kind === 207) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -38074,7 +38910,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 === 205 || node.parent.kind === 232 || node.parent.kind === 262) { + if (node.parent.kind === 206 || node.parent.kind === 233 || node.parent.kind === 264) { 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); @@ -38090,10 +38926,10 @@ var ts; if (languageVersion >= 1) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 171)) { + else if (ts.isChildOfNodeWithKind(node, 172)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 261)) { + else if (ts.isChildOfNodeWithKind(node, 263)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -38113,11 +38949,11 @@ var ts; } function getAmbientModules() { var result = []; - for (var sym in globals) { + globals.forEach(function (global, sym) { if (ambientModuleSymbolRegex.test(sym)) { - result.push(globals[sym]); + result.push(global); } - } + }); return result; } } @@ -38125,55 +38961,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ; - var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[141] = [ - { name: "left", test: ts.isEntityName }, - { name: "right", test: ts.isIdentifier } - ], - _a[145] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[182] = [ - { name: "type", test: ts.isTypeNode }, - { name: "expression", test: ts.isUnaryExpression } - ], - _a[200] = [ - { name: "expression", test: ts.isExpression }, - { name: "type", test: ts.isTypeNode } - ], - _a[201] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[230] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "members", test: ts.isEnumMember } - ], - _a[231] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isModuleName }, - { name: "body", test: ts.isModuleBody } - ], - _a[232] = [ - { name: "statements", test: ts.isStatement } - ], - _a[235] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "moduleReference", test: ts.isModuleReference } - ], - _a[246] = [ - { name: "expression", test: ts.isExpression, optional: true } - ], - _a[261] = [ - { name: "name", test: ts.isPropertyName }, - { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } - ], - _a)); function reduceNode(node, f, initial) { return node ? f(initial, node) : initial; } @@ -38187,41 +38974,45 @@ var ts; var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; - if ((kind > 0 && kind <= 140)) { + if ((kind > 0 && kind <= 141)) { return initial; } - if ((kind >= 156 && kind <= 171)) { + if ((kind >= 157 && kind <= 172)) { return initial; } var result = initial; switch (node.kind) { - case 204: - case 207: - case 198: - case 223: - case 294: + case 205: + case 208: + case 199: + case 224: + case 297: break; case 142: - result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); break; - case 144: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); + case 143: + result = reduceNode(node.expression, cbNode, result); break; case 145: - result = reduceNode(node.expression, cbNode, result); - break; - case 147: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 149: + case 146: + result = reduceNode(node.expression, cbNode, result); + break; + case 148: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 150: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38230,53 +39021,48 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 150: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; case 151: - result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; case 152: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 153: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 172: case 173: + case 174: result = reduceNodes(node.elements, cbNodes, result); break; - case 174: + case 175: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 175: + case 176: result = reduceNodes(node.elements, cbNodes, result); break; - case 176: - result = reduceNodes(node.properties, cbNodes, result); - break; case 177: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.properties, cbNodes, result); break; case 178: result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.argumentExpression, cbNode, result); + result = reduceNode(node.name, cbNode, result); break; case 179: result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); + result = reduceNode(node.argumentExpression, cbNode, result); break; case 180: result = reduceNode(node.expression, cbNode, result); @@ -38284,10 +39070,19 @@ var ts; result = reduceNodes(node.arguments, cbNodes, result); break; case 181: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 182: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 184: + case 183: + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 185: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -38295,126 +39090,133 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 185: + case 186: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 183: - case 186: + case 184: case 187: case 188: case 189: - case 195: + case 190: case 196: - case 201: + case 197: + case 202: result = reduceNode(node.expression, cbNode, result); break; - case 190: case 191: + case 192: result = reduceNode(node.operand, cbNode, result); break; - case 192: + case 193: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 193: + case 194: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 194: + case 195: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 197: + case 198: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 199: + case 200: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 203: + case 201: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.type, cbNode, result); + break; + case 202: + result = reduceNode(node.expression, cbNode, result); + break; + case 204: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 205: + case 206: result = reduceNodes(node.statements, cbNodes, result); break; - case 206: + case 207: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 208: + case 209: result = reduceNode(node.expression, cbNode, result); break; - case 209: + case 210: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 210: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; case 211: - case 218: - result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); break; case 212: + case 219: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 213: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 213: case 214: + case 215: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 217: - case 221: + case 218: + case 222: result = reduceNode(node.expression, cbNode, result); break; - case 219: + case 220: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 220: + case 221: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 222: + case 223: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 224: + case 225: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 225: - result = reduceNodes(node.declarations, cbNodes, result); - break; case 226: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); + result = reduceNodes(node.declarations, cbNodes, result); break; case 227: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 228: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38422,113 +39224,131 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; + case 231: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 232: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; case 233: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 234: result = reduceNodes(node.clauses, cbNodes, result); break; case 236: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.moduleReference, cbNode, result); + break; + case 237: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 237: + case 238: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 238: - result = reduceNode(node.name, cbNode, result); - break; case 239: - case 243: - result = reduceNodes(node.elements, cbNodes, result); + result = reduceNode(node.name, cbNode, result); break; case 240: case 244: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 241: + case 245: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 241: + case 242: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 242: + case 243: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; case 247: + result = reduceNode(node.expression, cbNode, result); + break; + case 248: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 248: case 249: - result = reduceNode(node.tagName, cbNode, result); - result = reduceNodes(node.attributes, cbNodes, result); - break; case 250: result = reduceNode(node.tagName, cbNode, result); + result = reduceNode(node.attributes, cbNode, result); break; case 251: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 252: - result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.tagName, cbNode, result); break; case 253: - result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.properties, cbNodes, result); + break; + case 252: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); break; case 254: result = reduceNode(node.expression, cbNode, result); + break; case 255: - result = reduceNodes(node.statements, cbNodes, result); + result = reduceNode(node.expression, cbNode, result); break; case 256: + result = reduceNode(node.expression, cbNode, result); + case 257: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 258: result = reduceNodes(node.types, cbNodes, result); break; - case 257: + case 259: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 258: + case 260: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 259: + case 261: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 260: + case 262: result = reduceNode(node.expression, cbNode, result); break; - case 262: + case 263: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + case 264: result = reduceNodes(node.statements, cbNodes, result); break; - case 295: + case 298: result = reduceNode(node.expression, cbNode, result); break; default: - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_1 = edgeTraversalPath; _i < edgeTraversalPath_1.length; _i++) { - var edge = edgeTraversalPath_1[_i]; - var value = node[edge.name]; - if (value !== undefined) { - result = ts.isArray(value) - ? reduceNodes(value, cbNodes, result) - : cbNode(result, value); - } - } - } break; } return result; } ts.reduceEachChild = reduceEachChild; - function visitNode(node, visitor, test, optional, lift, parenthesize, parentNode) { + function visitNode(node, visitor, test, optional, lift) { if (node === undefined || visitor === undefined) { return node; } @@ -38550,15 +39370,12 @@ var ts; else { visitedNode = visited; } - if (parenthesize !== undefined) { - visitedNode = parenthesize(visitedNode, parentNode); - } Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); return visitedNode; } ts.visitNode = visitNode; - function visitNodes(nodes, visitor, test, start, count, parenthesize, parentNode) { + function visitNodes(nodes, visitor, test, start, count) { if (nodes === undefined) { return undefined; } @@ -38571,7 +39388,7 @@ var ts; count = length - start; } if (start > 0 || count < length) { - updated = ts.createNodeArray([], undefined, nodes.hasTrailingComma && start + count === length); + updated = ts.createNodeArray([], nodes.hasTrailingComma && start + count === length); } for (var i = 0; i < count; i++) { var node = nodes[i + start]; @@ -38579,27 +39396,22 @@ var ts; var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { - updated = ts.createNodeArray(nodes.slice(0, i), nodes, nodes.hasTrailingComma); + updated = ts.createNodeArray(nodes.slice(0, i), nodes.hasTrailingComma); + ts.setTextRange(updated, nodes); } if (visited) { if (ts.isArray(visited)) { for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) { var visitedNode = visited_1[_i]; - visitedNode = parenthesize - ? parenthesize(visitedNode, parentNode) - : visitedNode; Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); updated.push(visitedNode); } } else { - var visitedNode = parenthesize - ? parenthesize(visited, parentNode) - : visited; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); - updated.push(visitedNode); + Debug.assertNode(visited, test); + aggregateTransformFlags(visited); + updated.push(visited); } } } @@ -38611,10 +39423,10 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); - return ts.createNodeArray(ts.concatenate(statements, declarations), statements); + return ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements); } ts.visitLexicalEnvironment = visitLexicalEnvironment; function visitParameterList(nodes, visitor, context) { @@ -38641,203 +39453,206 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 140)) { + if ((kind > 0 && kind <= 141)) { return node; } - if ((kind >= 156 && kind <= 171)) { + if ((kind >= 157 && kind <= 172)) { return node; } switch (node.kind) { - case 204: - case 207: - case 198: - case 223: + case 205: + case 208: + case 199: + case 224: return node; case 142: + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); + case 143: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 144: + case 145: return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), node.dotDotDotToken, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 147: + case 146: + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); + case 148: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 149: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 150: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); + return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 151: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); case 152: + return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 153: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 172: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 173: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 174: - return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); case 175: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); case 176: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); case 177: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); case 178: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); case 179: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); case 180: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); case 181: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 182: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); case 183: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 184: - return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 185: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 186: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 187: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 188: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); case 189: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); case 190: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 191: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); case 193: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 191: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 192: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); case 194: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 195: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); case 196: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); case 197: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 198: return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 199: + case 200: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 203: + case 201: + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); + case 202: + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + case 204: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 205: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); case 206: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 207: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 208: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 209: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 210: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); case 211: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 212: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 213: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 214: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 215: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 216: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 217: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 218: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); case 219: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 220: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); case 221: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 222: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 223: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); - case 224: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 225: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 226: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); case 227: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 228: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); + case 231: + return ts.updateEnumDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNodes(node.members, visitor, ts.isEnumMember)); + case 232: + return ts.updateModuleDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); case 233: + return ts.updateModuleBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 234: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 236: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + return ts.updateImportEqualsDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); case 237: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 238: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 239: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 240: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 241: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 242: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 243: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); case 244: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 245: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 247: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); case 248: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 249: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 250: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 251: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 252: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 253: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxAttributes(node, visitNodes(node.properties, visitor, ts.isJsxAttributeLike)); + case 249: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 250: + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 251: + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + case 252: + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 254: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 255: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 256: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); case 257: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); case 258: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); case 259: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 260: - return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 261: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); case 262: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 263: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 264: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 295: + case 298: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: - var updated = void 0; - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_2 = edgeTraversalPath; _i < edgeTraversalPath_2.length; _i++) { - var edge = edgeTraversalPath_2[_i]; - var value = node[edge.name]; - if (value !== undefined) { - var visited = ts.isArray(value) - ? visitNodes(value, visitor, edge.test, 0, value.length, edge.parenthesize, node) - : visitNode(value, visitor, edge.test, edge.optional, edge.lift, edge.parenthesize, node); - if (updated !== undefined || visited !== value) { - if (updated === undefined) { - updated = ts.getMutableClone(node); - } - if (visited !== value) { - updated[edge.name] = visited; - } - } - } - } - } - return updated ? ts.updateNode(updated, node) : node; + return node; } } ts.visitEachChild = visitEachChild; @@ -38846,17 +39661,17 @@ var ts; return statements; } return ts.isNodeArray(statements) - ? ts.createNodeArray(ts.concatenate(statements, declarations), statements) + ? ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements) : ts.addRange(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; function mergeFunctionBodyLexicalEnvironment(body, declarations) { if (body && declarations !== undefined && declarations.length > 0) { if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.createNodeArray(ts.concatenate(body.statements, declarations), body.statements)); + return ts.updateBlock(body, ts.setTextRange(ts.createNodeArray(ts.concatenate(body.statements, declarations)), body.statements)); } else { - return ts.createBlock(ts.createNodeArray([ts.createReturn(body, body)].concat(declarations), body), body, true); + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray([ts.setTextRange(ts.createReturn(body), body)].concat(declarations)), body), true), body); } } return body; @@ -38901,7 +39716,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 199)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 200)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -38949,10 +39764,14 @@ var ts; } } })(Debug = ts.Debug || (ts.Debug = {})); - var _a; })(ts || (ts = {})); var ts; (function (ts) { + var FlattenLevel; + (function (FlattenLevel) { + FlattenLevel[FlattenLevel["All"] = 0] = "All"; + FlattenLevel[FlattenLevel["ObjectRest"] = 1] = "ObjectRest"; + })(FlattenLevel = ts.FlattenLevel || (ts.FlattenLevel = {})); function flattenDestructuringAssignment(node, visitor, context, level, needsValue, createAssignmentCallback) { var location = node; var value; @@ -39006,7 +39825,7 @@ var ts; ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression); var expression = createAssignmentCallback ? createAssignmentCallback(target, value, location) - : ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value, location); + : ts.setTextRange(ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location); expression.original = original; emitExpression(expression); } @@ -39044,10 +39863,11 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_32 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_32, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value); variable.original = original; - if (ts.isIdentifier(name_32)) { + ts.setTextRange(variable, location); + if (ts.isIdentifier(name)) { ts.setEmitFlags(variable, 64); } ts.aggregateTransformFlags(variable); @@ -39193,8 +40013,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_33 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_33); + var name = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name); } } function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) { @@ -39205,7 +40025,7 @@ var ts; var temp = ts.createTempVariable(undefined); if (flattenContext.hoistTempVariables) { flattenContext.context.hoistVariableDeclaration(temp); - flattenContext.emitExpression(ts.createAssignment(temp, value, location)); + flattenContext.emitExpression(ts.setTextRange(ts.createAssignment(temp, value), location)); } else { flattenContext.emitBindingOrAssignment(temp, value, location, undefined); @@ -39255,12 +40075,21 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), undefined, [value, ts.createArrayLiteral(propertyNames, location)]); + return ts.createCall(ts.getHelperName("__rest"), undefined, [ + value, + ts.setTextRange(ts.createArrayLiteral(propertyNames), location) + ]); } })(ts || (ts = {})); var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; + var TypeScriptSubstitutionFlags; + (function (TypeScriptSubstitutionFlags) { + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; + })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); function transformTypeScript(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -39271,8 +40100,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(177); context.enableSubstitution(178); + context.enableSubstitution(179); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -39305,15 +40134,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 262: + case 264: + case 234: case 233: - case 232: - case 205: + case 206: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 228: case 227: - case 226: if (ts.hasModifier(node, 2)) { break; } @@ -39338,13 +40167,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 236: + case 237: return visitImportDeclaration(node); - case 235: + case 236: return visitImportEqualsDeclaration(node); - case 241: - return visitExportAssignment(node); case 242: + return visitExportAssignment(node); + case 243: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -39354,11 +40183,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 242 || - node.kind === 236 || + if (node.kind === 243 || node.kind === 237 || - (node.kind === 235 && - node.moduleReference.kind === 246)) { + node.kind === 238 || + (node.kind === 236 && + node.moduleReference.kind === 247)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -39374,15 +40203,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 150: - return undefined; - case 147: - case 155: case 151: + return undefined; + case 148: + case 156: case 152: - case 149: + case 153: + case 150: return visitorWorker(node); - case 204: + case 205: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -39413,23 +40242,22 @@ var ts; case 75: case 123: case 130: - case 162: case 163: - case 161: - case 156: - case 143: + case 164: + case 162: + case 157: + case 144: case 118: case 121: - case 134: + case 135: case 132: case 129: case 104: - case 135: - case 159: - case 158: + case 136: case 160: - case 157: - case 164: + case 159: + case 161: + case 158: case 165: case 166: case 167: @@ -39437,57 +40265,58 @@ var ts; case 169: case 170: case 171: - case 155: - case 145: - case 229: - case 147: - return undefined; - case 150: - return visitConstructor(node); - case 228: - return ts.createNotEmittedStatement(node); - case 227: - return visitClassDeclaration(node); - case 197: - return visitClassExpression(node); - case 256: - return visitHeritageClause(node); - case 199: - return visitExpressionWithTypeArguments(node); - case 149: - return visitMethodDeclaration(node); - case 151: - return visitGetAccessor(node); - case 152: - return visitSetAccessor(node); - case 226: - return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); - case 185: - return visitArrowFunction(node); - case 144: - return visitParameter(node); - case 183: - return visitParenthesizedExpression(node); - case 182: - case 200: - return visitAssertionExpression(node); - case 179: - return visitCallExpression(node); - case 180: - return visitNewExpression(node); - case 201: - return visitNonNullExpression(node); + case 172: + case 156: + case 146: case 230: - return visitEnumDeclaration(node); - case 206: - return visitVariableStatement(node); - case 224: - return visitVariableDeclaration(node); + case 148: + return undefined; + case 151: + return visitConstructor(node); + case 229: + return ts.createNotEmittedStatement(node); + case 228: + return visitClassDeclaration(node); + case 198: + return visitClassExpression(node); + case 258: + return visitHeritageClause(node); + case 200: + return visitExpressionWithTypeArguments(node); + case 150: + return visitMethodDeclaration(node); + case 152: + return visitGetAccessor(node); + case 153: + return visitSetAccessor(node); + case 227: + return visitFunctionDeclaration(node); + case 185: + return visitFunctionExpression(node); + case 186: + return visitArrowFunction(node); + case 145: + return visitParameter(node); + case 184: + return visitParenthesizedExpression(node); + case 183: + case 201: + return visitAssertionExpression(node); + case 180: + return visitCallExpression(node); + case 181: + return visitNewExpression(node); + case 202: + return visitNonNullExpression(node); case 231: + return visitEnumDeclaration(node); + case 207: + return visitVariableStatement(node); + case 225: + return visitVariableDeclaration(node); + case 232: return visitModuleDeclaration(node); - case 235: + case 236: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39547,11 +40376,12 @@ var ts; return ts.singleOrMany(statements); } function createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, hasStaticProperties) { - var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); + var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause)); var emitFlags = ts.getEmitFlags(node); if (hasStaticProperties) { emitFlags |= 32; } + ts.setTextRange(classDeclaration, node); ts.setOriginalNode(classDeclaration, node); ts.setEmitFlags(classDeclaration, emitFlags); return classDeclaration; @@ -39562,10 +40392,14 @@ var ts; var declName = ts.getLocalName(node, false, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, hasExtendsClause); - var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members, location); + var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); - var statement = ts.createLetStatement(declName, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression, location); + ts.setTextRange(classExpression, location); + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declName, undefined, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression) + ], 1)); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, location); ts.setCommentRange(statement, node); return statement; } @@ -39573,7 +40407,9 @@ var ts; var staticProperties = getInitializedProperties(node, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84; })); - var classExpression = ts.setOriginalNode(ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members, node), node); + var classExpression = ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members); + ts.setOriginalNode(classExpression, node); + ts.setTextRange(classExpression, node); if (staticProperties.length > 0) { var expressions = []; var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -39596,7 +40432,7 @@ var ts; members.push(constructor); } ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); - return ts.createNodeArray(members, node.members); + return ts.setTextRange(ts.createNodeArray(members), node.members); } function transformConstructor(node, hasExtendsClause) { var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); @@ -39607,7 +40443,7 @@ var ts; } var parameters = transformConstructorParameters(constructor); var body = transformConstructorBody(node, constructor, hasExtendsClause); - return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor(undefined, undefined, parameters, body, constructor || node), constructor)); + return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor(undefined, undefined, parameters, body), constructor || node), constructor)); } function transformConstructorParameters(constructor) { return ts.visitParameterList(constructor && constructor.parameters, visitor, context) @@ -39631,7 +40467,7 @@ var ts; ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } ts.addRange(statements, endLexicalEnvironment()); - return ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : undefined, true); + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined); } function addPrologueDirectivesAndInitialSuperCall(ctor, result) { if (ctor.body) { @@ -39641,7 +40477,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -39663,7 +40499,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 | 48); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536); - return ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), propertyName, node.name), localName), ts.moveRangePos(node, -1))); + return ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1))); } function getInitializedProperties(node, isStatic) { return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); @@ -39675,7 +40511,7 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 147 + return member.kind === 148 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } @@ -39748,12 +40584,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 151: case 152: + case 153: return getAllDecoratorsOfAccessors(node, member); - case 149: + case 150: return getAllDecoratorsOfMethod(member); - case 147: + case 148: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -39832,7 +40668,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 147 + ? member.kind === 148 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -39910,43 +40746,43 @@ var ts; (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, undefined, true))); + decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, true))); } } } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 149 - || kind === 151 + return kind === 150 || kind === 152 - || kind === 147; + || kind === 153 + || kind === 148; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 149; + return node.kind === 150; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 227: - case 197: + case 228: + case 198: return ts.getFirstConstructorWithBody(node) !== undefined; - case 149: - case 151: + case 150: case 152: + case 153: return true; } return false; } function serializeTypeOfNode(node) { switch (node.kind) { - case 147: - case 144: - case 151: - return serializeTypeNode(node.type); + case 148: + case 145: case 152: + return serializeTypeNode(node.type); + case 153: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 227: - case 197: - case 149: + case 228: + case 198: + case 150: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -39978,7 +40814,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 151) { + if (container && node.kind === 152) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -40001,24 +40837,24 @@ var ts; } switch (node.kind) { case 104: - case 137: + case 138: case 94: case 129: return ts.createVoidZero(); - case 166: + case 167: return serializeTypeNode(node.type); - case 158: case 159: + case 160: return ts.createIdentifier("Function"); - case 162: case 163: + case 164: return ts.createIdentifier("Array"); - case 156: + case 157: case 121: return ts.createIdentifier("Boolean"); - case 134: + case 135: return ts.createIdentifier("String"); - case 171: + case 172: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); @@ -40034,22 +40870,22 @@ var ts; break; case 132: return ts.createIdentifier("Number"); - case 135: + case 136: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 157: + case 158: return serializeTypeReferenceNode(node); + case 166: case 165: - case 164: return serializeUnionOrIntersectionType(node); - case 160: - case 168: + case 161: case 169: case 170: - case 161: + case 171: + case 162: case 118: - case 167: + case 168: break; default: ts.Debug.failBadSyntaxKind(node); @@ -40117,15 +40953,15 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 70: - var name_34 = ts.getMutableClone(node); - name_34.flags &= ~8; - name_34.original = undefined; - name_34.parent = currentScope; + var name = ts.getMutableClone(node); + name.flags &= ~8; + name.original = undefined; + name.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_34), ts.createLiteral("undefined")), name_34); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } - return name_34; - case 141: + return name; + case 142: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -40169,7 +41005,7 @@ var ts; hoistVariableDeclaration(generatedName); expression = ts.createAssignment(generatedName, expression); } - return ts.setOriginalNode(ts.createComputedPropertyName(expression, name), name); + return ts.updateComputedPropertyName(name, expression); } else { return name; @@ -40178,13 +41014,12 @@ var ts; function visitHeritageClause(node) { if (node.token === 84) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(84, types, node); + return ts.setTextRange(ts.createHeritageClause(84, types), node); } return undefined; } function visitExpressionWithTypeArguments(node) { - var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); - return ts.createExpressionWithTypeArguments(undefined, expression, node); + return ts.updateExpressionWithTypeArguments(node, undefined, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); } function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); @@ -40258,8 +41093,9 @@ var ts; if (ts.parameterIsThisKeyword(node)) { return undefined; } - var parameter = ts.createParameter(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), ts.moveRangePastModifiers(node)); + var parameter = ts.createParameter(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); ts.setOriginalNode(parameter, node); + ts.setTextRange(parameter, ts.moveRangePastModifiers(node)); ts.setCommentRange(parameter, node); ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); ts.setEmitFlags(parameter.name, 32); @@ -40271,7 +41107,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); + return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -40283,7 +41119,7 @@ var ts; return ts.flattenDestructuringAssignment(node, visitor, context, 0, false, createNamespaceExportExpression); } else { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), node); + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node); } } function visitVariableDeclaration(node) { @@ -40337,8 +41173,9 @@ var ts; var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg]), node); + var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg])); ts.setOriginalNode(enumStatement, node); + ts.setTextRange(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); statements.push(ts.createEndOfDeclarationMarker(node)); @@ -40352,11 +41189,11 @@ var ts; ts.addRange(statements, ts.map(node.members, transformEnumMember)); ts.addRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceLocalName; - return ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); + return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true); } function transformEnumMember(member) { var name = getExpressionForPropertyName(member, false); - return ts.createStatement(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name, member), member); + return ts.setTextRange(ts.createStatement(ts.setTextRange(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name), member)), member); } function transformEnumMemberDeclarationValue(member) { var value = resolver.getConstantValue(member); @@ -40388,16 +41225,16 @@ var ts; if (!currentScopeFirstDeclarationsOfName) { currentScopeFirstDeclarationsOfName = ts.createMap(); } - if (!(name in currentScopeFirstDeclarationsOfName)) { - currentScopeFirstDeclarationsOfName[name] = node; + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_35 = node.symbol && node.symbol.name; - if (name_35) { - return currentScopeFirstDeclarationsOfName[name_35] === node; + var name = node.symbol && node.symbol.name; + if (name) { + return currentScopeFirstDeclarationsOfName.get(name) === node; } } return false; @@ -40409,7 +41246,7 @@ var ts; ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 230) { + if (node.kind === 231) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -40450,8 +41287,9 @@ var ts; var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); + var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg])); ts.setOriginalNode(moduleStatement, node); + ts.setTextRange(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); statements.push(ts.createEndOfDeclarationMarker(node)); @@ -40469,7 +41307,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 232) { + if (body.kind === 233) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -40491,14 +41329,15 @@ var ts; currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 232) { + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); + ts.setTextRange(block, blockLocation); + if (body.kind !== 233) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 231) { + if (moduleDeclaration.body.kind === 232) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -40518,7 +41357,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 238) { + if (node.kind === 239) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -40570,9 +41409,9 @@ var ts; var moduleReference = ts.createExpressionFromEntityName(node.moduleReference); ts.setEmitFlags(moduleReference, 1536 | 2048); if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { - return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ + return ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.setOriginalNode(ts.createVariableDeclaration(node.name, undefined, moduleReference), node) - ]), node), node); + ])), node), node); } else { return ts.setOriginalNode(createNamespaceExport(node.name, moduleReference, node), node); @@ -40593,7 +41432,7 @@ var ts; && ts.hasModifier(node, 512); } function expressionToStatement(expression) { - return ts.createStatement(expression, undefined); + return ts.createStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), ts.getLocalName(node)); @@ -40603,10 +41442,10 @@ var ts; statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue), location); + return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue, location); + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); } function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) { return ts.getNamespaceMemberName(currentNamespaceContainerName, name, false, true); @@ -40622,7 +41461,7 @@ var ts; function getClassAliasIfNeeded(node) { if (resolver.getNodeCheckFlags(node) & 8388608) { enableSubstitutionForClassAliases(); - var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); + var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.unescapeIdentifier(node.name.text) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; hoistVariableDeclaration(classAlias); return classAlias; @@ -40646,24 +41485,24 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(70); - classAliases = ts.createMap(); + classAliases = []; } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(259); - context.enableEmitNotification(231); + context.enableSubstitution(261); + context.enableEmitNotification(232); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 231; + return ts.getOriginalNode(node).kind === 232; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 230; + return ts.getOriginalNode(node).kind === 231; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2; @@ -40671,12 +41510,12 @@ var ts; if (enabledSubstitutions & 8 && isTransformedEnumDeclaration(node)) { applicableSubstitutions |= 8; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -40686,14 +41525,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_36 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_36); + var name = node.name; + var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_36, initializer, node); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); } - return ts.createPropertyAssignment(name_36, exportedName, node); + return ts.setTextRange(ts.createPropertyAssignment(name, exportedName), node); } } return node; @@ -40702,9 +41541,9 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 177: - return substitutePropertyAccessExpression(node); case 178: + return substitutePropertyAccessExpression(node); + case 179: return substituteElementAccessExpression(node); } return node; @@ -40734,11 +41573,11 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 262) { - var substitute = (applicableSubstitutions & 2 && container.kind === 231) || - (applicableSubstitutions & 8 && container.kind === 230); + if (container && container.kind !== 264) { + var substitute = (applicableSubstitutions & 2 && container.kind === 232) || + (applicableSubstitutions & 8 && container.kind === 231); if (substitute) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } } } @@ -40785,10 +41624,10 @@ var ts; }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(paramHelper); - return ts.createCall(ts.getHelperName("__param"), undefined, [ + return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), undefined, [ ts.createLiteral(parameterOffset), expression - ], location); + ]), location); } var metadataHelper = { name: "typescript:metadata", @@ -40812,7 +41651,7 @@ var ts; function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) { context.requestEmitHelper(decorateHelper); var argumentsArray = []; - argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, undefined, true)); + argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, true)); argumentsArray.push(target); if (memberName) { argumentsArray.push(memberName); @@ -40820,7 +41659,7 @@ var ts; argumentsArray.push(descriptor); } } - return ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray, location); + return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray), location); } })(ts || (ts = {})); var ts; @@ -40847,37 +41686,37 @@ var ts; return node; } switch (node.kind) { - case 176: + case 177: return visitObjectLiteralExpression(node); - case 192: + case 193: return visitBinaryExpression(node, noDestructuringValue); - case 224: + case 225: return visitVariableDeclaration(node); - case 214: + case 215: return visitForOfStatement(node); - case 212: + case 213: return visitForStatement(node); - case 188: + case 189: return visitVoidExpression(node); - case 150: - return visitConstructorDeclaration(node); - case 149: - return visitMethodDeclaration(node); case 151: - return visitGetAccessorDeclaration(node); + return visitConstructorDeclaration(node); + case 150: + return visitMethodDeclaration(node); case 152: + return visitGetAccessorDeclaration(node); + case 153: return visitSetAccessorDeclaration(node); - case 226: + case 227: return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); case 185: + return visitFunctionExpression(node); + case 186: return visitArrowFunction(node); - case 144: + case 145: return visitParameter(node); - case 208: + case 209: return visitExpressionStatement(node); - case 183: + case 184: return visitParenthesizedExpression(node, noDestructuringValue); default: return ts.visitEachChild(node, visitor, context); @@ -40886,9 +41725,9 @@ var ts; function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; - for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { - var e = elements_3[_i]; - if (e.kind === 260) { + for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { + var e = elements_4[_i]; + if (e.kind === 262) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -40900,7 +41739,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 258) { + if (e.kind === 260) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -40917,7 +41756,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 1048576) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 176) { + if (objects.length && objects[0].kind !== 177) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -40961,25 +41800,26 @@ var ts; var firstDeclaration = ts.firstOrUndefined(initializer.declarations); var declarations = ts.flattenDestructuringBinding(firstDeclaration, visitor, context, 1, temp, false, true); if (ts.some(declarations)) { - var statement = ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(initializer, declarations), initializer); + var statement = ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(initializer, declarations)); + ts.setTextRange(statement, initializer); leadingStatements = ts.append(leadingStatements, statement); } } else if (ts.isAssignmentPattern(initializer)) { temp = ts.createTempVariable(undefined); - var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.createAssignment(initializer, temp, node.initializer)), visitor, context, 1); - leadingStatements = ts.append(leadingStatements, ts.createStatement(expression, node.initializer)); + var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.setTextRange(ts.createAssignment(initializer, temp), node.initializer)), visitor, context, 1); + leadingStatements = ts.append(leadingStatements, ts.setTextRange(ts.createStatement(expression), node.initializer)); } } if (temp) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var statement = ts.visitNode(node.statement, visitor, ts.isStatement); var block = ts.isBlock(statement) - ? ts.updateBlock(statement, ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements), statement.statements)) - : ts.createBlock(ts.append(leadingStatements, statement), statement, true); - return ts.updateForOf(node, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, undefined, undefined, node.initializer) - ], node.initializer, 1), expression, block); + ? ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements)), statement.statements)) + : ts.setTextRange(ts.createBlock(ts.append(leadingStatements, statement), true), statement); + return ts.updateForOf(node, ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer) + ], 1), node.initializer), expression, block); } return ts.visitEachChild(node, visitor, context); } @@ -41029,7 +41869,7 @@ var ts; var trailingStatements = endLexicalEnvironment(); if (ts.some(leadingStatements) || ts.some(trailingStatements)) { var block = ts.convertToFunctionBody(body, true); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements)), block.statements)); } return body; } @@ -41042,6 +41882,9 @@ var ts; text: "\n var __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };" }; function createAssignHelper(context, attributesSegments) { + if (context.getCompilerOptions().target >= 2) { + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), undefined, attributesSegments); + } context.requestEmitHelper(assignHelper); return ts.createCall(ts.getHelperName("__assign"), undefined, attributesSegments); } @@ -41073,11 +41916,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 247: - return visitJsxElement(node, false); case 248: + return visitJsxElement(node, false); + case 249: return visitJsxSelfClosingElement(node, false); - case 253: + case 255: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -41087,11 +41930,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 253: + case 255: return visitJsxExpression(node); - case 247: - return visitJsxElement(node, true); case 248: + return visitJsxElement(node, true); + case 249: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -41107,7 +41950,7 @@ var ts; function visitJsxOpeningLikeElement(node, children, isChild, location) { var tagName = getTagName(node); var objectProperties; - var attrs = node.attributes; + var attrs = node.attributes.properties; if (attrs.length === 0) { objectProperties = ts.createNull(); } @@ -41139,15 +41982,15 @@ var ts; } function transformJsxAttributeInitializer(node) { if (node === undefined) { - return ts.createLiteral(true); + return ts.createTrue(); } else if (node.kind === 9) { var decoded = tryDecodeEntities(node.text); - return decoded ? ts.createLiteral(decoded, node) : node; + return decoded ? ts.setTextRange(ts.createLiteral(decoded), node) : node; } - else if (node.kind === 253) { + else if (node.kind === 255) { if (node.expression === undefined) { - return ts.createLiteral(true); + return ts.createTrue(); } return visitJsxExpression(node); } @@ -41156,43 +41999,35 @@ var ts; } } function visitJsxText(node) { - var text = ts.getTextOfNode(node, true); - var parts; + var fixed = fixupWhitespaceAndDecodeEntities(ts.getTextOfNode(node, true)); + return fixed === undefined ? undefined : ts.createLiteral(fixed); + } + function fixupWhitespaceAndDecodeEntities(text) { + var acc; 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); - if (!parts) { - parts = []; - } - parts.push(ts.createLiteral(decodeEntities(part))); + if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) { + acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); } firstNonWhitespace = -1; } - else if (!ts.isWhiteSpace(c)) { + else if (!ts.isWhiteSpaceSingleLine(c)) { lastNonWhitespace = i; if (firstNonWhitespace === -1) { firstNonWhitespace = i; } } } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - if (!parts) { - parts = []; - } - parts.push(ts.createLiteral(decodeEntities(part))); - } - if (parts) { - return ts.reduceLeft(parts, aggregateJsxTextParts); - } - return undefined; + return firstNonWhitespace !== -1 + ? addLineOfJsxText(acc, text.substr(firstNonWhitespace)) + : acc; } - function aggregateJsxTextParts(left, right) { - return ts.createAdd(ts.createAdd(left, ts.createLiteral(" ")), right); + function addLineOfJsxText(acc, trimmedLine) { + var decoded = decodeEntities(trimmedLine); + return acc === undefined ? decoded : acc + " " + decoded; } function decodeEntities(text) { return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) { @@ -41203,7 +42038,7 @@ var ts; return String.fromCharCode(parseInt(hex, 16)); } else { - var ch = entities[word]; + var ch = entities.get(word); return ch ? String.fromCharCode(ch) : match; } }); @@ -41213,16 +42048,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 247) { + if (node.kind === 248) { return getTagName(node.openingElement); } else { - var name_37 = node.tagName; - if (ts.isIdentifier(name_37) && ts.isIntrinsicJsxName(name_37.text)) { - return ts.createLiteral(name_37.text); + var name = node.tagName; + if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.text)) { + return ts.createLiteral(name.text); } else { - return ts.createExpressionFromEntityName(name_37); + return ts.createExpressionFromEntityName(name); } } } @@ -41240,7 +42075,7 @@ var ts; } } ts.transformJsx = transformJsx; - var entities = ts.createMap({ + var entities = ts.createMapFromTemplate({ "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, @@ -41498,6 +42333,10 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); function transformES2017(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var resolver = context.getEmitResolver(); @@ -41528,22 +42367,22 @@ var ts; switch (node.kind) { case 119: return undefined; - case 189: + case 190: return visitAwaitExpression(node); - case 149: + case 150: return visitMethodDeclaration(node); - case 226: + case 227: return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); case 185: + return visitFunctionExpression(node); + case 186: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); } function visitMethodDeclaration(node) { return ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) @@ -41573,14 +42412,15 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 185; + var isArrowFunction = node.kind === 186; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(statements, node.body, true); + var block = ts.createBlock(statements, true); + ts.setTextRange(block, node.body); if (languageVersion >= 2) { if (resolver.getNodeCheckFlags(node) & 4096) { enableSubstitutionForAsyncMethodsWithSuper(); @@ -41598,7 +42438,7 @@ var ts; var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(block.statements, declarations), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); } return expression; } @@ -41611,7 +42451,7 @@ var ts; startLexicalEnvironment(); var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); var declarations = endLexicalEnvironment(); - return ts.updateBlock(visited, ts.createNodeArray(ts.concatenate(visited.statements, declarations), visited.statements)); + return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); } } function getPromiseConstructor(type) { @@ -41628,23 +42468,23 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(179); - context.enableSubstitution(177); + context.enableSubstitution(180); context.enableSubstitution(178); - context.enableEmitNotification(227); - context.enableEmitNotification(149); - context.enableEmitNotification(151); - context.enableEmitNotification(152); + context.enableSubstitution(179); + context.enableEmitNotification(228); context.enableEmitNotification(150); + context.enableEmitNotification(152); + context.enableEmitNotification(153); + context.enableEmitNotification(151); } } function substituteExpression(node) { switch (node.kind) { - case 177: - return substitutePropertyAccessExpression(node); case 178: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 179: + return substituteElementAccessExpression(node); + case 180: if (enabledSubstitutions & 1) { return substituteCallExpression(node); } @@ -41687,36 +42527,36 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 227 - || kind === 150 - || kind === 149 + return kind === 228 || kind === 151 - || kind === 152; + || kind === 150 + || kind === 152 + || kind === 153; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { if (enabledSubstitutions & 1 && isSuperContainer(node)) { var savedCurrentSuperContainer = currentSuperContainer; currentSuperContainer = node; - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSuperContainer = savedCurrentSuperContainer; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } return node; } function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { if (flags & 4096) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value"), location); } else { - return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), location); } } function getSuperContainerAsyncMethodFlags() { @@ -41769,7 +42609,7 @@ var ts; return node; } switch (node.kind) { - case 192: + case 193: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -41793,19 +42633,19 @@ var ts; if (ts.isElementAccessExpression(left)) { var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, left.argumentExpression), left); - value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, left); + target = ts.setTextRange(ts.createElementAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(ts.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left); + value = ts.setTextRange(ts.createElementAccess(expressionTemp, argumentExpressionTemp), left); } else if (ts.isPropertyAccessExpression(left)) { var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), left.name, left); - value = ts.createPropertyAccess(expressionTemp, left.name, left); + target = ts.setTextRange(ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), left.name), left); + value = ts.setTextRange(ts.createPropertyAccess(expressionTemp, left.name), left); } else { target = left; value = left; } - return ts.createAssignment(target, ts.createMathPow(value, right, node), node); + return ts.setTextRange(ts.createAssignment(target, ts.createMathPow(value, right, node)), node); } function visitExponentiationExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); @@ -41817,6 +42657,75 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var ES2015SubstitutionFlags; + (function (ES2015SubstitutionFlags) { + ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; + ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; + })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); + var HierarchyFacts; + (function (HierarchyFacts) { + HierarchyFacts[HierarchyFacts["None"] = 0] = "None"; + HierarchyFacts[HierarchyFacts["Function"] = 1] = "Function"; + HierarchyFacts[HierarchyFacts["ArrowFunction"] = 2] = "ArrowFunction"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBody"] = 4] = "AsyncFunctionBody"; + HierarchyFacts[HierarchyFacts["NonStaticClassElement"] = 8] = "NonStaticClassElement"; + HierarchyFacts[HierarchyFacts["CapturesThis"] = 16] = "CapturesThis"; + HierarchyFacts[HierarchyFacts["ExportedVariableStatement"] = 32] = "ExportedVariableStatement"; + HierarchyFacts[HierarchyFacts["TopLevel"] = 64] = "TopLevel"; + HierarchyFacts[HierarchyFacts["Block"] = 128] = "Block"; + HierarchyFacts[HierarchyFacts["IterationStatement"] = 256] = "IterationStatement"; + HierarchyFacts[HierarchyFacts["IterationStatementBlock"] = 512] = "IterationStatementBlock"; + HierarchyFacts[HierarchyFacts["ForStatement"] = 1024] = "ForStatement"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 2048] = "ForInOrForOfStatement"; + HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 4096] = "ConstructorWithCapturedSuper"; + HierarchyFacts[HierarchyFacts["ComputedPropertyName"] = 8192] = "ComputedPropertyName"; + HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask"; + HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes"; + HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 4032] = "BlockScopeExcludes"; + HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 64] = "SourceFileIncludes"; + HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 3968] = "SourceFileExcludes"; + HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes"; + HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 16256] = "ArrowFunctionExcludes"; + HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes"; + HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes"; + HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 256] = "DoOrWhileStatementIncludes"; + HierarchyFacts[HierarchyFacts["DoOrWhileStatementExcludes"] = 0] = "DoOrWhileStatementExcludes"; + HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 1280] = "ForStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 3008] = "ForStatementExcludes"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 2304] = "ForInOrForOfStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 1984] = "ForInOrForOfStatementExcludes"; + HierarchyFacts[HierarchyFacts["BlockIncludes"] = 128] = "BlockIncludes"; + HierarchyFacts[HierarchyFacts["BlockExcludes"] = 3904] = "BlockExcludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 4032] = "IterationStatementBlockExcludes"; + HierarchyFacts[HierarchyFacts["ComputedPropertyNameIncludes"] = 8192] = "ComputedPropertyNameIncludes"; + HierarchyFacts[HierarchyFacts["ComputedPropertyNameExcludes"] = 0] = "ComputedPropertyNameExcludes"; + HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget"; + HierarchyFacts[HierarchyFacts["NewTargetInComputedPropertyName"] = 32768] = "NewTargetInComputedPropertyName"; + HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask"; + HierarchyFacts[HierarchyFacts["PropagateNewTargetMask"] = 49152] = "PropagateNewTargetMask"; + })(HierarchyFacts || (HierarchyFacts = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -41853,7 +42762,7 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return hierarchyFacts & 4096 - && node.kind === 217 + && node.kind === 218 && !node.expression; } function shouldVisitNode(node) { @@ -41886,91 +42795,91 @@ var ts; switch (node.kind) { case 114: return undefined; - case 227: + case 228: return visitClassDeclaration(node); - case 197: + case 198: return visitClassExpression(node); - case 144: + case 145: return visitParameter(node); - case 226: + case 227: return visitFunctionDeclaration(node); - case 185: + case 186: return visitArrowFunction(node); - case 184: + case 185: return visitFunctionExpression(node); - case 224: + case 225: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 225: + case 226: return visitVariableDeclarationList(node); - case 219: - return visitSwitchStatement(node); - case 233: - return visitCaseBlock(node); - case 205: - return visitBlock(node, false); - case 216: - case 215: - return visitBreakOrContinueStatement(node); case 220: + return visitSwitchStatement(node); + case 234: + return visitCaseBlock(node); + case 206: + return visitBlock(node, false); + case 217: + case 216: + return visitBreakOrContinueStatement(node); + case 221: return visitLabeledStatement(node); - case 210: case 211: - return visitDoOrWhileStatement(node, undefined); case 212: - return visitForStatement(node, undefined); + return visitDoOrWhileStatement(node, undefined); case 213: - return visitForInStatement(node, undefined); + return visitForStatement(node, undefined); case 214: + return visitForInStatement(node, undefined); + case 215: return visitForOfStatement(node, undefined); - case 208: + case 209: return visitExpressionStatement(node); - case 176: + case 177: return visitObjectLiteralExpression(node); - case 257: - return visitCatchClause(node); case 259: + return visitCatchClause(node); + case 261: return visitShorthandPropertyAssignment(node); - case 142: + case 143: return visitComputedPropertyName(node); - case 175: + case 176: return visitArrayLiteralExpression(node); - case 179: - return visitCallExpression(node); case 180: + return visitCallExpression(node); + case 181: return visitNewExpression(node); - case 183: + case 184: return visitParenthesizedExpression(node, true); - case 192: + case 193: return visitBinaryExpression(node, true); case 12: case 13: case 14: case 15: return visitTemplateLiteral(node); - case 181: + case 182: return visitTaggedTemplateExpression(node); - case 194: - return visitTemplateExpression(node); case 195: - return visitYieldExpression(node); + return visitTemplateExpression(node); case 196: + return visitYieldExpression(node); + case 197: return visitSpreadElement(node); case 96: return visitSuperKeyword(false); case 98: return visitThisKeyword(node); - case 202: + case 203: return visitMetaProperty(node); - case 149: + case 150: return visitMethodDeclaration(node); - case 151: case 152: + case 153: return visitAccessorDeclaration(node); - case 206: + case 207: return visitVariableStatement(node); - case 217: + case 218: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -41985,7 +42894,7 @@ var ts; ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, 0, 0); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } function visitSwitchStatement(node) { if (convertedLoopState !== undefined) { @@ -42040,20 +42949,20 @@ var ts; if (ts.isGeneratedIdentifier(node)) { return node; } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + if (node.text !== "arguments" || !resolver.isArgumentsLocalBinding(node)) { return node; } return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 216 ? 2 : 4; - var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + var jump = node.kind === 217 ? 2 : 4; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 216) { + if (node.kind === 217) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -42063,7 +42972,7 @@ var ts; } } else { - if (node.kind === 216) { + if (node.kind === 217) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -42096,8 +43005,9 @@ var ts; var variable = ts.createVariableDeclaration(ts.getLocalName(node, true), undefined, transformClassLikeDeclarationToExpression(node)); ts.setOriginalNode(variable, node); var statements = []; - var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable]), node); + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable])); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, node); ts.startOnNewLine(statement); statements.push(statement); if (ts.hasModifier(node, 1)) { @@ -42152,13 +43062,13 @@ var ts; ts.setEmitFlags(statement, 1536 | 384); statements.push(statement); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true); ts.setEmitFlags(block, 1536); return block; } function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node)), extendsClauseElement)); + statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node))), extendsClauseElement)); } } function addConstructor(statements, node, extendsClauseElement) { @@ -42167,7 +43077,8 @@ var ts; var ancestorFacts = enterSubtree(16278, 73); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); + ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 8); } @@ -42214,24 +43125,25 @@ var ts; if (constructor) { prependCaptureNewTargetIfNeeded(statements, constructor, false); } - var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true); + ts.setTextRange(block, constructor ? constructor.body : node); if (!constructor) { ts.setEmitFlags(block, 1536); } return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 217) { + if (statement.kind === 218) { return true; } - else if (statement.kind === 209) { + else if (statement.kind === 210) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 205) { + else if (statement.kind === 206) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -42260,7 +43172,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 208 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 209 && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -42268,8 +43180,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 | 32768))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 192 - || superCallExpression.left.kind !== 179) { + if (superCallExpression.kind !== 193 + || superCallExpression.left.kind !== 180) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } ts.setCommentRange(returnStatement, ts.getCommentRange(ts.setEmitFlags(superCallExpression.left, 1536))); @@ -42293,10 +43205,10 @@ var ts; return undefined; } else if (ts.isBindingPattern(node.name)) { - return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined, node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined), node), node); } else if (node.initializer) { - return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined, node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined), node), node); } else { return node; @@ -42311,15 +43223,15 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_38 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_38)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_38, initializer); + if (ts.isBindingPattern(name)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_38, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer); } } } @@ -42334,10 +43246,11 @@ var ts; } function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer)), parameter)) - ], parameter), 1 | 32 | 384), undefined, parameter); + var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([ + ts.createStatement(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer))), parameter)) + ]), parameter), 1 | 32 | 384)); statement.startsOnNewLine = true; + ts.setTextRange(statement, parameter); ts.setEmitFlags(statement, 384 | 32 | 524288); statements.push(statement); } @@ -42354,22 +43267,22 @@ var ts; var expressionName = ts.getSynthesizedClone(parameter.name); var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) - ]), parameter), 524288)); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ])), parameter), 524288)); + var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) - ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 + ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ + ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp - : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) + : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), parameter)) ])); ts.setEmitFlags(forStatement, 524288); ts.startOnNewLine(forStatement); statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 && node.kind !== 185) { + if (node.transformFlags & 32768 && node.kind !== 186) { captureThisForNode(statements, node, ts.createThis()); } } @@ -42377,8 +43290,9 @@ var ts; enableSubstitutionsForCapturedThis(); var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("_this", undefined, initializer) - ]), originalStatement); + ])); ts.setEmitFlags(captureThisStatement, 1536 | 524288); + ts.setTextRange(captureThisStatement, originalStatement); ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } @@ -42386,18 +43300,18 @@ var ts; if (hierarchyFacts & 16384) { var newTarget = void 0; switch (node.kind) { - case 185: + case 186: return statements; - case 149: - case 151: + case 150: case 152: + case 153: newTarget = ts.createVoidZero(); break; - case 150: + case 151: newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); break; - case 226: - case 184: + case 227: + case 185: newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 92, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); break; default: @@ -42418,20 +43332,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 204: + case 205: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 149: + case 150: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 151: case 152: + case 153: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 150: + case 151: break; default: ts.Debug.failBadSyntaxKind(node); @@ -42440,7 +43354,7 @@ var ts; } } function transformSemicolonClassElementToStatement(member) { - return ts.createEmptyStatement(member); + return ts.setTextRange(ts.createEmptyStatement(), member); } function transformClassMethodDeclarationToStatement(receiver, member, container) { var ancestorFacts = enterSubtree(0, 0); @@ -42450,7 +43364,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); ts.setEmitFlags(memberFunction, 1536); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), member); + var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); ts.setEmitFlags(statement, 48); @@ -42458,8 +43372,9 @@ var ts; return statement; } function transformAccessorsToStatement(receiver, accessors, container) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false), ts.getSourceMapRange(accessors.firstAccessor)); + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false)); ts.setEmitFlags(statement, 1536); + ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { @@ -42488,11 +43403,11 @@ var ts; ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } - properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); + properties.push(ts.createPropertyAssignment("enumerable", ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue())); var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ target, propertyName, - ts.createObjectLiteral(properties, undefined, true) + ts.createObjectLiteral(properties, true) ]); if (startsOnNewLine) { call.startsOnNewLine = true; @@ -42507,7 +43422,8 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = enterSubtree(16256, 66); - var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node), node); + var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + ts.setTextRange(func, node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8); exitSubtree(ancestorFacts, 0, 0); @@ -42554,12 +43470,12 @@ var ts; : enterSubtree(16286, 65); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 && !name && (node.kind === 226 || node.kind === 184)) { + if (hierarchyFacts & 16384 && !name && (node.kind === 227 || node.kind === 185)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152, 0); convertedLoopState = savedConvertedLoopState; - return ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body, location), node); + return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body), location), node); } function transformFunctionBody(node) { var multiLine = false; @@ -42587,7 +43503,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 185); + ts.Debug.assert(node.kind === 186); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -42599,7 +43515,8 @@ var ts; } } var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, body); + var returnStatement = ts.createReturn(expression); + ts.setTextRange(returnStatement, body); ts.setEmitFlags(returnStatement, 384 | 32 | 1024); statements.push(returnStatement); closeBraceLocation = body; @@ -42610,7 +43527,8 @@ var ts; if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), multiLine); + ts.setTextRange(block, node.body); if (!multiLine && singleLine) { ts.setEmitFlags(block, 1); } @@ -42622,7 +43540,7 @@ var ts; } function visitFunctionBodyDownLevel(node) { var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); - return ts.updateBlock(updated, ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, true), updated.statements)); + return ts.updateBlock(updated, ts.setTextRange(ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, true)), updated.statements)); } function visitBlock(node, isFunctionBody) { if (isFunctionBody) { @@ -42637,9 +43555,9 @@ var ts; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 183: + case 184: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 192: + case 193: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -42647,9 +43565,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 183: + case 184: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 192: + case 193: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -42681,7 +43599,7 @@ var ts; } } if (assignments) { - updated = ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); + updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); })), node); } else { updated = undefined; @@ -42701,8 +43619,9 @@ var ts; var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 ? visitVariableDeclarationInLetDeclarationList : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, node); + var declarationList = ts.createVariableDeclarationList(declarations); ts.setOriginalNode(declarationList, node); + ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); if (node.transformFlags & 8388608 && (ts.isBindingPattern(node.declarations[0].name) @@ -42756,10 +43675,10 @@ var ts; return updated; } function recordLabel(node) { - convertedLoopState.labels[node.label.text] = node.label.text; + convertedLoopState.labels.set(node.label.text, node.label.text); } function resetLabel(node) { - convertedLoopState.labels[node.label.text] = undefined; + convertedLoopState.labels.set(node.label.text, undefined); } function visitLabeledStatement(node) { if (convertedLoopState && !convertedLoopState.labels) { @@ -42794,7 +43713,7 @@ var ts; var statements = []; var counter = ts.createLoopVariable(); var rhsReference = expression.kind === 70 - ? ts.createUniqueName(expression.text) + ? ts.createUniqueName(ts.unescapeIdentifier(expression.text)) : ts.createTempVariable(undefined); var elementAccess = ts.createElementAccess(rhsReference, counter); if (ts.isVariableDeclarationList(initializer)) { @@ -42804,17 +43723,18 @@ var ts; var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, elementAccess); - var declarationList = ts.createVariableDeclarationList(declarations, initializer); + var declarationList = ts.createVariableDeclarationList(declarations); ts.setOriginalNode(declarationList, initializer); + ts.setTextRange(declarationList, initializer); var firstDeclaration = declarations[0]; var lastDeclaration = ts.lastOrUndefined(declarations); ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); statements.push(ts.createVariableStatement(undefined, declarationList)); } else { - statements.push(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.createVariableDeclarationList([ + statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) - ], ts.moveRangePos(initializer, -1)), initializer), ts.moveRangeEnd(initializer, -1))); + ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); } } else { @@ -42824,7 +43744,7 @@ var ts; } else { assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createStatement(assignment), ts.moveRangeEnd(initializer, -1))); } } var bodyLocation; @@ -42833,7 +43753,7 @@ var ts; ts.addRange(statements, convertedLoopBodyStatements); } else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -42844,25 +43764,27 @@ var ts; } } ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression)); - var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); + var body = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation)); + ts.setTextRange(body, bodyLocation); ts.setEmitFlags(body, 48 | 384); - var forStatement = ts.createFor(ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) - ], node.expression), 1048576), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); + var forStatement = ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)), + ts.setTextRange(ts.createVariableDeclaration(rhsReference, undefined, expression), node.expression) + ]), node.expression), 1048576), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), body); ts.setEmitFlags(forStatement, 256); + ts.setTextRange(forStatement, node); return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 210: case 211: - return visitDoOrWhileStatement(node, outermostLabeledStatement); case 212: - return visitForStatement(node, outermostLabeledStatement); + return visitDoOrWhileStatement(node, outermostLabeledStatement); case 213: - return visitForInStatement(node, outermostLabeledStatement); + return visitForStatement(node, outermostLabeledStatement); case 214: + return visitForInStatement(node, outermostLabeledStatement); + case 215: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -42877,7 +43799,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 142) { + if (property.name.kind === 143) { numInitialProperties = i; break; } @@ -42888,7 +43810,7 @@ var ts; } var temp = ts.createTempVariable(hoistVariableDeclaration); var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 32768)); if (node.multiLine) { assignment.startsOnNewLine = true; } @@ -42939,11 +43861,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 212: case 213: case 214: + case 215: var initializer = node.initializer; - if (initializer && initializer.kind === 225) { + if (initializer && initializer.kind === 226) { loopInitializer = initializer; } break; @@ -42980,13 +43902,13 @@ var ts; copyOutParameters(loopOutParameters, 1, statements_4); } ts.addRange(statements_4, lexicalEnvironment); - loopBody = ts.createBlock(statements_4, undefined, true); + loopBody = ts.createBlock(statements_4, true); } if (ts.isBlock(loopBody)) { loopBody.multiLine = true; } else { - loopBody = ts.createBlock([loopBody], undefined, true); + loopBody = ts.createBlock([loopBody], true); } var isAsyncBlockContainingAwait = hierarchyFacts & 4 && (node.statement.transformFlags & 16777216) !== 0; @@ -43053,7 +43975,7 @@ var ts; var clone_4 = ts.getMutableClone(node); clone_4.statement = undefined; clone_4 = ts.visitEachChild(clone_4, visitor, context); - clone_4.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, true); clone_4.transformFlags = 0; ts.aggregateTransformFlags(clone_4); loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); @@ -43117,23 +44039,22 @@ var ts; if (!state.labeledNonLocalBreaks) { state.labeledNonLocalBreaks = ts.createMap(); } - state.labeledNonLocalBreaks[labelText] = labelMarker; + state.labeledNonLocalBreaks.set(labelText, labelMarker); } else { if (!state.labeledNonLocalContinues) { state.labeledNonLocalContinues = ts.createMap(); } - state.labeledNonLocalContinues[labelText] = labelMarker; + state.labeledNonLocalContinues.set(labelText, labelMarker); } } function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { if (!table) { return; } - for (var labelText in table) { - var labelMarker = table[labelText]; + table.forEach(function (labelMarker, labelText) { var statements = []; - if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) { var label = ts.createIdentifier(labelText); statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); } @@ -43142,7 +44063,7 @@ var ts; statements.push(ts.createReturn(loopResultName)); } caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); - } + }); } function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { var name = decl.name; @@ -43157,7 +44078,7 @@ var ts; else { loopParameters.push(ts.createParameter(undefined, undefined, undefined, name)); if (resolver.getNodeCheckFlags(decl) & 2097152) { - var outParamName = ts.createUniqueName("out_" + name.text); + var outParamName = ts.createUniqueName("out_" + ts.unescapeIdentifier(name.text)); loopOutParameters.push({ originalName: name, outParamName: outParamName }); } } @@ -43168,20 +44089,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 151: case 152: + case 153: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 149: + case 150: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 258: + case 260: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 259: + case 261: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -43191,14 +44112,16 @@ var ts; } } function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -43206,7 +44129,8 @@ var ts; } function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { var ancestorFacts = enterSubtree(0, 0); - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container), method); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container)); + ts.setTextRange(expression, method); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -43218,9 +44142,11 @@ var ts; var updated; if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var newVariableDeclaration = ts.createVariableDeclaration(temp); + ts.setTextRange(newVariableDeclaration, node.variableDeclaration); var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); - var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); + var list = ts.createVariableDeclarationList(vars); + ts.setTextRange(list, node.variableDeclaration); var destructure = ts.createVariableStatement(undefined, list); updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); } @@ -43238,7 +44164,7 @@ var ts; ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined); ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression)); - return ts.createPropertyAssignment(node.name, functionExpression, node); + return ts.setTextRange(ts.createPropertyAssignment(node.name, functionExpression), node); } function visitAccessorDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); @@ -43251,7 +44177,7 @@ var ts; return updated; } function visitShorthandPropertyAssignment(node) { - return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), node); + return ts.setTextRange(ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name)), node); } function visitComputedPropertyName(node) { var ancestorFacts = enterSubtree(0, 8192); @@ -43313,7 +44239,7 @@ var ts; })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 175 + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 176 ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -43328,7 +44254,7 @@ var ts; return ts.map(chunk, visitExpressionOfSpread); } function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { - return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, undefined, hasTrailingComma), visitor, ts.isExpression), undefined, multiLine); + return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -43337,7 +44263,7 @@ var ts; return ts.visitNode(node.expression, visitor, ts.isExpression); } function visitTemplateLiteral(node) { - return ts.createLiteral(node.text, node); + return ts.setTextRange(ts.createLiteral(node.text), node); } function visitTaggedTemplateExpression(node) { var tag = ts.visitNode(node.tag, visitor, ts.isExpression); @@ -43371,7 +44297,7 @@ var ts; var isLast = node.kind === 12 || node.kind === 15; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); - return ts.createLiteral(text, node); + return ts.setTextRange(ts.createLiteral(text), node); } function visitTemplateExpression(node) { var expressions = []; @@ -43379,7 +44305,8 @@ var ts; addTemplateSpans(expressions, node); var expression = ts.reduceLeft(expressions, ts.createAdd); if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); + expression.pos = node.pos; + expression.end = node.end; } return expression; } @@ -43420,16 +44347,16 @@ var ts; } return node; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8 ? 65 | 16 : 65); - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); exitSubtree(ancestorFacts, 0, 0); return; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { @@ -43441,18 +44368,18 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(98); - context.enableEmitNotification(150); - context.enableEmitNotification(149); context.enableEmitNotification(151); + context.enableEmitNotification(150); context.enableEmitNotification(152); + context.enableEmitNotification(153); + context.enableEmitNotification(186); context.enableEmitNotification(185); - context.enableEmitNotification(184); - context.enableEmitNotification(226); + context.enableEmitNotification(227); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -43472,10 +44399,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 174: - case 227: - case 230: - case 224: + case 175: + case 228: + case 231: + case 225: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -43502,7 +44429,7 @@ var ts; function substituteThisKeyword(node) { if (enabledSubstitutions & 1 && hierarchyFacts & 16) { - return ts.createIdentifier("_this", node); + return ts.setTextRange(ts.createIdentifier("_this"), node); } return node; } @@ -43518,11 +44445,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 208) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 209) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 179) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 180) { return false; } var callTarget = statementExpression.expression; @@ -43530,7 +44457,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 196) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 197) { return false; } var expression = callArgument.expression; @@ -43554,13 +44481,60 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var instructionNames = ts.createMap((_a = {}, - _a[2] = "return", - _a[3] = "break", - _a[4] = "yield", - _a[5] = "yield*", - _a[7] = "endfinally", - _a)); + var OpCode; + (function (OpCode) { + OpCode[OpCode["Nop"] = 0] = "Nop"; + OpCode[OpCode["Statement"] = 1] = "Statement"; + OpCode[OpCode["Assign"] = 2] = "Assign"; + OpCode[OpCode["Break"] = 3] = "Break"; + OpCode[OpCode["BreakWhenTrue"] = 4] = "BreakWhenTrue"; + OpCode[OpCode["BreakWhenFalse"] = 5] = "BreakWhenFalse"; + OpCode[OpCode["Yield"] = 6] = "Yield"; + OpCode[OpCode["YieldStar"] = 7] = "YieldStar"; + OpCode[OpCode["Return"] = 8] = "Return"; + OpCode[OpCode["Throw"] = 9] = "Throw"; + OpCode[OpCode["Endfinally"] = 10] = "Endfinally"; + })(OpCode || (OpCode = {})); + var BlockAction; + (function (BlockAction) { + BlockAction[BlockAction["Open"] = 0] = "Open"; + BlockAction[BlockAction["Close"] = 1] = "Close"; + })(BlockAction || (BlockAction = {})); + var CodeBlockKind; + (function (CodeBlockKind) { + CodeBlockKind[CodeBlockKind["Exception"] = 0] = "Exception"; + CodeBlockKind[CodeBlockKind["With"] = 1] = "With"; + CodeBlockKind[CodeBlockKind["Switch"] = 2] = "Switch"; + CodeBlockKind[CodeBlockKind["Loop"] = 3] = "Loop"; + CodeBlockKind[CodeBlockKind["Labeled"] = 4] = "Labeled"; + })(CodeBlockKind || (CodeBlockKind = {})); + var ExceptionBlockState; + (function (ExceptionBlockState) { + ExceptionBlockState[ExceptionBlockState["Try"] = 0] = "Try"; + ExceptionBlockState[ExceptionBlockState["Catch"] = 1] = "Catch"; + ExceptionBlockState[ExceptionBlockState["Finally"] = 2] = "Finally"; + ExceptionBlockState[ExceptionBlockState["Done"] = 3] = "Done"; + })(ExceptionBlockState || (ExceptionBlockState = {})); + var Instruction; + (function (Instruction) { + Instruction[Instruction["Next"] = 0] = "Next"; + Instruction[Instruction["Throw"] = 1] = "Throw"; + Instruction[Instruction["Return"] = 2] = "Return"; + Instruction[Instruction["Break"] = 3] = "Break"; + Instruction[Instruction["Yield"] = 4] = "Yield"; + Instruction[Instruction["YieldStar"] = 5] = "YieldStar"; + Instruction[Instruction["Catch"] = 6] = "Catch"; + Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; + })(Instruction || (Instruction = {})); + function getInstructionName(instruction) { + switch (instruction) { + case 2: return "return"; + case 3: return "break"; + case 4: return "yield"; + case 5: return "yield*"; + case 7: return "endfinally"; + } + } function transformGenerators(context) { var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); @@ -43626,13 +44600,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 210: - return visitDoStatement(node); case 211: + return visitDoStatement(node); + case 212: return visitWhileStatement(node); - case 219: - return visitSwitchStatement(node); case 220: + return visitSwitchStatement(node); + case 221: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -43640,24 +44614,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 226: + case 227: return visitFunctionDeclaration(node); - case 184: + case 185: return visitFunctionExpression(node); - case 151: case 152: + case 153: return visitAccessorDeclaration(node); - case 206: + case 207: return visitVariableStatement(node); - case 212: - return visitForStatement(node); case 213: + return visitForStatement(node); + case 214: return visitForInStatement(node); - case 216: - return visitBreakStatement(node); - case 215: - return visitContinueStatement(node); case 217: + return visitBreakStatement(node); + case 216: + return visitContinueStatement(node); + case 218: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -43673,21 +44647,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 192: - return visitBinaryExpression(node); case 193: + return visitBinaryExpression(node); + case 194: return visitConditionalExpression(node); - case 195: + case 196: return visitYieldExpression(node); - case 175: - return visitArrayLiteralExpression(node); case 176: + return visitArrayLiteralExpression(node); + case 177: return visitObjectLiteralExpression(node); - case 178: - return visitElementAccessExpression(node); case 179: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 180: + return visitCallExpression(node); + case 181: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -43695,9 +44669,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 226: + case 227: return visitFunctionDeclaration(node); - case 184: + case 185: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -43706,7 +44680,7 @@ var ts; } function visitFunctionDeclaration(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { - node = ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -43727,7 +44701,7 @@ var ts; } function visitFunctionExpression(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { - node = ts.setOriginalNode(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -43797,7 +44771,7 @@ var ts; operationArguments = savedOperationArguments; operationLocations = savedOperationLocations; state = savedState; - return ts.createBlock(statements, body, body.multiLine); + return ts.setTextRange(ts.createBlock(statements, body.multiLine), body); } function visitVariableStatement(node) { if (node.transformFlags & 16777216) { @@ -43854,10 +44828,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 177: + case 178: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 178: + case 179: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -43866,7 +44840,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 57, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.setTextRange(ts.createAssignment(target, ts.setTextRange(ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -43965,13 +44939,13 @@ var ts; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, location, multiLine); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { emitAssignment(temp, hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, undefined, multiLine)); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); hasAssignedTemp = true; leadingElement = undefined; expressions = []; @@ -43985,7 +44959,7 @@ var ts; var multiLine = node.multiLine; var numInitialProperties = countInitialNodesWithoutYield(properties); var temp = declareLocal(); - emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, multiLine)); + emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine)); var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties); expressions.push(multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); return ts.inlineExpressions(expressions); @@ -44024,7 +44998,7 @@ var ts; function visitNewExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, ts.createVoidZero())), undefined, [], node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, ts.createVoidZero())), undefined, []), node), node); } return ts.visitEachChild(node, visitor, context); } @@ -44053,35 +45027,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 205: + case 206: return transformAndEmitBlock(node); - case 208: - return transformAndEmitExpressionStatement(node); case 209: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 210: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 211: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 212: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 213: + return transformAndEmitForStatement(node); + case 214: return transformAndEmitForInStatement(node); - case 215: - return transformAndEmitContinueStatement(node); case 216: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 217: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 218: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 219: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 220: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 221: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 222: + return transformAndEmitThrowStatement(node); + case 223: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -44101,9 +45075,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - var name_39 = ts.getSynthesizedClone(variable.name); - ts.setCommentRange(name_39, variable.name); - hoistVariableDeclaration(name_39); + var name = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name, variable.name); + hoistVariableDeclaration(name); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -44212,7 +45186,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression), initializer)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -44222,7 +45196,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression), node.incrementor)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -44367,7 +45341,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 255 && defaultClauseIndex === -1) { + if (clause.kind === 257 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -44377,7 +45351,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 254) { + if (clause.kind === 256) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -44479,9 +45453,9 @@ var ts; } return -1; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } return node; @@ -44493,14 +45467,14 @@ var ts; return node; } function substituteExpressionIdentifier(node) { - if (renamedCatchVariables && ts.hasProperty(renamedCatchVariables, node.text)) { + if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { var original = ts.getOriginalNode(node); if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_40 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_40) { - var clone_7 = ts.getMutableClone(name_40); + var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; + if (name) { + var clone_7 = ts.getMutableClone(name); ts.setSourceMapRange(clone_7, node); ts.setCommentRange(clone_7, node); return clone_7; @@ -44608,10 +45582,10 @@ var ts; var name = declareLocal(text); if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = ts.createMap(); + renamedCatchVariableDeclarations = []; context.enableSubstitution(70); } - renamedCatchVariables[text] = true; + renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; var exception = peekBlock(); ts.Debug.assert(exception.state < 1); @@ -44812,23 +45786,23 @@ var ts; } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); - literal.trailingComment = instructionNames[instruction]; + literal.trailingComment = getInstructionName(instruction); return literal; } function createInlineBreak(label, location) { ts.Debug.assert(label > 0, "Invalid label: " + label); - return ts.createReturn(ts.createArrayLiteral([ + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), location); + ])), location); } function createInlineReturn(expression, location) { - return ts.createReturn(ts.createArrayLiteral(expression + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), location); + : [createInstruction(2)])), location); } function createGeneratorResume(location) { - return ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, [], location); + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, []), location); } function emitNop() { emitWorker(0); @@ -44894,7 +45868,7 @@ var ts; currentExceptionBlock = undefined; withBlockStack = undefined; var buildResult = buildStatements(); - return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 262144)); + return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, buildResult.length > 0)), 262144)); } function buildStatements() { if (operations) { @@ -45103,51 +46077,51 @@ var ts; } } function writeAssign(left, right, operationLocation) { - writeStatement(ts.createStatement(ts.createAssignment(left, right), operationLocation)); + writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); } function writeThrow(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createThrow(expression, operationLocation)); + writeStatement(ts.setTextRange(ts.createThrow(expression), operationLocation)); } function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), operationLocation), 384)); + : [createInstruction(2)])), operationLocation), 384)); } function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation), 384)); + ])), operationLocation), 384)); } function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation), 384)), 1)); + ])), operationLocation), 384)), 1)); } function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation), 384)), 1)); + ])), operationLocation), 384)), 1)); } function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4), expression] - : [createInstruction(4)]), operationLocation), 384)); + : [createInstruction(4)])), operationLocation), 384)); } function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(5), expression - ]), operationLocation), 384)); + ])), operationLocation), 384)); } function writeEndfinally() { lastOperationWasAbrupt = true; @@ -45167,7 +46141,6 @@ var ts; priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; - var _a; })(ts || (ts = {})); var ts; (function (ts) { @@ -45175,38 +46148,38 @@ var ts; var compilerOptions = context.getCompilerOptions(); var previousOnEmitNode; var noSubstitution; - if (compilerOptions.jsx === 1) { + if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(249); context.enableEmitNotification(250); - context.enableEmitNotification(248); + context.enableEmitNotification(251); + context.enableEmitNotification(249); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(177); - context.enableSubstitution(258); + context.enableSubstitution(178); + context.enableSubstitution(260); return transformSourceFile; function transformSourceFile(node) { return node; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 249: case 250: - case 248: + case 251: + case 249: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } - function onSubstituteNode(emitContext, node) { + function onSubstituteNode(hint, node) { if (node.id && noSubstitution && noSubstitution[node.id]) { - return previousOnSubstituteNode(emitContext, node); + return previousOnSubstituteNode(hint, node); } - node = previousOnSubstituteNode(emitContext, node); + node = previousOnSubstituteNode(hint, node); if (ts.isPropertyAccessExpression(node)) { return substitutePropertyAccessExpression(node); } @@ -45218,7 +46191,7 @@ var ts; function substitutePropertyAccessExpression(node) { var literalName = trySubstituteReservedName(node.name); if (literalName) { - return ts.createElementAccess(node.expression, literalName, node); + return ts.setTextRange(ts.createElementAccess(node.expression, literalName), node); } return node; } @@ -45232,7 +46205,7 @@ var ts; function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); if (token >= 71 && token <= 106) { - return ts.createLiteral(name, name); + return ts.setTextRange(ts.createLiteral(name), name); } return undefined; } @@ -45242,12 +46215,13 @@ var ts; var ts; (function (ts) { function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); + function getTransformModuleDelegate(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.AMD: return transformAMDModule; + case ts.ModuleKind.UMD: return transformUMDModule; + default: return transformCommonJSModule; + } + } var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); @@ -45259,13 +46233,13 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70); - context.enableSubstitution(192); - context.enableSubstitution(190); + context.enableSubstitution(193); context.enableSubstitution(191); - context.enableSubstitution(259); - context.enableEmitNotification(262); - var moduleInfoMap = ts.createMap(); - var deferredExports = ts.createMap(); + context.enableSubstitution(192); + context.enableSubstitution(261); + context.enableEmitNotification(264); + var moduleInfoMap = []; + var deferredExports = []; var currentSourceFile; var currentModuleInfo; var noSubstitution; @@ -45277,8 +46251,9 @@ var ts; return node; } currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); - var transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; + currentModuleInfo = ts.collectExternalModuleInfo(node, resolver, compilerOptions); + moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo; + var transformModule = getTransformModuleDelegate(moduleKind); var updated = transformModule(node); currentSourceFile = undefined; currentModuleInfo = undefined; @@ -45288,11 +46263,14 @@ var ts; startLexicalEnvironment(); var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, false); - var updated = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues) { ts.addEmitHelper(updated, exportStarHelper); } @@ -45302,7 +46280,7 @@ var ts; var define = ts.createIdentifier("define"); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - return ts.updateSourceFileNode(node, ts.createNodeArray([ + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), @@ -45313,11 +46291,11 @@ var ts; ts.createParameter(undefined, undefined, undefined, "exports") ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) ]))) - ], node.statements)); + ]), node.statements)); } function transformUMDModule(node) { var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.createBlock([ + var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(ts.createBlock([ ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ ts.createVariableStatement(undefined, [ ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [ @@ -45335,15 +46313,15 @@ var ts; ts.createIdentifier("factory") ])) ]))) - ], undefined, true)); - return ts.updateSourceFileNode(node, ts.createNodeArray([ + ], true), undefined)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createStatement(ts.createCall(umdHeader, undefined, [ ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ ts.createParameter(undefined, undefined, undefined, "require"), ts.createParameter(undefined, undefined, undefined, "exports") ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) ])) - ], node.statements)); + ]), node.statements)); } function collectAsynchronousDependencies(node, includeNonAmdDependencies) { var aliasedModuleNames = []; @@ -45378,11 +46356,14 @@ var ts; startLexicalEnvironment(); var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, true); - var body = ts.createBlock(statements, undefined, true); + var body = ts.createBlock(statements, true); if (currentModuleInfo.hasExportStarsToExportValues) { ts.addEmitHelper(body, exportStarHelper); } @@ -45391,12 +46372,14 @@ var ts; function addExportEqualsIfNeeded(statements, emitAsReturn) { if (currentModuleInfo.exportEquals) { if (emitAsReturn) { - var statement = ts.createReturn(currentModuleInfo.exportEquals.expression, currentModuleInfo.exportEquals); + var statement = ts.createReturn(currentModuleInfo.exportEquals.expression); + ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 384 | 1536); statements.push(statement); } else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression), currentModuleInfo.exportEquals); + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression)); + ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 1536); statements.push(statement); } @@ -45404,23 +46387,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 236: + case 237: return visitImportDeclaration(node); - case 235: + case 236: return visitImportEqualsDeclaration(node); - case 242: + case 243: return visitExportDeclaration(node); - case 241: + case 242: return visitExportAssignment(node); - case 206: + case 207: return visitVariableStatement(node); - case 226: - return visitFunctionDeclaration(node); case 227: + return visitFunctionDeclaration(node); + case 228: return visitClassDeclaration(node); - case 296: + case 299: return visitMergeDeclarationMarker(node); - case 297: + case 300: return visitEndOfDeclarationMarker(node); default: return node; @@ -45431,7 +46414,7 @@ var ts; var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { - return ts.createStatement(createRequireCall(node), node); + return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); } else { var variables = []; @@ -45444,13 +46427,13 @@ var ts; variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node))); } } - statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, undefined, languageVersion >= 2 ? 2 : 0), node)); + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, languageVersion >= 2 ? 2 : 0)), node)); } } else if (namespaceDeclaration && ts.isDefaultImport(node)) { statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node), node) - ], undefined, languageVersion >= 2 ? 2 : 0))); + ts.setTextRange(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node)), node) + ], languageVersion >= 2 ? 2 : 0))); } if (hasAssociatedEndOfDeclarationMarker(node)) { var id = ts.getOriginalNodeId(node); @@ -45474,17 +46457,17 @@ var ts; var statements; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(node.name, createRequireCall(node)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(node.name, createRequireCall(node))), node)); } else { - statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node)) - ], undefined, languageVersion >= 2 ? 2 : 0), node)); + ], languageVersion >= 2 ? 2 : 0)), node)); } } else { if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); } } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -45504,23 +46487,23 @@ var ts; if (node.exportClause) { var statements = []; if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node)) - ]), node)); + ])), node)); } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue), specifier)); + statements.push(ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); } return ts.singleOrMany(statements); } else { - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ + return ts.setTextRange(ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName - ]), node); + ])), node); } } function visitExportAssignment(node) { @@ -45541,7 +46524,7 @@ var ts; function visitFunctionDeclaration(node) { var statements; if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, node.parameters, undefined, node.body, node), node)); + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, node.parameters, undefined, node.body), node), node)); } else { statements = ts.append(statements, node); @@ -45558,7 +46541,7 @@ var ts; function visitClassDeclaration(node) { var statements; if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, node.heritageClauses, node.members, node), node)); + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, node.heritageClauses, node.members), node), node)); } else { statements = ts.append(statements, node); @@ -45594,7 +46577,7 @@ var ts; statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); } if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); } } else { @@ -45614,11 +46597,11 @@ var ts; return ts.flattenDestructuringAssignment(node, undefined, context, 0, false, createExportExpression); } else { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name, node.name), node.initializer); + return ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name), node.name), node.initializer); } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -45650,10 +46633,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 238: + case 239: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 239: + case 240: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -45711,7 +46694,7 @@ var ts; } function appendExportsOfDeclaration(statements, decl) { var name = ts.getDeclarationName(decl); - var exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; + var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { var exportSpecifier = exportSpecifiers_1[_i]; @@ -45721,28 +46704,28 @@ var ts; return statements; } function appendExportStatement(statements, exportName, expression, location, allowComments) { - if (exportName.text === "default") { - var sourceFile = ts.getOriginalNode(currentSourceFile, ts.isSourceFile); - if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 0) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements = ts.append(statements, ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); return statements; } + function createUnderscoreUnderscoreESModule() { + var statement; + if (languageVersion === 0) { + statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true))); + } + else { + statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ])); + } + ts.setEmitFlags(statement, 524288); + return statement; + } function createExportStatement(name, value, location, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value), location); + var statement = ts.setTextRange(ts.createStatement(createExportExpression(name, value)), location); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536); @@ -45750,7 +46733,7 @@ var ts; return statement; } function createExportExpression(name, value, location) { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value, location); + return ts.setTextRange(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location); } function modifierVisitor(node) { switch (node.kind) { @@ -45760,26 +46743,26 @@ var ts; } return node; } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 262) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; - noSubstitution = ts.createMap(); - previousOnEmitNode(emitContext, node, emitCallback); + noSubstitution = []; + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; currentModuleInfo = undefined; noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); if (node.id && noSubstitution[node.id]) { return node; } - if (emitContext === 1) { + if (hint === 1) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -45793,9 +46776,9 @@ var ts; if (exportedOrImportedName !== name) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, node); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); } - return ts.createPropertyAssignment(name, exportedOrImportedName, node); + return ts.setTextRange(ts.createPropertyAssignment(name, exportedOrImportedName), node); } return node; } @@ -45803,10 +46786,10 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 192: + case 193: return substituteBinaryExpression(node); + case 192: case 191: - case 190: return substituteUnaryExpression(node); } return node; @@ -45821,17 +46804,17 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 262) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); + if (exportContainer && exportContainer.kind === 264) { + return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_41 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_41), node); + var name = importDeclaration.propertyName || importDeclaration.name; + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name)), node); } } } @@ -45864,8 +46847,8 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 191 - ? ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1), node) + var expression = node.kind === 192 + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1)), node) : node; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; @@ -45887,7 +46870,6 @@ var ts; } } } - var _a; } ts.transformModule = transformModule; var exportStarHelper = { @@ -45908,14 +46890,14 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70); - context.enableSubstitution(192); - context.enableSubstitution(190); + context.enableSubstitution(193); context.enableSubstitution(191); - context.enableEmitNotification(262); - var moduleInfoMap = ts.createMap(); - var deferredExports = ts.createMap(); - var exportFunctionsMap = ts.createMap(); - var noSubstitutionMap = ts.createMap(); + context.enableSubstitution(192); + context.enableEmitNotification(264); + var moduleInfoMap = []; + var deferredExports = []; + var exportFunctionsMap = []; + var noSubstitutionMap = []; var currentSourceFile; var moduleInfo; var exportFunction; @@ -45934,7 +46916,8 @@ var ts; currentSourceFile = node; enclosingBlockScopedContainer = node; moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); - exportFunction = exportFunctionsMap[id] = ts.createUniqueName("exports"); + exportFunction = ts.createUniqueName("exports"); + exportFunctionsMap[id] = exportFunction; contextObject = ts.createUniqueName("context"); var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); @@ -45944,11 +46927,11 @@ var ts; ], undefined, moduleBodyBlock); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); - var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.createNodeArray([ + var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ], node.statements)), 1024); + ]), node.statements)), 1024); if (!(compilerOptions.outFile || compilerOptions.out)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -45971,12 +46954,12 @@ var ts; var externalImport = externalImports[i]; var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; + var groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { dependencyGroups[groupIndex].externalImports.push(externalImport); } else { - groupIndices[text] = dependencyGroups.length; + groupIndices.set(text, dependencyGroups.length); dependencyGroups.push({ name: externalModuleName, externalImports: [externalImport] @@ -45997,21 +46980,23 @@ var ts; ts.addRange(statements, hoistedStatements); ts.addRange(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + var moduleObject = ts.createObjectLiteral([ ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) - ]), true))); - return ts.createBlock(statements, undefined, true); + ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, true))) + ]); + moduleObject.multiLine = true; + statements.push(ts.createReturn(moduleObject)); + return ts.createBlock(statements, true); } function addExportStarIfNeeded(statements) { if (!moduleInfo.hasExportStarsToExportValues) { return; } - if (!moduleInfo.exportedNames && ts.isEmpty(moduleInfo.exportSpecifiers)) { + if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) { var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 242 && externalImport.exportClause) { + if (externalImport.kind === 243 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -46029,12 +47014,12 @@ var ts; if (exportedLocalName.text === "default") { continue; } - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createTrue())); } } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 242) { + if (externalImport.kind !== 243) { continue; } var exportDecl = externalImport; @@ -46043,12 +47028,12 @@ var ts; } for (var _f = 0, _g = exportDecl.exportClause.elements; _f < _g.length; _f++) { var element = _g[_f]; - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createTrue())); } } var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, undefined, true)) + ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, true)) ]))); var exportStarFunction = createExportStarFunction(exportedNamesStorageRef); statements.push(exportStarFunction); @@ -46073,7 +47058,7 @@ var ts; ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1) ])), ts.createStatement(ts.createCall(exportFunction, undefined, [exports])) - ], undefined, true)); + ], true)); } function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; @@ -46086,15 +47071,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 236: + case 237: if (!entry.importClause) { break; } - case 235: + case 236: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 242: + case 243: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -46102,7 +47087,7 @@ var ts; var e = _d[_c]; properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); } - statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, undefined, true)]))); + statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, true)]))); } else { statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); @@ -46110,19 +47095,19 @@ var ts; break; } } - setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, undefined, true))); + setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, true))); } - return ts.createArrayLiteral(setters, undefined, true); + return ts.createArrayLiteral(setters, true); } function sourceElementVisitor(node) { switch (node.kind) { - case 236: + case 237: return visitImportDeclaration(node); - case 235: + case 236: return visitImportEqualsDeclaration(node); - case 242: + case 243: return undefined; - case 241: + case 242: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -46189,7 +47174,7 @@ var ts; var statements; var name = ts.getLocalName(node); hoistVariableDeclaration(name); - statements = ts.append(statements, ts.createStatement(ts.createAssignment(name, ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement), node)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); @@ -46217,7 +47202,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { var id = ts.getOriginalNodeId(node); @@ -46243,7 +47228,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 1048576) === 0 - && (enclosingBlockScopedContainer.kind === 262 + && (enclosingBlockScopedContainer.kind === 264 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -46261,11 +47246,11 @@ var ts; function createVariableAssignment(name, value, location, isExportedDeclaration) { hoistVariableDeclaration(ts.getSynthesizedClone(name)); return isExportedDeclaration - ? createExportExpression(name, preventSubstitution(ts.createAssignment(name, value, location))) - : preventSubstitution(ts.createAssignment(name, value, location)); + ? createExportExpression(name, preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location))) + : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -46298,10 +47283,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 238: + case 239: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 239: + case 240: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -46371,7 +47356,7 @@ var ts; return statements; } var name = ts.getDeclarationName(decl); - var exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + var exportSpecifiers = moduleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { var exportSpecifier = exportSpecifiers_2[_i]; @@ -46400,43 +47385,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 206: + case 207: return visitVariableStatement(node); - case 226: - return visitFunctionDeclaration(node); case 227: + return visitFunctionDeclaration(node); + case 228: return visitClassDeclaration(node); - case 212: - return visitForStatement(node); case 213: - return visitForInStatement(node); + return visitForStatement(node); case 214: + return visitForInStatement(node); + case 215: return visitForOfStatement(node); - case 210: - return visitDoStatement(node); case 211: + return visitDoStatement(node); + case 212: return visitWhileStatement(node); - case 220: + case 221: return visitLabeledStatement(node); - case 218: - return visitWithStatement(node); case 219: + return visitWithStatement(node); + case 220: return visitSwitchStatement(node); - case 233: + case 234: return visitCaseBlock(node); - case 254: + case 256: return visitCaseClause(node); - case 255: - return visitDefaultClause(node); - case 222: - return visitTryStatement(node); case 257: + return visitDefaultClause(node); + case 223: + return visitTryStatement(node); + case 259: return visitCatchClause(node); - case 205: + case 206: return visitBlock(node); - case 296: + case 299: return visitMergeDeclarationMarker(node); - case 297: + case 300: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -46527,7 +47512,7 @@ var ts; } function destructuringVisitor(node) { if (node.transformFlags & 1024 - && node.kind === 192) { + && node.kind === 193) { return visitDestructuringAssignment(node); } else if (node.transformFlags & 2048) { @@ -46564,7 +47549,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 262; + return container !== undefined && container.kind === 264; } else { return false; @@ -46578,8 +47563,8 @@ var ts; } return node; } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 262) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -46588,22 +47573,22 @@ var ts; if (noSubstitution) { delete noSubstitutionMap[id]; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); if (isSubstitutionPrevented(node)) { return node; } - if (emitContext === 1) { + if (hint === 1) { return substituteExpression(node); } return node; @@ -46612,10 +47597,10 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 192: + case 193: return substituteBinaryExpression(node); - case 190: case 191: + case 192: return substituteUnaryExpression(node); } return node; @@ -46632,10 +47617,10 @@ var ts; var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node); } else if (ts.isImportSpecifier(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name), node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name)), node); } } } @@ -46667,14 +47652,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 191 - ? ts.createPrefix(node.operator, node.operand, node) + var expression = node.kind === 192 + ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { var exportName = exportedNames_4[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 191) { + if (node.kind === 192) { expression = node.operator === 42 ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -46691,7 +47676,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 262) { + if (exportContainer && exportContainer.kind === 264) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -46701,7 +47686,7 @@ var ts; } function preventSubstitution(node) { if (noSubstitution === undefined) - noSubstitution = ts.createMap(); + noSubstitution = []; noSubstitution[ts.getNodeId(node)] = true; return node; } @@ -46719,7 +47704,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(262); + context.enableEmitNotification(264); context.enableSubstitution(70); var currentSourceFile; return transformSourceFile; @@ -46734,7 +47719,7 @@ var ts; var statementOffset = ts.addPrologueDirectives(statements, node.statements); ts.append(statements, ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } else { return ts.visitEachChild(node, visitor, context); @@ -46744,9 +47729,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 235: + case 236: return undefined; - case 241: + case 242: return visitExportAssignment(node); } return node; @@ -46754,19 +47739,19 @@ var ts; function visitExportAssignment(node) { return node.isExportEquals ? undefined : node; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { if (ts.isSourceFile(node)) { currentSourceFile = node; - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (ts.isIdentifier(node) && emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (ts.isIdentifier(node) && hint === 1) { return substituteExpressionIdentifier(node); } return node; @@ -46785,14 +47770,21 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, - _a[ts.ModuleKind.System] = ts.transformSystemModule, - _a[ts.ModuleKind.AMD] = ts.transformModule, - _a[ts.ModuleKind.CommonJS] = ts.transformModule, - _a[ts.ModuleKind.UMD] = ts.transformModule, - _a[ts.ModuleKind.None] = ts.transformModule, - _a)); + function getModuleTransformer(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.ES2015: + return ts.transformES2015Module; + case ts.ModuleKind.System: + return ts.transformSystemModule; + default: + return ts.transformModule; + } + } + var SyntaxKindFeatureFlags; + (function (SyntaxKindFeatureFlags) { + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; + })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); function getTransformers(compilerOptions) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -46815,7 +47807,7 @@ var ts; transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); + transformers.push(getModuleTransformer(moduleKind)); if (languageVersion < 1) { transformers.push(ts.transformES5); } @@ -46823,7 +47815,7 @@ var ts; } ts.getTransformers = getTransformers; function transformFiles(resolver, host, sourceFiles, transformers) { - var enabledSyntaxKindFeatures = new Array(298); + var enabledSyntaxKindFeatures = new Array(301); var lexicalEnvironmentDisabled = false; var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; @@ -46844,16 +47836,19 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, - onSubstituteNode: function (_emitContext, node) { return node; }, + onSubstituteNode: function (_, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, + onEmitNode: function (hint, node, callback) { return callback(hint, node); }, enableEmitNotification: enableEmitNotification, isEmitNotificationEnabled: isEmitNotificationEnabled }; + ts.performance.mark("beforeTransform"); var transformation = ts.chain.apply(void 0, transformers)(context); var transformed = ts.map(sourceFiles, transformSourceFile); lexicalEnvironmentDisabled = true; + ts.performance.mark("afterTransform"); + ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { transformed: transformed, emitNodeWithSubstitution: emitNodeWithSubstitution, @@ -46872,16 +47867,12 @@ var ts; return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0 && (ts.getEmitFlags(node) & 4) === 0; } - function emitNodeWithSubstitution(emitContext, node, emitCallback) { + function emitNodeWithSubstitution(hint, node, emitCallback) { if (node) { if (isSubstitutionEnabled(node)) { - var substitute = context.onSubstituteNode(emitContext, node); - if (substitute && substitute !== node) { - emitCallback(emitContext, substitute); - return; - } + node = context.onSubstituteNode(hint, node) || node; } - emitCallback(emitContext, node); + emitCallback(hint, node); } } function enableEmitNotification(kind) { @@ -46891,13 +47882,13 @@ var ts; return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0 || (ts.getEmitFlags(node) & 2) !== 0; } - function emitNodeWithNotification(emitContext, node, emitCallback) { + function emitNodeWithNotification(hint, node, emitCallback) { if (node) { if (isEmitNotificationEnabled(node)) { - context.onEmitNode(emitContext, node, emitCallback); + context.onEmitNode(hint, node, emitCallback); } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } } @@ -46979,21 +47970,22 @@ var ts; } } ts.transformFiles = transformFiles; - var _a; })(ts || (ts = {})); var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, targetSourceFile) { var declarationDiagnostics = ts.createDiagnosticCollection(); - ts.forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); + ts.forEachEmittedFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); - function getDeclarationDiagnosticsFromFile(_a, sources, isBundledEmit) { + function getDeclarationDiagnosticsFromFile(_a, sourceFileOrBundle) { var declarationFilePath = _a.declarationFilePath; - emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit, false); + emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sourceFileOrBundle, false); } } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles) { + function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles) { + var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var isBundledEmit = sourceFileOrBundle.kind === 265; var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -47055,7 +48047,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 236); + ts.Debug.assert(aliasEmitInfo.node.kind === 237); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -47078,9 +48070,9 @@ var ts; } }); if (usedTypeDirectiveReferences) { - for (var directive in usedTypeDirectiveReferences) { + ts.forEachKey(usedTypeDirectiveReferences, function (directive) { referencesOutput += "/// " + newLine; - } + }); } return { reportedDeclarationError: reportedDeclarationError, @@ -47105,6 +48097,7 @@ var ts; var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; writer.reportInaccessibleThisError = reportInaccessibleThisError; + writer.reportIllegalExtends = reportIllegalExtends; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -47127,10 +48120,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 224) { + if (declaration.kind === 225) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 239 || declaration.kind === 240 || declaration.kind === 237) { + else if (declaration.kind === 240 || declaration.kind === 241 || declaration.kind === 238) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -47141,7 +48134,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 236) { + if (moduleElementEmitInfo.node.kind === 237) { moduleElementEmitInfo.isVisible = true; } else { @@ -47149,12 +48142,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 231) { + if (nodeToCheck.kind === 232) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 231) { + if (nodeToCheck.kind === 232) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -47173,8 +48166,8 @@ var ts; } for (var _i = 0, typeReferenceDirectives_1 = typeReferenceDirectives; _i < typeReferenceDirectives_1.length; _i++) { var directive = typeReferenceDirectives_1[_i]; - if (!(directive in usedTypeDirectiveReferences)) { - usedTypeDirectiveReferences[directive] = directive; + if (!usedTypeDirectiveReferences.has(directive)) { + usedTypeDirectiveReferences.set(directive, directive); } } } @@ -47201,6 +48194,12 @@ var ts; handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); } + function reportIllegalExtends() { + if (errorNameNode) { + reportedDeclarationError = true; + emitterDiagnostics.add(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced, ts.declarationNameToString(errorNameNode))); + } + } function reportInaccessibleThisError() { if (errorNameNode) { reportedDeclarationError = true; @@ -47210,12 +48209,16 @@ var ts; function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); - if (type) { + var shouldUseResolverType = declaration.kind === 145 && + resolver.isRequiredInitializedParameter(declaration); + if (type && !shouldUseResolverType) { emitType(type); } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 | 1024, writer); + var format = 2 | 1024 | + (shouldUseResolverType ? 4096 : 0); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer); errorNameNode = undefined; } } @@ -47267,49 +48270,50 @@ var ts; function emitType(type) { switch (type.kind) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 133: + case 136: case 104: - case 137: + case 138: case 94: case 129: - case 167: - case 171: - return writeTextOfNode(currentText, type); - case 199: - return emitExpressionWithTypeArguments(type); - case 157: - return emitTypeReference(type); - case 160: - return emitTypeQuery(type); - case 162: - return emitArrayType(type); - case 163: - return emitTupleType(type); - case 164: - return emitUnionType(type); - case 165: - return emitIntersectionType(type); - case 166: - return emitParenType(type); case 168: - return emitTypeOperator(type); - case 169: - return emitIndexedAccessType(type); - case 170: - return emitMappedType(type); + case 172: + return writeTextOfNode(currentText, type); + case 200: + return emitExpressionWithTypeArguments(type); case 158: - case 159: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 161: + return emitTypeQuery(type); + case 163: + return emitArrayType(type); + case 164: + return emitTupleType(type); + case 165: + return emitUnionType(type); + case 166: + return emitIntersectionType(type); + case 167: + return emitParenType(type); + case 169: + return emitTypeOperator(type); + case 170: + return emitIndexedAccessType(type); + case 171: + return emitMappedType(type); + case 159: + case 160: + return emitSignatureDeclarationWithJsDocComments(type); + case 162: return emitTypeLiteral(type); case 70: return emitEntityName(type); - case 141: + case 142: return emitEntityName(type); - case 156: + case 157: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -47317,22 +48321,22 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 141 ? entityName.left : entityName.expression; - var right = entityName.kind === 141 ? entityName.right : entityName.name; + var left = entityName.kind === 142 ? entityName.left : entityName.expression; + var right = entityName.kind === 142 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 235 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 236 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 177); + ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 178); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -47436,15 +48440,15 @@ var ts; } function getExportDefaultTempVariableName() { var baseName = "_default"; - if (!(baseName in currentIdentifiers)) { + if (!currentIdentifiers.has(baseName)) { return baseName; } var count = 0; while (true) { count++; - var name_42 = baseName + "_" + count; - if (!(name_42 in currentIdentifiers)) { - return name_42; + var name = baseName + "_" + count; + if (!currentIdentifiers.has(name)) { + return name; } } } @@ -47488,10 +48492,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 235 || - (node.parent.kind === 262 && isCurrentFileExternalModule)) { + else if (node.kind === 236 || + (node.parent.kind === 264 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 262) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 264) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -47500,7 +48504,7 @@ var ts; }); } else { - if (node.kind === 236) { + if (node.kind === 237) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -47518,30 +48522,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 226: - return writeFunctionDeclaration(node); - case 206: - return writeVariableStatement(node); - case 228: - return writeInterfaceDeclaration(node); case 227: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 207: + return writeVariableStatement(node); case 229: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 228: + return writeClassDeclaration(node); case 230: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 231: + return writeEnumDeclaration(node); + case 232: return writeModuleDeclaration(node); - case 235: - return writeImportEqualsDeclaration(node); case 236: + return writeImportEqualsDeclaration(node); + case 237: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 262) { + if (node.parent.kind === 264) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -47549,7 +48553,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 228 && !noDeclare) { + else if (node.kind !== 229 && !noDeclare) { write("declare "); } } @@ -47599,7 +48603,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 238) { + if (namedBindings.kind === 239) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -47622,7 +48626,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 238) { + if (node.importClause.namedBindings.kind === 239) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -47639,13 +48643,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 231; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 232; var moduleSpecifier; - if (parent.kind === 235) { + if (parent.kind === 236) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 231) { + else if (parent.kind === 232) { moduleSpecifier = parent.name; } else { @@ -47713,7 +48717,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 232) { + while (node.body && node.body.kind !== 233) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -47783,7 +48787,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 149 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 150 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -47793,52 +48797,69 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 158 || - node.parent.kind === 159 || - (node.parent.parent && node.parent.parent.kind === 161)) { - ts.Debug.assert(node.parent.kind === 149 || - node.parent.kind === 148 || - node.parent.kind === 158 || + if (node.parent.kind === 159 || + node.parent.kind === 160 || + (node.parent.parent && node.parent.parent.kind === 162)) { + ts.Debug.assert(node.parent.kind === 150 || + node.parent.kind === 149 || node.parent.kind === 159 || - node.parent.kind === 153 || - node.parent.kind === 154); + node.parent.kind === 160 || + node.parent.kind === 154 || + node.parent.kind === 155); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } + if (node.default && !isPrivateMethodTypeParameter(node)) { + write(" = "); + if (node.parent.kind === 159 || + node.parent.kind === 160 || + (node.parent.parent && node.parent.parent.kind === 162)) { + ts.Debug.assert(node.parent.kind === 150 || + node.parent.kind === 149 || + node.parent.kind === 159 || + node.parent.kind === 160 || + node.parent.kind === 154 || + node.parent.kind === 155); + emitType(node.default); + } + else { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.default, getTypeParameterConstraintVisibilityError); + } + } function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 227: + case 228: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 228: + case 229: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 154: + case 155: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 153: + case 154: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 150: case 149: - case 148: if (ts.hasModifier(node.parent, 32)) { 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 === 227) { + else if (node.parent.parent.kind === 228) { 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 226: + case 227: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 229: + case 230: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -47857,7 +48878,7 @@ var ts; write(">"); } } - function emitHeritageClause(typeReferences, isImplementsList) { + function emitHeritageClause(className, typeReferences, isImplementsList) { if (typeReferences) { write(isImplementsList ? " implements " : " extends "); emitCommaList(typeReferences, emitTypeOfTypeReference); @@ -47871,17 +48892,19 @@ var ts; } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; + errorNameNode = className; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 | 1024, writer); + errorNameNode = undefined; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 227) { + if (node.parent.parent.kind === 228) { 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; + ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } else { - diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; + diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; } return { diagnosticMessage: diagnosticMessage, @@ -47913,9 +48936,10 @@ var ts; emitTypeParameters(node.typeParameters); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); + node.name; + emitHeritageClause(node.name, [baseTypeNode], false); } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), true); + emitHeritageClause(node.name, ts.getClassImplementsHeritageClauseElements(node), true); write(" {"); writeLine(); increaseIndent(); @@ -47936,7 +48960,7 @@ var ts; emitTypeParameters(node.typeParameters); var interfaceExtendsTypes = ts.filter(ts.getInterfaceBaseTypeNodes(node), function (base) { return ts.isEntityNameExpression(base.expression); }); if (interfaceExtendsTypes && interfaceExtendsTypes.length) { - emitHeritageClause(interfaceExtendsTypes, false); + emitHeritageClause(node.name, interfaceExtendsTypes, false); } write(" {"); writeLine(); @@ -47958,17 +48982,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 224 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 225 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 147 || node.kind === 146 || - (node.kind === 144 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 148 || node.kind === 147 || + (node.kind === 145 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 147 || node.kind === 146) && node.parent.kind === 161) { + if ((node.kind === 148 || node.kind === 147) && node.parent.kind === 162) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -47981,14 +49005,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 224) { + if (node.kind === 225) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 === 147 || node.kind === 146) { + else if (node.kind === 148 || node.kind === 147) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -47996,7 +49020,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 === 227) { + else if (node.parent.kind === 228) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -48022,7 +49046,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 198) { + if (element.kind !== 199) { elements.push(element); } } @@ -48088,7 +49112,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 151 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 152 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -48101,7 +49125,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 151 + return accessor.kind === 152 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -48110,7 +49134,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 152) { + if (accessorWithTypeAnnotation.kind === 153) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -48156,17 +49180,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 226) { + if (node.kind === 227) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 149 || node.kind === 150) { + else if (node.kind === 150 || node.kind === 151) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 226) { + if (node.kind === 227) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 150) { + else if (node.kind === 151) { write("constructor"); } else { @@ -48186,15 +49210,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 155) { + if (node.kind === 156) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 154 || node.kind === 159) { + if (node.kind === 155 || node.kind === 160) { write("new "); } - else if (node.kind === 158) { + else if (node.kind === 159) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -48205,20 +49229,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 155) { + if (node.kind === 156) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 158 || node.kind === 159; - if (isFunctionTypeOrConstructorType || node.parent.kind === 161) { + var isFunctionTypeOrConstructorType = node.kind === 159 || node.kind === 160; + if (isFunctionTypeOrConstructorType || node.parent.kind === 162) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 150 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 151 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -48232,23 +49256,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 154: + case 155: diagnosticMessage = symbolAccessibilityResult.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 153: + case 154: diagnosticMessage = symbolAccessibilityResult.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 155: + case 156: diagnosticMessage = symbolAccessibilityResult.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 150: case 149: - case 148: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -48256,7 +49280,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 === 227) { + else if (node.parent.kind === 228) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -48269,7 +49293,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 226: + case 227: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -48301,9 +49325,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 158 || - node.parent.kind === 159 || - node.parent.parent.kind === 161) { + if (node.parent.kind === 159 || + node.parent.kind === 160 || + node.parent.parent.kind === 162) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -48319,26 +49343,26 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 150: + case 151: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 154: + case 155: return symbolAccessibilityResult.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 153: + case 154: return symbolAccessibilityResult.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 155: + case 156: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; + case 150: case 149: - case 148: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -48346,7 +49370,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 === 227) { + else if (node.parent.parent.kind === 228) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -48358,7 +49382,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 226: + case 227: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -48369,12 +49393,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 172) { + if (bindingPattern.kind === 173) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 173) { + else if (bindingPattern.kind === 174) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -48385,10 +49409,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 198) { + if (bindingElement.kind === 199) { write(" "); } - else if (bindingElement.kind === 174) { + else if (bindingElement.kind === 175) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -48410,39 +49434,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 226: - case 231: - case 235: - case 228: case 227: - case 229: - case 230: - return emitModuleElement(node, isModuleElementVisible(node)); - case 206: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 232: case 236: + case 229: + case 228: + case 230: + case 231: + return emitModuleElement(node, isModuleElementVisible(node)); + case 207: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 237: return emitModuleElement(node, !node.importClause); - case 242: + case 243: return emitExportDeclaration(node); + case 151: case 150: case 149: - case 148: return writeFunctionDeclaration(node); - case 154: - case 153: case 155: + case 154: + case 156: return emitSignatureDeclarationWithJsDocComments(node); - case 151: case 152: + case 153: return emitAccessorDeclaration(node); + case 148: case 147: - case 146: return emitPropertyDeclaration(node); - case 261: + case 263: return emitEnumMemberDeclaration(node); - case 241: + case 242: return emitExportAssignment(node); - case 262: + case 264: return emitSourceFile(node); } } @@ -48453,14 +49477,15 @@ var ts; declFileName = referencedFile.fileName; } else { - ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(declarationFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, sourceFileOrBundle) { + var isBundledEmit = sourceFileOrBundle.kind === 265; if (isBundledEmit && !addBundledFileReference) { return; } @@ -48470,10 +49495,11 @@ var ts; } } } - function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { - var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles); + function writeDeclarationFile(declarationFilePath, sourceFileOrBundle, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { + var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { + var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; var declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); ts.writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); @@ -48527,7 +49553,7 @@ var ts; getText: getText, getSourceMappingURL: getSourceMappingURL, }; - function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { + function initialize(filePath, sourceMapFilePath, sourceFileOrBundle) { if (disabled) { return; } @@ -48558,9 +49584,8 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (!isBundledEmit) { - ts.Debug.assert(sourceFiles.length === 1); - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFiles[0], host, sourceMapDir)); + if (sourceFileOrBundle.kind === 264) { + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); @@ -48651,28 +49676,28 @@ var ts; ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); } } - function emitNodeWithSourceMap(emitContext, node, emitCallback) { + function emitNodeWithSourceMap(hint, node, emitCallback) { if (disabled) { - return emitCallback(emitContext, node); + return emitCallback(hint, node); } if (node) { var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 294 + if (node.kind !== 297 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); } if (emitFlags & 64) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } - if (node.kind !== 294 + if (node.kind !== 297 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -48773,11 +49798,10 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function createCommentWriter(host, writer, sourceMap) { - var compilerOptions = host.getCompilerOptions(); - var extendedDiagnostics = compilerOptions.extendedDiagnostics; - var newLine = host.getNewLine(); - var emitPos = sourceMap.emitPos; + function createCommentWriter(printerOptions, emitPos) { + var extendedDiagnostics = printerOptions.extendedDiagnostics; + var newLine = ts.getNewLineCharacter(printerOptions); + var writer; var containerPos = -1; var containerEnd = -1; var declarationListContainerEnd = -1; @@ -48786,17 +49810,19 @@ var ts; var currentLineMap; var detachedCommentsInfo; var hasWrittenComment = false; - var disabled = compilerOptions.removeComments; + var disabled = printerOptions.removeComments; return { reset: reset, + setWriter: setWriter, setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, + emitLeadingCommentsOfPosition: emitLeadingCommentsOfPosition, }; - function emitNodeWithComments(emitContext, node, emitCallback) { + function emitNodeWithComments(hint, node, emitCallback) { if (disabled) { - emitCallback(emitContext, node); + emitCallback(hint, node); return; } if (node) { @@ -48805,18 +49831,18 @@ var ts; if ((pos < 0 && end < 0) || (pos === end)) { if (emitFlags & 2048) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } else { if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 294; + var isEmittedNode = node.kind !== 297; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { @@ -48830,7 +49856,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 225) { + if (node.kind === 226) { declarationListContainerEnd = end; } } @@ -48839,11 +49865,11 @@ var ts; } if (emitFlags & 2048) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } if (extendedDiagnostics) { ts.performance.mark("beginEmitNodeWithComment"); @@ -48914,9 +49940,11 @@ var ts; ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; } - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -48924,6 +49952,12 @@ var ts; writer.write(" "); } } + function emitLeadingCommentsOfPosition(pos) { + if (disabled || pos === -1) { + return; + } + emitLeadingComments(pos, true); + } function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } @@ -48931,9 +49965,11 @@ var ts; if (!writer.isAtStartOfLine()) { writer.write(" "); } - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -48951,9 +49987,11 @@ var ts; } } function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -48982,6 +50020,9 @@ var ts; currentLineMap = undefined; detachedCommentsInfo = undefined; } + function setWriter(output) { + writer = output; + } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; currentText = currentSourceFile.text; @@ -49013,9 +50054,11 @@ var ts; } } function writeComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); } function isTripleSlashComment(commentPos, commentEnd) { if (currentText.charCodeAt(commentPos + 1) === 47 && @@ -49033,44 +50076,39 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var id = function (s) { return s; }; - var nullTransformers = [function (_) { return id; }]; + var delimiters = createDelimiterMap(); + var brackets = createBracketsMap(); function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { - var delimiters = createDelimiterMap(); - var brackets = createBracketsMap(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = emitOnlyDtsFiles ? nullTransformers : ts.getTransformers(compilerOptions); + var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); - var write = writer.write, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var sourceMap = ts.createSourceMapWriter(host, writer); - var emitNodeWithSourceMap = sourceMap.emitNodeWithSourceMap, emitTokenWithSourceMap = sourceMap.emitTokenWithSourceMap; - var comments = ts.createCommentWriter(host, writer, sourceMap); - var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition; - var nodeIdToGeneratedName; - var autoGeneratedIdToGeneratedName; - var generatedNameSet; - var tempFlags; var currentSourceFile; - var currentText; - var currentFileIdentifiers; var bundledHelpers; var isOwnFileEmit; var emitSkipped = false; var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); - ts.performance.mark("beforeTransform"); - var _a = ts.transformFiles(resolver, host, sourceFiles, transformers), transformed = _a.transformed, emitNodeWithSubstitution = _a.emitNodeWithSubstitution, emitNodeWithNotification = _a.emitNodeWithNotification; - ts.performance.measure("transformTime", "beforeTransform"); + var transform = ts.transformFiles(resolver, host, sourceFiles, transformers); + var printer = createPrinter(compilerOptions, { + hasGlobalName: resolver.hasGlobalName, + onEmitNode: transform.emitNodeWithNotification, + onSubstituteNode: transform.emitNodeWithSubstitution, + onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, + onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, + onEmitSourceMapOfPosition: sourceMap.emitPos, + onEmitHelpers: emitHelpers, + onSetSourceFile: setSourceFile, + }); ts.performance.mark("beforePrint"); - ts.forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); - for (var _b = 0, sourceFiles_4 = sourceFiles; _b < sourceFiles_4.length; _b++) { - var sourceFile = sourceFiles_4[_b]; + for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { + var sourceFile = sourceFiles_2[_a]; ts.disposeEmitNodes(sourceFile); } return { @@ -49079,17 +50117,18 @@ var ts; emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList }; - function emitFile(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, isBundledEmit) { + function emitSourceFileOrBundle(_a, sourceFileOrBundle) { + var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath; if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { if (!emitOnlyDtsFiles) { - printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle); } } else { emitSkipped = true; } if (declarationFilePath) { - emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; + emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFileOrBundle(sourceFileOrBundle), host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; } if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { @@ -49103,24 +50142,24 @@ var ts; } } } - function printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit) { - sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); - nodeIdToGeneratedName = []; - autoGeneratedIdToGeneratedName = []; - generatedNameSet = ts.createMap(); - bundledHelpers = isBundledEmit ? ts.createMap() : undefined; - isOwnFileEmit = !isBundledEmit; - if (isBundledEmit && moduleKind) { - for (var _a = 0, sourceFiles_5 = sourceFiles; _a < sourceFiles_5.length; _a++) { - var sourceFile = sourceFiles_5[_a]; - emitHelpers(sourceFile, true); - } + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle) { + var bundle = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 264 ? sourceFileOrBundle : undefined; + var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; + sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFileOrBundle); + if (bundle) { + bundledHelpers = ts.createMap(); + isOwnFileEmit = false; + printer.writeBundle(bundle, writer); } - ts.forEach(sourceFiles, printSourceFile); - writeLine(); + else { + isOwnFileEmit = true; + printer.writeFile(sourceFile, writer); + } + writer.writeLine(); var sourceMappingURL = sourceMap.getSourceMappingURL(); if (sourceMappingURL) { - write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); + writer.write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); } if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) { ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), false, sourceFiles); @@ -49130,23 +50169,165 @@ var ts; } ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles); sourceMap.reset(); - comments.reset(); writer.reset(); - tempFlags = 0; currentSourceFile = undefined; - currentText = undefined; + bundledHelpers = undefined; isOwnFileEmit = false; } - function printSourceFile(node) { + function setSourceFile(node) { currentSourceFile = node; - currentText = node.text; - currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); - comments.setSourceFile(node); - pipelineEmitWithNotification(0, node); } - function emit(node) { - pipelineEmitWithNotification(3, node); + function emitHelpers(node, writeLines) { + var helpersEmitted = false; + var bundle = node.kind === 265 ? node : undefined; + if (bundle && moduleKind === ts.ModuleKind.None) { + return; + } + var numNodes = bundle ? bundle.sourceFiles.length : 1; + for (var i = 0; i < numNodes; i++) { + var currentNode = bundle ? bundle.sourceFiles[i] : node; + var sourceFile = ts.isSourceFile(currentNode) ? currentNode : currentSourceFile; + var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = ts.isSourceFile(currentNode) && !isOwnFileEmit; + var helpers = ts.getEmitHelpers(currentNode); + if (helpers) { + for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { + var helper = _b[_a]; + if (!helper.scoped) { + if (shouldSkip) + continue; + if (shouldBundle) { + if (bundledHelpers.get(helper.name)) { + continue; + } + bundledHelpers.set(helper.name, true); + } + } + else if (bundle) { + continue; + } + writeLines(helper.text); + helpersEmitted = true; + } + } + } + return helpersEmitted; + } + } + ts.emitFiles = emitFiles; + function createPrinter(printerOptions, handlers) { + if (printerOptions === void 0) { printerOptions = {}; } + if (handlers === void 0) { handlers = {}; } + var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, onSubstituteNode = handlers.onSubstituteNode; + var newLine = ts.getNewLineCharacter(printerOptions); + var languageVersion = ts.getEmitScriptTarget(printerOptions); + var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); + var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; + var currentSourceFile; + var nodeIdToGeneratedName; + var autoGeneratedIdToGeneratedName; + var generatedNames; + var tempFlagsStack; + var tempFlags; + var writer; + var ownWriter; + reset(); + return { + printNode: printNode, + printFile: printFile, + printBundle: printBundle, + writeNode: writeNode, + writeFile: writeFile, + writeBundle: writeBundle + }; + function printNode(hint, node, sourceFile) { + switch (hint) { + case 0: + ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); + break; + case 2: + ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); + break; + case 1: + ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); + break; + } + switch (node.kind) { + case 264: return printFile(node); + case 265: return printBundle(node); + } + writeNode(hint, node, sourceFile, beginPrint()); + return endPrint(); + } + function printBundle(bundle) { + writeBundle(bundle, beginPrint()); + return endPrint(); + } + function printFile(sourceFile) { + writeFile(sourceFile, beginPrint()); + return endPrint(); + } + function writeNode(hint, node, sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(hint, node, sourceFile); + reset(); + writer = previousWriter; + } + function writeBundle(bundle, output) { + var previousWriter = writer; + setWriter(output); + emitHelpersIndirect(bundle); + for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + print(0, sourceFile, sourceFile); + } + reset(); + writer = previousWriter; + } + function writeFile(sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(0, sourceFile, sourceFile); + reset(); + writer = previousWriter; + } + function beginPrint() { + return ownWriter || (ownWriter = ts.createTextWriter(newLine)); + } + function endPrint() { + var text = ownWriter.getText(); + ownWriter.reset(); + return text; + } + function print(hint, node, sourceFile) { + setSourceFile(sourceFile); + pipelineEmitWithNotification(hint, node); + } + function setSourceFile(sourceFile) { + currentSourceFile = sourceFile; + comments.setSourceFile(sourceFile); + if (onSetSourceFile) { + onSetSourceFile(sourceFile); + } + } + function setWriter(output) { + writer = output; + comments.setWriter(output); + } + function reset() { + nodeIdToGeneratedName = []; + autoGeneratedIdToGeneratedName = []; + generatedNames = ts.createMap(); + tempFlagsStack = []; + tempFlags = 0; + comments.reset(); + setWriter(undefined); + } + function emit(node, hint) { + if (hint === void 0) { hint = 3; } + pipelineEmitWithNotification(hint, node); } function emitIdentifierName(node) { pipelineEmitWithNotification(2, node); @@ -49154,51 +50335,60 @@ var ts; function emitExpression(node) { pipelineEmitWithNotification(1, node); } - function pipelineEmitWithNotification(emitContext, node) { - emitNodeWithNotification(emitContext, node, pipelineEmitWithComments); + function pipelineEmitWithNotification(hint, node) { + if (onEmitNode) { + onEmitNode(hint, node, pipelineEmitWithComments); + } + else { + pipelineEmitWithComments(hint, node); + } } - function pipelineEmitWithComments(emitContext, node) { - if (emitContext === 0) { - pipelineEmitWithSourceMap(emitContext, node); + function pipelineEmitWithComments(hint, node) { + if (emitNodeWithComments && hint !== 0) { + emitNodeWithComments(hint, node, pipelineEmitWithSourceMap); + } + else { + pipelineEmitWithSourceMap(hint, node); + } + } + function pipelineEmitWithSourceMap(hint, node) { + if (onEmitSourceMapOfNode && hint !== 0 && hint !== 2) { + onEmitSourceMapOfNode(hint, node, pipelineEmitWithSubstitution); + } + else { + pipelineEmitWithSubstitution(hint, node); + } + } + function pipelineEmitWithSubstitution(hint, node) { + if (onSubstituteNode) { + onSubstituteNode(hint, node, pipelineEmitWithHint); + } + else { + pipelineEmitWithHint(hint, node); + } + } + function pipelineEmitWithHint(hint, node) { + switch (hint) { + case 0: return pipelineEmitSourceFile(node); + case 2: return pipelineEmitIdentifierName(node); + case 1: return pipelineEmitExpression(node); + case 3: return pipelineEmitUnspecified(node); + } + } + function pipelineEmitSourceFile(node) { + ts.Debug.assertNode(node, ts.isSourceFile); + emitSourceFile(node); + } + function pipelineEmitIdentifierName(node) { + ts.Debug.assertNode(node, ts.isIdentifier); + emitIdentifier(node); + } + function pipelineEmitUnspecified(node) { + var kind = node.kind; + if (ts.isKeyword(kind)) { + writeTokenText(kind); return; } - emitNodeWithComments(emitContext, node, pipelineEmitWithSourceMap); - } - function pipelineEmitWithSourceMap(emitContext, node) { - if (emitContext === 0 - || emitContext === 2) { - pipelineEmitWithSubstitution(emitContext, node); - return; - } - emitNodeWithSourceMap(emitContext, node, pipelineEmitWithSubstitution); - } - function pipelineEmitWithSubstitution(emitContext, node) { - emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext); - } - function pipelineEmitForContext(emitContext, node) { - switch (emitContext) { - case 0: return pipelineEmitInSourceFileContext(node); - case 2: return pipelineEmitInIdentifierNameContext(node); - case 3: return pipelineEmitInUnspecifiedContext(node); - case 1: return pipelineEmitInExpressionContext(node); - } - } - function pipelineEmitInSourceFileContext(node) { - var kind = node.kind; - switch (kind) { - case 262: - return emitSourceFile(node); - } - } - function pipelineEmitInIdentifierNameContext(node) { - var kind = node.kind; - switch (kind) { - case 70: - return emitIdentifier(node); - } - } - function pipelineEmitInUnspecifiedContext(node) { - var kind = node.kind; switch (kind) { case 13: case 14: @@ -49206,229 +50396,197 @@ var ts; return emitLiteral(node); case 70: return emitIdentifier(node); - case 75: - case 78: - case 83: - case 104: - case 111: - case 112: - case 113: - case 114: - case 116: - case 117: - case 118: - case 119: - case 120: - case 121: - case 122: - case 123: - case 124: - case 125: - case 127: - case 128: - case 129: - case 130: - case 131: - case 132: - case 133: - case 134: - case 135: - case 136: - case 137: - case 138: - case 139: - case 140: - writeTokenText(kind); - return; - case 141: - return emitQualifiedName(node); case 142: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 143: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 144: - return emitParameter(node); + return emitTypeParameter(node); case 145: - return emitDecorator(node); + return emitParameter(node); case 146: - return emitPropertySignature(node); + return emitDecorator(node); case 147: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 148: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 149: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 150: - return emitConstructor(node); + return emitMethodDeclaration(node); case 151: + return emitConstructor(node); case 152: - return emitAccessorDeclaration(node); case 153: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 154: - return emitConstructSignature(node); + return emitCallSignature(node); case 155: - return emitIndexSignature(node); + return emitConstructSignature(node); case 156: - return emitTypePredicate(node); + return emitIndexSignature(node); case 157: - return emitTypeReference(node); + return emitTypePredicate(node); case 158: - return emitFunctionType(node); + return emitTypeReference(node); case 159: - return emitConstructorType(node); + return emitFunctionType(node); case 160: - return emitTypeQuery(node); + return emitConstructorType(node); case 161: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 162: - return emitArrayType(node); + return emitTypeLiteral(node); case 163: - return emitTupleType(node); + return emitArrayType(node); case 164: - return emitUnionType(node); + return emitTupleType(node); case 165: - return emitIntersectionType(node); + return emitUnionType(node); case 166: - return emitParenthesizedType(node); - case 199: - return emitExpressionWithTypeArguments(node); + return emitIntersectionType(node); case 167: - return emitThisType(); + return emitParenthesizedType(node); + case 200: + return emitExpressionWithTypeArguments(node); case 168: - return emitTypeOperator(node); + return emitThisType(); case 169: - return emitIndexedAccessType(node); + return emitTypeOperator(node); case 170: - return emitMappedType(node); + return emitIndexedAccessType(node); case 171: - return emitLiteralType(node); + return emitMappedType(node); case 172: - return emitObjectBindingPattern(node); + return emitLiteralType(node); case 173: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 174: + return emitArrayBindingPattern(node); + case 175: return emitBindingElement(node); - case 203: - return emitTemplateSpan(node); case 204: - return emitSemicolonClassElement(); + return emitTemplateSpan(node); case 205: - return emitBlock(node); + return emitSemicolonClassElement(); case 206: - return emitVariableStatement(node); + return emitBlock(node); case 207: - return emitEmptyStatement(); + return emitVariableStatement(node); case 208: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 209: - return emitIfStatement(node); + return emitExpressionStatement(node); case 210: - return emitDoStatement(node); + return emitIfStatement(node); case 211: - return emitWhileStatement(node); + return emitDoStatement(node); case 212: - return emitForStatement(node); + return emitWhileStatement(node); case 213: - return emitForInStatement(node); + return emitForStatement(node); case 214: - return emitForOfStatement(node); + return emitForInStatement(node); case 215: - return emitContinueStatement(node); + return emitForOfStatement(node); case 216: - return emitBreakStatement(node); + return emitContinueStatement(node); case 217: - return emitReturnStatement(node); + return emitBreakStatement(node); case 218: - return emitWithStatement(node); + return emitReturnStatement(node); case 219: - return emitSwitchStatement(node); + return emitWithStatement(node); case 220: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 221: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 222: - return emitTryStatement(node); + return emitThrowStatement(node); case 223: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 224: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 225: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 226: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 227: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 228: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 229: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 230: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 231: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 232: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 233: + return emitModuleBlock(node); + case 234: return emitCaseBlock(node); - case 235: - return emitImportEqualsDeclaration(node); case 236: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 237: - return emitImportClause(node); + return emitImportDeclaration(node); case 238: - return emitNamespaceImport(node); + return emitImportClause(node); case 239: - return emitNamedImports(node); + return emitNamespaceImport(node); case 240: - return emitImportSpecifier(node); + return emitNamedImports(node); case 241: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 242: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 243: - return emitNamedExports(node); + return emitExportDeclaration(node); case 244: - return emitExportSpecifier(node); + return emitNamedExports(node); case 245: - return; + return emitExportSpecifier(node); case 246: + return; + case 247: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 249: - return emitJsxOpeningElement(node); case 250: - return emitJsxClosingElement(node); + return emitJsxOpeningElement(node); case 251: - return emitJsxAttribute(node); + return emitJsxClosingElement(node); case 252: - return emitJsxSpreadAttribute(node); + return emitJsxAttribute(node); case 253: - return emitJsxExpression(node); + return emitJsxAttributes(node); case 254: - return emitCaseClause(node); + return emitJsxSpreadAttribute(node); case 255: - return emitDefaultClause(node); + return emitJsxExpression(node); case 256: - return emitHeritageClause(node); + return emitCaseClause(node); case 257: - return emitCatchClause(node); + return emitDefaultClause(node); case 258: - return emitPropertyAssignment(node); + return emitHeritageClause(node); case 259: - return emitShorthandPropertyAssignment(node); + return emitCatchClause(node); case 260: - return emitSpreadAssignment(node); + return emitPropertyAssignment(node); case 261: + return emitShorthandPropertyAssignment(node); + case 262: + return emitSpreadAssignment(node); + case 263: return emitEnumMember(node); } if (ts.isExpression(node)) { return pipelineEmitWithSubstitution(1, node); } } - function pipelineEmitInExpressionContext(node) { + function pipelineEmitExpression(node) { var kind = node.kind; switch (kind) { case 8: @@ -49446,68 +50604,81 @@ var ts; case 98: writeTokenText(kind); return; - case 175: - return emitArrayLiteralExpression(node); case 176: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 177: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 178: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 179: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 180: - return emitNewExpression(node); + return emitCallExpression(node); case 181: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 182: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 183: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 184: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 185: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 186: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 187: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 188: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 189: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 190: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 191: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 192: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 193: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 194: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 195: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 196: - return emitSpreadExpression(node); + return emitYieldExpression(node); case 197: - return emitClassExpression(node); + return emitSpreadExpression(node); case 198: + return emitClassExpression(node); + case 199: return; - case 200: - return emitAsExpression(node); case 201: - return emitNonNullExpression(node); + return emitAsExpression(node); case 202: + return emitNonNullExpression(node); + case 203: return emitMetaProperty(node); - case 247: - return emitJsxElement(node); case 248: + return emitJsxElement(node); + case 249: return emitJsxSelfClosingElement(node); - case 295: + case 298: return emitPartiallyEmittedExpression(node); } } + function emitBodyIndirect(node, elements, emitCallback) { + if (emitBodyWithDetachedComments) { + emitBodyWithDetachedComments(node, elements, emitCallback); + } + else { + emitCallback(node); + } + } + function emitHelpersIndirect(node) { + if (onEmitHelpers) { + onEmitHelpers(node, writeLines); + } + } function emitNumericLiteral(node) { emitLiteral(node); if (node.trailingComment) { @@ -49516,7 +50687,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralTextOfNode(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) + if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } @@ -49603,7 +50774,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 151 ? "get " : "set "); + write(node.kind === 152 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -49703,17 +50874,13 @@ var ts; write("{"); writeLine(); increaseIndent(); - if (node.readonlyToken) { - write("readonly "); - } + writeIfPresent(node.readonlyToken, "readonly "); write("["); emit(node.typeParameter.name); write(" in "); emit(node.typeParameter.constraint); write("]"); - if (node.questionToken) { - write("?"); - } + writeIfPresent(node.questionToken, "?"); write(": "); emit(node.type); write(";"); @@ -49785,7 +50952,7 @@ var ts; var indentAfterDot = false; if (!(ts.getEmitFlags(node) & 65536)) { var dotRangeStart = node.expression.end; - var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; + var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; var dotToken = { kind: 22, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); @@ -49801,13 +50968,15 @@ var ts; function needsDotDotForPropertyAccess(expression) { if (expression.kind === 8) { var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(22)) < 0; + return ts.getNumericLiteralFlags(text, 15) === 0 + && !expression.isOctalLiteral + && text.indexOf(ts.tokenToString(22)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); return isFinite(constantValue) && Math.floor(constantValue) === constantValue - && compilerOptions.removeComments; + && printerOptions.removeComments; } } function emitElementAccessExpression(node) { @@ -49833,11 +51002,9 @@ var ts; emitExpression(node.template); } function emitTypeAssertionExpression(node) { - if (node.type) { - write("<"); - emit(node.type); - write(">"); - } + write("<"); + emit(node.type); + write(">"); emitExpression(node.expression); } function emitParenthesizedExpression(node) { @@ -49884,7 +51051,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 190 + return operand.kind === 191 && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } @@ -49968,6 +51135,9 @@ var ts; else { writeToken(16, node.pos, node); emitBlockStatements(node); + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); writeToken(17, node.statements.end, node); } } @@ -50001,7 +51171,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 209) { + if (node.elseStatement.kind === 210) { write(" "); emit(node.elseStatement); } @@ -50063,7 +51233,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 225) { + if (node.kind === 226) { emit(node); } else { @@ -50160,11 +51330,10 @@ var ts; emitBlockFunctionBody(body); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); emitSignatureHead(node); emitBlockFunctionBody(body); - tempFlags = savedTempFlags; + popNameGenerationScope(); } if (indentedFlag) { decreaseIndent(); @@ -50213,9 +51382,10 @@ var ts; function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) + var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine - : emitBlockFunctionBodyWorker); + : emitBlockFunctionBodyWorker; + emitBodyIndirect(body, body.statements, emitBlockFunctionBody); decreaseIndent(); writeToken(17, body.statements.end, body); } @@ -50224,8 +51394,9 @@ var ts; } function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) { var statementOffset = emitPrologueDirectives(body.statements, true); - var helpersEmitted = emitHelpers(body); - if (statementOffset === 0 && !helpersEmitted && emitBlockFunctionBodyOnSingleLine) { + var pos = writer.getTextPos(); + emitHelpersIndirect(body); + if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); emitList(body, body.statements, 384); increaseIndent(); @@ -50248,15 +51419,14 @@ var ts; } emitTypeParameters(node, node.typeParameters); emitList(node, node.heritageClauses, 256); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 65); write("}"); + popNameGenerationScope(); if (indentedFlag) { decreaseIndent(); } - tempFlags = savedTempFlags; } function emitInterfaceDeclaration(node) { emitDecorators(node, node.decorators); @@ -50283,19 +51453,18 @@ var ts; emitModifiers(node, node.modifiers); write("enum "); emit(node.name); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 81); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 231) { + while (body.kind === 232) { write("."); emit(body.name); body = body.body; @@ -50308,13 +51477,12 @@ var ts; write("{ }"); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write("{"); increaseIndent(); emitBlockStatements(node); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } } function emitCaseBlock(node) { @@ -50416,14 +51584,18 @@ var ts; write("<"); emitJsxTagName(node.tagName); write(" "); - emitList(node, node.attributes, 131328); + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write("/>"); } function emitJsxOpeningElement(node) { write("<"); emitJsxTagName(node.tagName); - writeIfAny(node.attributes, " "); - emitList(node, node.attributes, 131328); + writeIfAny(node.attributes.properties, " "); + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write(">"); } function emitJsxText(node) { @@ -50434,6 +51606,9 @@ var ts; emitJsxTagName(node.tagName); write(">"); } + function emitJsxAttributes(node) { + emitList(node, node.properties, 131328); + } function emitJsxAttribute(node) { emit(node.name); emitWithPrefix("=", node.initializer); @@ -50491,7 +51666,6 @@ var ts; emitList(node, node.types, 272); } function emitCatchClause(node) { - writeLine(); var openParenPos = writeToken(73, node.pos); write(" "); writeToken(18, openParenPos); @@ -50504,7 +51678,7 @@ var ts; emit(node.name); write(": "); var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512) === 0) { + if (emitTrailingCommentsOfPosition && (ts.getEmitFlags(initializer) & 512) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -50530,16 +51704,15 @@ var ts; function emitSourceFile(node) { writeLine(); emitShebang(); - emitBodyWithDetachedComments(node, node.statements, emitSourceFileWorker); + emitBodyIndirect(node, node.statements, emitSourceFileWorker); } function emitSourceFileWorker(node) { var statements = node.statements; var statementOffset = emitPrologueDirectives(statements); - var savedTempFlags = tempFlags; - tempFlags = 0; - emitHelpers(node); + pushNameGenerationScope(); + emitHelpersIndirect(node); emitList(node, statements, 1, statementOffset); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitPartiallyEmittedExpression(node) { emitExpression(node.expression); @@ -50558,67 +51731,8 @@ var ts; } return statements.length; } - function emitHelpers(node, isBundle) { - var sourceFile = ts.isSourceFile(node) ? node : currentSourceFile; - var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); - var shouldBundle = ts.isSourceFile(node) && !isOwnFileEmit; - var helpersEmitted = false; - var helpers = ts.getEmitHelpers(node); - if (helpers) { - for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { - var helper = _b[_a]; - if (!helper.scoped) { - if (shouldSkip) - continue; - if (shouldBundle) { - if (bundledHelpers[helper.name]) { - continue; - } - bundledHelpers[helper.name] = true; - } - } - else if (isBundle) { - continue; - } - writeLines(helper.text); - helpersEmitted = true; - } - } - if (helpersEmitted) { - writeLine(); - } - return helpersEmitted; - } - function writeLines(text) { - var lines = text.split(/\r\n?|\n/g); - var indentation = guessIndentation(lines); - for (var i = 0; i < lines.length; i++) { - var line = indentation ? lines[i].slice(indentation) : lines[i]; - if (line.length) { - if (i > 0) { - writeLine(); - } - write(line); - } - } - } - function guessIndentation(lines) { - var indentation; - for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { - var line = lines_1[_a]; - for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { - if (!ts.isWhiteSpace(line.charCodeAt(i))) { - if (indentation === undefined || i < indentation) { - indentation = i; - break; - } - } - } - } - return indentation; - } function emitShebang() { - var shebang = ts.getShebang(currentText); + var shebang = ts.getShebang(currentSourceFile.text); if (shebang) { write(shebang); writeLine(); @@ -50733,6 +51847,9 @@ var ts; for (var i = 0; i < count; i++) { var child = children[start + i]; if (previousSibling) { + if (delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } write(delimiter); if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { if ((format & (3 | 64)) === 0) { @@ -50747,8 +51864,10 @@ var ts; } } if (shouldEmitInterveningComments) { - var commentRange = ts.getCommentRange(child); - emitTrailingCommentsOfPosition(commentRange.pos); + if (emitTrailingCommentsOfPosition) { + var commentRange = ts.getCommentRange(child); + emitTrailingCommentsOfPosition(commentRange.pos); + } } else { shouldEmitInterveningComments = mayEmitInterveningComments; @@ -50764,6 +51883,9 @@ var ts; if (format & 16 && hasTrailingComma) { write(","); } + if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } if (format & 64) { decreaseIndent(); } @@ -50778,6 +51900,38 @@ var ts; write(getClosingBracket(format)); } } + function write(s) { + writer.write(s); + } + function writeLine() { + writer.writeLine(); + } + function increaseIndent() { + writer.increaseIndent(); + } + function decreaseIndent() { + writer.decreaseIndent(); + } + function writeIfAny(nodes, text) { + if (ts.some(nodes)) { + write(text); + } + } + function writeIfPresent(node, text) { + if (node) { + write(text); + } + } + function writeToken(token, pos, contextNode) { + return onEmitSourceMapOfToken + ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) + : writeTokenText(token, pos); + } + function writeTokenText(token, pos) { + var tokenString = ts.tokenToString(token); + write(tokenString); + return pos < 0 ? pos : pos + tokenString.length; + } function writeLineOrSpace(node) { if (ts.getEmitFlags(node) & 1) { write(" "); @@ -50786,23 +51940,32 @@ var ts; writeLine(); } } - function writeIfAny(nodes, text) { - if (nodes && nodes.length > 0) { - write(text); + function writeLines(text) { + var lines = text.split(/\r\n?|\n/g); + var indentation = guessIndentation(lines); + for (var i = 0; i < lines.length; i++) { + var line = indentation ? lines[i].slice(indentation) : lines[i]; + if (line.length) { + writeLine(); + write(line); + writeLine(); + } } } - function writeIfPresent(node, text) { - if (node !== undefined) { - write(text); + function guessIndentation(lines) { + var indentation; + for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { + var line = lines_1[_a]; + for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { + if (!ts.isWhiteSpace(line.charCodeAt(i))) { + if (indentation === undefined || i < indentation) { + indentation = i; + break; + } + } + } } - } - function writeToken(token, pos, contextNode) { - return emitTokenWithSourceMap(contextNode, token, pos, writeTokenText); - } - function writeTokenText(token, pos) { - var tokenString = ts.tokenToString(token); - write(tokenString); - return pos < 0 ? pos : pos + tokenString.length; + return indentation; } function increaseIndentIf(value, valueToWriteWhenNotIndenting) { if (value) { @@ -50908,15 +52071,23 @@ var ts; && !ts.nodeIsSynthesized(node2) && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } + function isSingleLineEmptyBlock(block) { + return !block.multiLine + && isEmptyBlock(block); + } + function isEmptyBlock(block) { + return block.statements.length === 0 + && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + } function skipSynthesizedParentheses(node) { - while (node.kind === 183 && ts.nodeIsSynthesized(node)) { + while (node.kind === 184 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; } function getTextOfNode(node, includeTrivia) { if (ts.isGeneratedIdentifier(node)) { - return getGeneratedIdentifier(node); + return generateName(node); } else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { return ts.unescapeIdentifier(node.text); @@ -50941,23 +52112,37 @@ var ts; } return ts.getLiteralText(node, currentSourceFile, languageVersion); } - function isSingleLineEmptyBlock(block) { - return !block.multiLine - && isEmptyBlock(block); + function pushNameGenerationScope() { + tempFlagsStack.push(tempFlags); + tempFlags = 0; } - function isEmptyBlock(block) { - return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + function popNameGenerationScope() { + tempFlags = tempFlagsStack.pop(); + } + function generateName(name) { + if (name.autoGenerateKind === 4) { + var node = getNodeForGeneratedName(name); + return generateNameCached(node); + } + else { + var autoGenerateId = name.autoGenerateId; + return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(makeName(name))); + } + } + function generateNameCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); } function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentFileIdentifiers, name) && - !ts.hasProperty(generatedNameSet, name); + return !(hasGlobalName && hasGlobalName(name)) + && !currentSourceFile.identifiers.has(name) + && !generatedNames.has(name); } function isUniqueLocalName(name, container) { for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { + if (node.locals) { + var local = node.locals.get(name); + if (local && local.flags & (107455 | 1048576 | 8388608)) { return false; } } @@ -50966,21 +52151,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_43 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_43)) { + var name = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name)) { tempFlags |= flags; - return name_43; + return name; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_44 = count < 26 + var name = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_44)) { - return name_44; + if (isUniqueName(name)) { + return name; } } } @@ -50993,7 +52178,8 @@ var ts; while (true) { var generatedName = baseName + i; if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; + generatedNames.set(generatedName, generatedName); + return generatedName; } i++; } @@ -51016,7 +52202,7 @@ var ts; } function generateNameForMethodOrAccessor(node) { if (ts.isIdentifier(node.name)) { - return generateNameForNodeCached(node.name); + return generateNameCached(node.name); } return makeTempVariableName(0); } @@ -51024,34 +52210,34 @@ var ts; switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); + case 232: case 231: - case 230: return generateNameForModuleOrEnum(node); - case 236: - case 242: + case 237: + case 243: return generateNameForImportOrExportDeclaration(node); - case 226: case 227: - case 241: + case 228: + case 242: return generateNameForExportDefault(); - case 197: + case 198: return generateNameForClassExpression(); - case 149: - case 151: + case 150: case 152: + case 153: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); } } - function generateName(name) { + function makeName(name) { switch (name.autoGenerateKind) { case 1: return makeTempVariableName(0); case 2: return makeTempVariableName(268435456); case 3: - return makeUniqueName(name.text); + return makeUniqueName(ts.unescapeIdentifier(name.text)); } ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } @@ -51070,47 +52256,101 @@ var ts; } return node; } - function generateNameForNodeCached(node) { - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); - } - function getGeneratedIdentifier(name) { - if (name.autoGenerateKind === 4) { - var node = getNodeForGeneratedName(name); - return generateNameForNodeCached(node); - } - else { - var autoGenerateId = name.autoGenerateId; - return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(generateName(name))); - } - } - function createDelimiterMap() { - var delimiters = []; - delimiters[0] = ""; - delimiters[16] = ","; - delimiters[4] = " |"; - delimiters[8] = " &"; - return delimiters; - } - function getDelimiter(format) { - return delimiters[format & 28]; - } - function createBracketsMap() { - var brackets = []; - brackets[512] = ["{", "}"]; - brackets[1024] = ["(", ")"]; - brackets[2048] = ["<", ">"]; - brackets[4096] = ["[", "]"]; - return brackets; - } - function getOpeningBracket(format) { - return brackets[format & 7680][0]; - } - function getClosingBracket(format) { - return brackets[format & 7680][1]; - } } - ts.emitFiles = emitFiles; + ts.createPrinter = createPrinter; + function createDelimiterMap() { + var delimiters = []; + delimiters[0] = ""; + delimiters[16] = ","; + delimiters[4] = " |"; + delimiters[8] = " &"; + return delimiters; + } + function getDelimiter(format) { + return delimiters[format & 28]; + } + function createBracketsMap() { + var brackets = []; + brackets[512] = ["{", "}"]; + brackets[1024] = ["(", ")"]; + brackets[2048] = ["<", ">"]; + brackets[4096] = ["[", "]"]; + return brackets; + } + function getOpeningBracket(format) { + return brackets[format & 7680][0]; + } + function getClosingBracket(format) { + return brackets[format & 7680][1]; + } + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); + var ListFormat; + (function (ListFormat) { + ListFormat[ListFormat["None"] = 0] = "None"; + ListFormat[ListFormat["SingleLine"] = 0] = "SingleLine"; + ListFormat[ListFormat["MultiLine"] = 1] = "MultiLine"; + ListFormat[ListFormat["PreserveLines"] = 2] = "PreserveLines"; + ListFormat[ListFormat["LinesMask"] = 3] = "LinesMask"; + ListFormat[ListFormat["NotDelimited"] = 0] = "NotDelimited"; + ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; + ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; + ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; + ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; + ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; + ListFormat[ListFormat["Indented"] = 64] = "Indented"; + ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; + ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; + ListFormat[ListFormat["Braces"] = 512] = "Braces"; + ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; + ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; + ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; + ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; + ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; + ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; + ListFormat[ListFormat["Optional"] = 24576] = "Optional"; + ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; + ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; + ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; + ListFormat[ListFormat["Modifiers"] = 256] = "Modifiers"; + ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; + ListFormat[ListFormat["TypeLiteralMembers"] = 65] = "TypeLiteralMembers"; + ListFormat[ListFormat["TupleTypeElements"] = 336] = "TupleTypeElements"; + ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; + ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; + ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; + ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; + ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; + ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; + ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; + ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; + ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; + ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; + ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; + ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; + ListFormat[ListFormat["ClassHeritageClauses"] = 256] = "ClassHeritageClauses"; + ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; + ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; + ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; + ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; + ListFormat[ListFormat["NamedImportsOrExportsElements"] = 432] = "NamedImportsOrExportsElements"; + ListFormat[ListFormat["JsxElementChildren"] = 131072] = "JsxElementChildren"; + ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; + ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; + ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; + ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; + ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; + ListFormat[ListFormat["TypeArguments"] = 26960] = "TypeArguments"; + ListFormat[ListFormat["TypeParameters"] = 26960] = "TypeParameters"; + ListFormat[ListFormat["Parameters"] = 1360] = "Parameters"; + ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; + })(ListFormat || (ListFormat = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -51194,11 +52434,11 @@ var ts; return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; } function directoryExists(directoryPath) { - if (directoryPath in existingDirectories) { + if (existingDirectories.has(directoryPath)) { return true; } if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; + existingDirectories.set(directoryPath, true); return true; } return false; @@ -51217,9 +52457,10 @@ var ts; } var hash = ts.sys.createHash(data); var mtimeBefore = ts.sys.getModifiedTime(fileName); - if (mtimeBefore && fileName in outputFingerprints) { - var fingerprint = outputFingerprints[fileName]; - if (fingerprint.byteOrderMark === writeByteOrderMark && + if (mtimeBefore) { + var fingerprint = outputFingerprints.get(fileName); + if (fingerprint && + fingerprint.byteOrderMark === writeByteOrderMark && fingerprint.hash === hash && fingerprint.mtime.getTime() === mtimeBefore.getTime()) { return; @@ -51227,11 +52468,11 @@ var ts; } ts.sys.writeFile(fileName, data, writeByteOrderMark); var mtimeAfter = ts.sys.getModifiedTime(fileName); - outputFingerprints[fileName] = { + outputFingerprints.set(fileName, { hash: hash, byteOrderMark: writeByteOrderMark, mtime: mtimeAfter - }; + }); } function writeFile(fileName, data, writeByteOrderMark, onError) { try { @@ -51330,10 +52571,14 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_45 = names_1[_i]; - var result = name_45 in cache - ? cache[name_45] - : cache[name_45] = loader(name_45, containingFile); + var name = names_1[_i]; + var result = void 0; + if (cache.has(name)) { + result = cache.get(name); + } + else { + cache.set(name, result = loader(name, containingFile)); + } resolutions.push(result); } return resolutions; @@ -51442,7 +52687,7 @@ var ts; return program; function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); } @@ -51461,7 +52706,7 @@ var ts; classifiableNames = ts.createMap(); for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { var sourceFile = files_2[_i]; - ts.copyProperties(sourceFile.classifiableNames, classifiableNames); + ts.copyEntries(sourceFile.classifiableNames, classifiableNames); } } return classifiableNames; @@ -51644,7 +52889,7 @@ var ts; }; } function isSourceFileFromExternalLibrary(file) { - return sourceFilesFoundSearchingNodeModules[file.path]; + return sourceFilesFoundSearchingNodeModules.get(file.path); } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); @@ -51761,57 +53006,57 @@ var ts; return diagnostics; function walk(node) { switch (parent.kind) { - case 144: - case 147: + case 145: + case 148: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 184: - case 226: + case 153: case 185: - case 226: - case 224: + case 227: + case 186: + case 227: + case 225: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 235: + case 236: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 241: + case 242: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 256: + case 258: var heritageClause = node; if (heritageClause.token === 107) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 228: + case 229: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 231: + case 232: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 229: + case 230: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 230: + case 231: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 182: + case 183: var typeAssertionExpression = node; diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; @@ -51826,26 +53071,26 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 227: - case 149: - case 148: + case 228: case 150: + case 149: case 151: case 152: - case 184: - case 226: + case 153: case 185: - case 226: + case 227: + case 186: + case 227: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 206: + case 207: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 206); + return checkModifiers(nodes, parent.kind === 207); } break; - case 147: + case 148: if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; @@ -51856,15 +53101,15 @@ var ts; return; } break; - case 144: + case 145: if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 179: case 180: - case 199: + case 181: + case 200: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; @@ -51952,11 +53197,10 @@ var ts; if (options.importHelpers && (options.isolatedModules || isExternalModuleFile) && !file.isDeclarationFile) { - var externalHelpersModuleReference = ts.createSynthesizedNode(9); - externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(236); - importDecl.parent = file; + var externalHelpersModuleReference = ts.createLiteral(ts.externalHelpersModuleNameText); + var importDecl = ts.createImportDeclaration(undefined, undefined, undefined); externalHelpersModuleReference.parent = importDecl; + importDecl.parent = file; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -51972,9 +53216,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 237: case 236: - case 235: - case 242: + case 243: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -51986,7 +53230,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 231: + case 232: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -52070,18 +53314,18 @@ var ts; if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd); } - if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { - sourceFilesFoundSearchingNodeModules[file_1.path] = false; + if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth == 0) { + sourceFilesFoundSearchingNodeModules.set(file_1.path, false); if (!options.noResolve) { processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } - else if (file_1 && modulesWithElidedImports[file_1.path]) { + else if (file_1 && modulesWithElidedImports.get(file_1.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } } @@ -52097,7 +53341,7 @@ var ts; }); filesByName.set(path, file); if (file) { - sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0); + sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; if (host.useCaseSensitiveFileNames()) { var existingFile = filesByNameIgnoreCase.get(path); @@ -52141,7 +53385,7 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { - var previousResolution = resolvedTypeReferenceDirectives[typeReferenceDirective]; + var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { return; } @@ -52169,7 +53413,7 @@ var ts; fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { - resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective; + resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); } } function createDiagnostic(refFile, refPos, refEnd, message) { @@ -52210,7 +53454,7 @@ var ts; var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { - modulesWithElidedImports[file.path] = true; + modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = ts.toPath(resolvedFileName, currentDirectory, getCanonicalFileName); @@ -52228,8 +53472,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var file = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var file = sourceFiles_3[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -52240,8 +53484,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -52392,7 +53636,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { + ts.forEachEmittedFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -52446,6 +53690,1139 @@ var ts; ts.getResolutionDiagnostic = getResolutionDiagnostic; })(ts || (ts = {})); var ts; +(function (ts) { + ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; + ts.optionDeclarations = [ + { + name: "charset", + type: "string", + }, + ts.compileOnSaveCommandLineOption, + { + name: "declaration", + shortName: "d", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_d_ts_file, + }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + }, + { + name: "diagnostics", + type: "boolean", + }, + { + name: "extendedDiagnostics", + type: "boolean", + experimental: true + }, + { + name: "emitBOM", + type: "boolean" + }, + { + name: "help", + shortName: "h", + type: "boolean", + description: ts.Diagnostics.Print_this_message, + }, + { + name: "help", + shortName: "?", + type: "boolean" + }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, + }, + { + name: "inlineSourceMap", + type: "boolean", + }, + { + name: "inlineSources", + type: "boolean", + }, + { + name: "jsx", + type: ts.createMapFromTemplate({ + "preserve": 1, + "react-native": 3, + "react": 2 + }), + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, + }, + { + name: "reactNamespace", + type: "string", + description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit + }, + { + name: "jsxFactory", + type: "string", + description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, + { + name: "listFiles", + type: "boolean", + }, + { + name: "locale", + type: "string", + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + paramType: ts.Diagnostics.LOCATION, + }, + { + name: "module", + shortName: "m", + type: ts.createMapFromTemplate({ + "none": ts.ModuleKind.None, + "commonjs": ts.ModuleKind.CommonJS, + "amd": ts.ModuleKind.AMD, + "system": ts.ModuleKind.System, + "umd": ts.ModuleKind.UMD, + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, + }), + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, + paramType: ts.Diagnostics.KIND, + }, + { + name: "newLine", + type: ts.createMapFromTemplate({ + "crlf": 0, + "lf": 1 + }), + description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: ts.Diagnostics.NEWLINE, + }, + { + name: "noEmit", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs, + }, + { + name: "noEmitHelpers", + type: "boolean" + }, + { + name: "noEmitOnError", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "noErrorTruncation", + type: "boolean" + }, + { + name: "noImplicitAny", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, + }, + { + name: "noImplicitThis", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + }, + { + name: "noUnusedLocals", + type: "boolean", + description: ts.Diagnostics.Report_errors_on_unused_locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + description: ts.Diagnostics.Report_errors_on_unused_parameters, + }, + { + name: "noLib", + type: "boolean", + }, + { + name: "noResolve", + type: "boolean", + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + }, + { + name: "skipLibCheck", + type: "boolean", + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "out", + type: "string", + isFilePath: false, + paramType: ts.Diagnostics.FILE, + }, + { + name: "outFile", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + paramType: ts.Diagnostics.FILE, + }, + { + name: "outDir", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Redirect_output_structure_to_the_directory, + paramType: ts.Diagnostics.DIRECTORY, + }, + { + name: "preserveConstEnums", + type: "boolean", + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, + { + name: "pretty", + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, + type: "boolean" + }, + { + name: "project", + shortName: "p", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY + }, + { + name: "removeComments", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_comments_to_output, + }, + { + name: "rootDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + }, + { + name: "isolatedModules", + type: "boolean", + }, + { + name: "sourceMap", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_map_file, + }, + { + name: "sourceRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + paramType: ts.Diagnostics.LOCATION, + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + }, + { + name: "stripInternal", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + experimental: true + }, + { + name: "target", + shortName: "t", + type: ts.createMapFromTemplate({ + "es3": 0, + "es5": 1, + "es6": 2, + "es2015": 2, + "es2016": 3, + "es2017": 4, + "esnext": 5, + }), + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, + paramType: ts.Diagnostics.VERSION, + }, + { + name: "version", + shortName: "v", + type: "boolean", + description: ts.Diagnostics.Print_the_compiler_s_version, + }, + { + name: "watch", + shortName: "w", + type: "boolean", + description: ts.Diagnostics.Watch_input_files, + }, + { + name: "experimentalDecorators", + type: "boolean", + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + experimental: true, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: ts.createMapFromTemplate({ + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic, + }), + description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + paramType: ts.Diagnostics.STRATEGY, + }, + { + name: "allowUnusedLabels", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "noImplicitReturns", + type: "boolean", + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "allowUnreachableCode", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + { + name: "baseUrl", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + name: "paths", + type: "object", + isTSConfigOnly: true + }, + { + name: "rootDirs", + type: "list", + isTSConfigOnly: true, + element: { + name: "rootDirs", + type: "string", + isFilePath: true + } + }, + { + name: "typeRoots", + type: "list", + element: { + name: "typeRoots", + type: "string", + isFilePath: true + } + }, + { + name: "types", + type: "list", + element: { + name: "types", + type: "string" + }, + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + }, + { + name: "traceResolution", + type: "boolean", + description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process + }, + { + name: "allowJs", + type: "boolean", + description: ts.Diagnostics.Allow_javascript_files_to_be_compiled + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "noImplicitUseStrict", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + }, + { + name: "listEmittedFiles", + type: "boolean" + }, + { + name: "lib", + type: "list", + element: { + name: "lib", + type: ts.createMapFromTemplate({ + "es5": "lib.es5.d.ts", + "es6": "lib.es2015.d.ts", + "es2015": "lib.es2015.d.ts", + "es7": "lib.es2016.d.ts", + "es2016": "lib.es2016.d.ts", + "es2017": "lib.es2017.d.ts", + "dom": "lib.dom.d.ts", + "dom.iterable": "lib.dom.iterable.d.ts", + "webworker": "lib.webworker.d.ts", + "scripthost": "lib.scripthost.d.ts", + "es2015.core": "lib.es2015.core.d.ts", + "es2015.collection": "lib.es2015.collection.d.ts", + "es2015.generator": "lib.es2015.generator.d.ts", + "es2015.iterable": "lib.es2015.iterable.d.ts", + "es2015.promise": "lib.es2015.promise.d.ts", + "es2015.proxy": "lib.es2015.proxy.d.ts", + "es2015.reflect": "lib.es2015.reflect.d.ts", + "es2015.symbol": "lib.es2015.symbol.d.ts", + "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", + "es2016.array.include": "lib.es2016.array.include.d.ts", + "es2017.object": "lib.es2017.object.d.ts", + "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", + "es2017.string": "lib.es2017.string.d.ts", + }), + }, + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon + }, + { + name: "disableSizeLimit", + type: "boolean" + }, + { + name: "strictNullChecks", + type: "boolean", + description: ts.Diagnostics.Enable_strict_null_checks + }, + { + name: "importHelpers", + type: "boolean", + description: ts.Diagnostics.Import_emit_helpers_from_tslib + }, + { + name: "alwaysStrict", + type: "boolean", + description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + }, + { + name: "plugins", + type: "list", + isTSConfigOnly: true, + element: { + name: "plugin", + type: "object" + } + } + ]; + ts.typeAcquisitionDeclarations = [ + { + name: "enableAutoDiscovery", + type: "boolean", + }, + { + name: "enable", + type: "boolean", + }, + { + name: "include", + type: "list", + element: { + name: "include", + type: "string" + } + }, + { + name: "exclude", + type: "list", + element: { + name: "exclude", + type: "string" + } + } + ]; + ts.defaultInitCompilerOptions = { + module: ts.ModuleKind.CommonJS, + target: 1, + noImplicitAny: false, + sourceMap: false, + }; + var optionNameMapCache; + function convertEnableAutoDiscoveryToEnable(typeAcquisition) { + if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) { + var result = { + enable: typeAcquisition.enableAutoDiscovery, + include: typeAcquisition.include || [], + exclude: typeAcquisition.exclude || [] + }; + return result; + } + return typeAcquisition; + } + ts.convertEnableAutoDiscoveryToEnable = convertEnableAutoDiscoveryToEnable; + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } + var optionNameMap = ts.createMap(); + var shortOptionNames = ts.createMap(); + ts.forEach(ts.optionDeclarations, function (option) { + optionNameMap.set(option.name.toLowerCase(), option); + if (option.shortName) { + shortOptionNames.set(option.shortName, option.name); + } + }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function createCompilerDiagnosticForInvalidCustomType(opt) { + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); + return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + } + ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; + function parseCustomTypeOption(opt, value, errors) { + return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors); + } + ts.parseCustomTypeOption = parseCustomTypeOption; + function parseListTypeOption(opt, value, errors) { + if (value === void 0) { value = ""; } + value = trimString(value); + if (ts.startsWith(value, "-")) { + return undefined; + } + if (value === "") { + return []; + } + var values = value.split(","); + switch (opt.element.type) { + case "number": + return ts.map(values, parseInt); + case "string": + return ts.map(values, function (v) { return v || ""; }); + default: + return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); + } + } + ts.parseListTypeOption = parseListTypeOption; + function parseCommandLine(commandLine, readFile) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; + parseStrings(commandLine); + return { + options: options, + fileNames: fileNames, + errors: errors + }; + function parseStrings(args) { + var i = 0; + while (i < args.length) { + var s = args[i]; + i++; + if (s.charCodeAt(0) === 64) { + parseResponseFile(s.slice(1)); + } + else if (s.charCodeAt(0) === 45) { + s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); + var short = shortOptionNames.get(s); + if (short !== undefined) { + s = short; + } + var opt = optionNameMap.get(s); + if (opt) { + if (opt.isTSConfigOnly) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); + } + else { + if (!args[i] && opt.type !== "boolean") { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); + } + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); + i++; + break; + case "boolean": + var optValue = args[i]; + options[opt.name] = optValue !== "false"; + if (optValue === "false" || optValue === "true") { + i++; + } + break; + case "string": + options[opt.name] = args[i] || ""; + i++; + break; + case "list": + var result = parseListTypeOption(opt, args[i], errors); + options[opt.name] = result || []; + if (result) { + i++; + } + break; + default: + options[opt.name] = parseCustomTypeOption(opt, args[i], errors); + i++; + break; + } + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); + } + } + else { + fileNames.push(s); + } + } + } + function parseResponseFile(fileName) { + var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); + if (!text) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); + return; + } + var args = []; + var pos = 0; + while (true) { + while (pos < text.length && text.charCodeAt(pos) <= 32) + pos++; + if (pos >= text.length) + break; + var start = pos; + if (text.charCodeAt(start) === 34) { + pos++; + while (pos < text.length && text.charCodeAt(pos) !== 34) + pos++; + if (pos < text.length) { + args.push(text.substring(start + 1, pos)); + pos++; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName)); + } + } + else { + while (text.charCodeAt(pos) > 32) + pos++; + args.push(text.substring(start, pos)); + } + } + parseStrings(args); + } + } + ts.parseCommandLine = parseCommandLine; + function readConfigFile(fileName, readFile) { + var text = ""; + try { + text = readFile(fileName); + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; + } + return parseConfigFileTextToJson(fileName, text); + } + ts.readConfigFile = readConfigFile; + function parseConfigFileTextToJson(fileName, jsonText, stripComments) { + if (stripComments === void 0) { stripComments = true; } + try { + var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; + return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + } + } + ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + function generateTSConfig(options, fileNames) { + var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); + var configurations = { + compilerOptions: serializeCompilerOptions(compilerOptions) + }; + if (fileNames && fileNames.length) { + configurations.files = fileNames; + } + return configurations; + function getCustomTypeMapOfCommandLineOption(optionDefinition) { + if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + return undefined; + } + else if (optionDefinition.type === "list") { + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + } + else { + return optionDefinition.type; + } + } + function getNameOfCompilerOptionValue(value, customTypeMap) { + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { + return key; + } + }); + } + function serializeCompilerOptions(options) { + var result = {}; + var optionsNameMap = getOptionNameMap().optionNameMap; + for (var name in options) { + if (ts.hasProperty(options, name)) { + switch (name) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); + if (optionDefinition) { + var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + result[name] = value; + } + else { + if (optionDefinition.type === "list") { + var convertedValue = []; + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); + } + result[name] = convertedValue; + } + else { + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } + } + break; + } + } + } + return result; + } + } + ts.generateTSConfig = generateTSConfig; + function removeComments(jsonText) { + var output = ""; + var scanner = ts.createScanner(1, false, 0, jsonText); + var token; + while ((token = scanner.scan()) !== 1) { + switch (token) { + case 2: + case 3: + output += scanner.getTokenText().replace(/\S/g, " "); + break; + default: + output += scanner.getTokenText(); + break; + } + } + return output; + } + function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions) { + if (existingOptions === void 0) { existingOptions = {}; } + if (resolutionStack === void 0) { resolutionStack = []; } + if (extraFileExtensions === void 0) { extraFileExtensions = []; } + var errors = []; + basePath = ts.normalizeSlashes(basePath); + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); + if (resolutionStack.indexOf(resolvedPath) >= 0) { + return { + options: {}, + fileNames: [], + typeAcquisition: {}, + raw: json, + errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], + wildcardDirectories: {} + }; + } + var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); + var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; + var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); + if (json["extends"]) { + var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; + if (typeof json["extends"] === "string") { + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); + } + if (include && !json["include"]) { + json["include"] = include; + } + if (exclude && !json["exclude"]) { + json["exclude"] = exclude; + } + if (files && !json["files"]) { + json["files"] = files; + } + options = ts.assign({}, baseOptions, options); + } + options = ts.extend(existingOptions, options); + options.configFilePath = configFileName; + var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; + var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + return { + options: options, + fileNames: fileNames, + typeAcquisition: typeAcquisition, + raw: json, + errors: errors, + wildcardDirectories: wildcardDirectories, + compileOnSave: compileOnSave + }; + function tryExtendsName(extendedConfig) { + if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig)); + return; + } + var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { + extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return; + } + } + var extendedResult = readConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); + if (extendedResult.error) { + errors.push(extendedResult.error); + return; + } + var extendedDirname = ts.getDirectoryPath(extendedConfigPath); + var relativeDifference = ts.convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); + var updatePath = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference, path); }; + var result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, undefined, ts.getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); + errors.push.apply(errors, result.errors); + var _a = ts.map(["include", "exclude", "files"], function (key) { + if (!json[key] && extendedResult.config[key]) { + return ts.map(extendedResult.config[key], updatePath); + } + }), include = _a[0], exclude = _a[1], files = _a[2]; + return [include, exclude, files, result.options]; + } + function getFileNames(errors) { + var fileNames; + if (ts.hasProperty(json, "files")) { + if (ts.isArray(json["files"])) { + fileNames = json["files"]; + if (fileNames.length === 0) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json")); + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } + } + var includeSpecs; + if (ts.hasProperty(json, "include")) { + if (ts.isArray(json["include"])) { + includeSpecs = json["include"]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array")); + } + } + var excludeSpecs; + if (ts.hasProperty(json, "exclude")) { + if (ts.isArray(json["exclude"])) { + excludeSpecs = json["exclude"]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); + } + } + else if (ts.hasProperty(json, "excludes")) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); + } + else { + excludeSpecs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"]; + var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; + if (outDir) { + excludeSpecs.push(outDir); + } + } + if (fileNames === undefined && includeSpecs === undefined) { + includeSpecs = ["**/*"]; + } + var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions); + if (result.fileNames.length === 0 && !ts.hasProperty(json, "files") && resolutionStack.length === 0) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []))); + } + return result; + } + var _b; + } + ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { + if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { + return false; + } + var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); + if (typeof result === "boolean" && result) { + return result; + } + return false; + } + ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; + function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { + var errors = []; + var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); + return { options: options, errors: errors }; + } + ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; + function convertTypeAcquisitionFromJson(jsonOptions, basePath, configFileName) { + var errors = []; + var options = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); + return { options: options, errors: errors }; + } + ts.convertTypeAcquisitionFromJson = convertTypeAcquisitionFromJson; + function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } + : {}; + convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); + return options; + } + function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + var options = { enable: ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; + var typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions); + convertOptionsFromJson(ts.typeAcquisitionDeclarations, typeAcquisition, basePath, options, ts.Diagnostics.Unknown_type_acquisition_option_0, errors); + return options; + } + function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { + if (!jsonOptions) { + return; + } + var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); + for (var id in jsonOptions) { + var opt = optionNameMap.get(id); + if (opt) { + defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); + } + else { + errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id)); + } + } + } + function convertJsonOption(opt, value, basePath, errors) { + var optType = opt.type; + var expectedType = typeof optType === "string" ? optType : "string"; + if (optType === "list" && ts.isArray(value)) { + return convertJsonOptionOfListType(opt, value, basePath, errors); + } + else if (typeof value === expectedType) { + if (typeof optType !== "string") { + return convertJsonOptionOfCustomType(opt, value, errors); + } + else { + if (opt.isFilePath) { + value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } + } + } + return value; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); + } + } + function convertJsonOptionOfCustomType(opt, value, errors) { + var key = value.toLowerCase(); + var val = opt.type.get(key); + if (val !== undefined) { + return val; + } + else { + errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); + } + } + function convertJsonOptionOfListType(option, values, basePath, errors) { + return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); + } + function trimString(s) { + return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); + } + var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; + var invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; + var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; + var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; + var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; + function matchFileNames(fileNames, include, exclude, basePath, options, host, errors, extraFileExtensions) { + basePath = ts.normalizePath(basePath); + var keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; + var literalFileMap = ts.createMap(); + var wildcardFileMap = ts.createMap(); + if (include) { + include = validateSpecs(include, errors, false); + } + if (exclude) { + exclude = validateSpecs(exclude, errors, true); + } + var wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); + var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions); + if (fileNames) { + for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { + var fileName = fileNames_1[_i]; + var file = ts.combinePaths(basePath, fileName); + literalFileMap.set(keyMapper(file), file); + } + } + if (include && include.length > 0) { + for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, exclude, include); _a < _b.length; _a++) { + var file = _b[_a]; + if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) { + continue; + } + removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); + var key = keyMapper(file); + if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) { + wildcardFileMap.set(key, file); + } + } + } + var literalFiles = ts.arrayFrom(literalFileMap.values()); + var wildcardFiles = ts.arrayFrom(wildcardFileMap.values()); + return { + fileNames: literalFiles.concat(wildcardFiles), + wildcardDirectories: wildcardDirectories + }; + } + function validateSpecs(specs, errors, allowTrailingRecursion) { + var validSpecs = []; + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + var spec = specs_1[_i]; + if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + } + else if (invalidMultipleRecursionPatterns.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); + } + else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + } + else { + validSpecs.push(spec); + } + } + return validSpecs; + } + function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { + var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); + var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); + var wildcardDirectories = {}; + if (include !== undefined) { + var recursiveKeys = []; + for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { + var file = include_1[_i]; + var spec = ts.normalizePath(ts.combinePaths(path, file)); + if (excludeRegex && excludeRegex.test(spec)) { + continue; + } + var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames); + if (match) { + var key = match.key, flags = match.flags; + var existingFlags = wildcardDirectories[key]; + if (existingFlags === undefined || existingFlags < flags) { + wildcardDirectories[key] = flags; + if (flags === 1) { + recursiveKeys.push(key); + } + } + } + } + for (var key in wildcardDirectories) + if (ts.hasProperty(wildcardDirectories, key)) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } + } + } + ; + } + return wildcardDirectories; + } + function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { + var match = wildcardDirectoryPattern.exec(spec); + if (match) { + return { + key: useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(), + flags: watchRecursivePattern.test(spec) ? 1 : 0 + }; + } + if (ts.isImplicitGlob(spec)) { + return { key: spec, flags: 1 }; + } + return undefined; + } + function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { + var extensionPriority = ts.getExtensionPriority(file, extensions); + var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions); + for (var i = 0; i < adjustedExtensionPriority; i++) { + var higherPriorityExtension = extensions[i]; + var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); + if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { + return true; + } + } + return false; + } + function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { + var extensionPriority = ts.getExtensionPriority(file, extensions); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions); + for (var i = nextExtensionPriority; i < extensions.length; i++) { + var lowerPriorityExtension = extensions[i]; + var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); + wildcardFiles.delete(lowerPriorityPath); + } + } + function caseSensitiveKeyMapper(key) { + return key; + } + function caseInsensitiveKeyMapper(key) { + return key.toLowerCase(); + } +})(ts || (ts = {})); +var ts; (function (ts) { var ScriptSnapshot; (function (ScriptSnapshot) { @@ -52515,6 +54892,22 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + var OutputFileType; + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(OutputFileType = ts.OutputFileType || (ts.OutputFileType = {})); + var EndOfLineState; + (function (EndOfLineState) { + EndOfLineState[EndOfLineState["None"] = 0] = "None"; + EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; + EndOfLineState[EndOfLineState["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate"; + EndOfLineState[EndOfLineState["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail"; + EndOfLineState[EndOfLineState["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition"; + })(EndOfLineState = ts.EndOfLineState || (ts.EndOfLineState = {})); var TokenClass; (function (TokenClass) { TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; @@ -52561,6 +54954,7 @@ var ts; ScriptElementKind.letElement = "let"; ScriptElementKind.directory = "directory"; ScriptElementKind.externalModuleName = "external module name"; + ScriptElementKind.jsxAttribute = "JSX attribute"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { @@ -52602,40 +54996,76 @@ var ts; ClassificationTypeNames.jsxText = "jsx text"; ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; ts.ClassificationTypeNames = ClassificationTypeNames; + var ClassificationType; + (function (ClassificationType) { + ClassificationType[ClassificationType["comment"] = 1] = "comment"; + ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; + ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; + ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; + ClassificationType[ClassificationType["operator"] = 5] = "operator"; + ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; + ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; + ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; + ClassificationType[ClassificationType["text"] = 9] = "text"; + ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; + ClassificationType[ClassificationType["className"] = 11] = "className"; + ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; + ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; + ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; + ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; + ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; + ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; + ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName"; + ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName"; + ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName"; + ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName"; + ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; + ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; + ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; + })(ClassificationType = ts.ClassificationType || (ts.ClassificationType = {})); })(ts || (ts = {})); var ts; (function (ts) { ts.scanner = ts.createScanner(5, true); ts.emptyArray = []; + var SemanticMeaning; + (function (SemanticMeaning) { + SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; + SemanticMeaning[SemanticMeaning["Value"] = 1] = "Value"; + SemanticMeaning[SemanticMeaning["Type"] = 2] = "Type"; + SemanticMeaning[SemanticMeaning["Namespace"] = 4] = "Namespace"; + SemanticMeaning[SemanticMeaning["All"] = 7] = "All"; + })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 144: - case 224: - case 174: - case 147: - case 146: - case 258: - case 259: - case 261: - case 149: + case 145: + case 225: + case 175: case 148: + case 147: + case 260: + case 261: + case 263: case 150: + case 149: case 151: case 152: - case 226: - case 184: - case 185: - case 257: - return 1; - case 143: - case 228: - case 229: - case 161: - return 2; + case 153: case 227: + case 185: + case 186: + case 259: + case 252: + return 1; + case 144: + case 229: case 230: - return 1 | 2; + case 162: + return 2; + case 228: case 231: + return 1 | 2; + case 232: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -52645,21 +55075,24 @@ var ts; else { return 4; } - case 239: case 240: - case 235: - case 236: case 241: + case 236: + case 237: case 242: + case 243: return 1 | 2 | 4; - case 262: + case 264: return 4 | 1; } return 1 | 2 | 4; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 241) { + if (node.kind === 264) { + return 1; + } + else if (node.parent.kind === 242) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -52681,15 +55114,15 @@ var ts; ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { ts.Debug.assert(node.kind === 70); - if (node.parent.kind === 141 && + if (node.parent.kind === 142 && node.parent.right === node && - node.parent.parent.kind === 235) { + node.parent.parent.kind === 236) { return 1 | 2 | 4; } return 4; } function isInRightSideOfImport(node) { - while (node.parent.kind === 141) { + while (node.parent.kind === 142) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -52700,27 +55133,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 141) { - while (root.parent && root.parent.kind === 141) { + if (root.parent.kind === 142) { + while (root.parent && root.parent.kind === 142) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 157 && !isLastClause; + return root.parent.kind === 158 && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 177) { - while (root.parent && root.parent.kind === 177) { + if (root.parent.kind === 178) { + while (root.parent && root.parent.kind === 178) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 199 && root.parent.parent.kind === 256) { + if (!isLastClause && root.parent.kind === 200 && root.parent.parent.kind === 258) { var decl = root.parent.parent.parent; - return (decl.kind === 227 && root.parent.parent.token === 107) || - (decl.kind === 228 && root.parent.parent.token === 84); + return (decl.kind === 228 && root.parent.parent.token === 107) || + (decl.kind === 229 && root.parent.parent.token === 84); } return false; } @@ -52728,17 +55161,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 157 || - (node.parent.kind === 199 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 158 || + (node.parent.kind === 200 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 98 && !ts.isPartOfExpression(node)) || - node.kind === 167; + node.kind === 168; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 179); + return isCallOrNewExpressionTarget(node, 180); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 180); + return isCallOrNewExpressionTarget(node, 181); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -52751,7 +55184,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 220 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 221 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -52761,13 +55194,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 && - (node.parent.kind === 216 || node.parent.kind === 215) && + (node.parent.kind === 217 || node.parent.kind === 216) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 && - node.parent.kind === 220 && + node.parent.kind === 221 && node.parent.label === node; } function isLabelName(node) { @@ -52775,15 +55208,15 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 141 && node.parent.right === node; + return node.parent.kind === 142 && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 177 && node.parent.name === node; + return node && node.parent && node.parent.kind === 178 && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 231 && node.parent.name === node; + return node.parent.kind === 232 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -52794,19 +55227,19 @@ var ts; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { - case 147: - case 146: - case 258: - case 261: - case 149: case 148: - case 151: + case 147: + case 260: + case 263: + case 150: + case 149: case 152: - case 231: + case 153: + case 232: return node.parent.name === node; - case 178: + case 179: return node.parent.argumentExpression === node; - case 142: + case 143: return true; } } @@ -52850,17 +55283,17 @@ var ts; return undefined; } switch (node.kind) { - case 262: + case 264: + case 150: case 149: - case 148: - case 226: - case 184: - case 151: - case 152: case 227: + case 185: + case 152: + case 153: case 228: - case 230: + case 229: case 231: + case 232: return node; } } @@ -52868,46 +55301,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 262: + case 264: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 231: + case 232: return ts.ScriptElementKind.moduleElement; - case 227: - case 197: + case 228: + case 198: return ts.ScriptElementKind.classElement; - case 228: return ts.ScriptElementKind.interfaceElement; - case 229: return ts.ScriptElementKind.typeElement; - case 230: return ts.ScriptElementKind.enumElement; - case 224: + case 229: return ts.ScriptElementKind.interfaceElement; + case 230: return ts.ScriptElementKind.typeElement; + case 231: return ts.ScriptElementKind.enumElement; + case 225: return getKindOfVariableDeclaration(node); - case 174: + case 175: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); + case 186: + case 227: case 185: - case 226: - case 184: return ts.ScriptElementKind.functionElement; - case 151: return ts.ScriptElementKind.memberGetAccessorElement; - case 152: return ts.ScriptElementKind.memberSetAccessorElement; + case 152: return ts.ScriptElementKind.memberGetAccessorElement; + case 153: return ts.ScriptElementKind.memberSetAccessorElement; + case 150: case 149: - case 148: return ts.ScriptElementKind.memberFunctionElement; + case 148: case 147: - case 146: return ts.ScriptElementKind.memberVariableElement; - case 155: return ts.ScriptElementKind.indexSignatureElement; - case 154: return ts.ScriptElementKind.constructSignatureElement; - case 153: return ts.ScriptElementKind.callSignatureElement; - case 150: return ts.ScriptElementKind.constructorImplementationElement; - case 143: return ts.ScriptElementKind.typeParameterElement; - case 261: return ts.ScriptElementKind.enumMemberElement; - case 144: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 235: - case 240: - case 237: - case 244: + case 156: return ts.ScriptElementKind.indexSignatureElement; + case 155: return ts.ScriptElementKind.constructSignatureElement; + case 154: return ts.ScriptElementKind.callSignatureElement; + case 151: return ts.ScriptElementKind.constructorImplementationElement; + case 144: return ts.ScriptElementKind.typeParameterElement; + case 263: return ts.ScriptElementKind.enumMemberElement; + case 145: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 236: + case 241: case 238: + case 245: + case 239: return ts.ScriptElementKind.alias; - case 286: + case 289: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -52922,7 +55355,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 171 ? node.parent : node; + var searchNode = node.parent.kind === 172 ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32) { return type; @@ -52935,7 +55368,7 @@ var ts; case 98: return true; case 70: - return ts.identifierIsThisKeyword(node) && node.parent.kind === 144; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 145; default: return false; } @@ -52979,41 +55412,41 @@ var ts; return false; } switch (n.kind) { - case 227: case 228: - case 230: - case 176: - case 172: - case 161: - case 205: - case 232: + case 229: + case 231: + case 177: + case 173: + case 162: + case 206: case 233: - case 239: - case 243: + case 234: + case 240: + case 244: return nodeEndsWith(n, 17, sourceFile); - case 257: + case 259: return isCompletedNode(n.block, sourceFile); - case 180: + case 181: if (!n.arguments) { return true; } - case 179: - case 183: - case 166: + case 180: + case 184: + case 167: return nodeEndsWith(n, 19, sourceFile); - case 158: case 159: + case 160: return isCompletedNode(n.type, sourceFile); - case 150: case 151: case 152: - case 226: - case 184: - case 149: - case 148: - case 154: case 153: + case 227: case 185: + case 150: + case 149: + case 155: + case 154: + case 186: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -53021,65 +55454,65 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19, sourceFile); - case 231: + case 232: return n.body && isCompletedNode(n.body, sourceFile); - case 209: + case 210: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 208: + case 209: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24); - case 175: - case 173: - case 178: - case 142: - case 163: + case 176: + case 174: + case 179: + case 143: + case 164: return nodeEndsWith(n, 21, sourceFile); - case 155: + case 156: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21, sourceFile); - case 254: - case 255: + case 256: + case 257: return false; - case 212: case 213: case 214: - case 211: + case 215: + case 212: return isCompletedNode(n.statement, sourceFile); - case 210: + case 211: var hasWhileKeyword = findChildOfKind(n, 105, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 19, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 160: + case 161: return isCompletedNode(n.exprName, sourceFile); - case 187: - case 186: case 188: - case 195: + case 187: + case 189: case 196: + case 197: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 181: + case 182: return isCompletedNode(n.template, sourceFile); - case 194: + case 195: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 203: + case 204: return ts.nodeIsPresent(n.literal); - case 242: - case 236: + case 243: + case 237: return ts.nodeIsPresent(n.moduleSpecifier); - case 190: + case 191: return isCompletedNode(n.operand, sourceFile); - case 192: - return isCompletedNode(n.right, sourceFile); case 193: + return isCompletedNode(n.right, sourceFile); + case 194: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -53122,7 +55555,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 293 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 296 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -53257,7 +55690,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 262); + ts.Debug.assert(startNode !== undefined || n.kind === 264); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -53302,13 +55735,13 @@ var ts; if (token.kind === 26 && token.parent.kind === 10) { return true; } - if (token.kind === 26 && token.parent.kind === 253) { + if (token.kind === 26 && token.parent.kind === 255) { return true; } - if (token && token.kind === 17 && token.parent.kind === 253) { + if (token && token.kind === 17 && token.parent.kind === 255) { return true; } - if (token.kind === 26 && token.parent.kind === 250) { + if (token.kind === 26 && token.parent.kind === 251) { return true; } return false; @@ -53399,17 +55832,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 157 || node.kind === 179) { + if (node.kind === 158 || node.kind === 180) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 227 || node.kind === 228) { + if (ts.isFunctionLike(node) || node.kind === 228 || node.kind === 229) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 140; + return n.kind >= 0 && n.kind <= 141; } ts.isToken = isToken; function isWord(kind) { @@ -53468,18 +55901,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 175 || - node.kind === 176) { - if (node.parent.kind === 192 && + if (node.kind === 176 || + node.kind === 177) { + if (node.parent.kind === 193 && node.parent.left === node && node.parent.operatorToken.kind === 57) { return true; } - if (node.parent.kind === 214 && + if (node.parent.kind === 215 && node.parent.initializer === node) { return true; } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 258 ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 260 ? node.parent.parent : node.parent)) { return true; } } @@ -53507,10 +55940,30 @@ var ts; } } ts.isInNonReferenceComment = isInNonReferenceComment; + function createTextSpanFromNode(node, sourceFile) { + return ts.createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); + } + ts.createTextSpanFromNode = createTextSpanFromNode; + function isTypeKeyword(kind) { + switch (kind) { + case 118: + case 121: + case 129: + case 132: + case 133: + case 135: + case 136: + case 104: + return true; + default: + return false; + } + } + ts.isTypeKeyword = isTypeKeyword; })(ts || (ts = {})); (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 144; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 145; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -53534,7 +55987,8 @@ var ts; decreaseIndent: function () { indent--; }, clear: resetWriter, trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop }; function writeIndent() { if (lineStart) { @@ -53686,7 +56140,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location) && - location.parent.kind === 142) { + location.parent.kind === 143) { return location.text; } var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); @@ -53696,7 +56150,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 240 || location.parent.kind === 244) && + (location.parent.kind === 241 || location.parent.kind === 245) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -53805,89 +56259,89 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 206: + case 207: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 224: - case 147: - case 146: - return spanInVariableDeclaration(node); - case 144: - return spanInParameterDeclaration(node); - case 226: - case 149: + case 225: case 148: - case 151: - case 152: + case 147: + return spanInVariableDeclaration(node); + case 145: + return spanInParameterDeclaration(node); + case 227: case 150: - case 184: + case 149: + case 152: + case 153: + case 151: case 185: + case 186: return spanInFunctionDeclaration(node); - case 205: + case 206: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 232: + case 233: return spanInBlock(node); - case 257: + case 259: return spanInBlock(node.block); - case 208: - return textSpan(node.expression); - case 217: - return textSpan(node.getChildAt(0), node.expression); - case 211: - return textSpanEndingAtNextToken(node, node.expression); - case 210: - return spanInNode(node.statement); - case 223: - return textSpan(node.getChildAt(0)); case 209: - return textSpanEndingAtNextToken(node, node.expression); - case 220: - return spanInNode(node.statement); - case 216: - case 215: - return textSpan(node.getChildAt(0), node.label); + return textSpan(node.expression); + case 218: + return textSpan(node.getChildAt(0), node.expression); case 212: - return spanInForStatement(node); - case 213: return textSpanEndingAtNextToken(node, node.expression); - case 214: - return spanInInitializerOfForLike(node); - case 219: + case 211: + return spanInNode(node.statement); + case 224: + return textSpan(node.getChildAt(0)); + case 210: return textSpanEndingAtNextToken(node, node.expression); - case 254: - case 255: - return spanInNode(node.statements[0]); - case 222: - return spanInBlock(node.tryBlock); case 221: + return spanInNode(node.statement); + case 217: + case 216: + return textSpan(node.getChildAt(0), node.label); + case 213: + return spanInForStatement(node); + case 214: + return textSpanEndingAtNextToken(node, node.expression); + case 215: + return spanInInitializerOfForLike(node); + case 220: + return textSpanEndingAtNextToken(node, node.expression); + case 256: + case 257: + return spanInNode(node.statements[0]); + case 223: + return spanInBlock(node.tryBlock); + case 222: return textSpan(node, node.expression); - case 241: - return textSpan(node, node.expression); - case 235: - return textSpan(node, node.moduleReference); - case 236: - return textSpan(node, node.moduleSpecifier); case 242: + return textSpan(node, node.expression); + case 236: + return textSpan(node, node.moduleReference); + case 237: return textSpan(node, node.moduleSpecifier); - case 231: + case 243: + return textSpan(node, node.moduleSpecifier); + case 232: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 227: - case 230: - case 261: - case 174: - return textSpan(node); - case 218: - return spanInNode(node.statement); - case 145: - return spanInNodeArray(node.parent.decorators); - case 172: - case 173: - return spanInBindingPattern(node); case 228: + case 231: + case 263: + case 175: + return textSpan(node); + case 219: + return spanInNode(node.statement); + case 146: + return spanInNodeArray(node.parent.decorators); + case 173: + case 174: + return spanInBindingPattern(node); case 229: + case 230: return undefined; case 24: case 1: @@ -53915,20 +56369,20 @@ var ts; case 73: case 86: return spanInNextNode(node); - case 140: + case 141: return spanInOfKeyword(node); default: if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); } if ((node.kind === 70 || - node.kind == 196 || - node.kind === 258 || - node.kind === 259) && + node.kind == 197 || + node.kind === 260 || + node.kind === 261) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 192) { + if (node.kind === 193) { var binaryExpression = node; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); @@ -53943,38 +56397,38 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 210: + case 211: return spanInPreviousNode(node); - case 145: + case 146: return spanInNode(node.parent); - case 212: - case 214: + case 213: + case 215: return textSpan(node); - case 192: + case 193: if (node.parent.operatorToken.kind === 25) { return textSpan(node); } break; - case 185: + case 186: if (node.parent.body === node) { return textSpan(node); } break; } } - if (node.parent.kind === 258 && + if (node.parent.kind === 260 && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 182 && node.parent.type === node) { + if (node.parent.kind === 183 && node.parent.type === node) { return spanInNextNode(node.parent.type); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); } - if ((node.parent.kind === 224 || - node.parent.kind === 144)) { + if ((node.parent.kind === 225 || + node.parent.kind === 145)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -53982,7 +56436,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 192) { + if (node.parent.kind === 193) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -54003,7 +56457,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 213) { + if (variableDeclaration.parent.parent.kind === 214) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -54011,7 +56465,7 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 214) { + variableDeclaration.parent.parent.kind === 215) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -54043,7 +56497,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 227 && functionDeclaration.kind !== 150); + (functionDeclaration.parent.kind === 228 && functionDeclaration.kind !== 151); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -54063,22 +56517,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 231: + case 232: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 211: - case 209: - case 213: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 212: + case 210: case 214: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 213: + case 215: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 225) { + if (forLikeStatement.initializer.kind === 226) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -54100,62 +56554,62 @@ var ts; } } function spanInBindingPattern(bindingPattern) { - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 198 ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 199 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - if (bindingPattern.parent.kind === 174) { + if (bindingPattern.parent.kind === 175) { return textSpan(bindingPattern.parent); } return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 173 && node.kind !== 172); - var elements = node.kind === 175 ? + ts.Debug.assert(node.kind !== 174 && node.kind !== 173); + var elements = node.kind === 176 ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 198 ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 199 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - return textSpan(node.parent.kind === 192 ? node.parent : node); + return textSpan(node.parent.kind === 193 ? node.parent : node); } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 230: + case 231: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 227: + case 228: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 233: + case 234: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 232: + case 233: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 230: - case 227: + case 231: + case 228: return textSpan(node); - case 205: + case 206: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 257: + case 259: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 233: + case 234: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 172: + case 173: var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -54168,7 +56622,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 173: + case 174: var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -54180,33 +56634,33 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 210 || - node.parent.kind === 179 || - node.parent.kind === 180) { + if (node.parent.kind === 211 || + node.parent.kind === 180 || + node.parent.kind === 181) { return spanInPreviousNode(node); } - if (node.parent.kind === 183) { + if (node.parent.kind === 184) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 184: - case 226: case 185: - case 149: - case 148: - case 151: - case 152: + case 227: + case 186: case 150: - case 211: - case 210: + case 149: + case 152: + case 153: + case 151: case 212: - case 214: - case 179: + case 211: + case 213: + case 215: case 180: - case 183: + case 181: + case 184: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -54214,26 +56668,26 @@ var ts; } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || - node.parent.kind === 258 || - node.parent.kind === 144) { + node.parent.kind === 260 || + node.parent.kind === 145) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 182) { + if (node.parent.kind === 183) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 210) { + if (node.parent.kind === 211) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 214) { + if (node.parent.kind === 215) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -54264,7 +56718,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 124 || - keyword2 === 133 || + keyword2 === 134 || keyword2 === 122 || keyword2 === 114) { return true; @@ -54380,10 +56834,10 @@ var ts; angleBracketStack--; } else if (token === 118 || - token === 134 || + token === 135 || token === 132 || token === 121 || - token === 135) { + token === 136) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { token = 70; } @@ -54538,7 +56992,7 @@ var ts; } } function isKeyword(token) { - return token >= 71 && token <= 140; + return token >= 71 && token <= 141; } function classFromKind(token) { if (isKeyword(token)) { @@ -54584,10 +57038,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { - case 231: - case 227: + case 232: case 228: - case 226: + case 229: + case 227: cancellationToken.throwIfCancellationRequested(); } } @@ -54631,7 +57085,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 231 && + return declaration.kind === 232 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -54642,7 +57096,7 @@ var ts; checkForClassificationCancellation(cancellationToken, kind); if (kind === 70 && !ts.nodeIsMissing(node)) { var identifier = node; - if (classifiableNames[identifier.text]) { + if (classifiableNames.get(identifier.text)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var type = classifySymbol(symbol, ts.getMeaningFromLocation(node)); @@ -54772,16 +57226,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 282: + case 285: processJSDocParameterTag(tag); break; - case 285: + case 288: processJSDocTemplateTag(tag); break; - case 284: + case 287: processElement(tag.typeExpression); break; - case 283: + case 286: processElement(tag.typeExpression); break; } @@ -54862,22 +57316,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 249: + case 250: if (token.parent.tagName === token) { return 19; } break; - case 250: + case 251: if (token.parent.tagName === token) { return 20; } break; - case 248: + case 249: if (token.parent.tagName === token) { return 21; } break; - case 251: + case 252: if (token.parent.name === token) { return 22; } @@ -54897,17 +57351,17 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 57) { - if (token.parent.kind === 224 || - token.parent.kind === 147 || - token.parent.kind === 144 || - token.parent.kind === 251) { + if (token.parent.kind === 225 || + token.parent.kind === 148 || + token.parent.kind === 145 || + token.parent.kind === 252) { return 5; } } - if (token.parent.kind === 192 || - token.parent.kind === 190 || + if (token.parent.kind === 193 || token.parent.kind === 191 || - token.parent.kind === 193) { + token.parent.kind === 192 || + token.parent.kind === 194) { return 5; } } @@ -54917,7 +57371,7 @@ var ts; return 4; } else if (tokenKind === 9) { - return token.parent.kind === 251 ? 24 : 6; + return token.parent.kind === 252 ? 24 : 6; } else if (tokenKind === 11) { return 6; @@ -54931,32 +57385,32 @@ var ts; else if (tokenKind === 70) { if (token) { switch (token.parent.kind) { - case 227: + case 228: if (token.parent.name === token) { return 11; } return; - case 143: + case 144: if (token.parent.name === token) { return 15; } return; - case 228: + case 229: if (token.parent.name === token) { return 13; } return; - case 230: + case 231: if (token.parent.name === token) { return 12; } return; - case 231: + case 232: if (token.parent.name === token) { return 14; } return; - case 144: + case 145: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 : 17; } @@ -54989,10 +57443,10 @@ var ts; (function (Completions) { function getCompletionsAtPosition(host, typeChecker, log, compilerOptions, sourceFile, position) { if (ts.isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position); + return getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); } if (ts.isInString(sourceFile, position)) { - return getStringLiteralCompletionEntries(sourceFile, position); + return getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log); } var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (!completionData) { @@ -55004,13 +57458,13 @@ var ts; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, true); - ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, true, typeChecker, compilerOptions.target, log); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target)); } else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 && - location.parent && location.parent.kind === 250) { + location.parent && location.parent.kind === 251) { var tagName = location.parent.parent.openingElement.tagName; entries.push({ name: tagName.text, @@ -55023,531 +57477,535 @@ var ts; return undefined; } } - getCompletionEntriesFromSymbols(symbols, entries, location, true); + getCompletionEntriesFromSymbols(symbols, entries, location, true, typeChecker, compilerOptions.target, log); } if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { - var entries = []; - var nameTable = ts.getNameTable(sourceFile); - for (var name_46 in nameTable) { - if (nameTable[name_46] === position) { - continue; + } + Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames, target) { + var entries = []; + var nameTable = ts.getNameTable(sourceFile); + nameTable.forEach(function (pos, name) { + if (pos === position) { + return; + } + if (!uniqueNames.get(name)) { + uniqueNames.set(name, name); + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name), target, true); + if (displayName) { + var entry = { + name: displayName, + kind: ts.ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } - if (!uniqueNames[name_46]) { - uniqueNames[name_46] = name_46; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_46), compilerOptions.target, true); - if (displayName) { - var entry = { - name: displayName, - kind: ts.ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; + } + }); + return entries; + } + function createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target) { + var displayName = getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, target, performCharacterChecks, location); + if (!displayName) { + return undefined; + } + return { + name: displayName, + kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), + kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), + sortText: "0", + }; + } + function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks, typeChecker, target, log) { + var start = ts.timestamp(); + var uniqueNames = ts.createMap(); + if (symbols) { + for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { + var symbol = symbols_4[_i]; + var entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + if (entry) { + var id = ts.escapeIdentifier(entry.name); + if (!uniqueNames.get(id)) { entries.push(entry); + uniqueNames.set(id, id); } } } - return entries; } - function createCompletionEntry(symbol, location, performCharacterChecks) { - var displayName = getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, compilerOptions.target, performCharacterChecks, location); - if (!displayName) { - return undefined; + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); + return uniqueNames; + } + function getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log) { + var node = ts.findPrecedingToken(position, sourceFile); + if (!node || node.kind !== 9) { + return undefined; + } + if (node.parent.kind === 260 && + node.parent.parent.kind === 177 && + node.parent.name === node) { + return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent, typeChecker, compilerOptions.target, log); + } + else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { + return getStringLiteralCompletionEntriesFromElementAccess(node.parent, typeChecker, compilerOptions.target, log); + } + else if (node.parent.kind === 237 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + return getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); + } + else if (isEqualityExpression(node.parent)) { + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.left === node ? node.parent.right : node.parent.left), typeChecker); + } + else if (ts.isCaseOrDefaultClause(node.parent)) { + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.parent.parent.expression), typeChecker); + } + else { + var argumentInfo = ts.SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); + if (argumentInfo) { + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker); } - return { - name: displayName, - kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0", - }; + return getStringLiteralCompletionEntriesFromType(typeChecker.getContextualType(node), typeChecker); } - function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { - var start = ts.timestamp(); - var uniqueNames = ts.createMap(); - if (symbols) { - for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { - var symbol = symbols_4[_i]; - var entry = createCompletionEntry(symbol, location, performCharacterChecks); - if (entry) { - var id = ts.escapeIdentifier(entry.name); - if (!uniqueNames[id]) { - entries.push(entry); - uniqueNames[id] = id; + } + function getStringLiteralCompletionEntriesFromPropertyAssignment(element, typeChecker, target, log) { + var type = typeChecker.getContextualType(element.parent); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + } + } + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker) { + var candidates = []; + var entries = []; + typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); + for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { + var candidate = candidates_3[_i]; + addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries, typeChecker); + } + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; + } + return undefined; + } + function getStringLiteralCompletionEntriesFromElementAccess(node, typeChecker, target, log) { + var type = typeChecker.getTypeAtLocation(node.expression); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + } + return undefined; + } + function getStringLiteralCompletionEntriesFromType(type, typeChecker) { + if (type) { + var entries = []; + addStringLiteralCompletionsFromType(type, entries, typeChecker); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; + } + } + return undefined; + } + function addStringLiteralCompletionsFromType(type, result, typeChecker) { + if (type && type.flags & 16384) { + type = typeChecker.getApparentType(type); + } + if (!type) { + return; + } + if (type.flags & 65536) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + addStringLiteralCompletionsFromType(t, result, typeChecker); + } + } + else if (type.flags & 32) { + result.push({ + name: type.text, + kindModifiers: ts.ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.variableElement, + sortText: "0" + }); + } + } + function getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker) { + var literalValue = ts.normalizeSlashes(node.text); + var scriptPath = node.getSourceFile().path; + var scriptDirectory = ts.getDirectoryPath(scriptPath); + var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); + var entries; + if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { + var extensions = ts.getSupportedExtensions(compilerOptions); + if (compilerOptions.rootDirs) { + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, false, span, compilerOptions, host, scriptPath); + } + else { + entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, false, span, host, scriptPath); + } + } + else { + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); + } + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: entries + }; + } + function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { + rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); + var relativeDirectory; + for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { + var rootDirectory = rootDirs_1[_i]; + if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + break; + } + } + return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); + } + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, compilerOptions, host, exclude) { + var basePath = compilerOptions.project || host.getCurrentDirectory(); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + var result = []; + for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { + var baseDirectory = baseDirectories_1[_i]; + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); + } + return result; + } + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, host, exclude, result) { + if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); + fragment = ts.getDirectoryPath(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; + } + fragment = ts.ensureTrailingDirectorySeparator(fragment); + var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); + var baseDirectory = ts.getDirectoryPath(absolutePath); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + if (tryDirectoryExists(host, baseDirectory)) { + var files = tryReadDirectory(host, baseDirectory, extensions, undefined, ["./*"]); + if (files) { + var foundFiles = ts.createMap(); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var filePath = files_3[_i]; + filePath = ts.normalizePath(filePath); + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0) { + continue; + } + var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + if (!foundFiles.get(foundFileName)) { + foundFiles.set(foundFileName, true); + } + } + ts.forEachKey(foundFiles, function (foundFile) { + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); + }); + } + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { + var directory = directories_2[_a]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); + } + } + } + return result; + } + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span, compilerOptions, host, typeChecker) { + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var result; + if (baseUrl) { + var fileExtensions = ts.getSupportedExtensions(compilerOptions); + var projectDir = compilerOptions.project || host.getCurrentDirectory(); + var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); + result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, false, span, host); + if (paths) { + for (var path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { + var pattern = _a[_i]; + for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { + var match = _c[_b]; + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + else if (ts.startsWith(path, fragment)) { + var entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); + } } } } } - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); - return uniqueNames; } - function getStringLiteralCompletionEntries(sourceFile, position) { - var node = ts.findPrecedingToken(position, sourceFile); - if (!node || node.kind !== 9) { - return undefined; + else { + result = []; + } + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); + for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { + var moduleName = _e[_d]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + return result; + } + function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { + if (host.readDirectory) { + var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; + if (parsed) { + var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); + var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); + var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; + var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; + var normalizedSuffix = ts.normalizePath(parsed.suffix); + var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); + var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + var includeGlob = normalizedSuffix ? "**/*" : "./*"; + var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); + if (matches) { + var result = []; + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; + var normalizedMatch = ts.normalizePath(match); + if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { + continue; + } + var start = completePrefix.length; + var length_5 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); + } + return result; + } } - if (node.parent.kind === 258 && - node.parent.parent.kind === 176 && - node.parent.name === node) { - return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); + } + return undefined; + } + function enumeratePotentialNonRelativeModules(fragment, scriptPath, options, typeChecker, host) { + var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; + var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; + var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); + var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); + if (isNestedModule) { + var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { + if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { + return moduleName.substr(moduleNameWithSeperator_1.length); + } + return moduleName; + }); + } + if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { + for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { + var visibleModule = _a[_i]; + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.moduleName); + } + else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { + var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, undefined, ["./*"]); + if (nestedFiles) { + for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { + var f = nestedFiles_1[_b]; + f = ts.normalizePath(f); + var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + } + } + } } - else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { - return getStringLiteralCompletionEntriesFromElementAccess(node.parent); - } - else if (node.parent.kind === 236 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { - return getStringLiteralCompletionEntriesFromModuleNames(node); + } + return ts.deduplicate(nonRelativeModules); + } + function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { + var token = ts.getTokenAtPosition(sourceFile, position); + if (!token) { + return undefined; + } + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + if (!commentRanges || !commentRanges.length) { + return undefined; + } + var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); + if (!range) { + return undefined; + } + var completionInfo = { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: [] + }; + var text = sourceFile.text.substr(range.pos, position - range.pos); + var match = tripleSlashDirectiveFragmentRegex.exec(text); + if (match) { + var prefix = match[1]; + var kind = match[2]; + var toComplete = match[3]; + var scriptPath = ts.getDirectoryPath(sourceFile.path); + if (kind === "path") { + var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, host, sourceFile.path); } else { - var argumentInfo = ts.SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); - if (argumentInfo) { - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); - } - return getStringLiteralCompletionEntriesFromContextualType(node); + var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); } } - function getStringLiteralCompletionEntriesFromPropertyAssignment(element) { - var type = typeChecker.getContextualType(element.parent); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + return completionInfo; + } + function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { + if (result === void 0) { result = []; } + if (options.types) { + for (var _i = 0, _a = options.types; _i < _a.length; _i++) { + var moduleName = _a[_i]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + } + else if (host.getDirectories) { + var typeRoots = void 0; + try { + typeRoots = ts.getEffectiveTypeRoots(options, host); + } + catch (e) { } + if (typeRoots) { + for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { + var root = typeRoots_2[_b]; + getCompletionEntriesFromDirectories(host, root, span, result); } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo) { - var candidates = []; - var entries = []; - typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); - for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { - var candidate = candidates_3[_i]; - if (candidate.parameters.length > argumentInfo.argumentIndex) { - var parameter = candidate.parameters[argumentInfo.argumentIndex]; - addStringLiteralCompletionsFromType(typeChecker.getTypeAtLocation(parameter.valueDeclaration), entries); + if (host.getDirectories) { + for (var _c = 0, _d = findPackageJsons(scriptPath, host); _c < _d.length; _c++) { + var packageJson = _d[_c]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, typesDir, span, result); + } + } + return result; + } + function getCompletionEntriesFromDirectories(host, directory, span, result) { + if (host.getDirectories && tryDirectoryExists(host, directory)) { + var directories = tryGetDirectories(host, directory); + if (directories) { + for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { + var typeDirectory = directories_3[_i]; + typeDirectory = ts.normalizePath(typeDirectory); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); } } - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; - } - return undefined; } - function getStringLiteralCompletionEntriesFromElementAccess(node) { - var type = typeChecker.getTypeAtLocation(node.expression); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + function findPackageJsons(currentDir, host) { + var paths = []; + var currentConfigPath; + while (true) { + currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + currentDir = ts.getDirectoryPath(currentConfigPath); + var parent = ts.getDirectoryPath(currentDir); + if (currentDir === parent) { + break; } - } - return undefined; - } - function getStringLiteralCompletionEntriesFromContextualType(node) { - var type = typeChecker.getContextualType(node); - if (type) { - var entries_2 = []; - addStringLiteralCompletionsFromType(type, entries_2); - if (entries_2.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; - } - } - return undefined; - } - function addStringLiteralCompletionsFromType(type, result) { - if (type && type.flags & 16384) { - type = typeChecker.getApparentType(type); - } - if (!type) { - return; - } - if (type.flags & 65536) { - ts.forEach(type.types, function (t) { return addStringLiteralCompletionsFromType(t, result); }); + currentDir = parent; } else { - if (type.flags & 32) { + break; + } + } + return paths; + } + function enumerateNodeModulesVisibleToScript(host, scriptPath) { + var result = []; + if (host.readFile && host.fileExists) { + for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + var packageJson = _a[_i]; + var contents = tryReadingPackageJson(packageJson); + if (!contents) { + return; + } + var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); + var foundModuleNames = []; + for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { + var key = nodeModulesDependencyKeys_1[_b]; + addPotentialPackageNames(contents[key], foundModuleNames); + } + for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { + var moduleName = foundModuleNames_1[_c]; + var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); result.push({ - name: type.text, - kindModifiers: ts.ScriptElementKindModifier.none, - kind: ts.ScriptElementKind.variableElement, - sortText: "0" + moduleName: moduleName, + moduleDir: moduleDir }); } } } - function getStringLiteralCompletionEntriesFromModuleNames(node) { - var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; - var scriptDirectory = ts.getDirectoryPath(scriptPath); - var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); - var entries; - if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { - if (compilerOptions.rootDirs) { - entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), false, span, scriptPath); - } - else { - entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), false, span, scriptPath); - } + return result; + function tryReadingPackageJson(filePath) { + try { + var fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; } - else { - entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); - } - return { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: entries - }; - } - function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { - rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); - var relativeDirectory; - for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { - var rootDirectory = rootDirs_1[_i]; - if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { - relativeDirectory = scriptPath.substr(rootDirectory.length); - break; - } - } - return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); - } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, exclude) { - var basePath = compilerOptions.project || host.getCurrentDirectory(); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); - var result = []; - for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { - var baseDirectory = baseDirectories_1[_i]; - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, exclude, result); - } - return result; - } - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, exclude, result) { - if (result === void 0) { result = []; } - if (fragment === undefined) { - fragment = ""; - } - fragment = ts.normalizeSlashes(fragment); - fragment = ts.getDirectoryPath(fragment); - if (fragment === "") { - fragment = "." + ts.directorySeparator; - } - fragment = ts.ensureTrailingDirectorySeparator(fragment); - var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); - var baseDirectory = ts.getDirectoryPath(absolutePath); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (tryDirectoryExists(host, baseDirectory)) { - var files = tryReadDirectory(host, baseDirectory, extensions, undefined, ["./*"]); - if (files) { - var foundFiles = ts.createMap(); - for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { - var filePath = files_3[_i]; - filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0) { - continue; - } - var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); - if (!foundFiles[foundFileName]) { - foundFiles[foundFileName] = true; - } - } - for (var foundFile in foundFiles) { - result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); - } - } - var directories = tryGetDirectories(host, baseDirectory); - if (directories) { - for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { - var directory = directories_2[_a]; - var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); - } - } - } - return result; - } - function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span) { - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var result; - if (baseUrl) { - var fileExtensions = ts.getSupportedExtensions(compilerOptions); - var projectDir = compilerOptions.project || host.getCurrentDirectory(); - var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, false, span); - if (paths) { - for (var path in paths) { - if (paths.hasOwnProperty(path)) { - if (path === "*") { - if (paths[path]) { - for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { - var pattern = _a[_i]; - for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions); _b < _c.length; _b++) { - var match = _c[_b]; - result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - else if (ts.startsWith(path, fragment)) { - var entry = paths[path] && paths[path].length === 1 && paths[path][0]; - if (entry) { - result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - } - } - else { - result = []; - } - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions); _d < _e.length; _d++) { - var moduleName = _e[_d]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - return result; - } - function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions) { - if (host.readDirectory) { - var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; - if (parsed) { - var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); - var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); - var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); - var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; - var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; - var normalizedSuffix = ts.normalizePath(parsed.suffix); - var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); - var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); - if (matches) { - var result = []; - for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { - var match = matches_1[_i]; - var normalizedMatch = ts.normalizePath(match); - if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { - continue; - } - var start = completePrefix.length; - var length_5 = normalizedMatch.length - start - normalizedSuffix.length; - result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); - } - return result; - } - } - } - return undefined; - } - function enumeratePotentialNonRelativeModules(fragment, scriptPath, options) { - var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; - var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; - var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); - var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); - if (isNestedModule) { - var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); - nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { - if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { - return moduleName.substr(moduleNameWithSeperator_1.length); - } - return moduleName; - }); - } - if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { - for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { - var visibleModule = _a[_i]; - if (!isNestedModule) { - nonRelativeModules.push(visibleModule.moduleName); - } - else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { - var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, undefined, ["./*"]); - if (nestedFiles) { - for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { - var f = nestedFiles_1[_b]; - f = ts.normalizePath(f); - var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); - nonRelativeModules.push(nestedModule); - } - } - } - } - } - return ts.deduplicate(nonRelativeModules); - } - function getTripleSlashReferenceCompletion(sourceFile, position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (!token) { + catch (e) { return undefined; } - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - if (!commentRanges || !commentRanges.length) { - return undefined; - } - var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); - if (!range) { - return undefined; - } - var completionInfo = { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: [] - }; - var text = sourceFile.text.substr(range.pos, position - range.pos); - var match = tripleSlashDirectiveFragmentRegex.exec(text); - if (match) { - var prefix = match[1]; - var kind = match[2]; - var toComplete = match[3]; - var scriptPath = ts.getDirectoryPath(sourceFile.path); - if (kind === "path") { - var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, sourceFile.path); - } - else { - var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); - } - } - return completionInfo; } - function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { - if (result === void 0) { result = []; } - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch (e) { } - if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, root, span, result); + function addPotentialPackageNames(dependencies, result) { + if (dependencies) { + for (var dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { + result.push(dep); } } } - if (host.getDirectories) { - for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { - var packageJson = _d[_c]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, typesDir, span, result); - } - } - return result; - } - function getCompletionEntriesFromDirectories(host, directory, span, result) { - if (host.getDirectories && tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { - var typeDirectory = directories_3[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - function findPackageJsons(currentDir) { - var paths = []; - var currentConfigPath; - while (true) { - currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_14 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_14) { - break; - } - currentDir = parent_14; - } - else { - break; - } - } - return paths; - } - function enumerateNodeModulesVisibleToScript(host, scriptPath) { - var result = []; - if (host.readFile && host.fileExists) { - for (var _i = 0, _a = findPackageJsons(scriptPath); _i < _a.length; _i++) { - var packageJson = _a[_i]; - var contents = tryReadingPackageJson(packageJson); - if (!contents) { - return; - } - var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); - var foundModuleNames = []; - for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { - var key = nodeModulesDependencyKeys_1[_b]; - addPotentialPackageNames(contents[key], foundModuleNames); - } - for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { - var moduleName = foundModuleNames_1[_c]; - var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName: moduleName, - moduleDir: moduleDir - }); - } - } - } - return result; - function tryReadingPackageJson(filePath) { - try { - var fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; - } - catch (e) { - return undefined; - } - } - function addPotentialPackageNames(dependencies, result) { - if (dependencies) { - for (var dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { - result.push(dep); - } - } - } - } - } - function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; - } - function getDirectoryFragmentTextSpan(text, textStart) { - var index = text.lastIndexOf(ts.directorySeparator); - var offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset }; - } - function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 ? 2 : 1; - var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 || slashCharCode === 92; - } - return false; - } - function normalizeAndPreserveTrailingSlash(path) { - return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); } } - Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function createCompletionEntryForModule(name, kind, replacementSpan) { + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; + } + function getDirectoryFragmentTextSpan(text, textStart) { + var index = text.lastIndexOf(ts.directorySeparator); + var offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset }; + } + function isPathRelativeToScript(path) { + if (path && path.length >= 2 && path.charCodeAt(0) === 46) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 ? 2 : 1; + var slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === 47 || slashCharCode === 92; + } + return false; + } + function normalizeAndPreserveTrailingSlash(path) { + return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); + } function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_3 = completionData.location; - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_3) === entryName ? s : undefined; }); + var symbols = completionData.symbols, location_1 = completionData.location; + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_1) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_3, location_3, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), @@ -55573,8 +58031,8 @@ var ts; function getCompletionEntrySymbol(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_4 = completionData.location; - return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_4) === entryName ? s : undefined; }); + var symbols = completionData.symbols, location_2 = completionData.location; + return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_2) === entryName ? s : undefined; }); } return undefined; } @@ -55599,9 +58057,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 284: - case 282: - case 283: + case 287: + case 285: + case 286: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -55636,13 +58094,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_15 = contextToken.parent, kind = contextToken.kind; + var parent = contextToken.parent, kind = contextToken.kind; if (kind === 22) { - if (parent_15.kind === 177) { + if (parent.kind === 178) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_15.kind === 141) { + else if (parent.kind === 142) { node = contextToken.parent.left; isRightOfDot = true; } @@ -55651,13 +58109,25 @@ var ts; } } else if (sourceFile.languageVariant === 1) { - if (kind === 26) { - isRightOfOpenTag = true; - location = contextToken; - } - else if (kind === 40 && contextToken.parent.kind === 250) { - isStartingCloseTag = true; - location = contextToken; + switch (contextToken.parent.kind) { + case 251: + if (kind === 40) { + isStartingCloseTag = true; + location = contextToken; + } + break; + case 193: + if (!(contextToken.parent.left.flags & 32768)) { + break; + } + case 249: + case 248: + case 250: + if (kind === 26) { + isRightOfOpenTag = true; + location = contextToken; + } + break; } } } @@ -55700,7 +58170,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 70 || node.kind === 141 || node.kind === 177) { + if (node.kind === 70 || node.kind === 142 || node.kind === 178) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -55746,10 +58216,10 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 248) || (jsxContainer.kind === 249)) { - attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + if ((jsxContainer.kind === 249) || (jsxContainer.kind === 250)) { + attrsType = typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); if (attrsType) { - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); + symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes.properties); isMemberCompletion = true; isNewIdentifierLocation = false; return true; @@ -55767,9 +58237,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 262 || - scopeNode.kind === 194 || - scopeNode.kind === 253 || + scopeNode.kind === 264 || + scopeNode.kind === 195 || + scopeNode.kind === 255 || ts.isStatement(scopeNode); } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; @@ -55797,11 +58267,11 @@ var ts; return true; } if (contextToken.kind === 28 && contextToken.parent) { - if (contextToken.parent.kind === 249) { + if (contextToken.parent.kind === 250) { return true; } - if (contextToken.parent.kind === 250 || contextToken.parent.kind === 248) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 247; + if (contextToken.parent.kind === 251 || contextToken.parent.kind === 249) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 248; } } return false; @@ -55811,40 +58281,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 25: - return containingNodeKind === 179 - || containingNodeKind === 150 - || containingNodeKind === 180 - || containingNodeKind === 175 - || containingNodeKind === 192 - || containingNodeKind === 158; + return containingNodeKind === 180 + || containingNodeKind === 151 + || containingNodeKind === 181 + || containingNodeKind === 176 + || containingNodeKind === 193 + || containingNodeKind === 159; case 18: - return containingNodeKind === 179 - || containingNodeKind === 150 - || containingNodeKind === 180 - || containingNodeKind === 183 - || containingNodeKind === 166; + return containingNodeKind === 180 + || containingNodeKind === 151 + || containingNodeKind === 181 + || containingNodeKind === 184 + || containingNodeKind === 167; case 20: - return containingNodeKind === 175 - || containingNodeKind === 155 - || containingNodeKind === 142; + return containingNodeKind === 176 + || containingNodeKind === 156 + || containingNodeKind === 143; case 127: case 128: return true; case 22: - return containingNodeKind === 231; + return containingNodeKind === 232; case 16: - return containingNodeKind === 227; + return containingNodeKind === 228; case 57: - return containingNodeKind === 224 - || containingNodeKind === 192; + return containingNodeKind === 225 + || containingNodeKind === 193; case 13: - return containingNodeKind === 194; + return containingNodeKind === 195; case 14: - return containingNodeKind === 203; + return containingNodeKind === 204; case 113: case 111: case 112: - return containingNodeKind === 147; + return containingNodeKind === 148; } switch (previousToken.getText()) { case "public": @@ -55875,22 +58345,22 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 176) { + if (objectLikeContainer.kind === 177) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 172) { + else if (objectLikeContainer.kind === 173) { isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (ts.isVariableLike(rootDeclaration)) { var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 144) { + if (!canGetType && rootDeclaration.kind === 145) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 149 || rootDeclaration.parent.kind === 152) { + else if (rootDeclaration.parent.kind === 150 || rootDeclaration.parent.kind === 153) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -55916,9 +58386,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 239 ? - 236 : - 242; + var declarationKind = namedImportsOrExports.kind === 240 ? + 237 : + 243; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -55926,12 +58396,13 @@ var ts; } isMemberCompletion = true; isNewIdentifierLocation = false; - var exports; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); + if (!moduleSpecifierSymbol) { + symbols = ts.emptyArray; + return true; } - symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : ts.emptyArray; + var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); + symbols = filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements); return true; } function tryGetObjectLikeCompletionContainer(contextToken) { @@ -55939,9 +58410,9 @@ var ts; switch (contextToken.kind) { case 16: case 25: - var parent_16 = contextToken.parent; - if (parent_16 && (parent_16.kind === 176 || parent_16.kind === 172)) { - return parent_16; + var parent = contextToken.parent; + if (parent && (parent.kind === 177 || parent.kind === 173)) { + return parent; } break; } @@ -55954,8 +58425,8 @@ var ts; case 16: case 25: switch (contextToken.parent.kind) { - case 239: - case 243: + case 240: + case 244: return contextToken.parent; } } @@ -55964,34 +58435,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_17 = contextToken.parent; + var parent = contextToken.parent; switch (contextToken.kind) { case 27: case 40: case 70: - case 251: + case 253: case 252: - if (parent_17 && (parent_17.kind === 248 || parent_17.kind === 249)) { - return parent_17; + case 254: + if (parent && (parent.kind === 249 || parent.kind === 250)) { + return parent; } - else if (parent_17.kind === 251) { - return parent_17.parent; + else if (parent.kind === 252) { + return parent.parent.parent; } break; case 9: - if (parent_17 && ((parent_17.kind === 251) || (parent_17.kind === 252))) { - return parent_17.parent; + if (parent && ((parent.kind === 252) || (parent.kind === 254))) { + return parent.parent.parent; } break; case 17: - if (parent_17 && - parent_17.kind === 253 && - parent_17.parent && - (parent_17.parent.kind === 251)) { - return parent_17.parent.parent; + if (parent && + parent.kind === 255 && + parent.parent && parent.parent.kind === 252) { + return parent.parent.parent.parent; } - if (parent_17 && parent_17.kind === 252) { - return parent_17.parent; + if (parent && parent.kind === 254) { + return parent.parent.parent; } break; } @@ -56000,16 +58471,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 184: case 185: - case 226: + case 186: + case 227: + case 150: case 149: - case 148: - case 151: case 152: case 153: case 154: case 155: + case 156: return true; } return false; @@ -56018,66 +58489,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25: - return containingNodeKind === 224 || - containingNodeKind === 225 || - containingNodeKind === 206 || - containingNodeKind === 230 || + return containingNodeKind === 225 || + containingNodeKind === 226 || + containingNodeKind === 207 || + containingNodeKind === 231 || isFunction(containingNodeKind) || - containingNodeKind === 227 || - containingNodeKind === 197 || containingNodeKind === 228 || - containingNodeKind === 173 || - containingNodeKind === 229; + containingNodeKind === 198 || + containingNodeKind === 229 || + containingNodeKind === 174 || + containingNodeKind === 230; case 22: - return containingNodeKind === 173; - case 55: return containingNodeKind === 174; + case 55: + return containingNodeKind === 175; case 20: - return containingNodeKind === 173; + return containingNodeKind === 174; case 18: - return containingNodeKind === 257 || + return containingNodeKind === 259 || isFunction(containingNodeKind); case 16: - return containingNodeKind === 230 || - containingNodeKind === 228 || - containingNodeKind === 161; - case 24: - return containingNodeKind === 146 && - contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 228 || - contextToken.parent.parent.kind === 161); - case 26: - return containingNodeKind === 227 || - containingNodeKind === 197 || - containingNodeKind === 228 || + return containingNodeKind === 231 || containingNodeKind === 229 || + containingNodeKind === 162; + case 24: + return containingNodeKind === 147 && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 229 || + contextToken.parent.parent.kind === 162); + case 26: + return containingNodeKind === 228 || + containingNodeKind === 198 || + containingNodeKind === 229 || + containingNodeKind === 230 || isFunction(containingNodeKind); case 114: - return containingNodeKind === 147; + return containingNodeKind === 148; case 23: - return containingNodeKind === 144 || + return containingNodeKind === 145 || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 173); + contextToken.parent.parent.kind === 174); case 113: case 111: case 112: - return containingNodeKind === 144; + return containingNodeKind === 145; case 117: - return containingNodeKind === 240 || - containingNodeKind === 244 || - containingNodeKind === 238; + return containingNodeKind === 241 || + containingNodeKind === 245 || + containingNodeKind === 239; case 74: case 82: case 108: case 88: case 103: case 124: - case 133: + case 134: case 90: case 109: case 75: case 115: - case 136: + case 137: return true; } switch (contextToken.getText()) { @@ -56114,13 +58585,13 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_47 = element.propertyName || element.name; - existingImportsOrExports[name_47.text] = true; + var name = element.propertyName || element.name; + existingImportsOrExports.set(name.text, true); } - if (!ts.someProperties(existingImportsOrExports)) { + if (existingImportsOrExports.size === 0) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); } - return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports[e.name]; }); + return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports.get(e.name); }); } function filterObjectMembersList(contextualMemberSymbols, existingMembers) { if (!existingMembers || existingMembers.length === 0) { @@ -56129,19 +58600,19 @@ var ts; var existingMemberNames = ts.createMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; - if (m.kind !== 258 && - m.kind !== 259 && - m.kind !== 174 && - m.kind !== 149 && - m.kind !== 151 && - m.kind !== 152) { + if (m.kind !== 260 && + m.kind !== 261 && + m.kind !== 175 && + m.kind !== 150 && + m.kind !== 152 && + m.kind !== 153) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 174 && m.propertyName) { + if (m.kind === 175 && m.propertyName) { if (m.propertyName.kind === 70) { existingName = m.propertyName.text; } @@ -56149,9 +58620,9 @@ var ts; else { existingName = m.name.text; } - existingMemberNames[existingName] = true; + existingMemberNames.set(existingName, true); } - return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames[m.name]; }); + return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames.get(m.name); }); } function filterJsxAttributes(symbols, attributes) { var seenNames = ts.createMap(); @@ -56160,11 +58631,11 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 251) { - seenNames[attr.name.text] = true; + if (attr.kind === 252) { + seenNames.set(attr.name.text, true); } } - return ts.filter(symbols, function (a) { return !seenNames[a.name]; }); + return ts.filter(symbols, function (a) { return !seenNames.get(a.name); }); } } function getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, target, performCharacterChecks, location) { @@ -56193,7 +58664,7 @@ var ts; return name; } var keywordCompletions = []; - for (var i = 71; i <= 140; i++) { + for (var i = 71; i <= 141; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -56233,6 +58704,15 @@ var ts; catch (e) { } return undefined; } + function isEqualityExpression(node) { + return ts.isBinaryExpression(node) && isEqualityOperatorKind(node.operatorToken.kind); + } + function isEqualityOperatorKind(kind) { + return kind == 31 || + kind === 32 || + kind === 33 || + kind === 34; + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); var ts; @@ -56241,495 +58721,480 @@ var ts; (function (DocumentHighlights) { function getDocumentHighlights(typeChecker, cancellationToken, sourceFile, position, sourceFilesToSearch) { var node = ts.getTouchingWord(sourceFile, position); + return node && (getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) || getSyntacticDocumentHighlights(node, sourceFile)); + } + DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + function getHighlightSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var end = node.getEnd(); + return { + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(start, end), + kind: ts.HighlightSpanKind.none + }; + } + function getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) { + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch); + return referencedSymbols && convertReferencedSymbols(referencedSymbols); + } + function convertReferencedSymbols(referencedSymbols) { + var fileNameToDocumentHighlights = ts.createMap(); + var result = []; + for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { + var referencedSymbol = referencedSymbols_1[_i]; + for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { + var referenceEntry = _b[_a]; + var fileName = referenceEntry.fileName; + var documentHighlights = fileNameToDocumentHighlights.get(fileName); + if (!documentHighlights) { + documentHighlights = { fileName: fileName, highlightSpans: [] }; + fileNameToDocumentHighlights.set(fileName, documentHighlights); + result.push(documentHighlights); + } + documentHighlights.highlightSpans.push({ + textSpan: referenceEntry.textSpan, + kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference + }); + } + } + return result; + } + function getSyntacticDocumentHighlights(node, sourceFile) { + var highlightSpans = getHighlightSpans(node, sourceFile); + if (!highlightSpans || highlightSpans.length === 0) { + return undefined; + } + return [{ fileName: sourceFile.fileName, highlightSpans: highlightSpans }]; + } + function hasKind(node, kind) { + return node !== undefined && node.kind === kind; + } + function parent(node) { + return node && node.parent; + } + function getHighlightSpans(node, sourceFile) { if (!node) { return undefined; } - return getSemanticDocumentHighlights(node) || getSyntacticDocumentHighlights(node); - function getHighlightSpanForNode(node) { - var start = node.getStart(); - var end = node.getEnd(); - return { - fileName: sourceFile.fileName, - textSpan: ts.createTextSpanFromBounds(start, end), - kind: ts.HighlightSpanKind.none - }; + switch (node.kind) { + case 89: + case 81: + if (hasKind(node.parent, 210)) { + return getIfElseOccurrences(node.parent, sourceFile); + } + break; + case 95: + if (hasKind(node.parent, 218)) { + return highlightSpans(getReturnOccurrences(node.parent)); + } + break; + case 99: + if (hasKind(node.parent, 222)) { + return highlightSpans(getThrowOccurrences(node.parent)); + } + break; + case 101: + case 73: + case 86: + var tryStatement = node.kind === 73 ? parent(parent(node)) : parent(node); + if (hasKind(tryStatement, 223)) { + return highlightSpans(getTryCatchFinallyOccurrences(tryStatement, sourceFile)); + } + break; + case 97: + if (hasKind(node.parent, 220)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent)); + } + break; + case 72: + case 78: + if (hasKind(parent(parent(parent(node))), 220)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent.parent.parent)); + } + break; + case 71: + case 76: + if (hasKind(node.parent, 217) || hasKind(node.parent, 216)) { + return highlightSpans(getBreakOrContinueStatementOccurrences(node.parent)); + } + break; + case 87: + if (hasKind(node.parent, 213) || + hasKind(node.parent, 214) || + hasKind(node.parent, 215)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case 105: + case 80: + if (hasKind(node.parent, 212) || hasKind(node.parent, 211)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case 122: + if (hasKind(node.parent, 151)) { + return highlightSpans(getConstructorOccurrences(node.parent)); + } + break; + case 124: + case 134: + if (hasKind(node.parent, 152) || hasKind(node.parent, 153)) { + return highlightSpans(getGetAndSetOccurrences(node.parent)); + } + break; + default: + if (ts.isModifierKind(node.kind) && node.parent && + (ts.isDeclaration(node.parent) || node.parent.kind === 207)) { + return highlightSpans(getModifierOccurrences(node.kind, node.parent)); + } } - function getSemanticDocumentHighlights(node) { - if (node.kind === 70 || - node.kind === 98 || - node.kind === 167 || - node.kind === 96 || - node.kind === 9 || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, false, false, false); - return convertReferencedSymbols(referencedSymbols); - } - return undefined; - function convertReferencedSymbols(referencedSymbols) { - if (!referencedSymbols) { - return undefined; - } - var fileNameToDocumentHighlights = ts.createMap(); - var result = []; - for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { - var referencedSymbol = referencedSymbols_1[_i]; - for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { - var referenceEntry = _b[_a]; - var fileName = referenceEntry.fileName; - var documentHighlights = fileNameToDocumentHighlights[fileName]; - if (!documentHighlights) { - documentHighlights = { fileName: fileName, highlightSpans: [] }; - fileNameToDocumentHighlights[fileName] = documentHighlights; - result.push(documentHighlights); - } - documentHighlights.highlightSpans.push({ - textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference - }); - } - } - return result; - } + function highlightSpans(nodes) { + return nodes && nodes.map(function (node) { return getHighlightSpanForNode(node, sourceFile); }); } - function getSyntacticDocumentHighlights(node) { - var fileName = sourceFile.fileName; - var highlightSpans = getHighlightSpans(node); - if (!highlightSpans || highlightSpans.length === 0) { - return undefined; + } + function aggregateOwnedThrowStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 222) { + statementAccumulator.push(node); } - return [{ fileName: fileName, highlightSpans: highlightSpans }]; - function hasKind(node, kind) { - return node !== undefined && node.kind === kind; - } - function parent(node) { - return node && node.parent; - } - function getHighlightSpans(node) { - if (node) { - switch (node.kind) { - case 89: - case 81: - if (hasKind(node.parent, 209)) { - return getIfElseOccurrences(node.parent); - } - break; - case 95: - if (hasKind(node.parent, 217)) { - return getReturnOccurrences(node.parent); - } - break; - case 99: - if (hasKind(node.parent, 221)) { - return getThrowOccurrences(node.parent); - } - break; - case 73: - if (hasKind(parent(parent(node)), 222)) { - return getTryCatchFinallyOccurrences(node.parent.parent); - } - break; - case 101: - case 86: - if (hasKind(parent(node), 222)) { - return getTryCatchFinallyOccurrences(node.parent); - } - break; - case 97: - if (hasKind(node.parent, 219)) { - return getSwitchCaseDefaultOccurrences(node.parent); - } - break; - case 72: - case 78: - if (hasKind(parent(parent(parent(node))), 219)) { - return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); - } - break; - case 71: - case 76: - if (hasKind(node.parent, 216) || hasKind(node.parent, 215)) { - return getBreakOrContinueStatementOccurrences(node.parent); - } - break; - case 87: - if (hasKind(node.parent, 212) || - hasKind(node.parent, 213) || - hasKind(node.parent, 214)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 105: - case 80: - if (hasKind(node.parent, 211) || hasKind(node.parent, 210)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 122: - if (hasKind(node.parent, 150)) { - return getConstructorOccurrences(node.parent); - } - break; - case 124: - case 133: - if (hasKind(node.parent, 151) || hasKind(node.parent, 152)) { - return getGetAndSetOccurrences(node.parent); - } - break; - default: - if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 206)) { - return getModifierOccurrences(node.kind, node.parent); - } - } - } - return undefined; - } - function aggregateOwnedThrowStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 221) { - statementAccumulator.push(node); - } - else if (node.kind === 222) { - var tryStatement = node; - if (tryStatement.catchClause) { - aggregate(tryStatement.catchClause); - } - else { - aggregate(tryStatement.tryBlock); - } - if (tryStatement.finallyBlock) { - aggregate(tryStatement.finallyBlock); - } - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, aggregate); - } - } - } - function getThrowStatementOwner(throwStatement) { - var child = throwStatement; - while (child.parent) { - var parent_18 = child.parent; - if (ts.isFunctionBlock(parent_18) || parent_18.kind === 262) { - return parent_18; - } - if (parent_18.kind === 222) { - var tryStatement = parent_18; - if (tryStatement.tryBlock === child && tryStatement.catchClause) { - return child; - } - } - child = parent_18; - } - return undefined; - } - function aggregateAllBreakAndContinueStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 216 || node.kind === 215) { - statementAccumulator.push(node); - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, aggregate); - } - } - } - function ownsBreakOrContinueStatement(owner, statement) { - var actualOwner = getBreakOrContinueOwner(statement); - return actualOwner && actualOwner === owner; - } - function getBreakOrContinueOwner(statement) { - for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { - switch (node_2.kind) { - case 219: - if (statement.kind === 215) { - continue; - } - case 212: - case 213: - case 214: - case 211: - case 210: - if (!statement.label || isLabeledBy(node_2, statement.label.text)) { - return node_2; - } - break; - default: - if (ts.isFunctionLike(node_2)) { - return undefined; - } - break; - } - } - return undefined; - } - function getModifierOccurrences(modifier, declaration) { - var container = declaration.parent; - if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 227 || - container.kind === 197 || - (declaration.kind === 144 && hasKind(container, 150)))) { - return undefined; - } - } - else if (modifier === 114) { - if (!(container.kind === 227 || container.kind === 197)) { - return undefined; - } - } - else if (modifier === 83 || modifier === 123) { - if (!(container.kind === 232 || container.kind === 262)) { - return undefined; - } - } - else if (modifier === 116) { - if (!(container.kind === 227 || declaration.kind === 227)) { - return undefined; - } + else if (node.kind === 223) { + var tryStatement = node; + if (tryStatement.catchClause) { + aggregate(tryStatement.catchClause); } else { - return undefined; - } - var keywords = []; - var modifierFlag = getFlagFromModifier(modifier); - var nodes; - switch (container.kind) { - case 232: - case 262: - if (modifierFlag & 128) { - nodes = declaration.members.concat(declaration); - } - else { - nodes = container.statements; - } - break; - case 150: - nodes = container.parameters.concat(container.parent.members); - break; - case 227: - case 197: - nodes = container.members; - if (modifierFlag & 28) { - var constructor = ts.forEach(container.members, function (member) { - return member.kind === 150 && member; - }); - if (constructor) { - nodes = nodes.concat(constructor.parameters); - } - } - else if (modifierFlag & 128) { - nodes = nodes.concat(container); - } - break; - default: - ts.Debug.fail("Invalid container kind."); - } - ts.forEach(nodes, function (node) { - if (ts.getModifierFlags(node) & modifierFlag) { - ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - function getFlagFromModifier(modifier) { - switch (modifier) { - case 113: - return 4; - case 111: - return 8; - case 112: - return 16; - case 114: - return 32; - case 83: - return 1; - case 123: - return 2; - case 116: - return 128; - default: - ts.Debug.fail(); - } - } - } - function pushKeywordIf(keywordList, token) { - var expected = []; - for (var _i = 2; _i < arguments.length; _i++) { - expected[_i - 2] = arguments[_i]; - } - if (token && ts.contains(expected, token.kind)) { - keywordList.push(token); - return true; - } - return false; - } - function getGetAndSetOccurrences(accessorDeclaration) { - var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 151); - tryPushAccessorKeyword(accessorDeclaration.symbol, 152); - 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, 124, 133); }); - } - } - } - function getConstructorOccurrences(constructorDeclaration) { - var declarations = constructorDeclaration.symbol.getDeclarations(); - var keywords = []; - ts.forEach(declarations, function (declaration) { - ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 122); - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getLoopBreakContinueOccurrences(loopNode) { - var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { - if (loopNode.kind === 210) { - var loopTokens = loopNode.getChildren(); - for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 105)) { - break; - } - } - } - } - var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71, 76); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { - var owner = getBreakOrContinueOwner(breakOrContinueStatement); - if (owner) { - switch (owner.kind) { - case 212: - case 213: - case 214: - case 210: - case 211: - return getLoopBreakContinueOccurrences(owner); - case 219: - return getSwitchCaseDefaultOccurrences(owner); - } - } - return undefined; - } - function getSwitchCaseDefaultOccurrences(switchStatement) { - var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 97); - ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 72, 78); - var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71); - } - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getTryCatchFinallyOccurrences(tryStatement) { - var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 101); - if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73); + aggregate(tryStatement.tryBlock); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 86); + aggregate(tryStatement.finallyBlock); } - return ts.map(keywords, getHighlightSpanForNode); } - function getThrowOccurrences(throwStatement) { - var owner = getThrowStatementOwner(throwStatement); - if (!owner) { - return undefined; - } - var keywords = []; - ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); - }); - if (ts.isFunctionBlock(owner)) { - ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); - }); - } - return ts.map(keywords, getHighlightSpanForNode); - } - function getReturnOccurrences(returnStatement) { - var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 205))) { - return undefined; - } - var keywords = []; - ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); - }); - ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getIfElseOccurrences(ifStatement) { - var keywords = []; - while (hasKind(ifStatement.parent, 209) && ifStatement.parent.elseStatement === ifStatement) { - ifStatement = ifStatement.parent; - } - while (ifStatement) { - var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 89); - for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 81)) { - break; - } - } - if (!hasKind(ifStatement.elseStatement, 209)) { - break; - } - ifStatement = ifStatement.elseStatement; - } - var result = []; - for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 81 && i < keywords.length - 1) { - var elseKeyword = keywords[i]; - var ifKeyword = keywords[i + 1]; - var shouldCombindElseAndIf = true; - for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { - if (!ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { - shouldCombindElseAndIf = false; - break; - } - } - if (shouldCombindElseAndIf) { - result.push({ - fileName: fileName, - textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: ts.HighlightSpanKind.reference - }); - i++; - continue; - } - } - result.push(getHighlightSpanForNode(keywords[i])); - } - return result; + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); } } } - DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + function getThrowStatementOwner(throwStatement) { + var child = throwStatement; + while (child.parent) { + var parent_2 = child.parent; + if (ts.isFunctionBlock(parent_2) || parent_2.kind === 264) { + return parent_2; + } + if (parent_2.kind === 223) { + var tryStatement = parent_2; + if (tryStatement.tryBlock === child && tryStatement.catchClause) { + return child; + } + } + child = parent_2; + } + return undefined; + } + function aggregateAllBreakAndContinueStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 217 || node.kind === 216) { + statementAccumulator.push(node); + } + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); + } + } + } + function ownsBreakOrContinueStatement(owner, statement) { + var actualOwner = getBreakOrContinueOwner(statement); + return actualOwner && actualOwner === owner; + } + function getBreakOrContinueOwner(statement) { + for (var node = statement.parent; node; node = node.parent) { + switch (node.kind) { + case 220: + if (statement.kind === 216) { + continue; + } + case 213: + case 214: + case 215: + case 212: + case 211: + if (!statement.label || isLabeledBy(node, statement.label.text)) { + return node; + } + break; + default: + if (ts.isFunctionLike(node)) { + return undefined; + } + break; + } + } + return undefined; + } + function getModifierOccurrences(modifier, declaration) { + var container = declaration.parent; + if (ts.isAccessibilityModifier(modifier)) { + if (!(container.kind === 228 || + container.kind === 198 || + (declaration.kind === 145 && hasKind(container, 151)))) { + return undefined; + } + } + else if (modifier === 114) { + if (!(container.kind === 228 || container.kind === 198)) { + return undefined; + } + } + else if (modifier === 83 || modifier === 123) { + if (!(container.kind === 233 || container.kind === 264)) { + return undefined; + } + } + else if (modifier === 116) { + if (!(container.kind === 228 || declaration.kind === 228)) { + return undefined; + } + } + else { + return undefined; + } + var keywords = []; + var modifierFlag = getFlagFromModifier(modifier); + var nodes; + switch (container.kind) { + case 233: + case 264: + if (modifierFlag & 128) { + nodes = declaration.members.concat(declaration); + } + else { + nodes = container.statements; + } + break; + case 151: + nodes = container.parameters.concat(container.parent.members); + break; + case 228: + case 198: + nodes = container.members; + if (modifierFlag & 28) { + var constructor = ts.forEach(container.members, function (member) { + return member.kind === 151 && member; + }); + if (constructor) { + nodes = nodes.concat(constructor.parameters); + } + } + else if (modifierFlag & 128) { + nodes = nodes.concat(container); + } + break; + default: + ts.Debug.fail("Invalid container kind."); + } + ts.forEach(nodes, function (node) { + if (ts.getModifierFlags(node) & modifierFlag) { + ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); + } + }); + return keywords; + function getFlagFromModifier(modifier) { + switch (modifier) { + case 113: + return 4; + case 111: + return 8; + case 112: + return 16; + case 114: + return 32; + case 83: + return 1; + case 123: + return 2; + case 116: + return 128; + default: + ts.Debug.fail(); + } + } + } + function pushKeywordIf(keywordList, token) { + var expected = []; + for (var _i = 2; _i < arguments.length; _i++) { + expected[_i - 2] = arguments[_i]; + } + if (token && ts.contains(expected, token.kind)) { + keywordList.push(token); + return true; + } + return false; + } + function getGetAndSetOccurrences(accessorDeclaration) { + var keywords = []; + tryPushAccessorKeyword(accessorDeclaration.symbol, 152); + tryPushAccessorKeyword(accessorDeclaration.symbol, 153); + return keywords; + function tryPushAccessorKeyword(accessorSymbol, accessorKind) { + var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); + if (accessor) { + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124, 134); }); + } + } + } + function getConstructorOccurrences(constructorDeclaration) { + var declarations = constructorDeclaration.symbol.getDeclarations(); + var keywords = []; + ts.forEach(declarations, function (declaration) { + ts.forEach(declaration.getChildren(), function (token) { + return pushKeywordIf(keywords, token, 122); + }); + }); + return keywords; + } + function getLoopBreakContinueOccurrences(loopNode) { + var keywords = []; + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { + if (loopNode.kind === 211) { + var loopTokens = loopNode.getChildren(); + for (var i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], 105)) { + break; + } + } + } + } + var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(loopNode, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71, 76); + } + }); + return keywords; + } + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { + var owner = getBreakOrContinueOwner(breakOrContinueStatement); + if (owner) { + switch (owner.kind) { + case 213: + case 214: + case 215: + case 211: + case 212: + return getLoopBreakContinueOccurrences(owner); + case 220: + return getSwitchCaseDefaultOccurrences(owner); + } + } + return undefined; + } + function getSwitchCaseDefaultOccurrences(switchStatement) { + var keywords = []; + pushKeywordIf(keywords, switchStatement.getFirstToken(), 97); + ts.forEach(switchStatement.caseBlock.clauses, function (clause) { + pushKeywordIf(keywords, clause.getFirstToken(), 72, 78); + var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(switchStatement, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71); + } + }); + }); + return keywords; + } + function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { + var keywords = []; + pushKeywordIf(keywords, tryStatement.getFirstToken(), 101); + if (tryStatement.catchClause) { + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73); + } + if (tryStatement.finallyBlock) { + var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 86); + } + return keywords; + } + function getThrowOccurrences(throwStatement) { + var owner = getThrowStatementOwner(throwStatement); + if (!owner) { + return undefined; + } + var keywords = []; + ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); + }); + if (ts.isFunctionBlock(owner)) { + ts.forEachReturnStatement(owner, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); + }); + } + return keywords; + } + function getReturnOccurrences(returnStatement) { + var func = ts.getContainingFunction(returnStatement); + if (!(func && hasKind(func.body, 206))) { + return undefined; + } + var keywords = []; + ts.forEachReturnStatement(func.body, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); + }); + ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); + }); + return keywords; + } + function getIfElseOccurrences(ifStatement, sourceFile) { + var keywords = []; + while (hasKind(ifStatement.parent, 210) && ifStatement.parent.elseStatement === ifStatement) { + ifStatement = ifStatement.parent; + } + while (ifStatement) { + var children = ifStatement.getChildren(); + pushKeywordIf(keywords, children[0], 89); + for (var i = children.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, children[i], 81)) { + break; + } + } + if (!hasKind(ifStatement.elseStatement, 210)) { + break; + } + ifStatement = ifStatement.elseStatement; + } + var result = []; + for (var i = 0; i < keywords.length; i++) { + if (keywords[i].kind === 81 && i < keywords.length - 1) { + var elseKeyword = keywords[i]; + var ifKeyword = keywords[i + 1]; + var shouldCombindElseAndIf = true; + for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { + if (!ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { + shouldCombindElseAndIf = false; + break; + } + } + if (shouldCombindElseAndIf) { + result.push({ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), + kind: ts.HighlightSpanKind.reference + }); + i++; + continue; + } + } + result.push(getHighlightSpanForNode(keywords[i], sourceFile)); + } + return result; + } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 220; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 221; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -56748,15 +59213,15 @@ var ts; return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + "|" + settings.allowJs + "|" + settings.baseUrl + "|" + JSON.stringify(settings.typeRoots) + "|" + JSON.stringify(settings.rootDirs) + "|" + JSON.stringify(settings.paths); } function getBucketForCompilationSettings(key, createIfMissing) { - var bucket = buckets[key]; + var bucket = buckets.get(key); if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(); + buckets.set(key, bucket = ts.createFileMap()); } return bucket; } function reportStats() { - var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { - var entries = buckets[name]; + var bucketInfoArray = ts.arrayFrom(buckets.keys()).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { + var entries = buckets.get(name); var sourceFiles = []; entries.forEachValue(function (key, entry) { sourceFiles.push({ @@ -56844,881 +59309,937 @@ var ts; (function (ts) { var FindAllReferences; (function (FindAllReferences) { - function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments) { + function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments, isForRename) { var node = ts.getTouchingPropertyName(sourceFile, position, true); - if (node === sourceFile) { - return undefined; - } - switch (node.kind) { - case 8: - if (!ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - break; - } - case 70: - case 98: - case 122: - case 9: - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, false); - } - return undefined; + return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename); } FindAllReferences.findReferencedSymbols = findReferencedSymbols; - function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, implementations) { + function convertReferences(referenceSymbols) { + return referenceSymbols && ts.flatMap(referenceSymbols, function (r) { return r.references; }); + } + FindAllReferences.convertReferences = convertReferences; + function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename, implementations) { if (!implementations) { - if (ts.isLabelName(node)) { - if (ts.isJumpStatementTarget(node)) { - var labelDefinition = ts.getTargetLabel(node.parent, node.text); - return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; - } - else { - return getLabelReferencesInNode(node.parent, node); - } - } - if (ts.isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles); - } - if (node.kind === 96) { - return getReferencesForSuperKeyword(node); + var special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken); + if (special) { + return special; } } var symbol = typeChecker.getSymbolAtLocation(node); - if (!implementations && !symbol && node.kind === 9) { - return getReferencesForStringLiteral(node, sourceFiles); - } if (!symbol) { + if (!implementations && node.kind === 9) { + return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); + } return undefined; } var declarations = symbol.declarations; if (!declarations || !declarations.length) { return undefined; } - var result; + var _a = followAliases(symbol, node, typeChecker, isForRename), aliasedSymbol = _a.symbol, shorthandModuleSymbol = _a.shorthandModuleSymbol; + symbol = aliasedSymbol; + var searchSymbols = populateSearchSymbolSet(symbol, node, typeChecker, implementations); + if (shorthandModuleSymbol) { + searchSymbols.push(shorthandModuleSymbol); + } var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), declarations); + var result = []; + var symbolToIndex = []; + var inheritsFromCache = ts.createMap(); var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); var scope = getSymbolScope(symbol); - var symbolToIndex = []; if (scope) { - result = []; - getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + getRefs(scope, declaredName); } else { - var internedName = getInternedName(symbol, node); - for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { - var sourceFile = sourceFiles_8[_i]; + var isDefault = ts.isExportDefaultSymbol(symbol); + var internedName = isDefault ? symbol.valueDeclaration.localSymbol.name : getInternedName(symbol, node); + for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { + var sourceFile = sourceFiles_5[_i]; cancellationToken.throwIfCancellationRequested(); - var nameTable = ts.getNameTable(sourceFile); - if (nameTable[internedName] !== undefined) { - result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + var searchName = (isDefault ? getDefaultImportName(symbol, sourceFile, typeChecker) : undefined) || + (sourceFileHasName(sourceFile, internedName) ? declaredName : undefined); + if (searchName !== undefined) { + getRefs(sourceFile, searchName); } } } return result; - function getDefinition(symbol) { - var info = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node); - var name = ts.map(info.displayParts, function (p) { return p.text; }).join(""); - var declarations = symbol.declarations; - if (!declarations || declarations.length === 0) { - return undefined; - } - return { - containerKind: "", - containerName: "", - name: name, - kind: info.symbolKind, - fileName: declarations[0].getSourceFile().fileName, - textSpan: ts.createTextSpan(declarations[0].getStart(), 0), - displayParts: info.displayParts - }; + function getRefs(scope, searchName) { + getReferencesInNode(scope, symbol, searchName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache); } - function getAliasSymbolForPropertyNameSymbol(symbol, location) { - if (symbol.flags & 8388608) { - var defaultImport = ts.getDeclarationOfKind(symbol, 237); - if (defaultImport) { - return typeChecker.getAliasedSymbol(symbol); - } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 240 || - declaration.kind === 244) ? declaration : undefined; }); - if (importOrExportSpecifier && - (!importOrExportSpecifier.propertyName || - importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 240 ? - typeChecker.getAliasedSymbol(symbol) : - typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); - } + } + FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; + function getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken) { + if (ts.isTypeKeyword(node.kind)) { + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + } + if (ts.isLabelName(node)) { + if (ts.isJumpStatementTarget(node)) { + var labelDefinition = ts.getTargetLabel(node.parent, node.text); + return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, cancellationToken); } + else { + return getLabelReferencesInNode(node.parent, node, cancellationToken); + } + } + if (ts.isThis(node)) { + return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); + } + if (node.kind === 96) { + return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); + } + return undefined; + } + function followAliases(symbol, node, typeChecker, isForRename) { + while (true) { + if (isForRename && isImportDefaultSymbol(symbol)) { + return { symbol: symbol }; + } + var aliasedSymbol = getAliasSymbolForPropertyNameSymbol(symbol, node, typeChecker); + if (!aliasedSymbol || !aliasedSymbol.declarations) { + return { symbol: symbol }; + } + if (ts.isShorthandAmbientModuleSymbol(aliasedSymbol)) { + return { symbol: symbol, shorthandModuleSymbol: aliasedSymbol }; + } + symbol = aliasedSymbol; + } + } + function sourceFileHasName(sourceFile, name) { + return ts.getNameTable(sourceFile).get(name) !== undefined; + } + function getDefaultImportName(symbol, sourceFile, checker) { + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var importSpecifier = _a[_i]; + var importDecl = importSpecifier.parent; + ts.Debug.assert(importDecl.moduleSpecifier === importSpecifier); + var defaultName = importDecl.importClause.name; + var defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName)); + if (symbol === defaultReferencedSymbol) { + return defaultName.text; + } + } + return undefined; + } + function getDefinition(symbol, node, typeChecker) { + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node), displayParts = _a.displayParts, symbolKind = _a.symbolKind; + var name = displayParts.map(function (p) { return p.text; }).join(""); + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { return undefined; } - function followAliasIfNecessary(symbol, location) { - return getAliasSymbolForPropertyNameSymbol(symbol, location) || symbol; - } - function getPropertySymbolOfDestructuringAssignment(location) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - typeChecker.getPropertySymbolOfDestructuringAssignment(location); - } - function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 174); - return bindingElement && - bindingElement.parent.kind === 172 && - !bindingElement.propertyName; - } - function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 174); - var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); - } + return { + containerKind: "", + containerName: "", + name: name, + kind: symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: ts.createTextSpan(declarations[0].getStart(), 0), + displayParts: displayParts + }; + } + function getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) { + if (!(symbol.flags & 8388608)) { return undefined; } - function getInternedName(symbol, location) { - if (ts.isImportOrExportSpecifierName(location)) { - return location.getText(); - } - var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); - symbol = localExportDefaultSymbol || symbol; - return ts.stripQuotes(symbol.name); + var defaultImport = ts.getDeclarationOfKind(symbol, 238); + if (defaultImport) { + return typeChecker.getAliasedSymbol(symbol); } - function getSymbolScope(symbol) { - var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 184 || valueDeclaration.kind === 197)) { - return valueDeclaration; - } - if (symbol.flags & (4 | 8192)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); - if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 227); - } - } - if (symbol.flags & 8388608) { - return undefined; - } - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - return undefined; - } - if (symbol.parent || (symbol.flags & 268435456)) { - return undefined; - } - var scope; - var declarations = symbol.getDeclarations(); - if (declarations) { - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; - var container = ts.getContainerNode(declaration); - if (!container) { - return undefined; - } - if (scope && scope !== container) { - return undefined; - } - if (container.kind === 262 && !ts.isExternalModule(container)) { - return undefined; - } - scope = container; - } - } - return scope; + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 241 || + declaration.kind === 245) ? declaration : undefined; }); + if (importOrExportSpecifier && + (!importOrExportSpecifier.propertyName || + importOrExportSpecifier.propertyName === location)) { + return importOrExportSpecifier.kind === 241 ? + typeChecker.getAliasedSymbol(symbol) : + typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } - function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { - var positions = []; - if (!symbolName || !symbolName.length) { - return positions; + } + function followAliasIfNecessary(symbol, location, typeChecker) { + return getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) || symbol; + } + function getPropertySymbolOfDestructuringAssignment(location, typeChecker) { + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && + typeChecker.getPropertySymbolOfDestructuringAssignment(location); + } + function isObjectBindingPatternElementWithoutPropertyName(symbol) { + var bindingElement = ts.getDeclarationOfKind(symbol, 175); + return bindingElement && + bindingElement.parent.kind === 173 && + !bindingElement.propertyName; + } + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker) { + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + var bindingElement = ts.getDeclarationOfKind(symbol, 175); + var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); + return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + } + return undefined; + } + function getInternedName(symbol, location) { + if (ts.isImportOrExportSpecifierName(location)) { + return location.text; + } + return ts.stripQuotes(symbol.name); + } + function getSymbolScope(symbol) { + var valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && (valueDeclaration.kind === 185 || valueDeclaration.kind === 198)) { + return valueDeclaration; + } + if (symbol.flags & (4 | 8192)) { + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); + if (privateDeclaration) { + return ts.getAncestor(privateDeclaration, 228); } - var text = sourceFile.text; - var sourceLength = text.length; - var symbolNameLength = symbolName.length; - var position = text.indexOf(symbolName, start); - while (position >= 0) { - cancellationToken.throwIfCancellationRequested(); - if (position > end) - break; - var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5))) { - positions.push(position); + } + if (symbol.flags & 8388608) { + return undefined; + } + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + return undefined; + } + if (symbol.parent || (symbol.flags & 134217728 && symbol.checkFlags & 2)) { + return undefined; + } + var scope; + var declarations = symbol.getDeclarations(); + if (declarations) { + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; + var container = ts.getContainerNode(declaration); + if (!container) { + return undefined; } - position = text.indexOf(symbolName, position + symbolNameLength + 1); + if (scope && scope !== container) { + return undefined; + } + if (container.kind === 264 && !ts.isExternalModule(container)) { + return undefined; + } + scope = container; } + } + return scope; + } + function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end, cancellationToken) { + var positions = []; + if (!symbolName || !symbolName.length) { return positions; } - function getLabelReferencesInNode(container, targetLabel) { - var references = []; - var sourceFile = container.getSourceFile(); - var labelName = targetLabel.text; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.getWidth() !== labelName.length) { - return; - } - if (node === targetLabel || - (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ts.ScriptElementKind.label, - name: labelName, - textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()), - displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] - }; - return [{ definition: definition, references: references }]; + var text = sourceFile.text; + var sourceLength = text.length; + var symbolNameLength = symbolName.length; + var position = text.indexOf(symbolName, start); + while (position >= 0) { + cancellationToken.throwIfCancellationRequested(); + if (position > end) + break; + var endPosition = position + symbolNameLength; + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5))) { + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); } - function isValidReferencePosition(node, searchSymbolName) { - if (node) { - switch (node.kind) { - case 70: - return node.getWidth() === searchSymbolName.length; - case 9: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - return node.getWidth() === searchSymbolName.length + 2; + return positions; + } + function getLabelReferencesInNode(container, targetLabel, cancellationToken) { + var references = []; + var sourceFile = container.getSourceFile(); + var labelName = targetLabel.text; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { + return; + } + if (node === targetLabel || + (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { + references.push(getReferenceEntryFromNode(node)); + } + }); + var definition = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ts.ScriptElementKind.label, + name: labelName, + textSpan: ts.createTextSpanFromNode(targetLabel, sourceFile), + displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] + }; + return [{ definition: definition, references: references }]; + } + function isValidReferencePosition(node, searchSymbolName) { + switch (node && node.kind) { + case 70: + return node.getWidth() === searchSymbolName.length; + case 9: + return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + node.getWidth() === searchSymbolName.length + 2; + case 8: + return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; + default: + return false; + } + } + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + var name = ts.tokenToString(keywordKind); + var references = []; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var sourceFile = sourceFiles_6[_i]; + cancellationToken.throwIfCancellationRequested(); + addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); + } + if (!references.length) + return undefined; + var definition = { + containerKind: "", + containerName: "", + fileName: references[0].fileName, + kind: ts.ScriptElementKind.keyword, + name: name, + textSpan: references[0].textSpan, + displayParts: [{ text: name, kind: ts.ScriptElementKind.keyword }] + }; + return [{ definition: definition, references: references }]; + } + function addReferencesForKeywordInFile(sourceFile, kind, searchText, cancellationToken, references) { + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { + var position = possiblePositions_1[_i]; + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (referenceLocation.kind === kind) { + references.push({ + textSpan: ts.createTextSpanFromNode(referenceLocation), + fileName: sourceFile.fileName, + isWriteAccess: false, + isDefinition: false, + }); + } + } + } + function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache) { + var sourceFile = container.getSourceFile(); + var start = findInComments ? container.getFullStart() : container.getStart(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); + var parents = getParentSymbolsOfPropertyAccess(); + for (var _i = 0, possiblePositions_2 = possiblePositions; _i < possiblePositions_2.length; _i++) { + var position = possiblePositions_2[_i]; + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (!isValidReferencePosition(referenceLocation, searchText)) { + if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { + result.push({ + definition: undefined, + references: [{ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpan(position, searchText.length), + isWriteAccess: false, + isDefinition: false + }] + }); + } + continue; + } + if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { + continue; + } + var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); + if (referenceSymbol) { + var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); + var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocation.kind === 122, parents, inheritsFromCache, typeChecker); + if (relatedSymbol) { + addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); + } + else if (!(referenceSymbol.flags & 134217728) && ts.contains(searchSymbols, shorthandValueSymbol)) { + addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); + } + else if (searchLocation.kind === 122) { + findAdditionalConstructorReferences(referenceSymbol, referenceLocation); + } + } + } + return; + function getParentSymbolsOfPropertyAccess() { + if (implementations) { + var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); + if (propertyAccessExpression) { + var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); + if (localParentType) { + if (localParentType.symbol && localParentType.symbol.flags & (32 | 64) && localParentType.symbol !== searchSymbol.parent) { + return [localParentType.symbol]; } - break; - case 8: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return node.getWidth() === searchSymbolName.length; + else if (localParentType.flags & 196608) { + return getSymbolsForClassAndInterfaceComponents(localParentType); } - break; + } + } + } + } + function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { + ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); + var referenceClass = referenceLocation.parent; + if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { + ts.Debug.assert(referenceClass.name === referenceLocation); + addReferences(findOwnConstructorCalls(searchSymbol, sourceFile)); + } + else { + var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); + if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation, typeChecker) === searchSymbol) { + addReferences(superConstructorAccesses(classExtending)); + } + } + } + function addReferences(references) { + if (references.length) { + var referencedSymbol = getReferencedSymbol(searchSymbol); + ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); + } + } + function getReferencedSymbol(symbol) { + var symbolId = ts.getSymbolId(symbol); + var index = symbolToIndex[symbolId]; + if (index === undefined) { + index = result.length; + symbolToIndex[symbolId] = index; + result.push({ + definition: getDefinition(symbol, searchLocation, typeChecker), + references: [] + }); + } + return result[index]; + } + function addReferenceToRelatedSymbol(node, relatedSymbol) { + var references = getReferencedSymbol(relatedSymbol).references; + if (implementations) { + getImplementationReferenceEntryForNode(node, references, typeChecker); + } + else { + references.push(getReferenceEntryFromNode(node)); + } + } + } + function getPropertyAccessExpressionFromRightHandSide(node) { + return ts.isRightSideOfPropertyAccess(node) && node.parent; + } + function findOwnConstructorCalls(classSymbol, sourceFile) { + var result = []; + for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var ctrKeyword = ts.findChildOfKind(decl, 122, sourceFile); + ts.Debug.assert(decl.kind === 151 && !!ctrKeyword); + result.push(ctrKeyword); + } + classSymbol.exports.forEach(function (member) { + var decl = member.valueDeclaration; + if (decl && decl.kind === 150) { + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 98, function (thisKeyword) { + if (ts.isNewExpressionTarget(thisKeyword)) { + result.push(thisKeyword); + } + }); + } + } + }); + return result; + } + function superConstructorAccesses(cls) { + var symbol = cls.symbol; + var ctr = symbol.members.get("__constructor"); + if (!ctr) { + return []; + } + var result = []; + for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.Debug.assert(decl.kind === 151); + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 96, function (node) { + if (ts.isCallExpressionTarget(node)) { + result.push(node); + } + }); + } + } + ; + return result; + } + function getImplementationReferenceEntryForNode(refNode, result, typeChecker) { + if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { + result.push(getReferenceEntryFromNode(refNode.parent)); + } + else if (refNode.kind === 70) { + if (refNode.parent.kind === 261) { + getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + } + var containingClass = getContainingClassIfInHeritageClause(refNode); + if (containingClass) { + result.push(getReferenceEntryFromNode(containingClass)); + return; + } + var containingTypeReference = getContainingTypeReference(refNode); + if (containingTypeReference) { + var parent = containingTypeReference.parent; + if (ts.isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent.initializer)); + } + else if (ts.isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { + if (parent.body.kind === 206) { + ts.forEachReturnStatement(parent.body, function (returnStatement) { + if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { + maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); + } + }); + } + else if (isImplementationExpression(parent.body)) { + maybeAdd(getReferenceEntryFromNode(parent.body)); + } + } + else if (ts.isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { + maybeAdd(getReferenceEntryFromNode(parent.expression)); + } + } + } + function maybeAdd(a) { + if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { + result.push(a); + } + } + } + function getSymbolsForClassAndInterfaceComponents(type, result) { + if (result === void 0) { result = []; } + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var componentType = _a[_i]; + if (componentType.symbol && componentType.symbol.getFlags() & (32 | 64)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & 196608) { + getSymbolsForClassAndInterfaceComponents(componentType, result); + } + } + return result; + } + function getContainingTypeReference(node) { + var topLevelTypeReference = undefined; + while (node) { + if (ts.isTypeNode(node)) { + topLevelTypeReference = node; + } + node = node.parent; + } + return topLevelTypeReference; + } + function getContainingClassIfInHeritageClause(node) { + if (node && node.parent) { + if (node.kind === 200 + && node.parent.kind === 258 + && ts.isClassLike(node.parent.parent)) { + return node.parent.parent; + } + else if (node.kind === 70 || node.kind === 178) { + return getContainingClassIfInHeritageClause(node.parent); + } + } + return undefined; + } + function isImplementationExpression(node) { + switch (node.kind) { + case 184: + return isImplementationExpression(node.expression); + case 186: + case 185: + case 177: + case 198: + case 176: + return true; + default: + return false; + } + } + function explicitlyInheritsFrom(child, parent, cachedResults, typeChecker) { + var parentIsInterface = parent.getFlags() & 64; + return searchHierarchy(child); + function searchHierarchy(symbol) { + if (symbol === parent) { + return true; + } + var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); + var cached = cachedResults.get(key); + if (cached !== undefined) { + return cached; + } + cachedResults.set(key, false); + var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + if (parentIsInterface) { + var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { + var typeReference = interfaceReferences_1[_i]; + if (searchTypeReference(typeReference)) { + return true; + } + } + } + } + return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + } + else if (declaration.kind === 229) { + if (parentIsInterface) { + return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); + } + } + return false; + }); + cachedResults.set(key, inherits); + return inherits; + } + function searchTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); } } return false; } - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { - var sourceFile = container.getSourceFile(); - var start = findInComments ? container.getFullStart() : container.getStart(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd()); - var parents = getParentSymbolsOfPropertyAccess(); - var inheritsFromCache = ts.createMap(); - if (possiblePositions.length) { - var searchSymbols_1 = populateSearchSymbolSet(searchSymbol, searchLocation); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { - if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || - (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: ts.createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); - } - return; - } - if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { - return; - } - var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, searchLocation.kind === 122, parents, inheritsFromCache); - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); - } - else if (!(referenceSymbol.flags & 67108864) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); - } - else if (searchLocation.kind === 122) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); - } - } - }); - } - return; - function getParentSymbolsOfPropertyAccess() { - if (implementations) { - var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); - if (propertyAccessExpression) { - var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); - if (localParentType) { - if (localParentType.symbol && localParentType.symbol.flags & (32 | 64) && localParentType.symbol !== searchSymbol.parent) { - return [localParentType.symbol]; - } - else if (localParentType.flags & 196608) { - return getSymbolsForClassAndInterfaceComponents(localParentType); - } - } - } - } - } - function getPropertyAccessExpressionFromRightHandSide(node) { - return ts.isRightSideOfPropertyAccess(node) && node.parent; - } - function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { - ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); - var referenceClass = referenceLocation.parent; - if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { - ts.Debug.assert(referenceClass.name === referenceLocation); - addReferences(findOwnConstructorCalls(searchSymbol)); - } - else { - var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); - if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) { - addReferences(superConstructorAccesses(classExtending)); - } - } - } - function addReferences(references) { - if (references.length) { - var referencedSymbol = getReferencedSymbol(searchSymbol); - ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); - } - } - function findOwnConstructorCalls(classSymbol) { - var result = []; - for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 150); - var ctrKeyword = decl.getChildAt(0); - ts.Debug.assert(ctrKeyword.kind === 122); - result.push(ctrKeyword); - } - ts.forEachProperty(classSymbol.exports, function (member) { - var decl = member.valueDeclaration; - if (decl && decl.kind === 149) { - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 98, function (thisKeyword) { - if (ts.isNewExpressionTarget(thisKeyword)) { - result.push(thisKeyword); - } - }); - } - } - }); - return result; - } - function superConstructorAccesses(cls) { - var symbol = cls.symbol; - var ctr = symbol.members["__constructor"]; - if (!ctr) { - return []; - } - var result = []; - for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 150); - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 96, function (node) { - if (ts.isCallExpressionTarget(node)) { - result.push(node); - } - }); - } - } - ; - return result; - } - function getReferencedSymbol(symbol) { - var symbolId = ts.getSymbolId(symbol); - var index = symbolToIndex[symbolId]; - if (index === undefined) { - index = result.length; - symbolToIndex[symbolId] = index; - result.push({ - definition: getDefinition(symbol), - references: [] - }); - } - return result[index]; - } - function addReferenceToRelatedSymbol(node, relatedSymbol) { - var references = getReferencedSymbol(relatedSymbol).references; - if (implementations) { - getImplementationReferenceEntryForNode(node, references); - } - else { - references.push(getReferenceEntryFromNode(node)); - } - } - } - function getImplementationReferenceEntryForNode(refNode, result) { - if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); - } - else if (refNode.kind === 70) { - if (refNode.parent.kind === 259) { - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); - } - var containingClass = getContainingClassIfInHeritageClause(refNode); - if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); - return; - } - var containingTypeReference = getContainingTypeReference(refNode); - if (containingTypeReference) { - var parent_19 = containingTypeReference.parent; - if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_19.initializer)); - } - else if (ts.isFunctionLike(parent_19) && parent_19.type === containingTypeReference && parent_19.body) { - if (parent_19.body.kind === 205) { - ts.forEachReturnStatement(parent_19.body, function (returnStatement) { - if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); - } - }); - } - else if (isImplementationExpression(parent_19.body)) { - maybeAdd(getReferenceEntryFromNode(parent_19.body)); - } - } - else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_19.expression)); - } - } - } - function maybeAdd(a) { - if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { - result.push(a); - } - } - } - function getSymbolsForClassAndInterfaceComponents(type, result) { - if (result === void 0) { result = []; } - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var componentType = _a[_i]; - if (componentType.symbol && componentType.symbol.getFlags() & (32 | 64)) { - result.push(componentType.symbol); - } - if (componentType.getFlags() & 196608) { - getSymbolsForClassAndInterfaceComponents(componentType, result); - } - } - return result; - } - function getContainingTypeReference(node) { - var topLevelTypeReference = undefined; - while (node) { - if (ts.isTypeNode(node)) { - topLevelTypeReference = node; - } - node = node.parent; - } - return topLevelTypeReference; - } - function getContainingClassIfInHeritageClause(node) { - if (node && node.parent) { - if (node.kind === 199 - && node.parent.kind === 256 - && ts.isClassLike(node.parent.parent)) { - return node.parent.parent; - } - else if (node.kind === 70 || node.kind === 177) { - return getContainingClassIfInHeritageClause(node.parent); - } - } + } + function getReferencesForSuperKeyword(superKeyword, typeChecker, cancellationToken) { + var searchSpaceNode = ts.getSuperContainer(superKeyword, false); + if (!searchSpaceNode) { return undefined; } - function isImplementationExpression(node) { - if (node.kind === 183) { - return isImplementationExpression(node.expression); - } - return node.kind === 185 || - node.kind === 184 || - node.kind === 176 || - node.kind === 197 || - node.kind === 175; - } - function explicitlyInheritsFrom(child, parent, cachedResults) { - var parentIsInterface = parent.getFlags() & 64; - return searchHierarchy(child); - function searchHierarchy(symbol) { - if (symbol === parent) { - return true; - } - var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); - if (key in cachedResults) { - return cachedResults[key]; - } - cachedResults[key] = false; - var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - if (parentIsInterface) { - var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); - if (interfaceReferences) { - for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { - var typeReference = interfaceReferences_1[_i]; - if (searchTypeReference(typeReference)) { - return true; - } - } - } - } - return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - } - else if (declaration.kind === 228) { - if (parentIsInterface) { - return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); - } - } - return false; - }); - cachedResults[key] = inherits; - return inherits; - } - function searchTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type && type.symbol) { - return searchHierarchy(type.symbol); - } - } - return false; - } - } - function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, false); - if (!searchSpaceNode) { + var staticFlag = 32; + switch (searchSpaceNode.kind) { + case 148: + case 147: + case 150: + case 149: + case 151: + case 152: + case 153: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; + break; + default: return undefined; + } + var references = []; + var sourceFile = searchSpaceNode.getSourceFile(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + for (var _i = 0, possiblePositions_3 = possiblePositions; _i < possiblePositions_3.length; _i++) { + var position = possiblePositions_3[_i]; + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 96) { + continue; } - var staticFlag = 32; - switch (searchSpaceNode.kind) { - case 147: - case 146: - case 149: - case 148: - case 150: - case 151: - case 152: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; + var container = ts.getSuperContainer(node, false); + if (container && (32 & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(getReferenceEntryFromNode(node)); + } + } + var definition = getDefinition(searchSpaceNode.symbol, superKeyword, typeChecker); + return [{ definition: definition, references: references }]; + } + function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, typeChecker, cancellationToken) { + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); + var staticFlag = 32; + switch (searchSpaceNode.kind) { + case 150: + case 149: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; - default: + } + case 148: + case 147: + case 151: + case 152: + case 153: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; + break; + case 264: + if (ts.isExternalModule(searchSpaceNode)) { return undefined; - } - var references = []; + } + case 227: + case 185: + break; + default: + return undefined; + } + var references = []; + var possiblePositions; + if (searchSpaceNode.kind === 264) { + ts.forEach(sourceFiles, function (sourceFile) { + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { var sourceFile = searchSpaceNode.getSourceFile(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); + var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: thisOrSuperKeyword.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: "this", + textSpan: ts.createTextSpanFromNode(thisOrSuperKeyword), + displayParts: displayParts + }, + references: references + }]; + function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 96) { + if (!node || !ts.isThis(node)) { return; } - var container = ts.getSuperContainer(node, false); - if (container && (32 & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); + var container = ts.getThisContainer(node, false); + switch (searchSpaceNode.kind) { + case 185: + case 227: + if (searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 150: + case 149: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 198: + case 228: + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 264: + if (container.kind === 264 && !ts.isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); + } + break; } }); - var definition = getDefinition(searchSpaceNode.symbol); - return [{ definition: definition, references: references }]; } - function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); - var staticFlag = 32; - switch (searchSpaceNode.kind) { - case 149: - case 148: - if (ts.isObjectLiteralMethod(searchSpaceNode)) { - break; + } + function getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (!type) { + return undefined; + } + var references = []; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); + } + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: type.text, + textSpan: ts.createTextSpanFromNode(node), + displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] + }, + references: references + }]; + function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { + for (var _i = 0, possiblePositions_4 = possiblePositions; _i < possiblePositions_4.length; _i++) { + var position = possiblePositions_4[_i]; + cancellationToken.throwIfCancellationRequested(); + var node_2 = ts.getTouchingWord(sourceFile, position); + if (!node_2 || node_2.kind !== 9) { + return; + } + var type_2 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + if (type_2 === searchType) { + references.push(getReferenceEntryFromNode(node_2)); + } + } + } + } + function populateSearchSymbolSet(symbol, location, typeChecker, implementations) { + var result = [symbol]; + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 261) { + var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, typeChecker); + if (propertySymbol) { + result.push(propertySymbol); + } + } + if (containingObjectLiteralElement) { + ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { + ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); + }); + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } + } + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 145 && + ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + ts.addRange(result, typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); + } + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker); + if (bindingElementPropertySymbol) { + result.push(bindingElementPropertySymbol); + } + for (var _i = 0, _a = typeChecker.getRootSymbols(symbol); _i < _a.length; _i++) { + var rootSymbol = _a[_i]; + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap(), typeChecker); + } + } + return result; + } + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, typeChecker) { + if (!symbol) { + return; + } + if (previousIterationSymbolsCache.has(symbol.name)) { + return; + } + if (symbol.flags & (32 | 64)) { + ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === 229) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); + } + }); + } + return; + function getPropertySymbolFromTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type) { + var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); + if (propertySymbol) { + result.push.apply(result, typeChecker.getRootSymbols(propertySymbol)); } - case 147: - case 146: - case 150: - case 151: - case 152: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; - break; - case 262: - if (ts.isExternalModule(searchSpaceNode)) { + previousIterationSymbolsCache.set(symbol.name, symbol); + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, typeChecker); + } + } + } + } + function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker) { + if (ts.contains(searchSymbols, referenceSymbol)) { + return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) ? referenceSymbol : undefined; + } + var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation, typeChecker); + if (aliasSymbol) { + return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker); + } + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { + return ts.find(typeChecker.getRootSymbols(contextualSymbol), function (symbol) { return ts.contains(searchSymbols, symbol); }); + }); + if (contextualSymbol) { + return contextualSymbol; + } + var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, typeChecker); + if (propertySymbol && ts.contains(searchSymbols, propertySymbol)) { + return propertySymbol; + } + } + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, typeChecker); + if (bindingElementPropertySymbol && ts.contains(searchSymbols, bindingElementPropertySymbol)) { + return bindingElementPropertySymbol; + } + return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { + if (ts.contains(searchSymbols, rootSymbol)) { + return rootSymbol; + } + if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + if (parents) { + if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache, typeChecker); })) { return undefined; } - case 226: - case 184: - break; - default: - return undefined; - } - var references = []; - var possiblePositions; - if (searchSpaceNode.kind === 262) { - ts.forEach(sourceFiles, function (sourceFile) { - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); - }); - } - else { - var sourceFile = searchSpaceNode.getSourceFile(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); - } - var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: "this", - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: displayParts - }, - references: references - }]; - function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || !ts.isThis(node)) { - return; - } - var container = ts.getThisContainer(node, false); - switch (searchSpaceNode.kind) { - case 184: - case 226: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 149: - case 148: - if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 197: - case 227: - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 262: - if (container.kind === 262 && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); - } - } - function getReferencesForStringLiteral(node, sourceFiles) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (!type) { - return undefined; - } - var references = []; - for (var _i = 0, sourceFiles_9 = sourceFiles; _i < sourceFiles_9.length; _i++) { - var sourceFile = sourceFiles_9[_i]; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd()); - getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); - } - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: type.text, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] - }, - references: references - }]; - function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { - for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { - var position = possiblePositions_1[_i]; - cancellationToken.throwIfCancellationRequested(); - var node_3 = ts.getTouchingWord(sourceFile, position); - if (!node_3 || node_3.kind !== 9) { - return; - } - var type_1 = ts.getStringLiteralTypeForNode(node_3, typeChecker); - if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_3)); - } } + var result = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap(), typeChecker); + return ts.find(result, function (symbol) { return ts.contains(searchSymbols, symbol); }); } - } - function populateSearchSymbolSet(symbol, location) { - var result = [symbol]; - var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 259) { - var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); - if (propertySymbol) { - result.push(propertySymbol); - } - } - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(symbol, location); - if (aliasSymbol) { - result = result.concat(populateSearchSymbolSet(aliasSymbol, location)); - } - if (containingObjectLiteralElement) { - ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (contextualSymbol) { - ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); - }); - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); - } - } - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 144 && - ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { - result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); - } - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol); - if (bindingElementPropertySymbol) { - result.push(bindingElementPropertySymbol); - } - ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap()); - } - }); - return result; - } - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache) { - if (!symbol) { - return; - } - if (symbol.name in previousIterationSymbolsCache) { - return; - } - if (symbol.flags & (32 | 64)) { - ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === 228) { - ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); - } - }); - } - return; - function getPropertySymbolFromTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type) { - var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); - if (propertySymbol) { - result.push.apply(result, typeChecker.getRootSymbols(propertySymbol)); - } - previousIterationSymbolsCache[symbol.name] = symbol; - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); - } - } - } - } - function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache) { - if (ts.contains(searchSymbols, referenceSymbol)) { - return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) && referenceSymbol; - } - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); - if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache); - } - var containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); - if (containingObjectLiteralElement) { - var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (contextualSymbol) { - return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - }); - if (contextualSymbol) { - return contextualSymbol; - } - var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation); - if (propertySymbol && searchSymbols.indexOf(propertySymbol) >= 0) { - return propertySymbol; - } - } - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol); - if (bindingElementPropertySymbol && searchSymbols.indexOf(bindingElementPropertySymbol) >= 0) { - return bindingElementPropertySymbol; - } - return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { - if (searchSymbols.indexOf(rootSymbol) >= 0) { - return rootSymbol; - } - if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - if (parents) { - if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache); })) { - return undefined; - } - } - var result_4 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_4, ts.createMap()); - return ts.forEach(result_4, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - } - return undefined; - }); - } - function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 142) { - var nameExpression = node.name.expression; - if (ts.isStringOrNumericLiteral(nameExpression)) { - return nameExpression.text; - } - return undefined; - } - return node.name.text; - } - function getPropertySymbolsFromContextualType(node) { - var objectLiteral = node.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - var name = getNameFromObjectLiteralElement(node); - if (name && contextualType) { - var result_5 = []; - var symbol_2 = contextualType.getProperty(name); - if (symbol_2) { - result_5.push(symbol_2); - } - if (contextualType.flags & 65536) { - ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name); - if (symbol) { - result_5.push(symbol); - } - }); - } - return result_5; + return undefined; + }); + } + function getNameFromObjectLiteralElement(node) { + if (node.name.kind === 143) { + var nameExpression = node.name.expression; + if (ts.isStringOrNumericLiteral(nameExpression)) { + return nameExpression.text; } return undefined; } - function getIntersectingMeaningFromDeclarations(meaning, declarations) { - if (declarations) { - var lastIterationMeaning = void 0; - do { - lastIterationMeaning = meaning; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; - var declarationMeaning = ts.getMeaningFromDeclaration(declaration); - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; - } - } - } while (meaning !== lastIterationMeaning); + return node.name.text; + } + function getPropertySymbolsFromContextualType(node, typeChecker) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + var result_4 = []; + var symbol = contextualType.getProperty(name); + if (symbol) { + result_4.push(symbol); } - return meaning; + if (contextualType.flags & 65536) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_4.push(symbol); + } + }); + } + return result_4; } + return undefined; } - FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; - function convertReferences(referenceSymbols) { - if (!referenceSymbols) { - return undefined; + function getIntersectingMeaningFromDeclarations(meaning, declarations) { + if (declarations) { + var lastIterationMeaning = void 0; + do { + lastIterationMeaning = meaning; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + var declarationMeaning = ts.getMeaningFromDeclaration(declaration); + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } while (meaning !== lastIterationMeaning); } - var referenceEntries = []; - for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) { - var referenceSymbol = referenceSymbols_1[_i]; - ts.addRange(referenceEntries, referenceSymbol.references); - } - return referenceEntries; + return meaning; } - FindAllReferences.convertReferences = convertReferences; function isImplementation(node) { if (!node) { return false; @@ -57727,7 +60248,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 224) { + else if (node.kind === 225) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2); } @@ -57737,18 +60258,18 @@ var ts; } else { switch (node.kind) { - case 227: - case 197: - case 230: + case 228: + case 198: case 231: + case 232: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 206) { - ts.Debug.assert(node.parent.kind === 225); + if (node.parent && node.parent.parent && node.parent.parent.kind === 207) { + ts.Debug.assert(node.parent.kind === 226); return node.parent.parent; } } @@ -57786,10 +60307,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 191 || parent.kind === 190) { + if (parent.kind === 192 || parent.kind === 191) { return true; } - else if (parent.kind === 192 && parent.left === node) { + else if (parent.kind === 193 && parent.left === node) { var operator = parent.operatorToken.kind; return 57 <= operator && operator <= 69; } @@ -57804,29 +60325,6 @@ var ts; forEachDescendantOfKind(child, kind, action); }); } - function getContainingObjectLiteralElement(node) { - switch (node.kind) { - case 9: - case 8: - if (node.parent.kind === 142) { - return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; - } - case 70: - return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; - } - return undefined; - } - function isObjectLiteralPropertyDeclaration(node) { - switch (node.kind) { - case 258: - case 259: - case 149: - case 151: - case 152: - return true; - } - return false; - } function tryGetClassByExtendingIdentifier(node) { return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); } @@ -57836,6 +60334,9 @@ var ts; } return false; } + function isImportDefaultSymbol(symbol) { + return symbol.declarations[0].kind === 238; + } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); var ts; @@ -57853,11 +60354,9 @@ var ts; } var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { - var referenceFile = program.getResolvedTypeReferenceDirectives()[typeReferenceDirective.fileName]; - if (referenceFile && referenceFile.resolvedFileName) { - return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; - } - return undefined; + var referenceFile = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); + return referenceFile && referenceFile.resolvedFileName && + [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; } var node = ts.getTouchingPropertyName(sourceFile, position); if (node === sourceFile) { @@ -57866,7 +60365,7 @@ var ts; if (ts.isJumpStatementTarget(node)) { var labelName = node.text; var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ts.ScriptElementKind.label, labelName, undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, ts.ScriptElementKind.label, labelName, undefined)] : undefined; } var typeChecker = program.getTypeChecker(); var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); @@ -57881,11 +60380,11 @@ var ts; var declaration = symbol.declarations[0]; if (node.kind === 70 && (node.parent === declaration || - (declaration.kind === 240 && declaration.parent && declaration.parent.kind === 239))) { + (declaration.kind === 241 && declaration.parent && declaration.parent.kind === 240))) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 259) { + if (node.parent.kind === 261) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -57896,6 +60395,22 @@ var ts; var shorthandContainerName_1 = typeChecker.symbolToString(symbol.parent, node); return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind_1, shorthandSymbolName_1, shorthandContainerName_1); }); } + if (ts.isJsxOpeningLikeElement(node.parent)) { + var _a = getSymbolInfo(typeChecker, symbol, node), symbolName = _a.symbolName, symbolKind = _a.symbolKind, containerName = _a.containerName; + return [createDefinitionInfo(symbol.valueDeclaration, symbolKind, symbolName, containerName)]; + } + var element = ts.getContainingObjectLiteralElement(node); + if (element) { + if (typeChecker.getContextualType(element.parent)) { + var result = []; + var propertySymbols = ts.getPropertySymbolsFromContextualType(typeChecker, element); + for (var _i = 0, propertySymbols_1 = propertySymbols; _i < propertySymbols_1.length; _i++) { + var propertySymbol = propertySymbols_1[_i]; + result.push.apply(result, getDefinitionFromSymbol(typeChecker, propertySymbol, node)); + } + return result; + } + } return getDefinitionFromSymbol(typeChecker, symbol, node); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; @@ -57913,13 +60428,13 @@ var ts; return undefined; } if (type.flags & 65536 && !(type.flags & 16)) { - var result_6 = []; + var result_5 = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(result_6, getDefinitionFromSymbol(typeChecker, t.symbol, node)); + ts.addRange(result_5, getDefinitionFromSymbol(typeChecker, t.symbol, node)); } }); - return result_6; + return result_5; } if (!type.symbol) { return undefined; @@ -57961,29 +60476,40 @@ var ts; function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { var declarations = []; var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 150) || - (!selectConstructors && (d.kind === 226 || d.kind === 149 || d.kind === 148))) { + for (var _i = 0, signatureDeclarations_1 = signatureDeclarations; _i < signatureDeclarations_1.length; _i++) { + var d = signatureDeclarations_1[_i]; + if (selectConstructors ? d.kind === 151 : isSignatureDeclaration(d)) { declarations.push(d); if (d.body) definition = d; } - }); - if (definition) { - result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); - return true; } - else if (declarations.length) { - result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); + if (declarations.length) { + result.push(createDefinitionInfo(definition || ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); return true; } return false; } } + function isSignatureDeclaration(node) { + switch (node.kind) { + case 151: + case 227: + case 150: + case 149: + return true; + default: + return false; + } + } function createDefinitionInfo(node, symbolKind, symbolName, containerName) { + return createDefinitionInfoFromName(node.name || node, symbolKind, symbolName, containerName); + } + function createDefinitionInfoFromName(name, symbolKind, symbolName, containerName) { + var sourceFile = name.getSourceFile(); return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromNode(name, sourceFile), kind: symbolKind, name: symbolName, containerKind: undefined, @@ -58030,7 +60556,14 @@ var ts; } function tryGetSignatureDeclaration(typeChecker, node) { var callLike = getAncestorCallLikeExpression(node); - return callLike && typeChecker.getResolvedSignature(callLike).declaration; + var signature = callLike && typeChecker.getResolvedSignature(callLike); + if (signature) { + var decl = signature.declaration; + if (decl && isSignatureDeclaration(decl)) { + return decl; + } + } + return undefined; } })(GoToDefinition = ts.GoToDefinition || (ts.GoToDefinition = {})); })(ts || (ts = {})); @@ -58039,7 +60572,7 @@ var ts; var GoToImplementation; (function (GoToImplementation) { function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { - if (node.parent.kind === 259) { + if (node.parent.kind === 261) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -58049,7 +60582,7 @@ var ts; return symbol.valueDeclaration && [ts.FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; } else { - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, false, false, true); + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, false, false, false, true); var result = ts.flatMap(referencedSymbols, function (symbol) { return ts.map(symbol.references, function (_a) { var textSpan = _a.textSpan, fileName = _a.fileName; @@ -58165,16 +60698,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 226: - case 149: - case 150: case 227: - case 206: + case 150: + case 151: + case 228: + case 207: break findOwner; - case 262: + case 264: return undefined; - case 231: - if (commentOwner.parent.kind === 231) { + case 232: + if (commentOwner.parent.kind === 232) { return undefined; } break findOwner; @@ -58214,7 +60747,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 206) { + if (commentOwner.kind === 207) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -58224,17 +60757,17 @@ var ts; return ts.emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 183) { + while (rightHandSide.kind === 184) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 184: case 185: + case 186: return rightHandSide.parameters; - case 197: + case 198: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150) { + if (member.kind === 151) { return member.parameters; } } @@ -58245,47 +60778,210 @@ var ts; })(JsDoc = ts.JsDoc || (ts.JsDoc = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var JsTyping; + (function (JsTyping) { + ; + ; + var safeList; + var EmptySafeList = ts.createMap(); + JsTyping.nodeCoreModuleList = [ + "buffer", "querystring", "events", "http", "cluster", + "zlib", "os", "https", "punycode", "repl", "readline", + "vm", "child_process", "url", "dns", "net", + "dgram", "fs", "path", "string_decoder", "tls", + "crypto", "stream", "util", "assert", "tty", "domain", + "constants", "process", "v8", "timers", "console" + ]; + var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typeAcquisition, unresolvedImports) { + var inferredTypings = ts.createMap(); + if (!typeAcquisition || !typeAcquisition.enable) { + return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; + } + fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { + var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); + return kind === 1 || kind === 2; + }); + if (!safeList) { + var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); + safeList = result.config ? ts.createMapFromTemplate(result.config) : EmptySafeList; + } + var filesToWatch = []; + var searchDirs = []; + var exclude = []; + mergeTypings(typeAcquisition.include); + exclude = typeAcquisition.exclude || []; + var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); + if (projectRootPath) { + possibleSearchDirs.push(projectRootPath); + } + searchDirs = ts.deduplicate(possibleSearchDirs); + for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { + var searchDir = searchDirs_1[_i]; + var packageJsonPath = ts.combinePaths(searchDir, "package.json"); + getTypingNamesFromJson(packageJsonPath, filesToWatch); + var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); + getTypingNamesFromJson(bowerJsonPath, filesToWatch); + var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); + getTypingNamesFromNodeModuleFolder(nodeModulesPath); + } + getTypingNamesFromSourceFileNames(fileNames); + if (unresolvedImports) { + for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { + var moduleId = unresolvedImports_1[_a]; + var typingName = nodeCoreModules.has(moduleId) ? "node" : moduleId; + if (!inferredTypings.has(typingName)) { + inferredTypings.set(typingName, undefined); + } + } + } + packageNameToTypingLocation.forEach(function (typingLocation, name) { + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined) { + inferredTypings.set(name, typingLocation); + } + }); + for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { + var excludeTypingName = exclude_1[_b]; + inferredTypings.delete(excludeTypingName); + } + var newTypingNames = []; + var cachedTypingPaths = []; + inferredTypings.forEach(function (inferred, typing) { + if (inferred !== undefined) { + cachedTypingPaths.push(inferred); + } + else { + newTypingNames.push(typing); + } + }); + return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; + function mergeTypings(typingNames) { + if (!typingNames) { + return; + } + for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { + var typing = typingNames_1[_i]; + if (!inferredTypings.has(typing)) { + inferredTypings.set(typing, undefined); + } + } + } + function getTypingNamesFromJson(jsonPath, filesToWatch) { + if (host.fileExists(jsonPath)) { + filesToWatch.push(jsonPath); + } + var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); + if (result.config) { + var jsonConfig = result.config; + if (jsonConfig.dependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); + } + if (jsonConfig.devDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); + } + if (jsonConfig.optionalDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); + } + if (jsonConfig.peerDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); + } + } + } + function getTypingNamesFromSourceFileNames(fileNames) { + var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); + var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); + var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); + if (safeList !== EmptySafeList) { + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return safeList.has(f); })); + } + var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); + if (hasJsxFile) { + mergeTypings(["react"]); + } + } + function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { + if (!host.directoryExists(nodeModulesPath)) { + return; + } + var typingNames = []; + var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); + for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { + var fileName = fileNames_2[_i]; + var normalizedFileName = ts.normalizePath(fileName); + if (ts.getBaseFileName(normalizedFileName) !== "package.json") { + continue; + } + var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); + if (!result.config) { + continue; + } + var packageJson = result.config; + if (packageJson._requiredBy && + ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { + continue; + } + if (!packageJson.name) { + continue; + } + if (packageJson.typings) { + var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); + inferredTypings.set(packageJson.name, absolutePath); + } + else { + typingNames.push(packageJson.name); + } + } + mergeTypings(typingNames); + } + } + JsTyping.discoverTypings = discoverTypings; + })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var NavigateTo; (function (NavigateTo) { function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; - ts.forEach(sourceFiles, function (sourceFile) { + var _loop_4 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { - return; + return "continue"; } - var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_48 in nameToDeclarations) { - var declarations = nameToDeclarations[name_48]; + ts.forEachEntry(sourceFile.getNamedDeclarations(), function (declarations, name) { if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_48); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); if (!matches) { - continue; + return; } - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { + var declaration = declarations_12[_i]; if (patternMatcher.patternContainsDots) { var containers = getContainers(declaration); if (!containers) { - return undefined; + return true; } - matches = patternMatcher.getMatches(containers, name_48); + matches = patternMatcher.getMatches(containers, name); if (!matches) { - continue; + return; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_48, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } - } - }); + }); + }; + for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { + var sourceFile = sourceFiles_8[_i]; + _loop_4(sourceFile); + } rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 237 || decl.kind === 240 || decl.kind === 235) { + if (decl.kind === 238 || decl.kind === 241 || decl.kind === 236) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -58326,7 +61022,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 142) { + else if (declaration.name.kind === 143) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -58343,7 +61039,7 @@ var ts; } return true; } - if (expression.kind === 177) { + if (expression.kind === 178) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -58354,7 +61050,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 142) { + if (declaration.name.kind === 143) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -58395,7 +61091,7 @@ var ts; matchKind: ts.PatternMatchKind[rawItem.matchKind], isCaseSensitive: rawItem.isCaseSensitive, fileName: rawItem.fileName, - textSpan: ts.createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), + textSpan: ts.createTextSpanFromNode(declaration), containerName: container && container.name ? container.name.text : "", containerKind: container && container.name ? ts.getNodeKind(container) : "" }; @@ -58486,7 +61182,7 @@ var ts; return; } switch (node.kind) { - case 150: + case 151: var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { @@ -58496,28 +61192,28 @@ var ts; } } break; - case 149: - case 151: + case 150: case 152: - case 148: + case 153: + case 149: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; + case 148: case 147: - case 146: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 237: + case 238: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 238) { + if (namedBindings.kind === 239) { addLeafNode(namedBindings); } else { @@ -58528,12 +61224,12 @@ var ts; } } break; - case 174: - case 224: + case 175: + case 225: var decl = node; - var name_49 = decl.name; - if (ts.isBindingPattern(name_49)) { - addChildrenRecursively(name_49); + var name = decl.name; + if (ts.isBindingPattern(name)) { + addChildrenRecursively(name); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { addChildrenRecursively(decl.initializer); @@ -58542,12 +61238,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; + case 186: + case 227: case 185: - case 226: - case 184: addNodeWithRecursiveChild(node, node.body); break; - case 230: + case 231: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -58557,9 +61253,9 @@ var ts; } endNode(); break; - case 227: - case 197: case 228: + case 198: + case 229: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -58567,21 +61263,21 @@ var ts; } endNode(); break; - case 231: + case 232: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 244: - case 235: - case 155: - case 153: + case 245: + case 236: + case 156: case 154: - case 229: + case 155: + case 230: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 286) { + if (tag.kind === 289) { addLeafNode(tag); } }); @@ -58597,9 +61293,9 @@ var ts; if (!name) { return true; } - var itemsWithSameName = nameToItems[name]; + var itemsWithSameName = nameToItems.get(name); if (!itemsWithSameName) { - nameToItems[name] = child; + nameToItems.set(name, child); return true; } if (itemsWithSameName instanceof Array) { @@ -58617,7 +61313,7 @@ var ts; if (tryMerge(itemWithSameName, child)) { return false; } - nameToItems[name] = [itemWithSameName, child]; + nameToItems.set(name, [itemWithSameName, child]); return true; } function tryMerge(a, b) { @@ -58629,12 +61325,12 @@ var ts; } }); function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 231 || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 232 || areSameModule(a, b)); function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 231) { + if (a.body.kind !== 232) { return true; } return areSameModule(a.body, b.body); @@ -58660,32 +61356,15 @@ var ts; function compareChildren(child1, child2) { var name1 = tryGetName(child1.node), name2 = tryGetName(child2.node); if (name1 && name2) { - var cmp = localeCompareFix(name1, name2); + var cmp = ts.compareStringsCaseInsensitive(name1, name2); return cmp !== 0 ? cmp : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } else { return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } } - var localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; - var localeCompareFix = localeCompareIsCorrect ? ts.collator.compare : function (a, b) { - for (var i = 0; i < Math.min(a.length, b.length); i++) { - var chA = a.charAt(i), chB = b.charAt(i); - if (chA === "\"" && chB === "'") { - return 1; - } - if (chA === "'" && chB === "\"") { - return -1; - } - var cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); - if (cmp !== 0) { - return cmp; - } - } - return a.length - b.length; - }; function tryGetName(node) { - if (node.kind === 231) { + if (node.kind === 232) { return getModuleName(node); } var decl = node; @@ -58693,18 +61372,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 184: case 185: - case 197: + case 186: + case 198: return getFunctionOrClassName(node); - case 286: + case 289: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 231) { + if (node.kind === 232) { return getModuleName(node); } var name = node.name; @@ -58715,29 +61394,29 @@ var ts; } } switch (node.kind) { - case 262: + case 264: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 185: - case 226: - case 184: + case 186: case 227: - case 197: + case 185: + case 228: + case 198: if (ts.getModifierFlags(node) & 512) { return "default"; } return getFunctionOrClassName(node); - case 150: + case 151: return "constructor"; - case 154: - return "new()"; - case 153: - return "()"; case 155: + return "new()"; + case 154: + return "()"; + case 156: return "[]"; - case 286: + case 289: return getJSDocTypedefTagName(node); default: return ""; @@ -58749,7 +61428,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 206) { + if (parentNode && parentNode.kind === 207) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -58777,24 +61456,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 227: - case 197: - case 230: case 228: + case 198: case 231: - case 262: case 229: - case 286: + case 232: + case 264: + case 230: + case 289: return true; - case 150: - case 149: case 151: + case 150: case 152: - case 224: + case 153: + case 225: return hasSomeImportantChild(item); + case 186: + case 227: case 185: - case 226: - case 184: return isTopLevelFunctionDeclaration(item); default: return false; @@ -58804,10 +61483,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 232: - case 262: - case 149: + case 233: + case 264: case 150: + case 151: return true; default: return hasSomeImportantChild(item); @@ -58816,7 +61495,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 224 && childKind !== 174; + return childKind !== 225 && childKind !== 175; }); } } @@ -58826,7 +61505,7 @@ var ts; return { text: getItemName(n.node), kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: ts.map(n.children, convertToTree) }; @@ -58835,7 +61514,7 @@ var ts; return { text: getItemName(n.node), kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, indent: n.indent, @@ -58871,35 +61550,41 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 231) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 232) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } return result.join("."); } function getInteriorModule(decl) { - return decl.body.kind === 231 ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 232 ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 142; + return !member.name || member.name.kind === 143; } function getNodeSpan(node) { - return node.kind === 262 + return node.kind === 264 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) - : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); + : ts.createTextSpanFromNode(node, curSourceFile); + } + function getModifiers(node) { + if (node.parent && node.parent.kind === 225) { + node = node.parent; + } + return ts.getNodeModifiers(node); } function getFunctionOrClassName(node) { if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 224) { + else if (node.parent.kind === 225) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 192 && + else if (node.parent.kind === 193 && node.parent.operatorToken.kind === 57) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 258 && node.parent.name) { + else if (node.parent.kind === 260 && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512) { @@ -58910,7 +61595,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 184 || node.kind === 185 || node.kind === 197; + return node.kind === 185 || node.kind === 186 || node.kind === 198; } var whiteSpaceRegex = /\s+/g; })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); @@ -58926,7 +61611,7 @@ var ts; if (hintSpanNode && startElement && endElement) { var span_12 = { textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), - hintSpan: ts.createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), + hintSpan: ts.createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse }; @@ -58983,7 +61668,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 185; + return ts.isFunctionBlock(node) && node.parent.kind !== 186; } var depth = 0; var maxDepth = 20; @@ -58995,26 +61680,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 205: + case 206: if (!ts.isFunctionBlock(n)) { - var parent_20 = n.parent; + var parent = n.parent; var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); - if (parent_20.kind === 210 || - parent_20.kind === 213 || - parent_20.kind === 214 || - parent_20.kind === 212 || - parent_20.kind === 209 || - parent_20.kind === 211 || - parent_20.kind === 218 || - parent_20.kind === 257) { - addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); + if (parent.kind === 211 || + parent.kind === 214 || + parent.kind === 215 || + parent.kind === 213 || + parent.kind === 210 || + parent.kind === 212 || + parent.kind === 219 || + parent.kind === 259) { + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_20.kind === 222) { - var tryStatement = parent_20; + if (parent.kind === 223) { + var tryStatement = parent; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -59025,7 +61710,7 @@ var ts; } } } - var span_14 = ts.createTextSpanFromBounds(n.getStart(), n.end); + var span_14 = ts.createTextSpanFromNode(n); elements.push({ textSpan: span_14, hintSpan: span_14, @@ -59034,23 +61719,23 @@ var ts; }); break; } - case 232: { + case 233: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 227: case 228: - case 230: - case 176: - case 233: { + case 229: + case 231: + case 177: + case 234: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 175: + case 176: var openBracket = ts.findChildOfKind(n, 20, sourceFile); var closeBracket = ts.findChildOfKind(n, 21, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -59127,10 +61812,11 @@ var ts; return totalMatch; } function getWordSpans(word) { - if (!(word in stringToWordSpans)) { - stringToWordSpans[word] = breakIntoWordSpans(word); + var spans = stringToWordSpans.get(word); + if (!spans) { + stringToWordSpans.set(word, spans = breakIntoWordSpans(word)); } - return stringToWordSpans[word]; + return spans; } function matchTextChunk(candidate, chunk, punctuationStripped) { var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); @@ -59563,7 +62249,7 @@ var ts; else { if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59589,7 +62275,7 @@ var ts; } if (token === 17) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59603,7 +62289,7 @@ var ts; token = nextToken(); if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59629,7 +62315,7 @@ var ts; } if (token === 17) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59639,7 +62325,7 @@ var ts; } else if (token === 38) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59766,90 +62452,82 @@ var ts; var Rename; (function (Rename) { function getRenameInfo(typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile, position) { - var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); + var getCanonicalDefaultLibName = ts.memoize(function () { return getCanonicalFileName(ts.normalizePath(defaultLibFileName)); }); var node = ts.getTouchingWord(sourceFile, position, true); - if (node) { - if (node.kind === 70 || - node.kind === 9 || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - ts.isThis(node)) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var declarations = symbol.getDeclarations(); - if (declarations && declarations.length > 0) { - if (ts.forEach(declarations, isDefinedInLibraryFile)) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); - var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - if (kind) { - return { - canRename: true, - kind: kind, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: typeChecker.getFullyQualifiedName(symbol), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - else if (node.kind === 9) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (type) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - else { - var displayName = ts.stripQuotes(type.text); - return { - canRename: true, - kind: ts.ScriptElementKind.variableElement, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: displayName, - kindModifiers: ts.ScriptElementKindModifier.none, - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - } - } - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element)); - function getRenameInfoError(localizedErrorMessage) { - return { - canRename: false, - localizedErrorMessage: localizedErrorMessage, - displayName: undefined, - fullDisplayName: undefined, - kind: undefined, - kindModifiers: undefined, - triggerSpan: undefined - }; - } + var renameInfo = node && nodeIsEligibleForRename(node) + ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) + : undefined; + return renameInfo || getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); function isDefinedInLibraryFile(declaration) { - if (defaultLibFileName) { - var sourceFile_1 = declaration.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_1.fileName)); - if (canonicalName === canonicalDefaultLibName) { - return true; - } + if (!defaultLibFileName) { + return false; } - return false; - } - function createTriggerSpanForNode(node, sourceFile) { - var start = node.getStart(sourceFile); - var width = node.getWidth(sourceFile); - if (node.kind === 9) { - start += 1; - width -= 2; - } - return ts.createTextSpan(start, width); + var sourceFile = declaration.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); + return canonicalName === getCanonicalDefaultLibName(); } } Rename.getRenameInfo = getRenameInfo; + function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + var declarations = symbol.getDeclarations(); + if (declarations && declarations.length > 0) { + if (ts.some(declarations, isDefinedInLibraryFile)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); + } + var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); + var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); + return kind ? getRenameInfoSuccess(displayName, typeChecker.getFullyQualifiedName(symbol), kind, ts.SymbolDisplay.getSymbolModifiers(symbol), node, sourceFile) : undefined; + } + } + else if (node.kind === 9) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (type) { + if (isDefinedInLibraryFile(node)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); + } + var displayName = ts.stripQuotes(type.text); + return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); + } + } + } + function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { + return { + canRename: true, + kind: kind, + displayName: displayName, + localizedErrorMessage: undefined, + fullDisplayName: fullDisplayName, + kindModifiers: kindModifiers, + triggerSpan: createTriggerSpanForNode(node, sourceFile) + }; + } + function getRenameInfoError(diagnostic) { + return { + canRename: false, + localizedErrorMessage: ts.getLocaleSpecificMessage(diagnostic), + displayName: undefined, + fullDisplayName: undefined, + kind: undefined, + kindModifiers: undefined, + triggerSpan: undefined + }; + } + function createTriggerSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var width = node.getWidth(sourceFile); + if (node.kind === 9) { + start += 1; + width -= 2; + } + return ts.createTextSpan(start, width); + } + function nodeIsEligibleForRename(node) { + return node.kind === 70 || node.kind === 9 || + ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + ts.isThis(node); + } })(Rename = ts.Rename || (ts.Rename = {})); })(ts || (ts = {})); var ts; @@ -59857,6 +62535,13 @@ var ts; var SignatureHelp; (function (SignatureHelp) { var emptyArray = []; + var ArgumentListKind; + (function (ArgumentListKind) { + ArgumentListKind[ArgumentListKind["TypeArguments"] = 0] = "TypeArguments"; + ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; + ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; + ArgumentListKind[ArgumentListKind["JSXAttributesArguments"] = 3] = "JSXAttributesArguments"; + })(ArgumentListKind = SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); @@ -59882,14 +62567,14 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 179) { + if (argumentInfo.invocation.kind !== 180) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; var name = expression.kind === 70 ? expression - : expression.kind === 177 + : expression.kind === 178 ? expression.name : undefined; if (!name || !name.text) { @@ -59899,10 +62584,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameToDeclarations = sourceFile.getNamedDeclarations(); - var declarations = nameToDeclarations[name.text]; + var declarations = nameToDeclarations.get(name.text); if (declarations) { - for (var _b = 0, declarations_10 = declarations; _b < declarations_10.length; _b++) { - var declaration = declarations_10[_b]; + for (var _b = 0, declarations_13 = declarations; _b < declarations_13.length; _b++) { + var declaration = declarations_13[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -59918,7 +62603,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 179 || node.parent.kind === 180) { + if (node.parent.kind === 180 || node.parent.kind === 181) { var callExpression = node.parent; if (node.kind === 26 || node.kind === 18) { @@ -59950,23 +62635,23 @@ var ts; } return undefined; } - else if (node.kind === 12 && node.parent.kind === 181) { + else if (node.kind === 12 && node.parent.kind === 182) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0, sourceFile); } } - else if (node.kind === 13 && node.parent.parent.kind === 181) { + else if (node.kind === 13 && node.parent.parent.kind === 182) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 194); + ts.Debug.assert(templateExpression.kind === 195); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 203 && node.parent.parent.parent.kind === 181) { + else if (node.parent.kind === 204 && node.parent.parent.parent.kind === 182) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 194); + ts.Debug.assert(templateExpression.kind === 195); if (node.kind === 15 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -59974,8 +62659,20 @@ var ts; var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position); return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } + else if (node.parent && ts.isJsxOpeningLikeElement(node.parent)) { + var attributeSpanStart = node.parent.attributes.getFullStart(); + var attributeSpanEnd = ts.skipTrivia(sourceFile.text, node.parent.attributes.getEnd(), false); + return { + kind: 3, + invocation: node.parent, + argumentsSpan: ts.createTextSpan(attributeSpanStart, attributeSpanEnd - attributeSpanStart), + argumentIndex: 0, + argumentCount: 1 + }; + } return undefined; } + SignatureHelp.getImmediatelyContainingArgumentInfo = getImmediatelyContainingArgumentInfo; function getArgumentIndex(argumentsList, node) { var argumentIndex = 0; var listChildren = argumentsList.getChildren(); @@ -60030,7 +62727,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 194) { + if (template.kind === 195) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -60039,7 +62736,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 262; n = n.parent) { + for (var n = node; n.kind !== 264; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -60171,7 +62868,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 197) ? + return ts.getDeclarationOfKind(symbol, 198) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384) return ts.ScriptElementKind.enumElement; @@ -60228,7 +62925,7 @@ var ts; if (flags & 16384) return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4) { - if (flags & 268435456) { + if (flags & 134217728 && symbol.checkFlags & 2) { var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); if (rootSymbolFlags & (98308 | 3)) { @@ -60245,6 +62942,9 @@ var ts; } return unionPropertyKind; } + if (location.parent && ts.isJsxAttribute(location.parent)) { + return ts.ScriptElementKind.jsxAttribute; + } return ts.ScriptElementKind.memberVariableElement; } return ts.ScriptElementKind.unknown; @@ -60271,26 +62971,29 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 177) { + if (location.parent && location.parent.kind === 178) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } - var callExpression = void 0; - if (location.kind === 179 || location.kind === 180) { - callExpression = location; + var callExpressionLike = void 0; + if (location.kind === 180 || location.kind === 181) { + callExpressionLike = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { - callExpression = location.parent; + callExpressionLike = location.parent; } - if (callExpression) { + else if (location.parent && ts.isJsxOpeningLikeElement(location.parent) && ts.isFunctionLike(symbol.valueDeclaration)) { + callExpressionLike = location.parent; + } + if (callExpressionLike) { var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 180 || callExpression.expression.kind === 96; + var useConstructSignatures = callExpressionLike.kind === 181 || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 96); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -60314,6 +63017,7 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { + case ts.ScriptElementKind.jsxAttribute: case ts.ScriptElementKind.memberVariableElement: case ts.ScriptElementKind.variableElement: case ts.ScriptElementKind.constElement: @@ -60338,21 +63042,21 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 122 && location.parent.kind === 150)) { + (location.kind === 122 && location.parent.kind === 151)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 150 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 151 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 150) { + if (functionDeclaration.kind === 151) { symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 153 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 154 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -60361,7 +63065,7 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 197)) { + if (ts.getDeclarationOfKind(symbol, 198)) { pushTypePart(ts.ScriptElementKind.localClassElement); } else { @@ -60380,7 +63084,7 @@ var ts; } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(136)); + displayParts.push(ts.keywordPart(137)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -60401,7 +63105,7 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 231); + var declaration = ts.getDeclarationOfKind(symbol, 232); var isNamespace = declaration && declaration.name && declaration.name.kind === 70; displayParts.push(ts.keywordPart(isNamespace ? 128 : 127)); displayParts.push(ts.spacePart()); @@ -60420,25 +63124,25 @@ var ts; writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var declaration = ts.getDeclarationOfKind(symbol, 143); + var declaration = ts.getDeclarationOfKind(symbol, 144); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 154) { + if (declaration.kind === 155) { displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 153 && declaration.name) { + else if (declaration.kind !== 154 && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } - else if (declaration.kind === 229) { + else if (declaration.kind === 230) { addInPrefix(); - displayParts.push(ts.keywordPart(136)); + displayParts.push(ts.keywordPart(137)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -60449,7 +63153,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 261) { + if (declaration.kind === 263) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -60461,7 +63165,7 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 234) { + if (symbol.declarations[0].kind === 235) { displayParts.push(ts.keywordPart(83)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(128)); @@ -60472,7 +63176,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 235) { + if (declaration.kind === 236) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -60507,6 +63211,7 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } if (symbolKind === ts.ScriptElementKind.memberVariableElement || + symbolKind === ts.ScriptElementKind.jsxAttribute || symbolFlags & 3 || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { @@ -60540,10 +63245,10 @@ var ts; if (!documentation) { documentation = symbol.getDocumentationComment(); if (documentation.length === 0 && symbol.flags & 4) { - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 262; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 264; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 192) { + if (!declaration.parent || declaration.parent.kind !== 193) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -60623,14 +63328,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 184) { + if (declaration.kind === 185) { return true; } - if (declaration.kind !== 224 && declaration.kind !== 226) { + if (declaration.kind !== 225 && declaration.kind !== 227) { return false; } - for (var parent_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { - if (parent_21.kind === 262 || parent_21.kind === 232) { + for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { + if (parent.kind === 264 || parent.kind === 233) { return false; } } @@ -60665,7 +63370,7 @@ var ts; sourceFile.moduleName = transpileOptions.moduleName; } if (transpileOptions.renamedDependencies) { - sourceFile.renamedDependencies = ts.createMap(transpileOptions.renamedDependencies); + sourceFile.renamedDependencies = ts.createMapFromTemplate(transpileOptions.renamedDependencies); } var newLine = ts.getNewLineCharacter(options); var outputText; @@ -60711,10 +63416,10 @@ var ts; var commandLineOptionsStringToEnum; function fixupCompilerOptions(options, diagnostics) { commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { - return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); + return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_3 = function (opt) { + var _loop_5 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -60723,14 +63428,14 @@ var ts; options[opt.name] = ts.parseCustomTypeOption(opt, value, diagnostics); } else { - if (!ts.forEachProperty(opt.type, function (v) { return v === value; })) { + if (!ts.forEachEntry(opt.type, function (v) { return v === value; })) { diagnostics.push(ts.createCompilerDiagnosticForInvalidCustomType(opt)); } } }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_3(opt); + _loop_5(opt); } return options; } @@ -60742,6 +63447,15 @@ var ts; var standardScanner = ts.createScanner(5, false, 0); var jsxScanner = ts.createScanner(5, false, 1); var scanner; + var ScanAction; + (function (ScanAction) { + ScanAction[ScanAction["Scan"] = 0] = "Scan"; + ScanAction[ScanAction["RescanGreaterThanToken"] = 1] = "RescanGreaterThanToken"; + ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken"; + ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken"; + ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; + ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; + })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; @@ -60821,10 +63535,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { + case 252: + case 250: case 251: case 249: - case 250: - case 248: return node.kind === 70; } } @@ -61035,6 +63749,20 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + var FormattingRequestKind; + (function (FormattingRequestKind) { + FormattingRequestKind[FormattingRequestKind["FormatDocument"] = 0] = "FormatDocument"; + FormattingRequestKind[FormattingRequestKind["FormatSelection"] = 1] = "FormatSelection"; + FormattingRequestKind[FormattingRequestKind["FormatOnEnter"] = 2] = "FormatOnEnter"; + FormattingRequestKind[FormattingRequestKind["FormatOnSemicolon"] = 3] = "FormatOnSemicolon"; + FormattingRequestKind[FormattingRequestKind["FormatOnClosingCurlyBrace"] = 4] = "FormatOnClosingCurlyBrace"; + })(FormattingRequestKind = formatting.FormattingRequestKind || (formatting.FormattingRequestKind = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -61056,6 +63784,19 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleAction; + (function (RuleAction) { + RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; + RuleAction[RuleAction["Space"] = 2] = "Space"; + RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; + RuleAction[RuleAction["Delete"] = 8] = "Delete"; + })(RuleAction = formatting.RuleAction || (formatting.RuleAction = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -61086,6 +63827,17 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleFlags; + (function (RuleFlags) { + RuleFlags[RuleFlags["None"] = 0] = "None"; + RuleFlags[RuleFlags["CanDeleteNewLines"] = 1] = "CanDeleteNewLines"; + })(RuleFlags = formatting.RuleFlags || (formatting.RuleFlags = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -61157,7 +63909,7 @@ var ts; this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromRange(0, 140, [19])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromRange(0, 141, [19])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17, 81), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17, 105), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); @@ -61200,14 +63952,14 @@ var ts; this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([19, 80, 81, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2)); this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101, 86]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 133]), 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 134]), 70), 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127, 131]), 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 130, 133, 114, 136, 138, 126]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 138])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 130, 134, 114, 137, 139, 126]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 139])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); @@ -61221,7 +63973,7 @@ var ts; this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 133, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 134, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38, formatting.Shared.TokenRange.FromTokens([70, 18])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); @@ -61327,44 +64079,44 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_50 in o) { - if (o[name_50] === rule) { - return name_50; + for (var name in o) { + if (o[name] === rule) { + return name; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 212; + return context.contextNode.kind === 213; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 192: case 193: - case 200: - case 244: - case 240: - case 156: - case 164: + case 194: + case 201: + case 245: + case 241: + case 157: case 165: + case 166: return true; - case 174: - case 229: - case 235: - case 224: - case 144: - case 261: + case 175: + case 230: + case 236: + case 225: + case 145: + case 263: + case 148: case 147: - case 146: return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; - case 213: - case 143: - return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; case 214: - return context.currentTokenSpan.kind === 140 || context.nextTokenSpan.kind === 140; + case 144: + return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; + case 215: + return context.currentTokenSpan.kind === 141 || context.nextTokenSpan.kind === 141; } return false; }; @@ -61372,13 +64124,13 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 193; + return context.contextNode.kind === 194; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; Rules.IsBraceWrappedContext = function (context) { - return context.contextNode.kind === 172 || Rules.IsSingleLineBlockContext(context); + return context.contextNode.kind === 173 || Rules.IsSingleLineBlockContext(context); }; Rules.IsBeforeMultilineBlockContext = function (context) { return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); @@ -61400,65 +64152,65 @@ var ts; return true; } switch (node.kind) { - case 205: + case 206: + case 234: + case 177: case 233: - case 176: - case 232: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 226: + case 227: + case 150: case 149: - case 148: - case 151: case 152: case 153: - case 184: - case 150: + case 154: case 185: - case 228: + case 151: + case 186: + case 229: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 226 || context.contextNode.kind === 184; + return context.contextNode.kind === 227 || context.contextNode.kind === 185; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 227: - case 197: case 228: - case 230: - case 161: + case 198: + case 229: case 231: - case 242: + case 162: + case 232: case 243: - case 236: - case 239: + case 244: + case 237: + case 240: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 227: - case 231: - case 230: - case 257: + case 228: case 232: - case 219: + case 231: + case 259: + case 233: + case 220: return true; - case 205: { + case 206: { var blockParent = context.currentTokenParent.parent; - if (blockParent.kind !== 185 && - blockParent.kind !== 184) { + if (blockParent.kind !== 186 && + blockParent.kind !== 185) { return true; } } @@ -61467,29 +64219,29 @@ var ts; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 209: - case 219: - case 212: + case 210: + case 220: case 213: case 214: + case 215: + case 212: + case 223: case 211: - case 222: - case 210: - case 218: - case 257: + case 219: + case 259: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 176; + return context.contextNode.kind === 177; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 179; + return context.contextNode.kind === 180; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 180; + return context.contextNode.kind === 181; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -61501,25 +64253,25 @@ var ts; return context.nextTokenSpan.kind !== 21; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 185; + return context.contextNode.kind === 186; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 247; + return context.contextNode.kind !== 248; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 253; + return context.contextNode.kind === 255; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 251; + return context.nextTokenParent.kind === 252; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 251; + return context.contextNode.kind === 252; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 248; + return context.contextNode.kind === 249; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -61534,42 +64286,42 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 145; + return node.kind === 146; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 225 && + return context.currentTokenParent.kind === 226 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 231; + return context.contextNode.kind === 232; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 161; + return context.contextNode.kind === 162; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 26 && token.kind !== 28) { return false; } switch (parent.kind) { - case 157: - case 182: + case 158: + case 183: + case 230: + case 228: + case 198: case 229: case 227: - case 197: - case 228: - case 226: - case 184: case 185: + case 186: + case 150: case 149: - case 148: - case 153: case 154: - case 179: + case 155: case 180: - case 199: + case 181: + case 200: return true; default: return false; @@ -61580,16 +64332,16 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 182; + return context.contextNode.kind === 183; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 188; + return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 189; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 195 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 196 && context.contextNode.expression !== undefined; }; Rules.IsNonNullAssertionContext = function (context) { - return context.contextNode.kind === 201; + return context.contextNode.kind === 202; }; return Rules; }()); @@ -61611,7 +64363,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 140 + 1; + this.mapRowLength = 141 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -61624,7 +64376,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - ts.Debug.assert(row <= 140 && column <= 140, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 141 && column <= 141, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -61788,7 +64540,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 140; token++) { + for (var token = 0; token <= 141; token++) { result.push(token); } return result; @@ -61832,9 +64584,9 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(71, 140); + TokenRange.Keywords = TokenRange.FromRange(71, 141); TokenRange.BinaryOperators = TokenRange.FromRange(26, 69); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 140, 117, 125]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 141, 117, 125]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42, 43, 51, 50]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 70, 18, 20, 16, 98, 93]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); @@ -61842,7 +64594,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([70, 132, 134, 121, 135, 104, 118]); + TokenRange.TypeNames = TokenRange.FromTokens([70, 132, 135, 121, 136, 104, 118]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -61990,6 +64742,10 @@ var ts; (function (ts) { var formatting; (function (formatting) { + var Constants; + (function (Constants) { + Constants[Constants["Unknown"] = -1] = "Unknown"; + })(Constants || (Constants = {})); function formatOnEnter(position, sourceFile, rulesProvider, options) { var line = sourceFile.getLineAndCharacterOfPosition(position).line; if (line === 0) { @@ -62062,17 +64818,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 227: case 228: + case 229: return ts.rangeContainsRange(parent.members, node); - case 231: - var body = parent.body; - return body && body.kind === 232 && ts.rangeContainsRange(body.statements, node); - case 262: - case 205: case 232: + var body = parent.body; + return body && body.kind === 233 && ts.rangeContainsRange(body.statements, node); + case 264: + case 206: + case 233: return ts.rangeContainsRange(parent.statements, node); - case 257: + case 259: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -62228,18 +64984,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 227: return 74; - case 228: return 108; - case 226: return 88; - case 230: return 230; - case 151: return 124; - case 152: return 133; - case 149: + case 228: return 74; + case 229: return 108; + case 227: return 88; + case 231: return 231; + case 152: return 124; + case 153: return 134; + case 150: if (node.asteriskToken) { return 38; } - case 147: - case 144: + case 148: + case 145: return node.name.kind; } } @@ -62271,16 +65027,16 @@ var ts; return indentation; case 40: case 28: { - if (container.kind === 249 || - container.kind === 250 || - container.kind === 248) { + if (container.kind === 250 || + container.kind === 251 || + container.kind === 249) { return indentation; } break; } case 20: case 21: { - if (container.kind !== 170) { + if (container.kind !== 171) { return indentation; } break; @@ -62368,11 +65124,11 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 145 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 146 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 175 && inheritedIndentation === -1) { + if (isFirstListItem && parent.kind === 176 && inheritedIndentation === -1) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -62688,12 +65444,12 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 150: - case 226: - case 184: - case 149: - case 148: + case 151: + case 227: case 185: + case 150: + case 149: + case 186: if (node.typeParameters === list) { return 26; } @@ -62701,8 +65457,8 @@ var ts; return 18; } break; - case 179: case 180: + case 181: if (node.typeArguments === list) { return 26; } @@ -62710,7 +65466,7 @@ var ts; return 18; } break; - case 157: + case 158: if (node.typeArguments === list) { return 26; } @@ -62783,6 +65539,10 @@ var ts; (function (formatting) { var SmartIndenter; (function (SmartIndenter) { + var Value; + (function (Value) { + Value[Value["Unknown"] = -1] = "Unknown"; + })(Value || (Value = {})); function getIndentation(position, sourceFile, options) { if (position > sourceFile.text.length) { return getBaseIndentation(options); @@ -62811,7 +65571,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 25 && precedingToken.parent.kind !== 192) { + if (precedingToken.kind === 25 && precedingToken.parent.kind !== 193) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -62913,7 +65673,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 262 || !parentAndChildShareLine); + (parent.kind === 264 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -62937,7 +65697,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 209 && parent.elseStatement === child) { + if (parent.kind === 210 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -62949,23 +65709,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 157: + case 158: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 176: + case 177: return node.parent.properties; - case 175: + case 176: return node.parent.elements; - case 226: - case 184: + case 227: case 185: + case 186: + case 150: case 149: - case 148: - case 153: - case 154: { + case 154: + case 155: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -62976,8 +65736,8 @@ var ts; } break; } - case 180: - case 179: { + case 181: + case 180: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -63005,8 +65765,8 @@ var ts; if (node.kind === 19) { return -1; } - if (node.parent && (node.parent.kind === 179 || - node.parent.kind === 180) && + if (node.parent && (node.parent.kind === 180 || + node.parent.kind === 181) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -63024,10 +65784,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 179: case 180: - case 177: + case 181: case 178: + case 179: node = node.expression; break; default: @@ -63081,49 +65841,49 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 208: - case 227: - case 197: + case 209: case 228: - case 230: + case 198: case 229: - case 175: - case 205: - case 232: + case 231: + case 230: case 176: - case 161: - case 170: - case 163: - case 233: - case 255: - case 254: - case 183: - case 177: - case 179: - case 180: case 206: - case 224: - case 241: - case 217: - case 193: - case 173: - case 172: - case 249: - case 248: - case 253: - case 148: - case 153: - case 154: - case 144: - case 158: - case 159: - case 166: + case 233: + case 177: + case 162: + case 171: + case 164: + case 234: + case 257: + case 256: + case 184: + case 178: + case 180: case 181: - case 189: - case 243: - case 239: + case 207: + case 225: + case 242: + case 218: + case 194: + case 174: + case 173: + case 250: + case 249: + case 255: + case 149: + case 154: + case 155: + case 145: + case 159: + case 160: + case 167: + case 182: + case 190: case 244: case 240: + case 245: + case 241: return true; } return false; @@ -63131,27 +65891,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 210: case 211: - case 213: - case 214: case 212: - case 209: - case 226: - case 184: - case 149: + case 214: + case 215: + case 213: + case 210: + case 227: case 185: case 150: + case 186: case 151: case 152: - return childKind !== 205; - case 242: - return childKind !== 243; - case 236: - return childKind !== 237 || - (child.namedBindings && child.namedBindings.kind !== 239); - case 247: - return childKind !== 250; + case 153: + return childKind !== 206; + case 243: + return childKind !== 244; + case 237: + return childKind !== 238 || + (child.namedBindings && child.namedBindings.kind !== 240); + case 248: + return childKind !== 251; } return indentByDefault; } @@ -63167,7 +65927,7 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var codeFixes = ts.createMap(); + var codeFixes = []; function registerCodeFix(action) { ts.forEach(action.errorCodes, function (error) { var fixes = codeFixes[error]; @@ -63240,9 +66000,9 @@ var ts; if (IndexInfoOfKind) { var writer = ts.getSingleLineStringWriter(); checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); - var result_7 = writer.string(); + var result_6 = writer.string(); ts.releaseStringWriter(writer); - return result_7; + return result_6; } } return ""; @@ -63328,7 +66088,7 @@ var ts; if (!superCall) { return undefined; } - if (superCall.expression && superCall.expression.kind == 179) { + if (superCall.expression && superCall.expression.kind == 180) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -63352,7 +66112,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 208 && ts.isSuperCall(n.expression)) { + if (n.kind === 209 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -63431,6 +66191,24 @@ var ts; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + var start = token.getStart(sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_this_to_unresolved_variable), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start: start, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var codefix; (function (codefix) { @@ -63449,41 +66227,41 @@ var ts; switch (token.kind) { case 70: switch (token.parent.kind) { - case 224: + case 225: switch (token.parent.parent.parent.kind) { - case 212: + case 213: var forStatement = token.parent.parent.parent; var forInitializer = forStatement.initializer; if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); + return createCodeFixToRemoveNode(forInitializer); } else { return removeSingleItem(forInitializer.declarations, token); } - case 214: + case 215: var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 225) { + if (forOfStatement.initializer.kind === 226) { var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); + return createCodeFix("{}", forOfInitializer.declarations[0].getStart(), forOfInitializer.declarations[0].getWidth()); } break; - case 213: + case 214: return undefined; - case 257: + case 259: var catchClause = token.parent.parent; var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); + return createCodeFixToRemoveNode(parameter); default: var variableStatement = token.parent.parent.parent; if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); + return createCodeFixToRemoveNode(variableStatement); } else { var declarations = variableStatement.declarationList.declarations; return removeSingleItem(declarations, token); } } - case 143: + case 144: var typeParameters = token.parent.parent.typeParameters; if (typeParameters.length === 1) { return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); @@ -63491,71 +66269,94 @@ var ts; else { return removeSingleItem(typeParameters, token); } - case 144: + case 145: var functionDeclaration = token.parent.parent; if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + return createCodeFixToRemoveNode(token.parent); } else { return removeSingleItem(functionDeclaration.parameters, token); } - case 235: + case 236: var importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case 240: + return createCodeFixToRemoveNode(importEquals); + case 241: var namedImports = token.parent.parent; if (namedImports.elements.length === 1) { var importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); + return createCodeFixToRemoveNode(importSpec); } else { return removeSingleItem(namedImports.elements, token); } - case 237: + case 238: var importClause = token.parent; if (!importClause.namedBindings) { var importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + return createCodeFixToRemoveNode(importDecl); } else { - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); + var start_4 = importClause.name.getStart(); + var end = findFirstNonSpaceCharPosStarting(importClause.name.end); + if (sourceFile.text.charCodeAt(end) === 44) { + end = findFirstNonSpaceCharPosStarting(end + 1); + } + return createCodeFix("", start_4, end - start_4); } - case 238: + case 239: var namespaceImport = token.parent; if (namespaceImport.name == token && !namespaceImport.parent.name) { var importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + return createCodeFixToRemoveNode(importDecl); } else { - var start_4 = namespaceImport.parent.name.end; - return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); + var start_5 = namespaceImport.parent.name.end; + return createCodeFix("", start_5, namespaceImport.parent.namedBindings.end - start_5); } } break; - case 147: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case 238: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + case 148: + case 239: + return createCodeFixToRemoveNode(token.parent); } if (ts.isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + return createCodeFixToRemoveNode(token.parent); } else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); + return createCodeFixToRemoveNode(token.parent.parent); } else { return undefined; } function findImportDeclaration(token) { var importDecl = token; - while (importDecl.kind != 236 && importDecl.parent) { + while (importDecl.kind != 237 && importDecl.parent) { importDecl = importDecl.parent; } return importDecl; } + function createCodeFixToRemoveNode(node) { + var end = node.getEnd(); + var endCharCode = sourceFile.text.charCodeAt(end); + var afterEndCharCode = sourceFile.text.charCodeAt(end + 1); + if (ts.isLineBreak(endCharCode)) { + end += 1; + } + if (ts.isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) { + end += 1; + } + var start = node.getStart(); + return createCodeFix("", start, end - start); + } + function findFirstNonSpaceCharPosStarting(start) { + while (ts.isWhiteSpace(sourceFile.text.charCodeAt(start))) { + start += 1; + } + return start; + } function createCodeFix(newText, start, length) { return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: newText, span: { start: start, length: length } }] @@ -63586,18 +66387,19 @@ var ts; })(ModuleSpecifierComparison || (ModuleSpecifierComparison = {})); var ImportCodeActionMap = (function () { function ImportCodeActionMap() { - this.symbolIdToActionMap = ts.createMap(); + this.symbolIdToActionMap = []; } ImportCodeActionMap.prototype.addAction = function (symbolId, newAction) { if (!newAction) { return; } - if (!this.symbolIdToActionMap[symbolId]) { + var actions = this.symbolIdToActionMap[symbolId]; + if (!actions) { this.symbolIdToActionMap[symbolId] = [newAction]; return; } if (newAction.kind === "CodeChange") { - this.symbolIdToActionMap[symbolId].push(newAction); + actions.push(newAction); return; } var updatedNewImports = []; @@ -63630,8 +66432,8 @@ var ts; }; ImportCodeActionMap.prototype.getAllActions = function () { var result = []; - for (var symbolId in this.symbolIdToActionMap) { - result = ts.concatenate(result, this.symbolIdToActionMap[symbolId]); + for (var key in this.symbolIdToActionMap) { + result = ts.concatenate(result, this.symbolIdToActionMap[key]); } return result; }; @@ -63662,6 +66464,7 @@ var ts; codefix.registerCodeFix({ errorCodes: [ ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics.Cannot_find_namespace_0.code, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code ], getCodeActions: function (context) { @@ -63672,7 +66475,7 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, context.span.start); var name = token.getText(); var symbolIdActionMap = new ImportCodeActionMap(); - var cachedImportDeclarations = ts.createMap(); + var cachedImportDeclarations = []; var cachedNewImportInsertPosition; var currentTokenMeaning = ts.getMeaningFromLocation(token); if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { @@ -63706,8 +66509,9 @@ var ts; return symbolIdActionMap.getAllActions(); function getImportDeclarations(moduleSymbol) { var moduleSymbolId = getUniqueSymbolId(moduleSymbol); - if (cachedImportDeclarations[moduleSymbolId]) { - return cachedImportDeclarations[moduleSymbolId]; + var cached = cachedImportDeclarations[moduleSymbolId]; + if (cached) { + return cached; } var existingDeclarations = []; for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { @@ -63722,10 +66526,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 236) { + if (node.kind === 237) { return node; } - if (node.kind === 235) { + if (node.kind === 236) { return node; } node = node.parent; @@ -63756,11 +66560,11 @@ var ts; var namespaceImportDeclaration; var namedImportDeclaration; var existingModuleSpecifier; - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; - if (declaration.kind === 236) { + for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { + var declaration = declarations_14[_i]; + if (declaration.kind === 237) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 238) { + if (namedBindings && namedBindings.kind === 239) { namespaceImportDeclaration = declaration; } else { @@ -63787,7 +66591,7 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 246) { + if (declaration.moduleReference && declaration.moduleReference.kind === 247) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); @@ -63820,7 +66624,7 @@ var ts; } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 236) { + if (declaration.kind === 237) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -63854,18 +66658,18 @@ var ts; : "" + context.newLineCharacter + importStatementText + ";"; return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], newText, { start: cachedNewImportInsertPosition, length: 0 }, sourceFile.fileName, "NewImport", moduleSpecifierWithoutQuotes); function getModuleSpecifierForNewImport() { - var fileName = sourceFile.path; - var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().path; + var fileName = sourceFile.fileName; + var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; var sourceDirectory = ts.getDirectoryPath(fileName); var options = context.program.getCompilerOptions(); return tryGetModuleNameFromAmbientModule() || - tryGetModuleNameFromBaseUrl() || - tryGetModuleNameFromRootDirs() || tryGetModuleNameFromTypeRoots() || tryGetModuleNameAsNodeModule() || + tryGetModuleNameFromBaseUrl() || + tryGetModuleNameFromRootDirs() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 262) { + if (moduleSymbol.valueDeclaration.kind !== 264) { return moduleSymbol.name; } } @@ -63873,8 +66677,7 @@ var ts; if (!options.baseUrl) { return undefined; } - var normalizedBaseUrl = ts.toPath(options.baseUrl, ts.getDirectoryPath(options.baseUrl), getCanonicalFileName); - var relativeName = tryRemoveParentDirectoryName(moduleFileName, normalizedBaseUrl); + var relativeName = getRelativePathIfInDirectory(moduleFileName, options.baseUrl); if (!relativeName) { return undefined; } @@ -63908,9 +66711,8 @@ var ts; } function tryGetModuleNameFromRootDirs() { if (options.rootDirs) { - var normalizedRootDirs = ts.map(options.rootDirs, function (rootDir) { return ts.toPath(rootDir, undefined, getCanonicalFileName); }); - var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, normalizedRootDirs); - var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, normalizedRootDirs); + var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, options.rootDirs); + var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, options.rootDirs); if (normalizedTargetPath !== undefined) { var relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath; return ts.removeFileExtension(relativePath); @@ -63972,7 +66774,7 @@ var ts; function getPathRelativeToRootDirs(path, rootDirs) { for (var _i = 0, rootDirs_2 = rootDirs; _i < rootDirs_2.length; _i++) { var rootDir = rootDirs_2[_i]; - var relativeName = tryRemoveParentDirectoryName(path, rootDir); + var relativeName = getRelativePathIfInDirectory(path, rootDir); if (relativeName !== undefined) { return relativeName; } @@ -63986,19 +66788,14 @@ var ts; } return fileName; } + function getRelativePathIfInDirectory(path, directoryPath) { + var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); + return ts.isRootedDiskPath(relativePath) || ts.startsWith(relativePath, "..") ? undefined : relativePath; + } function getRelativePath(path, directoryPath) { var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); return ts.moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath; } - function tryRemoveParentDirectoryName(path, parentDirectory) { - var index = path.indexOf(parentDirectory); - if (index === 0) { - return ts.endsWith(parentDirectory, ts.directorySeparator) - ? path.substring(parentDirectory.length) - : path.substring(parentDirectory.length + 1); - } - return undefined; - } } } function createCodeAction(description, diagnosticArgs, newText, span, fileName, kind, moduleSpecifier) { @@ -64019,7 +66816,7 @@ var ts; (function (codefix) { function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { var classMembers = classDeclaration.symbol.members; - var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !(symbol.getName() in classMembers); }); + var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !classMembers.has(symbol.getName()); }); var insertion = ""; for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { var symbol = missingMembers_1[_i]; @@ -64038,14 +66835,14 @@ var ts; var name = declaration.name ? declaration.name.getText() : undefined; var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); switch (declaration.kind) { - case 151: case 152: - case 146: + case 153: case 147: + case 148: var typeString = checker.typeToString(type, enclosingDeclaration, 0); return "" + visibility + name + ": " + typeString + ";" + newlineChar; - case 148: case 149: + case 150: var signatures = checker.getSignaturesOfType(type, 0); if (!(signatures && signatures.length > 0)) { return ""; @@ -64076,7 +66873,7 @@ var ts; } } function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { - var newSignatureDeclaration = ts.createNode(153); + var newSignatureDeclaration = ts.createNode(154); newSignatureDeclaration.parent = enclosingDeclaration; newSignatureDeclaration.name = signatures[0].getDeclaration().name; var maxNonRestArgs = -1; @@ -64107,7 +66904,7 @@ var ts; } return checker.getSignatureFromDeclaration(newSignatureDeclaration); function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { - var newParameter = ts.createNode(144); + var newParameter = ts.createNode(145); newParameter.symbol = new SymbolConstructor(1, maxArgsParameterSymbolNames[index] || "rest"); newParameter.symbol.valueDeclaration = newParameter; newParameter.symbol.declarations = [newParameter]; @@ -64137,7 +66934,7 @@ var ts; (function (ts) { ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 141 ? new NodeObject(kind, pos, end) : + var node = kind >= 142 ? new NodeObject(kind, pos, end) : kind === 70 ? new IdentifierObject(70, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; @@ -64195,7 +66992,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(293, nodes.pos, nodes.end, this); + var list = createNode(296, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -64214,11 +67011,11 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 141) { + if (this.kind >= 142) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 279 && this.kind <= 292; + var useJSDocScanner_1 = this.kind >= 282 && this.kind <= 295; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -64271,8 +67068,10 @@ var ts; if (!children.length) { return undefined; } - var child = children[0]; - return child.kind < 141 ? child : child.getFirstToken(sourceFile); + var child = ts.find(children, function (kid) { return kid.kind < 266 || kid.kind > 295; }); + return child.kind < 142 ? + child : + child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -64280,7 +67079,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 141 ? child : child.getLastToken(sourceFile); + return child.kind < 142 ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -64477,27 +67276,31 @@ var ts; return this.namedDeclarations; }; SourceFileObject.prototype.computeNamedDeclarations = function () { - var result = ts.createMap(); + var result = ts.createMultiMap(); ts.forEachChild(this, visit); return result; function addDeclaration(declaration) { var name = getDeclarationName(declaration); if (name) { - ts.multiMapAdd(result, name, declaration); + result.add(name, declaration); } } function getDeclarations(name) { - return result[name] || (result[name] = []); + var declarations = result.get(name); + if (!declarations) { + result.set(name, declarations = []); + } + return declarations; } function getDeclarationName(declaration) { if (declaration.name) { - var result_8 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_8 !== undefined) { - return result_8; + var result_7 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_7 !== undefined) { + return result_7; } - if (declaration.name.kind === 142) { + if (declaration.name.kind === 143) { var expr = declaration.name.expression; - if (expr.kind === 177) { + if (expr.kind === 178) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -64517,10 +67320,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 226: - case 184: + case 227: + case 185: + case 150: case 149: - case 148: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -64537,30 +67340,30 @@ var ts; } ts.forEachChild(node, visit); break; - case 227: - case 197: case 228: + case 198: case 229: case 230: case 231: - case 235: - case 244: - case 240: - case 235: - case 237: + case 232: + case 236: + case 245: + case 241: + case 236: case 238: - case 151: + case 239: case 152: - case 161: + case 153: + case 162: addDeclaration(node); ts.forEachChild(node, visit); break; - case 144: + case 145: if (!ts.hasModifier(node, 92)) { break; } - case 224: - case 174: { + case 225: + case 175: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -64569,24 +67372,24 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 261: + case 263: + case 148: case 147: - case 146: addDeclaration(node); break; - case 242: + case 243: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 236: + case 237: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 238) { + if (importClause.namedBindings.kind === 239) { addDeclaration(importClause.namedBindings); } else { @@ -65029,10 +67832,10 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { case 70: - case 177: - case 141: + case 178: + case 142: case 98: - case 167: + case 168: case 96: var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -65071,8 +67874,8 @@ var ts; function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); if (results) { - var sourceFile_2 = getCanonicalFileName(ts.normalizeSlashes(fileName)); - results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_2; }); + var sourceFile_1 = getCanonicalFileName(ts.normalizeSlashes(fileName)); + results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_1; }); } return results; } @@ -65106,20 +67909,20 @@ var ts; } } function findRenameLocations(fileName, position, findInStrings, findInComments) { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments, true); return ts.FindAllReferences.convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, false, false, false); return ts.FindAllReferences.convertReferences(referencedSymbols); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, false, false, false); return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); } - function findReferencedSymbols(fileName, position, findInStrings, findInComments) { + function findReferencedSymbols(fileName, position, findInStrings, findInComments, isForRename) { synchronizeHostData(); - return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments); + return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments, isForRename); } function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { synchronizeHostData(); @@ -65161,15 +67964,15 @@ var ts; return; } switch (node.kind) { - case 177: - case 141: + case 178: + case 142: case 9: case 85: case 100: case 94: case 96: case 98: - case 167: + case 168: case 70: break; default: @@ -65181,7 +67984,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 231 && + if (nodeForStartPos.parent.parent.kind === 232 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -65313,7 +68116,7 @@ var ts; var span = { start: start, length: end - start }; var newLineChar = ts.getNewLineOrDefaultFromHost(host); var allFixes = []; - ts.forEach(errorCodes, function (error) { + ts.forEach(ts.deduplicate(errorCodes), function (error) { cancellationToken.throwIfCancellationRequested(); var context = { errorCode: error, @@ -65474,15 +68277,15 @@ var ts; function walk(node) { switch (node.kind) { case 70: - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + setNameTable(node.text, node); break; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 246 || + node.parent.kind === 247 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + setNameTable(node.text, node); } break; default: @@ -65495,11 +68298,66 @@ var ts; } } } + function setNameTable(text, node) { + nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); + } } + function isObjectLiteralElement(node) { + switch (node.kind) { + case 252: + case 254: + case 260: + case 261: + case 150: + case 152: + case 153: + return true; + } + return false; + } + function getContainingObjectLiteralElement(node) { + switch (node.kind) { + case 9: + case 8: + if (node.parent.kind === 143) { + return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; + } + case 70: + return isObjectLiteralElement(node.parent) && + (node.parent.parent.kind === 177 || node.parent.parent.kind === 253) && + node.parent.name === node ? node.parent : undefined; + } + return undefined; + } + ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; + function getPropertySymbolsFromContextualType(typeChecker, node) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = ts.getTextOfPropertyName(node.name); + if (name && contextualType) { + var result_8 = []; + var symbol = contextualType.getProperty(name); + if (contextualType.flags & 65536) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_8.push(symbol); + } + }); + return result_8; + } + if (symbol) { + result_8.push(symbol); + return result_8; + } + } + return undefined; + } + ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 178 && + node.parent.kind === 179 && node.parent.argumentExpression === node; } function getDefaultLibFilePath(options) { @@ -65509,10 +68367,728 @@ var ts; throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); } ts.getDefaultLibFilePath = getDefaultLibFilePath; - function initializeServices() { - ts.objectAllocator = getServicesObjectAllocator(); + ts.objectAllocator = getServicesObjectAllocator(); +})(ts || (ts = {})); +var debugObjectHost = (function () { return this; })(); +var ts; +(function (ts) { + function logInternalError(logger, err) { + if (logger) { + logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); + } } - initializeServices(); + var ScriptSnapshotShimAdapter = (function () { + function ScriptSnapshotShimAdapter(scriptSnapshotShim) { + this.scriptSnapshotShim = scriptSnapshotShim; + } + 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); + }; + ScriptSnapshotShimAdapter.prototype.dispose = function () { + if ("dispose" in this.scriptSnapshotShim) { + this.scriptSnapshotShim.dispose(); + } + }; + return ScriptSnapshotShimAdapter; + }()); + var LanguageServiceShimHostAdapter = (function () { + function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; + this.shimHost = shimHost; + this.loggingEnabled = false; + this.tracingEnabled = false; + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { + var result = ts.getProperty(resolutionsInFile, name); + return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; + }); + }; + } + if ("directoryExists" in this.shimHost) { + this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; + } + if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { + this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { + var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); + return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); + }; + } + } + 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.getTypeRootsVersion = function () { + if (!this.shimHost.getTypeRootsVersion) { + return 0; + } + return this.shimHost.getTypeRootsVersion(); + }; + 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"); + } + var compilerOptions = JSON.parse(settingsJson); + compilerOptions.allowNonTsExtensions = true; + return compilerOptions; + }; + LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { + var encoded = this.shimHost.getScriptFileNames(); + return this.files = JSON.parse(encoded); + }; + LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { + var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); + return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); + }; + LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { + if ("getScriptKind" in this.shimHost) { + return this.shimHost.getScriptKind(fileName); + } + else { + return 0; + } + }; + 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.getDirectories = function (path) { + return JSON.parse(this.shimHost.getDirectories(path)); + }; + LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { + return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); + }; + LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { + var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); + }; + LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { + return this.shimHost.readFile(path, encoding); + }; + LanguageServiceShimHostAdapter.prototype.fileExists = function (path) { + return this.shimHost.fileExists(path); + }; + return LanguageServiceShimHostAdapter; + }()); + ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken) { + this.hostCancellationToken = hostCancellationToken; + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = ts.timestamp(); + 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) { + var _this = this; + this.shimHost = shimHost; + this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + if ("directoryExists" in this.shimHost) { + this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; + } + if ("realpath" in this.shimHost) { + this.realpath = function (path) { return _this.shimHost.realpath(path); }; + } + } + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { + try { + var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); + } + catch (e) { + var results = []; + for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { + var extension = extensions_2[_i]; + for (var _a = 0, _b = this.readDirectoryFallback(rootDir, extension, exclude); _a < _b.length; _a++) { + var file = _b[_a]; + if (!ts.contains(results, file)) { + results.push(file); + } + } + } + return results; + } + }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; + CoreServicesShimHostAdapter.prototype.readDirectoryFallback = function (rootDir, extension, exclude) { + return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); + }; + CoreServicesShimHostAdapter.prototype.getDirectories = function (path) { + return JSON.parse(this.shimHost.getDirectories(path)); + }; + return CoreServicesShimHostAdapter; + }()); + ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; + function simpleForwardCall(logger, actionDescription, action, logPerformance) { + var start; + if (logPerformance) { + logger.log(actionDescription); + start = ts.timestamp(); + } + var result = action(); + if (logPerformance) { + var end = ts.timestamp(); + 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) { + return forwardCall(logger, actionDescription, true, action, logPerformance); + } + function forwardCall(logger, actionDescription, returnJson, action, logPerformance) { + try { + var result = simpleForwardCall(logger, actionDescription, action, logPerformance); + return returnJson ? JSON.stringify({ result: 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) { + var _this = _super.call(this, factory) || this; + _this.host = host; + _this.languageService = languageService; + _this.logPerformance = false; + _this.logger = _this.host; + return _this; + } + 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 = ts.getNewLineOrDefaultFromHost(this.host); + return ts.realizeDiagnostics(diagnostics, newLine); + }; + LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); + }; + LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); + }; + 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.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 () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { + var _this = this; + return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); + }; + LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); + }; + 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.getImplementationAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(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 () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { + var _this = this; + return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); + }; + 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 () { + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); + }); + }; + LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { + var _this = this; + return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { + var _this = this; + return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); + }; + LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); + }; + LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + }; + LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { + var _this = this; + return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); + }; + LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { + var _this = this; + return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); + }; + LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { + var _this = this; + return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); + }; + LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { + var _this = this; + return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); + }; + 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) { + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.logPerformance = false; + _this.classifier = ts.createClassifier(); + return _this; + } + 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 result = ""; + for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { + var item = _a[_i]; + result += item.length + "\n"; + result += item.classification + "\n"; + } + result += classification.finalLexState; + return result; + }; + return ClassifierShimObject; + }(ShimBase)); + var CoreServicesShimObject = (function (_super) { + __extends(CoreServicesShimObject, _super); + function CoreServicesShimObject(factory, logger, host) { + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.host = host; + _this.logPerformance = false; + return _this; + } + CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; + return { + resolvedFileName: resolvedFileName, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; + CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + return { + resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined, + primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; + CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); + return { + referencedFiles: _this.convertFileReferences(result.referencedFiles), + importedFiles: _this.convertFileReferences(result.importedFiles), + ambientExternalModules: result.ambientExternalModules, + isLibFile: result.isLibFile, + typeReferenceDirectives: _this.convertFileReferences(result.typeReferenceDirectives) + }; + }); + }; + CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); + }); + }; + CoreServicesShimObject.prototype.convertFileReferences = function (refs) { + if (!refs) { + return undefined; + } + var result = []; + for (var _i = 0, refs_2 = refs; _i < refs_2.length; _i++) { + var ref = refs_2[_i]; + result.push({ + path: ts.normalizeSlashes(ref.fileName), + position: ref.pos, + length: ref.end - ref.pos + }); + } + return result; + }; + 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.parseConfigFileTextToJson(fileName, text); + if (result.error) { + return { + options: {}, + typeAcquisition: {}, + files: [], + raw: {}, + errors: [realizeDiagnostic(result.error, "\r\n")] + }; + } + var normalizedFileName = ts.normalizeSlashes(fileName); + var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); + return { + options: configFile.options, + typeAcquisition: configFile.typeAcquisition, + files: configFile.fileNames, + raw: configFile.raw, + errors: realizeDiagnostics(configFile.errors, "\r\n") + }; + }); + }; + CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { + return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); }); + }; + CoreServicesShimObject.prototype.discoverTypings = function (discoverTypingsJson) { + var _this = this; + var getCanonicalFileName = ts.createGetCanonicalFileName(false); + return this.forwardJSONCall("discoverTypings()", function () { + var info = JSON.parse(discoverTypingsJson); + return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typeAcquisition, info.unresolvedImports); + }); + }; + 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(), host.getCurrentDirectory()); + } + 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 = undefined; + }; + TypeScriptServicesFactory.prototype.registerShim = function (shim) { + this._shims.push(shim); + }; + TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { + for (var i = 0; i < this._shims.length; 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 = "2.3"; +var ts; +(function (ts) { + var server; + (function (server) { + server.ActionSet = "action::set"; + server.ActionInvalidate = "action::invalidate"; + server.EventBeginInstallTypes = "event::beginInstallTypes"; + server.EventEndInstallTypes = "event::endInstallTypes"; + var Arguments; + (function (Arguments) { + Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation"; + Arguments.LogFile = "--logFile"; + Arguments.EnableTelemetry = "--enableTelemetry"; + })(Arguments = server.Arguments || (server.Arguments = {})); + function hasArgument(argumentName) { + return ts.sys.args.indexOf(argumentName) >= 0; + } + server.hasArgument = hasArgument; + function findArgument(argumentName) { + var index = ts.sys.args.indexOf(argumentName); + return index >= 0 && index < ts.sys.args.length - 1 + ? ts.sys.args[index + 1] + : undefined; + } + server.findArgument = findArgument; + })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -65595,14 +69171,14 @@ var ts; }; } server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; - function mergeMaps(target, source) { + function mergeMapLikes(target, source) { for (var key in source) { if (ts.hasProperty(source, key)) { target[key] = source[key]; } } } - server.mergeMaps = mergeMaps; + server.mergeMapLikes = mergeMapLikes; function removeItemFromSet(items, itemToRemove) { if (items.length === 0) { return; @@ -65633,19 +69209,19 @@ var ts; } server.asNormalizedPath = asNormalizedPath; function createNormalizedPathMap() { - var map = Object.create(null); + var map = ts.createMap(); return { get: function (path) { - return map[path]; + return map.get(path); }, set: function (path, value) { - map[path] = value; + map.set(path, value); }, contains: function (path) { - return ts.hasProperty(map, path); + return map.has(path); }, remove: function (path) { - delete map[path]; + map.delete(path); } }; } @@ -65669,13 +69245,14 @@ var ts; this.pendingTimeouts = ts.createMap(); } ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { - if (ts.hasProperty(this.pendingTimeouts, operationId)) { - this.host.clearTimeout(this.pendingTimeouts[operationId]); + var pendingTimeout = this.pendingTimeouts.get(operationId); + if (pendingTimeout) { + this.host.clearTimeout(pendingTimeout); } - this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); + this.pendingTimeouts.set(operationId, this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb)); }; ThrottledOperations.run = function (self, operationId, cb) { - delete self.pendingTimeouts[operationId]; + self.pendingTimeouts.delete(operationId); cb(); }; return ThrottledOperations; @@ -65709,6 +69286,4438 @@ var ts; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var server; + (function (server) { + var TextStorage = (function () { + function TextStorage(host, fileName) { + this.host = host; + this.fileName = fileName; + this.svcVersion = 0; + this.textVersion = 0; + } + TextStorage.prototype.getVersion = function () { + return this.svc + ? "SVC-" + this.svcVersion + "-" + this.svc.getSnapshot().version + : "Text-" + this.textVersion; + }; + TextStorage.prototype.hasScriptVersionCache = function () { + return this.svc !== undefined; + }; + TextStorage.prototype.useScriptVersionCache = function (newText) { + this.switchToScriptVersionCache(newText); + }; + TextStorage.prototype.useText = function (newText) { + this.svc = undefined; + this.setText(newText); + }; + TextStorage.prototype.edit = function (start, end, newText) { + this.switchToScriptVersionCache().edit(start, end - start, newText); + }; + TextStorage.prototype.reload = function (text) { + if (this.svc) { + this.svc.reload(text); + } + else { + this.setText(text); + } + }; + TextStorage.prototype.reloadFromFile = function (tempFileName) { + if (this.svc || (tempFileName !== this.fileName)) { + this.reload(this.getFileText(tempFileName)); + } + else { + this.setText(undefined); + } + }; + TextStorage.prototype.getSnapshot = function () { + return this.svc + ? this.svc.getSnapshot() + : ts.ScriptSnapshot.fromString(this.getOrLoadText()); + }; + TextStorage.prototype.getLineInfo = function (line) { + return this.switchToScriptVersionCache().getSnapshot().index.lineNumberToInfo(line); + }; + TextStorage.prototype.lineToTextSpan = function (line) { + if (!this.svc) { + var lineMap = this.getLineMap(); + var start = lineMap[line]; + var end = line + 1 < lineMap.length ? lineMap[line + 1] : this.text.length; + return ts.createTextSpanFromBounds(start, end); + } + var index = this.svc.getSnapshot().index; + var lineInfo = index.lineNumberToInfo(line + 1); + var len; + if (lineInfo.leaf) { + len = lineInfo.leaf.text.length; + } + else { + var nextLineInfo = index.lineNumberToInfo(line + 2); + len = nextLineInfo.offset - lineInfo.offset; + } + return ts.createTextSpan(lineInfo.offset, len); + }; + TextStorage.prototype.lineOffsetToPosition = function (line, offset) { + if (!this.svc) { + return ts.computePositionOfLineAndCharacter(this.getLineMap(), line - 1, offset - 1); + } + var index = this.svc.getSnapshot().index; + var lineInfo = index.lineNumberToInfo(line); + return (lineInfo.offset + offset - 1); + }; + TextStorage.prototype.positionToLineOffset = function (position) { + if (!this.svc) { + var _a = ts.computeLineAndCharacterOfPosition(this.getLineMap(), position), line = _a.line, character = _a.character; + return { line: line + 1, offset: character + 1 }; + } + var index = this.svc.getSnapshot().index; + var lineOffset = index.charOffsetToLineNumberAndPos(position); + return { line: lineOffset.line, offset: lineOffset.offset + 1 }; + }; + TextStorage.prototype.getFileText = function (tempFileName) { + return this.host.readFile(tempFileName || this.fileName) || ""; + }; + TextStorage.prototype.ensureNoScriptVersionCache = function () { + ts.Debug.assert(!this.svc, "ScriptVersionCache should not be set"); + }; + TextStorage.prototype.switchToScriptVersionCache = function (newText) { + if (!this.svc) { + this.svc = server.ScriptVersionCache.fromString(this.host, newText !== undefined ? newText : this.getOrLoadText()); + this.svcVersion++; + this.text = undefined; + } + return this.svc; + }; + TextStorage.prototype.getOrLoadText = function () { + this.ensureNoScriptVersionCache(); + if (this.text === undefined) { + this.setText(this.getFileText()); + } + return this.text; + }; + TextStorage.prototype.getLineMap = function () { + this.ensureNoScriptVersionCache(); + return this.lineMap || (this.lineMap = ts.computeLineStarts(this.getOrLoadText())); + }; + TextStorage.prototype.setText = function (newText) { + this.ensureNoScriptVersionCache(); + if (newText === undefined || this.text !== newText) { + this.text = newText; + this.lineMap = undefined; + this.textVersion++; + } + }; + return TextStorage; + }()); + server.TextStorage = TextStorage; + var ScriptInfo = (function () { + function ScriptInfo(host, fileName, scriptKind, hasMixedContent) { + if (hasMixedContent === void 0) { hasMixedContent = false; } + this.host = host; + this.fileName = fileName; + this.scriptKind = scriptKind; + this.hasMixedContent = hasMixedContent; + this.containingProjects = []; + this.path = ts.toPath(fileName, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + this.textStorage = new TextStorage(host, fileName); + if (hasMixedContent) { + this.textStorage.reload(""); + } + this.scriptKind = scriptKind + ? scriptKind + : ts.getScriptKindFromFileName(fileName); + } + ScriptInfo.prototype.isScriptOpen = function () { + return this.isOpen; + }; + ScriptInfo.prototype.open = function (newText) { + this.isOpen = true; + this.textStorage.useScriptVersionCache(newText); + this.markContainingProjectsAsDirty(); + }; + ScriptInfo.prototype.close = function () { + this.isOpen = false; + this.textStorage.useText(this.hasMixedContent ? "" : undefined); + this.markContainingProjectsAsDirty(); + }; + ScriptInfo.prototype.getSnapshot = function () { + return this.textStorage.getSnapshot(); + }; + ScriptInfo.prototype.getFormatCodeSettings = function () { + return this.formatCodeSettings; + }; + ScriptInfo.prototype.attachToProject = function (project) { + var isNew = !this.isAttached(project); + if (isNew) { + this.containingProjects.push(project); + } + return isNew; + }; + ScriptInfo.prototype.isAttached = function (project) { + switch (this.containingProjects.length) { + case 0: return false; + case 1: return this.containingProjects[0] === project; + case 2: return this.containingProjects[0] === project || this.containingProjects[1] === project; + default: return ts.contains(this.containingProjects, project); + } + }; + ScriptInfo.prototype.detachFromProject = function (project) { + switch (this.containingProjects.length) { + case 0: + return; + case 1: + if (this.containingProjects[0] === project) { + this.containingProjects.pop(); + } + break; + case 2: + if (this.containingProjects[0] === project) { + this.containingProjects[0] = this.containingProjects.pop(); + } + else if (this.containingProjects[1] === project) { + this.containingProjects.pop(); + } + break; + default: + server.removeItemFromSet(this.containingProjects, project); + break; + } + }; + ScriptInfo.prototype.detachAllProjects = function () { + for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + p.removeFile(this, false); + } + this.containingProjects.length = 0; + }; + ScriptInfo.prototype.getDefaultProject = function () { + if (this.containingProjects.length === 0) { + return server.Errors.ThrowNoProject(); + } + return this.containingProjects[0]; + }; + ScriptInfo.prototype.registerFileUpdate = function () { + for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + p.registerFileUpdate(this.path); + } + }; + ScriptInfo.prototype.setFormatOptions = function (formatSettings) { + if (formatSettings) { + if (!this.formatCodeSettings) { + this.formatCodeSettings = server.getDefaultFormatCodeSettings(this.host); + } + server.mergeMapLikes(this.formatCodeSettings, formatSettings); + } + }; + ScriptInfo.prototype.setWatcher = function (watcher) { + this.stopWatcher(); + this.fileWatcher = watcher; + }; + ScriptInfo.prototype.stopWatcher = function () { + if (this.fileWatcher) { + this.fileWatcher.close(); + this.fileWatcher = undefined; + } + }; + ScriptInfo.prototype.getLatestVersion = function () { + return this.textStorage.getVersion(); + }; + ScriptInfo.prototype.reload = function (script) { + this.textStorage.reload(script); + this.markContainingProjectsAsDirty(); + }; + ScriptInfo.prototype.saveTo = function (fileName) { + var snap = this.textStorage.getSnapshot(); + this.host.writeFile(fileName, snap.getText(0, snap.getLength())); + }; + ScriptInfo.prototype.reloadFromFile = function (tempFileName) { + if (this.hasMixedContent) { + this.reload(""); + } + else { + this.textStorage.reloadFromFile(tempFileName); + this.markContainingProjectsAsDirty(); + } + }; + ScriptInfo.prototype.getLineInfo = function (line) { + return this.textStorage.getLineInfo(line); + }; + ScriptInfo.prototype.editContent = function (start, end, newText) { + this.textStorage.edit(start, end, newText); + this.markContainingProjectsAsDirty(); + }; + ScriptInfo.prototype.markContainingProjectsAsDirty = function () { + for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + p.markAsDirty(); + } + }; + ScriptInfo.prototype.lineToTextSpan = function (line) { + return this.textStorage.lineToTextSpan(line); + }; + ScriptInfo.prototype.lineOffsetToPosition = function (line, offset) { + return this.textStorage.lineOffsetToPosition(line, offset); + }; + ScriptInfo.prototype.positionToLineOffset = function (position) { + return this.textStorage.positionToLineOffset(position); + }; + ScriptInfo.prototype.isJavaScript = function () { + return this.scriptKind === 1 || this.scriptKind === 2; + }; + return ScriptInfo; + }()); + server.ScriptInfo = ScriptInfo; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var LSHost = (function () { + function LSHost(host, project, cancellationToken) { + var _this = this; + this.host = host; + this.project = project; + this.cancellationToken = cancellationToken; + this.resolvedModuleNames = ts.createFileMap(); + this.resolvedTypeReferenceDirectives = ts.createFileMap(); + this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); + if (host.trace) { + this.trace = function (s) { return host.trace(s); }; + } + this.resolveModuleName = function (moduleName, containingFile, compilerOptions, host) { + var globalCache = _this.project.getTypeAcquisition().enable + ? _this.project.projectService.typingsInstaller.globalTypingsCacheLocation + : undefined; + var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host); + if (ts.moduleHasNonRelativeName(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTypeScript(primaryResult.resolvedModule.extension)) && globalCache !== undefined) { + var _a = ts.loadModuleFromGlobalCache(moduleName, _this.project.getProjectName(), compilerOptions, host, globalCache), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; + if (resolvedModule) { + return { resolvedModule: resolvedModule, failedLookupLocations: primaryResult.failedLookupLocations.concat(failedLookupLocations) }; + } + } + return primaryResult; + }; + if (this.host.realpath) { + this.realpath = function (path) { return _this.host.realpath(path); }; + } + } + LSHost.prototype.startRecordingFilesWithChangedResolutions = function () { + this.filesWithChangedSetOfUnresolvedImports = []; + }; + LSHost.prototype.finishRecordingFilesWithChangedResolutions = function () { + var collected = this.filesWithChangedSetOfUnresolvedImports; + this.filesWithChangedSetOfUnresolvedImports = undefined; + return collected; + }; + LSHost.prototype.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult, getResultFileName, logChanges) { + var path = ts.toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); + var currentResolutionsInFile = cache.get(path); + var newResolutions = ts.createMap(); + var resolvedModules = []; + var compilerOptions = this.getCompilationSettings(); + var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name = names_2[_i]; + var resolution = newResolutions.get(name); + if (!resolution) { + var existingResolution = currentResolutionsInFile && currentResolutionsInFile.get(name); + if (moduleResolutionIsValid(existingResolution)) { + resolution = existingResolution; + } + else { + resolution = loader(name, containingFile, compilerOptions, this); + newResolutions.set(name, resolution); + } + if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { + this.filesWithChangedSetOfUnresolvedImports.push(path); + logChanges = false; + } + } + ts.Debug.assert(resolution !== undefined); + resolvedModules.push(getResult(resolution)); + } + cache.set(path, newResolutions); + return resolvedModules; + function resolutionIsEqualTo(oldResolution, newResolution) { + if (oldResolution === newResolution) { + return true; + } + if (!oldResolution || !newResolution) { + return false; + } + var oldResult = getResult(oldResolution); + var newResult = getResult(newResolution); + if (oldResult === newResult) { + return true; + } + if (!oldResult || !newResult) { + return false; + } + return getResultFileName(oldResult) === getResultFileName(newResult); + } + function moduleResolutionIsValid(resolution) { + if (!resolution) { + return false; + } + var result = getResult(resolution); + if (result) { + return getResultFileName(result) !== lastDeletedFileName; + } + return resolution.failedLookupLocations.length === 0; + } + }; + LSHost.prototype.getNewLine = function () { + return this.host.newLine; + }; + LSHost.prototype.getProjectVersion = function () { + return this.project.getProjectVersion(); + }; + LSHost.prototype.getCompilationSettings = function () { + return this.compilationSettings; + }; + LSHost.prototype.useCaseSensitiveFileNames = function () { + return this.host.useCaseSensitiveFileNames; + }; + LSHost.prototype.getCancellationToken = function () { + return this.cancellationToken; + }; + LSHost.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { + return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, function (m) { return m.resolvedTypeReferenceDirective; }, function (r) { return r.resolvedFileName; }, false); + }; + LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { + return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, this.resolveModuleName, function (m) { return m.resolvedModule; }, function (r) { return r.resolvedFileName; }, true); + }; + LSHost.prototype.getDefaultLibFileName = function () { + var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); + return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings)); + }; + LSHost.prototype.getScriptSnapshot = function (filename) { + var scriptInfo = this.project.getScriptInfoLSHost(filename); + if (scriptInfo) { + return scriptInfo.getSnapshot(); + } + }; + LSHost.prototype.getScriptFileNames = function () { + return this.project.getRootFilesLSHost(); + }; + LSHost.prototype.getTypeRootsVersion = function () { + return this.project.typesVersion; + }; + LSHost.prototype.getScriptKind = function (fileName) { + var info = this.project.getScriptInfoLSHost(fileName); + return info && info.scriptKind; + }; + LSHost.prototype.getScriptVersion = function (filename) { + var info = this.project.getScriptInfoLSHost(filename); + return info && info.getLatestVersion(); + }; + LSHost.prototype.getCurrentDirectory = function () { + return this.host.getCurrentDirectory(); + }; + LSHost.prototype.resolvePath = function (path) { + return this.host.resolvePath(path); + }; + LSHost.prototype.fileExists = function (path) { + return this.host.fileExists(path); + }; + LSHost.prototype.readFile = function (fileName) { + return this.host.readFile(fileName); + }; + LSHost.prototype.directoryExists = function (path) { + return this.host.directoryExists(path); + }; + LSHost.prototype.readDirectory = function (path, extensions, exclude, include) { + return this.host.readDirectory(path, extensions, exclude, include); + }; + LSHost.prototype.getDirectories = function (path) { + return this.host.getDirectories(path); + }; + LSHost.prototype.notifyFileRemoved = function (info) { + this.resolvedModuleNames.remove(info.path); + this.resolvedTypeReferenceDirectives.remove(info.path); + }; + LSHost.prototype.setCompilationSettings = function (opt) { + if (ts.changesAffectModuleResolution(this.compilationSettings, opt)) { + this.resolvedModuleNames.clear(); + this.resolvedTypeReferenceDirectives.clear(); + } + this.compilationSettings = opt; + }; + return LSHost; + }()); + server.LSHost = LSHost; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + server.nullTypingsInstaller = { + enqueueInstallTypingsRequest: ts.noop, + attach: ts.noop, + onProjectClosed: ts.noop, + globalTypingsCacheLocation: undefined + }; + var TypingsCacheEntry = (function () { + function TypingsCacheEntry() { + } + return TypingsCacheEntry; + }()); + function setIsEqualTo(arr1, arr2) { + if (arr1 === arr2) { + return true; + } + if ((arr1 || server.emptyArray).length === 0 && (arr2 || server.emptyArray).length === 0) { + return true; + } + var set = ts.createMap(); + var unique = 0; + for (var _i = 0, arr1_1 = arr1; _i < arr1_1.length; _i++) { + var v = arr1_1[_i]; + if (set.get(v) !== true) { + set.set(v, true); + unique++; + } + } + for (var _a = 0, arr2_1 = arr2; _a < arr2_1.length; _a++) { + var v = arr2_1[_a]; + var isSet = set.get(v); + if (isSet === undefined) { + return false; + } + if (isSet === true) { + set.set(v, false); + unique--; + } + } + return unique === 0; + } + function typeAcquisitionChanged(opt1, opt2) { + return opt1.enable !== opt2.enable || + !setIsEqualTo(opt1.include, opt2.include) || + !setIsEqualTo(opt1.exclude, opt2.exclude); + } + function compilerOptionsChanged(opt1, opt2) { + return opt1.allowJs != opt2.allowJs; + } + function unresolvedImportsChanged(imports1, imports2) { + if (imports1 === imports2) { + return false; + } + return !ts.arrayIsEqualTo(imports1, imports2); + } + var TypingsCache = (function () { + function TypingsCache(installer) { + this.installer = installer; + this.perProjectCache = ts.createMap(); + } + TypingsCache.prototype.getTypingsForProject = function (project, unresolvedImports, forceRefresh) { + var typeAcquisition = project.getTypeAcquisition(); + if (!typeAcquisition || !typeAcquisition.enable) { + return server.emptyArray; + } + var entry = this.perProjectCache.get(project.getProjectName()); + var result = entry ? entry.typings : server.emptyArray; + if (forceRefresh || + !entry || + typeAcquisitionChanged(typeAcquisition, entry.typeAcquisition) || + compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions) || + unresolvedImportsChanged(unresolvedImports, entry.unresolvedImports)) { + this.perProjectCache.set(project.getProjectName(), { + compilerOptions: project.getCompilerOptions(), + typeAcquisition: typeAcquisition, + typings: result, + unresolvedImports: unresolvedImports, + poisoned: true + }); + this.installer.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports); + } + return result; + }; + TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typeAcquisition, unresolvedImports, newTypings) { + this.perProjectCache.set(projectName, { + compilerOptions: compilerOptions, + typeAcquisition: typeAcquisition, + typings: server.toSortedReadonlyArray(newTypings), + unresolvedImports: unresolvedImports, + poisoned: false + }); + }; + TypingsCache.prototype.deleteTypingsForProject = function (projectName) { + this.perProjectCache.delete(projectName); + }; + TypingsCache.prototype.onProjectClosed = function (project) { + this.perProjectCache.delete(project.getProjectName()); + this.installer.onProjectClosed(project); + }; + return TypingsCache; + }()); + server.TypingsCache = TypingsCache; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + function shouldEmitFile(scriptInfo) { + return !scriptInfo.hasMixedContent; + } + server.shouldEmitFile = shouldEmitFile; + var BuilderFileInfo = (function () { + function BuilderFileInfo(scriptInfo, project) { + this.scriptInfo = scriptInfo; + this.project = project; + } + BuilderFileInfo.prototype.isExternalModuleOrHasOnlyAmbientExternalModules = function () { + var sourceFile = this.getSourceFile(); + return ts.isExternalModule(sourceFile) || this.containsOnlyAmbientModules(sourceFile); + }; + BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (statement.kind !== 232 || statement.name.kind !== 9) { + return false; + } + } + return true; + }; + BuilderFileInfo.prototype.computeHash = function (text) { + return this.project.projectService.host.createHash(text); + }; + BuilderFileInfo.prototype.getSourceFile = function () { + return this.project.getSourceFile(this.scriptInfo.path); + }; + BuilderFileInfo.prototype.updateShapeSignature = function () { + var sourceFile = this.getSourceFile(); + if (!sourceFile) { + return true; + } + var lastSignature = this.lastCheckedShapeSignature; + if (sourceFile.isDeclarationFile) { + this.lastCheckedShapeSignature = this.computeHash(sourceFile.text); + } + else { + var emitOutput = this.project.getFileEmitOutput(this.scriptInfo, true); + if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { + this.lastCheckedShapeSignature = this.computeHash(emitOutput.outputFiles[0].text); + } + } + return !lastSignature || this.lastCheckedShapeSignature !== lastSignature; + }; + return BuilderFileInfo; + }()); + server.BuilderFileInfo = BuilderFileInfo; + var AbstractBuilder = (function () { + function AbstractBuilder(project, ctor) { + this.project = project; + this.ctor = ctor; + } + AbstractBuilder.prototype.getFileInfos = function () { + return this.fileInfos_doNotAccessDirectly || (this.fileInfos_doNotAccessDirectly = ts.createFileMap()); + }; + AbstractBuilder.prototype.clear = function () { + this.fileInfos_doNotAccessDirectly = undefined; + }; + AbstractBuilder.prototype.getFileInfo = function (path) { + return this.getFileInfos().get(path); + }; + AbstractBuilder.prototype.getOrCreateFileInfo = function (path) { + var fileInfo = this.getFileInfo(path); + if (!fileInfo) { + var scriptInfo = this.project.getScriptInfo(path); + fileInfo = new this.ctor(scriptInfo, this.project); + this.setFileInfo(path, fileInfo); + } + return fileInfo; + }; + AbstractBuilder.prototype.getFileInfoPaths = function () { + return this.getFileInfos().getKeys(); + }; + AbstractBuilder.prototype.setFileInfo = function (path, info) { + this.getFileInfos().set(path, info); + }; + AbstractBuilder.prototype.removeFileInfo = function (path) { + this.getFileInfos().remove(path); + }; + AbstractBuilder.prototype.forEachFileInfo = function (action) { + this.getFileInfos().forEachValue(function (_path, value) { return action(value); }); + }; + AbstractBuilder.prototype.emitFile = function (scriptInfo, writeFile) { + var fileInfo = this.getFileInfo(scriptInfo.path); + if (!fileInfo) { + return false; + } + var _a = this.project.getFileEmitOutput(fileInfo.scriptInfo, false), emitSkipped = _a.emitSkipped, outputFiles = _a.outputFiles; + if (!emitSkipped) { + var projectRootPath = this.project.getProjectRootPath(); + for (var _i = 0, outputFiles_1 = outputFiles; _i < outputFiles_1.length; _i++) { + var outputFile = outputFiles_1[_i]; + var outputFileAbsoluteFileName = ts.getNormalizedAbsolutePath(outputFile.name, projectRootPath ? projectRootPath : ts.getDirectoryPath(scriptInfo.fileName)); + writeFile(outputFileAbsoluteFileName, outputFile.text, outputFile.writeByteOrderMark); + } + } + return !emitSkipped; + }; + return AbstractBuilder; + }()); + var NonModuleBuilder = (function (_super) { + __extends(NonModuleBuilder, _super); + function NonModuleBuilder(project) { + var _this = _super.call(this, project, BuilderFileInfo) || this; + _this.project = project; + return _this; + } + NonModuleBuilder.prototype.onProjectUpdateGraph = function () { + }; + NonModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { + var info = this.getOrCreateFileInfo(scriptInfo.path); + var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + if (info.updateShapeSignature()) { + var options = this.project.getCompilerOptions(); + if (options && (options.out || options.outFile)) { + return singleFileResult; + } + return this.project.getAllEmittableFiles(); + } + return singleFileResult; + }; + return NonModuleBuilder; + }(AbstractBuilder)); + var ModuleBuilderFileInfo = (function (_super) { + __extends(ModuleBuilderFileInfo, _super); + function ModuleBuilderFileInfo() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.references = []; + _this.referencedBy = []; + return _this; + } + ModuleBuilderFileInfo.compareFileInfos = function (lf, rf) { + var l = lf.scriptInfo.fileName; + var r = rf.scriptInfo.fileName; + return (l < r ? -1 : (l > r ? 1 : 0)); + }; + ; + ModuleBuilderFileInfo.addToReferenceList = function (array, fileInfo) { + if (array.length === 0) { + array.push(fileInfo); + return; + } + var insertIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); + if (insertIndex < 0) { + array.splice(~insertIndex, 0, fileInfo); + } + }; + ModuleBuilderFileInfo.removeFromReferenceList = function (array, fileInfo) { + if (!array || array.length === 0) { + return; + } + if (array[0] === fileInfo) { + array.splice(0, 1); + return; + } + var removeIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); + if (removeIndex >= 0) { + array.splice(removeIndex, 1); + } + }; + ModuleBuilderFileInfo.prototype.addReferencedBy = function (fileInfo) { + ModuleBuilderFileInfo.addToReferenceList(this.referencedBy, fileInfo); + }; + ModuleBuilderFileInfo.prototype.removeReferencedBy = function (fileInfo) { + ModuleBuilderFileInfo.removeFromReferenceList(this.referencedBy, fileInfo); + }; + ModuleBuilderFileInfo.prototype.removeFileReferences = function () { + for (var _i = 0, _a = this.references; _i < _a.length; _i++) { + var reference = _a[_i]; + reference.removeReferencedBy(this); + } + this.references = []; + }; + return ModuleBuilderFileInfo; + }(BuilderFileInfo)); + var ModuleBuilder = (function (_super) { + __extends(ModuleBuilder, _super); + function ModuleBuilder(project) { + var _this = _super.call(this, project, ModuleBuilderFileInfo) || this; + _this.project = project; + return _this; + } + ModuleBuilder.prototype.clear = function () { + this.projectVersionForDependencyGraph = undefined; + _super.prototype.clear.call(this); + }; + ModuleBuilder.prototype.getReferencedFileInfos = function (fileInfo) { + var _this = this; + if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { + return []; + } + var referencedFilePaths = this.project.getReferencedFiles(fileInfo.scriptInfo.path); + if (referencedFilePaths.length > 0) { + return ts.map(referencedFilePaths, function (f) { return _this.getOrCreateFileInfo(f); }).sort(ModuleBuilderFileInfo.compareFileInfos); + } + return []; + }; + ModuleBuilder.prototype.onProjectUpdateGraph = function () { + this.ensureProjectDependencyGraphUpToDate(); + }; + ModuleBuilder.prototype.ensureProjectDependencyGraphUpToDate = function () { + var _this = this; + if (!this.projectVersionForDependencyGraph || this.project.getProjectVersion() !== this.projectVersionForDependencyGraph) { + var currentScriptInfos = this.project.getScriptInfos(); + for (var _i = 0, currentScriptInfos_1 = currentScriptInfos; _i < currentScriptInfos_1.length; _i++) { + var scriptInfo = currentScriptInfos_1[_i]; + var fileInfo = this.getOrCreateFileInfo(scriptInfo.path); + this.updateFileReferences(fileInfo); + } + this.forEachFileInfo(function (fileInfo) { + if (!_this.project.containsScriptInfo(fileInfo.scriptInfo)) { + fileInfo.removeFileReferences(); + _this.removeFileInfo(fileInfo.scriptInfo.path); + } + }); + this.projectVersionForDependencyGraph = this.project.getProjectVersion(); + } + }; + ModuleBuilder.prototype.updateFileReferences = function (fileInfo) { + if (fileInfo.scriptVersionForReferences === fileInfo.scriptInfo.getLatestVersion()) { + return; + } + var newReferences = this.getReferencedFileInfos(fileInfo); + var oldReferences = fileInfo.references; + var oldIndex = 0; + var newIndex = 0; + while (oldIndex < oldReferences.length && newIndex < newReferences.length) { + var oldReference = oldReferences[oldIndex]; + var newReference = newReferences[newIndex]; + var compare = ModuleBuilderFileInfo.compareFileInfos(oldReference, newReference); + if (compare < 0) { + oldReference.removeReferencedBy(fileInfo); + oldIndex++; + } + else if (compare > 0) { + newReference.addReferencedBy(fileInfo); + newIndex++; + } + else { + oldIndex++; + newIndex++; + } + } + for (var i = oldIndex; i < oldReferences.length; i++) { + oldReferences[i].removeReferencedBy(fileInfo); + } + for (var i = newIndex; i < newReferences.length; i++) { + newReferences[i].addReferencedBy(fileInfo); + } + fileInfo.references = newReferences; + fileInfo.scriptVersionForReferences = fileInfo.scriptInfo.getLatestVersion(); + }; + ModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { + this.ensureProjectDependencyGraphUpToDate(); + var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + var fileInfo = this.getFileInfo(scriptInfo.path); + if (!fileInfo || !fileInfo.updateShapeSignature()) { + return singleFileResult; + } + if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { + return this.project.getAllEmittableFiles(); + } + var options = this.project.getCompilerOptions(); + if (options && (options.isolatedModules || options.out || options.outFile)) { + return singleFileResult; + } + var queue = fileInfo.referencedBy.slice(0); + var fileNameSet = ts.createMap(); + fileNameSet.set(scriptInfo.fileName, scriptInfo); + while (queue.length > 0) { + var processingFileInfo = queue.pop(); + if (processingFileInfo.updateShapeSignature() && processingFileInfo.referencedBy.length > 0) { + for (var _i = 0, _a = processingFileInfo.referencedBy; _i < _a.length; _i++) { + var potentialFileInfo = _a[_i]; + if (!fileNameSet.has(potentialFileInfo.scriptInfo.fileName)) { + queue.push(potentialFileInfo); + } + } + } + fileNameSet.set(processingFileInfo.scriptInfo.fileName, processingFileInfo.scriptInfo); + } + var result = []; + fileNameSet.forEach(function (scriptInfo, fileName) { + if (shouldEmitFile(scriptInfo)) { + result.push(fileName); + } + }); + return result; + }; + return ModuleBuilder; + }(AbstractBuilder)); + function createBuilder(project) { + var moduleKind = project.getCompilerOptions().module; + switch (moduleKind) { + case ts.ModuleKind.None: + return new NonModuleBuilder(project); + default: + return new ModuleBuilder(project); + } + } + server.createBuilder = createBuilder; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var ProjectKind; + (function (ProjectKind) { + ProjectKind[ProjectKind["Inferred"] = 0] = "Inferred"; + ProjectKind[ProjectKind["Configured"] = 1] = "Configured"; + ProjectKind[ProjectKind["External"] = 2] = "External"; + })(ProjectKind = server.ProjectKind || (server.ProjectKind = {})); + function remove(items, item) { + var index = items.indexOf(item); + if (index >= 0) { + items.splice(index, 1); + } + } + function countEachFileTypes(infos) { + var result = { js: 0, jsx: 0, ts: 0, tsx: 0, dts: 0 }; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + switch (info.scriptKind) { + case 1: + result.js += 1; + break; + case 2: + result.jsx += 1; + break; + case 3: + ts.fileExtensionIs(info.fileName, ".d.ts") + ? result.dts += 1 + : result.ts += 1; + break; + case 4: + result.tsx += 1; + break; + } + } + return result; + } + function hasOneOrMoreJsAndNoTsFiles(project) { + var counts = countEachFileTypes(project.getScriptInfos()); + return counts.js > 0 && counts.ts === 0 && counts.tsx === 0; + } + function allRootFilesAreJsOrDts(project) { + var counts = countEachFileTypes(project.getRootScriptInfos()); + return counts.ts === 0 && counts.tsx === 0; + } + server.allRootFilesAreJsOrDts = allRootFilesAreJsOrDts; + function allFilesAreJsOrDts(project) { + var counts = countEachFileTypes(project.getScriptInfos()); + return counts.ts === 0 && counts.tsx === 0; + } + server.allFilesAreJsOrDts = allFilesAreJsOrDts; + var UnresolvedImportsMap = (function () { + function UnresolvedImportsMap() { + this.perFileMap = ts.createFileMap(); + this.version = 0; + } + UnresolvedImportsMap.prototype.clear = function () { + this.perFileMap.clear(); + this.version = 0; + }; + UnresolvedImportsMap.prototype.getVersion = function () { + return this.version; + }; + UnresolvedImportsMap.prototype.remove = function (path) { + this.perFileMap.remove(path); + this.version++; + }; + UnresolvedImportsMap.prototype.get = function (path) { + return this.perFileMap.get(path); + }; + UnresolvedImportsMap.prototype.set = function (path, value) { + this.perFileMap.set(path, value); + this.version++; + }; + return UnresolvedImportsMap; + }()); + server.UnresolvedImportsMap = UnresolvedImportsMap; + var Project = (function () { + function Project(projectName, projectKind, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { + this.projectName = projectName; + this.projectKind = projectKind; + this.projectService = projectService; + this.documentRegistry = documentRegistry; + this.compilerOptions = compilerOptions; + this.compileOnSaveEnabled = compileOnSaveEnabled; + this.rootFiles = []; + this.rootFilesMap = ts.createFileMap(); + this.cachedUnresolvedImportsPerFile = new UnresolvedImportsMap(); + this.languageServiceEnabled = true; + this.lastReportedVersion = 0; + this.projectStructureVersion = 0; + this.projectStateVersion = 0; + this.typesVersion = 0; + if (!this.compilerOptions) { + this.compilerOptions = ts.getDefaultCompilerOptions(); + this.compilerOptions.allowNonTsExtensions = true; + this.compilerOptions.allowJs = true; + } + else if (hasExplicitListOfFiles || this.compilerOptions.allowJs) { + this.compilerOptions.allowNonTsExtensions = true; + } + this.setInternalCompilerOptionsForEmittingJsFiles(); + this.lsHost = new server.LSHost(this.projectService.host, this, this.projectService.cancellationToken); + this.lsHost.setCompilationSettings(this.compilerOptions); + this.languageService = ts.createLanguageService(this.lsHost, this.documentRegistry); + if (!languageServiceEnabled) { + this.disableLanguageService(); + } + this.builder = server.createBuilder(this); + this.markAsDirty(); + } + Project.prototype.isNonTsProject = function () { + this.updateGraph(); + return allFilesAreJsOrDts(this); + }; + Project.prototype.isJsOnlyProject = function () { + this.updateGraph(); + return hasOneOrMoreJsAndNoTsFiles(this); + }; + Project.prototype.getCachedUnresolvedImportsPerFile_TestOnly = function () { + return this.cachedUnresolvedImportsPerFile; + }; + Project.resolveModule = function (moduleName, initialDir, host, log) { + var resolvedPath = ts.normalizeSlashes(host.resolvePath(ts.combinePaths(initialDir, "node_modules"))); + log("Loading " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")"); + var result = host.require(resolvedPath, moduleName); + if (result.error) { + log("Failed to load module: " + JSON.stringify(result.error)); + return undefined; + } + return result.module; + }; + Project.prototype.setInternalCompilerOptionsForEmittingJsFiles = function () { + if (this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) { + this.compilerOptions.noEmitForJsFiles = true; + } + }; + Project.prototype.getProjectErrors = function () { + return this.projectErrors; + }; + Project.prototype.getLanguageService = function (ensureSynchronized) { + if (ensureSynchronized === void 0) { ensureSynchronized = true; } + if (ensureSynchronized) { + this.updateGraph(); + } + return this.languageService; + }; + Project.prototype.getCompileOnSaveAffectedFileList = function (scriptInfo) { + if (!this.languageServiceEnabled) { + return []; + } + this.updateGraph(); + return this.builder.getFilesAffectedBy(scriptInfo); + }; + Project.prototype.getProjectVersion = function () { + return this.projectStateVersion.toString(); + }; + Project.prototype.enableLanguageService = function () { + if (this.languageServiceEnabled) { + return; + } + this.languageServiceEnabled = true; + this.projectService.onUpdateLanguageServiceStateForProject(this, true); + }; + Project.prototype.disableLanguageService = function () { + if (!this.languageServiceEnabled) { + return; + } + this.languageService.cleanupSemanticCache(); + this.languageServiceEnabled = false; + this.projectService.onUpdateLanguageServiceStateForProject(this, false); + }; + Project.prototype.getProjectName = function () { + return this.projectName; + }; + Project.prototype.getExternalFiles = function () { + return []; + }; + Project.prototype.getSourceFile = function (path) { + if (!this.program) { + return undefined; + } + return this.program.getSourceFileByPath(path); + }; + Project.prototype.updateTypes = function () { + this.typesVersion++; + this.markAsDirty(); + this.updateGraph(); + }; + Project.prototype.close = function () { + if (this.program) { + for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { + var f = _a[_i]; + var info = this.projectService.getScriptInfo(f.fileName); + info.detachFromProject(this); + } + } + if (!this.program || !this.languageServiceEnabled) { + for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { + var root = _c[_b]; + root.detachFromProject(this); + } + } + this.rootFiles = undefined; + this.rootFilesMap = undefined; + this.program = undefined; + this.languageService.dispose(); + }; + Project.prototype.getCompilerOptions = function () { + return this.compilerOptions; + }; + Project.prototype.hasRoots = function () { + return this.rootFiles && this.rootFiles.length > 0; + }; + Project.prototype.getRootFiles = function () { + return this.rootFiles && this.rootFiles.map(function (info) { return info.fileName; }); + }; + Project.prototype.getRootFilesLSHost = function () { + var result = []; + if (this.rootFiles) { + for (var _i = 0, _a = this.rootFiles; _i < _a.length; _i++) { + var f = _a[_i]; + if (this.languageServiceEnabled || f.isScriptOpen()) { + result.push(f.fileName); + } + } + if (this.typingFiles) { + for (var _b = 0, _c = this.typingFiles; _b < _c.length; _b++) { + var f = _c[_b]; + result.push(f); + } + } + } + return result; + }; + Project.prototype.getRootScriptInfos = function () { + return this.rootFiles; + }; + Project.prototype.getScriptInfos = function () { + var _this = this; + if (!this.languageServiceEnabled) { + return this.rootFiles; + } + return ts.map(this.program.getSourceFiles(), function (sourceFile) { + var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.path); + if (!scriptInfo) { + ts.Debug.assert(false, "scriptInfo for a file '" + sourceFile.fileName + "' is missing."); + } + return scriptInfo; + }); + }; + Project.prototype.getFileEmitOutput = function (info, emitOnlyDtsFiles) { + if (!this.languageServiceEnabled) { + return undefined; + } + return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); + }; + Project.prototype.getFileNames = function (excludeFilesFromExternalLibraries) { + if (!this.program) { + return []; + } + if (!this.languageServiceEnabled) { + var rootFiles = this.getRootFiles(); + if (this.compilerOptions) { + var defaultLibrary = ts.getDefaultLibFilePath(this.compilerOptions); + if (defaultLibrary) { + (rootFiles || (rootFiles = [])).push(server.asNormalizedPath(defaultLibrary)); + } + } + return rootFiles; + } + var result = []; + for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { + var f = _a[_i]; + if (excludeFilesFromExternalLibraries && this.program.isSourceFileFromExternalLibrary(f)) { + continue; + } + result.push(server.asNormalizedPath(f.fileName)); + } + return result; + }; + Project.prototype.getAllEmittableFiles = function () { + if (!this.languageServiceEnabled) { + return []; + } + var defaultLibraryFileName = ts.getDefaultLibFileName(this.compilerOptions); + var infos = this.getScriptInfos(); + var result = []; + for (var _i = 0, infos_2 = infos; _i < infos_2.length; _i++) { + var info = infos_2[_i]; + if (ts.getBaseFileName(info.fileName) !== defaultLibraryFileName && server.shouldEmitFile(info)) { + result.push(info.fileName); + } + } + return result; + }; + Project.prototype.containsScriptInfo = function (info) { + return this.isRoot(info) || (this.program && this.program.getSourceFileByPath(info.path) !== undefined); + }; + Project.prototype.containsFile = function (filename, requireOpen) { + var info = this.projectService.getScriptInfoForNormalizedPath(filename); + if (info && (info.isScriptOpen() || !requireOpen)) { + return this.containsScriptInfo(info); + } + }; + Project.prototype.isRoot = function (info) { + return this.rootFilesMap && this.rootFilesMap.contains(info.path); + }; + Project.prototype.addRoot = function (info) { + if (!this.isRoot(info)) { + this.rootFiles.push(info); + this.rootFilesMap.set(info.path, info); + info.attachToProject(this); + this.markAsDirty(); + } + }; + Project.prototype.removeFile = function (info, detachFromProject) { + if (detachFromProject === void 0) { detachFromProject = true; } + if (this.isRoot(info)) { + this.removeRoot(info); + } + this.lsHost.notifyFileRemoved(info); + this.cachedUnresolvedImportsPerFile.remove(info.path); + if (detachFromProject) { + info.detachFromProject(this); + } + this.markAsDirty(); + }; + Project.prototype.registerFileUpdate = function (fileName) { + (this.updatedFileNames || (this.updatedFileNames = ts.createMap())).set(fileName, fileName); + }; + Project.prototype.markAsDirty = function () { + this.projectStateVersion++; + }; + Project.prototype.extractUnresolvedImportsFromSourceFile = function (file, result) { + var cached = this.cachedUnresolvedImportsPerFile.get(file.path); + if (cached) { + for (var _i = 0, cached_2 = cached; _i < cached_2.length; _i++) { + var f = cached_2[_i]; + result.push(f); + } + return; + } + var unresolvedImports; + if (file.resolvedModules) { + file.resolvedModules.forEach(function (resolvedModule, name) { + if (!resolvedModule && !ts.isExternalModuleNameRelative(name)) { + var trimmed = name.trim(); + var i = trimmed.indexOf("/"); + if (i !== -1 && trimmed.charCodeAt(0) === 64) { + i = trimmed.indexOf("/", i + 1); + } + if (i !== -1) { + trimmed = trimmed.substr(0, i); + } + (unresolvedImports || (unresolvedImports = [])).push(trimmed); + result.push(trimmed); + } + }); + } + this.cachedUnresolvedImportsPerFile.set(file.path, unresolvedImports || server.emptyArray); + }; + Project.prototype.updateGraph = function () { + this.lsHost.startRecordingFilesWithChangedResolutions(); + var hasChanges = this.updateGraphWorker(); + var changedFiles = this.lsHost.finishRecordingFilesWithChangedResolutions() || server.emptyArray; + for (var _i = 0, changedFiles_1 = changedFiles; _i < changedFiles_1.length; _i++) { + var file = changedFiles_1[_i]; + this.cachedUnresolvedImportsPerFile.remove(file); + } + var unresolvedImports; + if (hasChanges || changedFiles.length) { + var result = []; + for (var _a = 0, _b = this.program.getSourceFiles(); _a < _b.length; _a++) { + var sourceFile = _b[_a]; + this.extractUnresolvedImportsFromSourceFile(sourceFile, result); + } + this.lastCachedUnresolvedImportsList = server.toSortedReadonlyArray(result); + } + unresolvedImports = this.lastCachedUnresolvedImportsList; + var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, unresolvedImports, hasChanges); + if (this.setTypings(cachedTypings)) { + hasChanges = this.updateGraphWorker() || hasChanges; + } + if (this.languageServiceEnabled) { + this.builder.onProjectUpdateGraph(); + } + else { + this.builder.clear(); + } + if (hasChanges) { + this.projectStructureVersion++; + } + return !hasChanges; + }; + Project.prototype.setTypings = function (typings) { + if (ts.arrayIsEqualTo(this.typingFiles, typings)) { + return false; + } + this.typingFiles = typings; + this.markAsDirty(); + return true; + }; + Project.prototype.updateGraphWorker = function () { + var oldProgram = this.program; + this.program = this.languageService.getProgram(); + var hasChanges = false; + if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) { + hasChanges = true; + if (oldProgram) { + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var f = _a[_i]; + if (this.program.getSourceFileByPath(f.path)) { + continue; + } + var scriptInfoToDetach = this.projectService.getScriptInfo(f.fileName); + if (scriptInfoToDetach) { + scriptInfoToDetach.detachFromProject(this); + } + } + } + } + return hasChanges; + }; + Project.prototype.getScriptInfoLSHost = function (fileName) { + var scriptInfo = this.projectService.getOrCreateScriptInfo(fileName, false); + if (scriptInfo) { + scriptInfo.attachToProject(this); + } + return scriptInfo; + }; + Project.prototype.getScriptInfoForNormalizedPath = function (fileName) { + var scriptInfo = this.projectService.getOrCreateScriptInfoForNormalizedPath(fileName, false); + if (scriptInfo && !scriptInfo.isAttached(this)) { + return server.Errors.ThrowProjectDoesNotContainDocument(fileName, this); + } + return scriptInfo; + }; + Project.prototype.getScriptInfo = function (uncheckedFileName) { + return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + }; + Project.prototype.filesToString = function () { + if (!this.program) { + return ""; + } + var strBuilder = ""; + for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { + var file = _a[_i]; + strBuilder += file.fileName + "\n"; + } + return strBuilder; + }; + Project.prototype.setCompilerOptions = function (compilerOptions) { + if (compilerOptions) { + compilerOptions.allowNonTsExtensions = true; + if (ts.changesAffectModuleResolution(this.compilerOptions, compilerOptions)) { + this.cachedUnresolvedImportsPerFile.clear(); + this.lastCachedUnresolvedImportsList = undefined; + } + this.compilerOptions = compilerOptions; + this.setInternalCompilerOptionsForEmittingJsFiles(); + this.lsHost.setCompilationSettings(compilerOptions); + this.markAsDirty(); + } + }; + Project.prototype.reloadScript = function (filename, tempFileName) { + var script = this.projectService.getScriptInfoForNormalizedPath(filename); + if (script) { + ts.Debug.assert(script.isAttached(this)); + script.reloadFromFile(tempFileName); + return true; + } + return false; + }; + Project.prototype.getChangesSinceVersion = function (lastKnownVersion) { + this.updateGraph(); + var info = { + projectName: this.getProjectName(), + version: this.projectStructureVersion, + isInferred: this.projectKind === ProjectKind.Inferred, + options: this.getCompilerOptions(), + languageServiceDisabled: !this.languageServiceEnabled + }; + var updatedFileNames = this.updatedFileNames; + this.updatedFileNames = undefined; + if (this.lastReportedFileNames && lastKnownVersion === this.lastReportedVersion) { + if (this.projectStructureVersion == this.lastReportedVersion && !updatedFileNames) { + return { info: info, projectErrors: this.projectErrors }; + } + var lastReportedFileNames_1 = this.lastReportedFileNames; + var currentFiles_1 = ts.arrayToMap(this.getFileNames(), function (x) { return x; }); + var added_1 = []; + var removed_1 = []; + var updated = ts.arrayFrom(updatedFileNames.keys()); + ts.forEachKey(currentFiles_1, function (id) { + if (!lastReportedFileNames_1.has(id)) { + added_1.push(id); + } + }); + ts.forEachKey(lastReportedFileNames_1, function (id) { + if (!currentFiles_1.has(id)) { + removed_1.push(id); + } + }); + this.lastReportedFileNames = currentFiles_1; + this.lastReportedVersion = this.projectStructureVersion; + return { info: info, changes: { added: added_1, removed: removed_1, updated: updated }, projectErrors: this.projectErrors }; + } + else { + var projectFileNames = this.getFileNames(); + this.lastReportedFileNames = ts.arrayToMap(projectFileNames, function (x) { return x; }); + this.lastReportedVersion = this.projectStructureVersion; + return { info: info, files: projectFileNames, projectErrors: this.projectErrors }; + } + }; + Project.prototype.getReferencedFiles = function (path) { + var _this = this; + if (!this.languageServiceEnabled) { + return []; + } + var sourceFile = this.getSourceFile(path); + if (!sourceFile) { + return []; + } + var referencedFiles = ts.createMap(); + if (sourceFile.imports && sourceFile.imports.length > 0) { + var checker = this.program.getTypeChecker(); + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var importName = _a[_i]; + var symbol = checker.getSymbolAtLocation(importName); + if (symbol && symbol.declarations && symbol.declarations[0]) { + var declarationSourceFile = symbol.declarations[0].getSourceFile(); + if (declarationSourceFile) { + referencedFiles.set(declarationSourceFile.path, true); + } + } + } + } + var currentDirectory = ts.getDirectoryPath(path); + var getCanonicalFileName = ts.createGetCanonicalFileName(this.projectService.host.useCaseSensitiveFileNames); + if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) { + for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) { + var referencedFile = _c[_b]; + var referencedPath = ts.toPath(referencedFile.fileName, currentDirectory, getCanonicalFileName); + referencedFiles.set(referencedPath, true); + } + } + if (sourceFile.resolvedTypeReferenceDirectiveNames) { + sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) { + if (!resolvedTypeReferenceDirective) { + return; + } + var fileName = resolvedTypeReferenceDirective.resolvedFileName; + var typeFilePath = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + referencedFiles.set(typeFilePath, true); + }); + } + var allFileNames = ts.arrayFrom(referencedFiles.keys()); + return ts.filter(allFileNames, function (file) { return _this.projectService.host.fileExists(file); }); + }; + Project.prototype.removeRoot = function (info) { + remove(this.rootFiles, info); + this.rootFilesMap.remove(info.path); + }; + return Project; + }()); + server.Project = Project; + var InferredProject = (function (_super) { + __extends(InferredProject, _super); + function InferredProject(projectService, documentRegistry, compilerOptions) { + var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, undefined, true, compilerOptions, false) || this; + _this._isJsInferredProject = false; + _this.directoriesWatchedForTsconfig = []; + return _this; + } + InferredProject.prototype.toggleJsInferredProject = function (isJsInferredProject) { + if (isJsInferredProject !== this._isJsInferredProject) { + this._isJsInferredProject = isJsInferredProject; + this.setCompilerOptions(); + } + }; + InferredProject.prototype.setCompilerOptions = function (options) { + var newOptions = options ? ts.clone(options) : this.getCompilerOptions(); + if (!newOptions) { + return; + } + if (this._isJsInferredProject && typeof newOptions.maxNodeModuleJsDepth !== "number") { + newOptions.maxNodeModuleJsDepth = 2; + } + else if (!this._isJsInferredProject) { + newOptions.maxNodeModuleJsDepth = undefined; + } + newOptions.allowJs = true; + _super.prototype.setCompilerOptions.call(this, newOptions); + }; + InferredProject.prototype.addRoot = function (info) { + if (!this._isJsInferredProject && info.isJavaScript()) { + this.toggleJsInferredProject(true); + } + _super.prototype.addRoot.call(this, info); + }; + InferredProject.prototype.removeRoot = function (info) { + if (this._isJsInferredProject && info.isJavaScript()) { + if (ts.filter(this.getRootScriptInfos(), function (info) { return info.isJavaScript(); }).length === 0) { + this.toggleJsInferredProject(false); + } + } + _super.prototype.removeRoot.call(this, info); + }; + InferredProject.prototype.getProjectRootPath = function () { + if (this.projectService.useSingleInferredProject) { + return undefined; + } + var rootFiles = this.getRootFiles(); + return ts.getDirectoryPath(rootFiles[0]); + }; + InferredProject.prototype.close = function () { + _super.prototype.close.call(this); + for (var _i = 0, _a = this.directoriesWatchedForTsconfig; _i < _a.length; _i++) { + var directory = _a[_i]; + this.projectService.stopWatchingDirectory(directory); + } + }; + InferredProject.prototype.getTypeAcquisition = function () { + return { + enable: allRootFilesAreJsOrDts(this), + include: [], + exclude: [] + }; + }; + return InferredProject; + }(Project)); + InferredProject.newName = (function () { + var nextId = 1; + return function () { + var id = nextId; + nextId++; + return server.makeInferredProjectName(id); + }; + })(); + server.InferredProject = InferredProject; + var ConfiguredProject = (function (_super) { + __extends(ConfiguredProject, _super); + function ConfiguredProject(configFileName, projectService, documentRegistry, hasExplicitListOfFiles, compilerOptions, wildcardDirectories, languageServiceEnabled, compileOnSaveEnabled) { + var _this = _super.call(this, configFileName, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.configFileName = configFileName; + _this.wildcardDirectories = wildcardDirectories; + _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.plugins = []; + _this.openRefCount = 0; + _this.canonicalConfigFilePath = server.asNormalizedPath(projectService.toCanonicalFileName(configFileName)); + _this.enablePlugins(); + return _this; + } + ConfiguredProject.prototype.getConfigFilePath = function () { + return this.getProjectName(); + }; + ConfiguredProject.prototype.enablePlugins = function () { + var _this = this; + var host = this.projectService.host; + var options = this.getCompilerOptions(); + var log = function (message) { + _this.projectService.logger.info(message); + }; + if (!(options.plugins && options.plugins.length)) { + this.projectService.logger.info("No plugins exist"); + return; + } + if (!host.require) { + this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); + return; + } + for (var _i = 0, _a = options.plugins; _i < _a.length; _i++) { + var pluginConfigEntry = _a[_i]; + var searchPath = ts.getDirectoryPath(this.configFileName); + var resolvedModule = Project.resolveModule(pluginConfigEntry.name, searchPath, host, log); + if (resolvedModule) { + this.enableProxy(resolvedModule, pluginConfigEntry); + } + } + }; + ConfiguredProject.prototype.enableProxy = function (pluginModuleFactory, configEntry) { + try { + if (typeof pluginModuleFactory !== "function") { + this.projectService.logger.info("Skipped loading plugin " + configEntry.name + " because it did expose a proper factory function"); + return; + } + var info = { + config: configEntry, + project: this, + languageService: this.languageService, + languageServiceHost: this.lsHost, + serverHost: this.projectService.host + }; + var pluginModule = pluginModuleFactory({ typescript: ts }); + this.languageService = pluginModule.create(info); + this.plugins.push(pluginModule); + } + catch (e) { + this.projectService.logger.info("Plugin activation failed: " + e); + } + }; + ConfiguredProject.prototype.getProjectRootPath = function () { + return ts.getDirectoryPath(this.getConfigFilePath()); + }; + ConfiguredProject.prototype.setProjectErrors = function (projectErrors) { + this.projectErrors = projectErrors; + }; + ConfiguredProject.prototype.setTypeAcquisition = function (newTypeAcquisition) { + this.typeAcquisition = newTypeAcquisition; + }; + ConfiguredProject.prototype.getTypeAcquisition = function () { + return this.typeAcquisition; + }; + ConfiguredProject.prototype.getExternalFiles = function () { + var items = []; + for (var _i = 0, _a = this.plugins; _i < _a.length; _i++) { + var plugin = _a[_i]; + if (typeof plugin.getExternalFiles === "function") { + try { + items.push.apply(items, plugin.getExternalFiles(this)); + } + catch (e) { + this.projectService.logger.info("A plugin threw an exception in getExternalFiles: " + e); + } + } + } + return items; + }; + ConfiguredProject.prototype.watchConfigFile = function (callback) { + var _this = this; + this.projectFileWatcher = this.projectService.host.watchFile(this.getConfigFilePath(), function (_) { return callback(_this); }); + }; + ConfiguredProject.prototype.watchTypeRoots = function (callback) { + var _this = this; + var roots = this.getEffectiveTypeRoots(); + var watchers = []; + for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { + var root = roots_1[_i]; + this.projectService.logger.info("Add type root watcher for: " + root); + watchers.push(this.projectService.host.watchDirectory(root, function (path) { return callback(_this, path); }, false)); + } + this.typeRootsWatchers = watchers; + }; + ConfiguredProject.prototype.watchConfigDirectory = function (callback) { + var _this = this; + if (this.directoryWatcher) { + return; + } + var directoryToWatch = ts.getDirectoryPath(this.getConfigFilePath()); + this.projectService.logger.info("Add recursive watcher for: " + directoryToWatch); + this.directoryWatcher = this.projectService.host.watchDirectory(directoryToWatch, function (path) { return callback(_this, path); }, true); + }; + ConfiguredProject.prototype.watchWildcards = function (callback) { + var _this = this; + if (!this.wildcardDirectories) { + return; + } + var configDirectoryPath = ts.getDirectoryPath(this.getConfigFilePath()); + this.directoriesWatchedForWildcards = ts.createMap(); + this.wildcardDirectories.forEach(function (flag, directory) { + if (ts.comparePaths(configDirectoryPath, directory, ".", !_this.projectService.host.useCaseSensitiveFileNames) !== 0) { + var recursive = (flag & 1) !== 0; + _this.projectService.logger.info("Add " + (recursive ? "recursive " : "") + "watcher for: " + directory); + _this.directoriesWatchedForWildcards.set(directory, _this.projectService.host.watchDirectory(directory, function (path) { return callback(_this, path); }, recursive)); + } + }); + }; + ConfiguredProject.prototype.stopWatchingDirectory = function () { + if (this.directoryWatcher) { + this.directoryWatcher.close(); + this.directoryWatcher = undefined; + } + }; + ConfiguredProject.prototype.close = function () { + _super.prototype.close.call(this); + if (this.projectFileWatcher) { + this.projectFileWatcher.close(); + } + if (this.typeRootsWatchers) { + for (var _i = 0, _a = this.typeRootsWatchers; _i < _a.length; _i++) { + var watcher = _a[_i]; + watcher.close(); + } + this.typeRootsWatchers = undefined; + } + this.directoriesWatchedForWildcards.forEach(function (watcher) { + watcher.close(); + }); + this.directoriesWatchedForWildcards = undefined; + this.stopWatchingDirectory(); + }; + ConfiguredProject.prototype.addOpenRef = function () { + this.openRefCount++; + }; + ConfiguredProject.prototype.deleteOpenRef = function () { + this.openRefCount--; + return this.openRefCount; + }; + ConfiguredProject.prototype.getEffectiveTypeRoots = function () { + return ts.getEffectiveTypeRoots(this.getCompilerOptions(), this.projectService.host) || []; + }; + return ConfiguredProject; + }(Project)); + server.ConfiguredProject = ConfiguredProject; + var ExternalProject = (function (_super) { + __extends(ExternalProject, _super); + function ExternalProject(externalProjectName, projectService, documentRegistry, compilerOptions, languageServiceEnabled, compileOnSaveEnabled, projectFilePath) { + var _this = _super.call(this, externalProjectName, ProjectKind.External, projectService, documentRegistry, true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.projectFilePath = projectFilePath; + return _this; + } + ExternalProject.prototype.getProjectRootPath = function () { + if (this.projectFilePath) { + return ts.getDirectoryPath(this.projectFilePath); + } + return ts.getDirectoryPath(ts.normalizeSlashes(this.getProjectName())); + }; + ExternalProject.prototype.getTypeAcquisition = function () { + return this.typeAcquisition; + }; + ExternalProject.prototype.setProjectErrors = function (projectErrors) { + this.projectErrors = projectErrors; + }; + ExternalProject.prototype.setTypeAcquisition = function (newTypeAcquisition) { + if (!newTypeAcquisition) { + newTypeAcquisition = { + enable: allRootFilesAreJsOrDts(this), + include: [], + exclude: [] + }; + } + else { + if (newTypeAcquisition.enable === undefined) { + newTypeAcquisition.enable = allRootFilesAreJsOrDts(this); + } + if (!newTypeAcquisition.include) { + newTypeAcquisition.include = []; + } + if (!newTypeAcquisition.exclude) { + newTypeAcquisition.exclude = []; + } + } + this.typeAcquisition = newTypeAcquisition; + }; + return ExternalProject; + }(Project)); + server.ExternalProject = ExternalProject; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; + server.ContextEvent = "context"; + server.ConfigFileDiagEvent = "configFileDiag"; + server.ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; + function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions) { + var map = ts.createMap(); + for (var _i = 0, commandLineOptions_1 = commandLineOptions; _i < commandLineOptions_1.length; _i++) { + var option = commandLineOptions_1[_i]; + if (typeof option.type === "object") { + var optionMap = option.type; + optionMap.forEach(function (value) { + ts.Debug.assert(typeof value === "number"); + }); + map.set(option.name, optionMap); + } + } + return map; + } + var compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(ts.optionDeclarations); + var indentStyle = ts.createMapFromTemplate({ + "none": ts.IndentStyle.None, + "block": ts.IndentStyle.Block, + "smart": ts.IndentStyle.Smart + }); + function convertFormatOptions(protocolOptions) { + if (typeof protocolOptions.indentStyle === "string") { + protocolOptions.indentStyle = indentStyle.get(protocolOptions.indentStyle.toLowerCase()); + ts.Debug.assert(protocolOptions.indentStyle !== undefined); + } + return protocolOptions; + } + server.convertFormatOptions = convertFormatOptions; + function convertCompilerOptions(protocolOptions) { + compilerOptionConverters.forEach(function (mappedValues, id) { + var propertyValue = protocolOptions[id]; + if (typeof propertyValue === "string") { + protocolOptions[id] = mappedValues.get(propertyValue.toLowerCase()); + } + }); + return protocolOptions; + } + server.convertCompilerOptions = convertCompilerOptions; + function tryConvertScriptKindName(scriptKindName) { + return typeof scriptKindName === "string" + ? convertScriptKindName(scriptKindName) + : scriptKindName; + } + server.tryConvertScriptKindName = tryConvertScriptKindName; + function convertScriptKindName(scriptKindName) { + switch (scriptKindName) { + case "JS": + return 1; + case "JSX": + return 2; + case "TS": + return 3; + case "TSX": + return 4; + default: + return 0; + } + } + server.convertScriptKindName = convertScriptKindName; + function combineProjectOutput(projects, action, comparer, areEqual) { + var result = projects.reduce(function (previous, current) { return ts.concatenate(previous, action(current)); }, []).sort(comparer); + return projects.length > 1 ? ts.deduplicate(result, areEqual) : result; + } + server.combineProjectOutput = combineProjectOutput; + var fileNamePropertyReader = { + getFileName: function (x) { return x; }, + getScriptKind: function (_) { return undefined; }, + hasMixedContent: function (fileName, extraFileExtensions) { + var mixedContentExtensions = ts.map(ts.filter(extraFileExtensions, function (item) { return item.isMixedContent; }), function (item) { return item.extension; }); + return ts.forEach(mixedContentExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); + } + }; + var externalFilePropertyReader = { + getFileName: function (x) { return x.fileName; }, + getScriptKind: function (x) { return tryConvertScriptKindName(x.scriptKind); }, + hasMixedContent: function (x) { return x.hasMixedContent; } + }; + function findProjectByName(projectName, projects) { + for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) { + var proj = projects_1[_i]; + if (proj.getProjectName() === projectName) { + return proj; + } + } + } + function createFileNotFoundDiagnostic(fileName) { + return ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName); + } + function isRootFileInInferredProject(info) { + if (info.containingProjects.length === 0) { + return false; + } + return info.containingProjects[0].projectKind === server.ProjectKind.Inferred && info.containingProjects[0].isRoot(info); + } + var DirectoryWatchers = (function () { + function DirectoryWatchers(projectService) { + this.projectService = projectService; + this.directoryWatchersForTsconfig = ts.createMap(); + this.directoryWatchersRefCount = ts.createMap(); + } + DirectoryWatchers.prototype.stopWatchingDirectory = function (directory) { + var refCount = this.directoryWatchersRefCount.get(directory) - 1; + this.directoryWatchersRefCount.set(directory, refCount); + if (refCount === 0) { + this.projectService.logger.info("Close directory watcher for: " + directory); + this.directoryWatchersForTsconfig.get(directory).close(); + this.directoryWatchersForTsconfig.delete(directory); + } + }; + DirectoryWatchers.prototype.startWatchingContainingDirectoriesForFile = function (fileName, project, callback) { + var currentPath = ts.getDirectoryPath(fileName); + var parentPath = ts.getDirectoryPath(currentPath); + while (currentPath != parentPath) { + if (!this.directoryWatchersForTsconfig.has(currentPath)) { + this.projectService.logger.info("Add watcher for: " + currentPath); + this.directoryWatchersForTsconfig.set(currentPath, this.projectService.host.watchDirectory(currentPath, callback)); + this.directoryWatchersRefCount.set(currentPath, 1); + } + else { + this.directoryWatchersRefCount.set(currentPath, this.directoryWatchersRefCount.get(currentPath) + 1); + } + project.directoriesWatchedForTsconfig.push(currentPath); + currentPath = parentPath; + parentPath = ts.getDirectoryPath(parentPath); + } + }; + return DirectoryWatchers; + }()); + var ProjectService = (function () { + function ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, eventHandler) { + if (typingsInstaller === void 0) { typingsInstaller = server.nullTypingsInstaller; } + this.host = host; + this.logger = logger; + this.cancellationToken = cancellationToken; + this.useSingleInferredProject = useSingleInferredProject; + this.typingsInstaller = typingsInstaller; + this.eventHandler = eventHandler; + this.filenameToScriptInfo = ts.createFileMap(); + this.externalProjectToConfiguredProjectMap = ts.createMap(); + this.externalProjects = []; + this.inferredProjects = []; + this.configuredProjects = []; + this.openFiles = []; + ts.Debug.assert(!!host.createHash, "'ServerHost.createHash' is required for ProjectService"); + this.toCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + this.directoryWatchers = new DirectoryWatchers(this); + this.throttledOperations = new server.ThrottledOperations(host); + this.typingsInstaller.attach(this); + this.typingsCache = new server.TypingsCache(this.typingsInstaller); + this.hostConfiguration = { + formatCodeOptions: server.getDefaultFormatCodeSettings(this.host), + hostInfo: "Unknown host", + extraFileExtensions: [] + }; + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory()); + } + ProjectService.prototype.getChangedFiles_TestOnly = function () { + return this.changedFiles; + }; + ProjectService.prototype.ensureInferredProjectsUpToDate_TestOnly = function () { + this.ensureInferredProjectsUpToDate(); + }; + ProjectService.prototype.getCompilerOptionsForInferredProjects = function () { + return this.compilerOptionsForInferredProjects; + }; + ProjectService.prototype.onUpdateLanguageServiceStateForProject = function (project, languageServiceEnabled) { + if (!this.eventHandler) { + return; + } + this.eventHandler({ + eventName: server.ProjectLanguageServiceStateEvent, + data: { project: project, languageServiceEnabled: languageServiceEnabled } + }); + }; + ProjectService.prototype.updateTypingsForProject = function (response) { + var project = this.findProject(response.projectName); + if (!project) { + return; + } + switch (response.kind) { + case server.ActionSet: + this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typeAcquisition, response.unresolvedImports, response.typings); + break; + case server.ActionInvalidate: + this.typingsCache.deleteTypingsForProject(response.projectName); + break; + } + project.updateGraph(); + }; + ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions) { + this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions); + this.compilerOptionsForInferredProjects.allowNonTsExtensions = true; + this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; + for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { + var proj = _a[_i]; + proj.setCompilerOptions(this.compilerOptionsForInferredProjects); + proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave; + } + this.updateProjectGraphs(this.inferredProjects); + }; + ProjectService.prototype.stopWatchingDirectory = function (directory) { + this.directoryWatchers.stopWatchingDirectory(directory); + }; + ProjectService.prototype.findProject = function (projectName) { + if (projectName === undefined) { + return undefined; + } + if (server.isInferredProjectName(projectName)) { + this.ensureInferredProjectsUpToDate(); + return findProjectByName(projectName, this.inferredProjects); + } + return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(server.toNormalizedPath(projectName)); + }; + ProjectService.prototype.getDefaultProjectForFile = function (fileName, refreshInferredProjects) { + if (refreshInferredProjects) { + this.ensureInferredProjectsUpToDate(); + } + var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); + return scriptInfo && scriptInfo.getDefaultProject(); + }; + ProjectService.prototype.ensureInferredProjectsUpToDate = function () { + if (this.changedFiles) { + var projectsToUpdate = void 0; + if (this.changedFiles.length === 1) { + projectsToUpdate = this.changedFiles[0].containingProjects; + } + else { + projectsToUpdate = []; + for (var _i = 0, _a = this.changedFiles; _i < _a.length; _i++) { + var f = _a[_i]; + projectsToUpdate = projectsToUpdate.concat(f.containingProjects); + } + } + this.updateProjectGraphs(projectsToUpdate); + this.changedFiles = undefined; + } + }; + ProjectService.prototype.findContainingExternalProject = function (fileName) { + for (var _i = 0, _a = this.externalProjects; _i < _a.length; _i++) { + var proj = _a[_i]; + if (proj.containsFile(fileName)) { + return proj; + } + } + return undefined; + }; + ProjectService.prototype.getFormatCodeOptions = function (file) { + var formatCodeSettings; + if (file) { + var info = this.getScriptInfoForNormalizedPath(file); + if (info) { + formatCodeSettings = info.getFormatCodeSettings(); + } + } + return formatCodeSettings || this.hostConfiguration.formatCodeOptions; + }; + ProjectService.prototype.updateProjectGraphs = function (projects) { + var shouldRefreshInferredProjects = false; + for (var _i = 0, projects_2 = projects; _i < projects_2.length; _i++) { + var p = projects_2[_i]; + if (!p.updateGraph()) { + shouldRefreshInferredProjects = true; + } + } + if (shouldRefreshInferredProjects) { + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.onSourceFileChanged = function (fileName) { + var info = this.getScriptInfoForNormalizedPath(fileName); + if (!info) { + this.logger.info("Error: got watch notification for unknown file: " + fileName); + return; + } + if (!this.host.fileExists(fileName)) { + this.handleDeletedFile(info); + } + else { + if (info && (!info.isScriptOpen())) { + info.reloadFromFile(); + this.updateProjectGraphs(info.containingProjects); + } + } + }; + ProjectService.prototype.handleDeletedFile = function (info) { + this.logger.info(info.fileName + " deleted"); + info.stopWatcher(); + if (!info.isScriptOpen()) { + this.filenameToScriptInfo.remove(info.path); + this.lastDeletedFile = info; + var containingProjects = info.containingProjects.slice(); + info.detachAllProjects(); + this.updateProjectGraphs(containingProjects); + this.lastDeletedFile = undefined; + if (!this.eventHandler) { + return; + } + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var openFile = _a[_i]; + this.eventHandler({ + eventName: server.ContextEvent, + data: { project: openFile.getDefaultProject(), fileName: openFile.fileName } + }); + } + } + this.printProjects(); + }; + ProjectService.prototype.onTypeRootFileChanged = function (project, fileName) { + var _this = this; + this.logger.info("Type root file " + fileName + " changed"); + this.throttledOperations.schedule(project.getConfigFilePath() + " * type root", 250, function () { + project.updateTypes(); + _this.updateConfiguredProject(project); + _this.refreshInferredProjects(); + }); + }; + ProjectService.prototype.onSourceFileInDirectoryChangedForConfiguredProject = function (project, fileName) { + var _this = this; + if (fileName && !ts.isSupportedSourceFileName(fileName, project.getCompilerOptions(), this.hostConfiguration.extraFileExtensions)) { + return; + } + this.logger.info("Detected source file changes: " + fileName); + this.throttledOperations.schedule(project.getConfigFilePath(), 250, function () { return _this.handleChangeInSourceFileForConfiguredProject(project, fileName); }); + }; + ProjectService.prototype.handleChangeInSourceFileForConfiguredProject = function (project, triggerFile) { + var _this = this; + var _a = this.convertConfigFileContentToProjectOptions(project.getConfigFilePath()), projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; + this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors, triggerFile); + var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); })); + var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); })); + if (!ts.arrayIsEqualTo(currentRootFiles.sort(), newRootFiles.sort())) { + this.logger.info("Updating configured project"); + this.updateConfiguredProject(project); + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.onConfigChangedForConfiguredProject = function (project) { + var configFileName = project.getConfigFilePath(); + this.logger.info("Config file changed: " + configFileName); + var configFileErrors = this.updateConfiguredProject(project); + this.reportConfigFileDiagnostics(configFileName, configFileErrors, configFileName); + this.refreshInferredProjects(); + }; + ProjectService.prototype.onConfigFileAddedForInferredProject = function (fileName) { + if (ts.getBaseFileName(fileName) != "tsconfig.json") { + this.logger.info(fileName + " is not tsconfig.json"); + return; + } + var configFileErrors = this.convertConfigFileContentToProjectOptions(fileName).configFileErrors; + this.reportConfigFileDiagnostics(fileName, configFileErrors, fileName); + this.logger.info("Detected newly added tsconfig file: " + fileName); + this.reloadProjects(); + }; + ProjectService.prototype.getCanonicalFileName = function (fileName) { + var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return ts.normalizePath(name); + }; + ProjectService.prototype.removeProject = function (project) { + this.logger.info("remove project: " + project.getRootFiles().toString()); + project.close(); + switch (project.projectKind) { + case server.ProjectKind.External: + server.removeItemFromSet(this.externalProjects, project); + break; + case server.ProjectKind.Configured: + server.removeItemFromSet(this.configuredProjects, project); + break; + case server.ProjectKind.Inferred: + server.removeItemFromSet(this.inferredProjects, project); + break; + } + }; + ProjectService.prototype.assignScriptInfoToInferredProjectIfNecessary = function (info, addToListOfOpenFiles) { + var externalProject = this.findContainingExternalProject(info.fileName); + if (externalProject) { + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + return; + } + var foundConfiguredProject = false; + for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.projectKind === server.ProjectKind.Configured) { + foundConfiguredProject = true; + if (addToListOfOpenFiles) { + (p).addOpenRef(); + } + } + } + if (foundConfiguredProject) { + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + return; + } + if (info.containingProjects.length === 0) { + var inferredProject = this.createInferredProjectWithRootFileIfNecessary(info); + if (!this.useSingleInferredProject) { + for (var _b = 0, _c = this.openFiles; _b < _c.length; _b++) { + var f = _c[_b]; + if (f.containingProjects.length === 0) { + continue; + } + var defaultProject = f.getDefaultProject(); + if (isRootFileInInferredProject(info) && defaultProject !== inferredProject && inferredProject.containsScriptInfo(f)) { + this.removeProject(defaultProject); + f.attachToProject(inferredProject); + } + } + } + } + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + }; + ProjectService.prototype.closeOpenFile = function (info) { + info.close(); + server.removeItemFromSet(this.openFiles, info); + var projectsToRemove; + for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.projectKind === server.ProjectKind.Configured) { + if (info.hasMixedContent) { + info.registerFileUpdate(); + } + if (p.deleteOpenRef() === 0) { + (projectsToRemove || (projectsToRemove = [])).push(p); + } + } + else if (p.projectKind === server.ProjectKind.Inferred && p.isRoot(info)) { + (projectsToRemove || (projectsToRemove = [])).push(p); + } + if (!p.languageServiceEnabled) { + p.markAsDirty(); + } + } + if (projectsToRemove) { + for (var _b = 0, projectsToRemove_1 = projectsToRemove; _b < projectsToRemove_1.length; _b++) { + var project = projectsToRemove_1[_b]; + this.removeProject(project); + } + var orphanFiles = void 0; + for (var _c = 0, _d = this.openFiles; _c < _d.length; _c++) { + var f = _d[_c]; + if (f.containingProjects.length === 0) { + (orphanFiles || (orphanFiles = [])).push(f); + } + } + if (orphanFiles) { + for (var _e = 0, orphanFiles_1 = orphanFiles; _e < orphanFiles_1.length; _e++) { + var f = orphanFiles_1[_e]; + this.assignScriptInfoToInferredProjectIfNecessary(f, false); + } + } + } + if (info.containingProjects.length === 0) { + this.filenameToScriptInfo.remove(info.path); + } + }; + ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { + var searchPath = ts.getDirectoryPath(fileName); + this.logger.info("Search path: " + searchPath); + var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath)); + if (!configFileName) { + this.logger.info("No config files found."); + return {}; + } + this.logger.info("Config file name: " + configFileName); + var project = this.findConfiguredProjectByProjectName(configFileName); + if (!project) { + var _a = this.openConfigFile(configFileName, fileName), success = _a.success, errors = _a.errors; + if (!success) { + return { configFileName: configFileName, configFileErrors: errors }; + } + this.logger.info("Opened configuration file " + configFileName); + if (errors && errors.length > 0) { + return { configFileName: configFileName, configFileErrors: errors }; + } + } + else { + this.updateConfiguredProject(project); + } + return { configFileName: configFileName }; + }; + ProjectService.prototype.findConfigFile = function (searchPath) { + while (true) { + var tsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "tsconfig.json")); + if (this.host.fileExists(tsconfigFileName)) { + return tsconfigFileName; + } + var jsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "jsconfig.json")); + if (this.host.fileExists(jsconfigFileName)) { + return jsconfigFileName; + } + var parentPath = server.asNormalizedPath(ts.getDirectoryPath(searchPath)); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return undefined; + }; + ProjectService.prototype.printProjects = function () { + if (!this.logger.hasLevel(server.LogLevel.verbose)) { + return; + } + this.logger.startGroup(); + var counter = 0; + counter = printProjects(this.logger, this.externalProjects, counter); + counter = printProjects(this.logger, this.configuredProjects, counter); + counter = printProjects(this.logger, this.inferredProjects, counter); + this.logger.info("Open files: "); + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var rootFile = _a[_i]; + this.logger.info(rootFile.fileName); + } + this.logger.endGroup(); + function printProjects(logger, projects, counter) { + for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { + var project = projects_3[_i]; + project.updateGraph(); + logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); + logger.info(project.filesToString()); + logger.info("-----------------------------------------------"); + counter++; + } + return counter; + } + }; + ProjectService.prototype.findConfiguredProjectByProjectName = function (configFileName) { + configFileName = server.asNormalizedPath(this.toCanonicalFileName(configFileName)); + for (var _i = 0, _a = this.configuredProjects; _i < _a.length; _i++) { + var proj = _a[_i]; + if (proj.canonicalConfigFilePath === configFileName) { + return proj; + } + } + }; + ProjectService.prototype.findExternalProjectByProjectName = function (projectFileName) { + return findProjectByName(projectFileName, this.externalProjects); + }; + ProjectService.prototype.convertConfigFileContentToProjectOptions = function (configFilename) { + configFilename = ts.normalizePath(configFilename); + var configFileContent = this.host.readFile(configFilename); + var errors; + var result = ts.parseConfigFileTextToJson(configFilename, configFileContent); + var config = result.config; + if (result.error) { + var _a = ts.sanitizeConfigFile(configFilename, configFileContent), sanitizedConfig = _a.configJsonObject, diagnostics = _a.diagnostics; + config = sanitizedConfig; + errors = diagnostics.length ? diagnostics : [result.error]; + } + var parsedCommandLine = ts.parseJsonConfigFileContent(config, this.host, ts.getDirectoryPath(configFilename), {}, configFilename, [], this.hostConfiguration.extraFileExtensions); + if (parsedCommandLine.errors.length) { + errors = ts.concatenate(errors, parsedCommandLine.errors); + } + ts.Debug.assert(!!parsedCommandLine.fileNames); + if (parsedCommandLine.fileNames.length === 0) { + (errors || (errors = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename)); + return { success: false, configFileErrors: errors }; + } + var projectOptions = { + files: parsedCommandLine.fileNames, + compilerOptions: parsedCommandLine.options, + configHasFilesProperty: config["files"] !== undefined, + wildcardDirectories: ts.createMapFromTemplate(parsedCommandLine.wildcardDirectories), + typeAcquisition: parsedCommandLine.typeAcquisition, + compileOnSave: parsedCommandLine.compileOnSave + }; + return { success: true, projectOptions: projectOptions, configFileErrors: errors }; + }; + ProjectService.prototype.exceededTotalSizeLimitForNonTsFiles = function (options, fileNames, propertyReader) { + if (options && options.disableSizeLimit || !this.host.getFileSize) { + return false; + } + var totalNonTsFileSize = 0; + for (var _i = 0, fileNames_3 = fileNames; _i < fileNames_3.length; _i++) { + var f = fileNames_3[_i]; + var fileName = propertyReader.getFileName(f); + if (ts.hasTypeScriptFileExtension(fileName)) { + continue; + } + totalNonTsFileSize += this.host.getFileSize(fileName); + if (totalNonTsFileSize > server.maxProgramSizeForNonTsFiles) { + return true; + } + } + return false; + }; + ProjectService.prototype.createAndAddExternalProject = function (projectFileName, files, options, typeAcquisition) { + var compilerOptions = convertCompilerOptions(options); + var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, compilerOptions, !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); + this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, undefined, typeAcquisition, undefined); + this.externalProjects.push(project); + return project; + }; + ProjectService.prototype.reportConfigFileDiagnostics = function (configFileName, diagnostics, triggerFile) { + if (!this.eventHandler) { + return; + } + this.eventHandler({ + eventName: server.ConfigFileDiagEvent, + data: { configFileName: configFileName, diagnostics: diagnostics || [], triggerFile: triggerFile } + }); + }; + ProjectService.prototype.createAndAddConfiguredProject = function (configFileName, projectOptions, configFileErrors, clientFileName) { + var _this = this; + var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); + var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, projectOptions.wildcardDirectories, !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); + this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); + project.watchConfigFile(function (project) { return _this.onConfigChangedForConfiguredProject(project); }); + if (!sizeLimitExceeded) { + this.watchConfigDirectoryForProject(project, projectOptions); + } + project.watchWildcards(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); + project.watchTypeRoots(function (project, path) { return _this.onTypeRootFileChanged(project, path); }); + this.configuredProjects.push(project); + return project; + }; + ProjectService.prototype.watchConfigDirectoryForProject = function (project, options) { + var _this = this; + if (!options.configHasFilesProperty) { + project.watchConfigDirectory(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); + } + }; + ProjectService.prototype.addFilesToProjectAndUpdateGraph = function (project, files, propertyReader, clientFileName, typeAcquisition, configFileErrors) { + var errors; + for (var _i = 0, files_4 = files; _i < files_4.length; _i++) { + var f = files_4[_i]; + var rootFilename = propertyReader.getFileName(f); + var scriptKind = propertyReader.getScriptKind(f); + var hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); + if (this.host.fileExists(rootFilename)) { + var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFilename), clientFileName == rootFilename, undefined, scriptKind, hasMixedContent); + project.addRoot(info); + } + else { + (errors || (errors = [])).push(createFileNotFoundDiagnostic(rootFilename)); + } + } + project.setProjectErrors(ts.concatenate(configFileErrors, errors)); + project.setTypeAcquisition(typeAcquisition); + project.updateGraph(); + }; + ProjectService.prototype.openConfigFile = function (configFileName, clientFileName) { + var conversionResult = this.convertConfigFileContentToProjectOptions(configFileName); + var projectOptions = conversionResult.success + ? conversionResult.projectOptions + : { files: [], compilerOptions: {} }; + var project = this.createAndAddConfiguredProject(configFileName, projectOptions, conversionResult.configFileErrors, clientFileName); + return { + success: conversionResult.success, + project: project, + errors: project.getProjectErrors() + }; + }; + ProjectService.prototype.updateNonInferredProject = function (project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave, configFileErrors) { + var oldRootScriptInfos = project.getRootScriptInfos(); + var newRootScriptInfos = []; + var newRootScriptInfoMap = server.createNormalizedPathMap(); + var projectErrors; + var rootFilesChanged = false; + for (var _i = 0, newUncheckedFiles_1 = newUncheckedFiles; _i < newUncheckedFiles_1.length; _i++) { + var f = newUncheckedFiles_1[_i]; + var newRootFile = propertyReader.getFileName(f); + if (!this.host.fileExists(newRootFile)) { + (projectErrors || (projectErrors = [])).push(createFileNotFoundDiagnostic(newRootFile)); + continue; + } + var normalizedPath = server.toNormalizedPath(newRootFile); + var scriptInfo = this.getScriptInfoForNormalizedPath(normalizedPath); + if (!scriptInfo || !project.isRoot(scriptInfo)) { + rootFilesChanged = true; + if (!scriptInfo) { + var scriptKind = propertyReader.getScriptKind(f); + var hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); + scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, false, undefined, scriptKind, hasMixedContent); + } + } + newRootScriptInfos.push(scriptInfo); + newRootScriptInfoMap.set(scriptInfo.fileName, scriptInfo); + } + if (rootFilesChanged || newRootScriptInfos.length !== oldRootScriptInfos.length) { + var toAdd = void 0; + var toRemove = void 0; + for (var _a = 0, oldRootScriptInfos_1 = oldRootScriptInfos; _a < oldRootScriptInfos_1.length; _a++) { + var oldFile = oldRootScriptInfos_1[_a]; + if (!newRootScriptInfoMap.contains(oldFile.fileName)) { + (toRemove || (toRemove = [])).push(oldFile); + } + } + for (var _b = 0, newRootScriptInfos_1 = newRootScriptInfos; _b < newRootScriptInfos_1.length; _b++) { + var newFile = newRootScriptInfos_1[_b]; + if (!project.isRoot(newFile)) { + (toAdd || (toAdd = [])).push(newFile); + } + } + if (toRemove) { + for (var _c = 0, toRemove_1 = toRemove; _c < toRemove_1.length; _c++) { + var f = toRemove_1[_c]; + project.removeFile(f); + } + } + if (toAdd) { + for (var _d = 0, toAdd_1 = toAdd; _d < toAdd_1.length; _d++) { + var f = toAdd_1[_d]; + if (f.isScriptOpen() && isRootFileInInferredProject(f)) { + var inferredProject = f.containingProjects[0]; + inferredProject.removeFile(f); + if (!inferredProject.hasRoots()) { + this.removeProject(inferredProject); + } + } + project.addRoot(f); + } + } + } + project.setCompilerOptions(newOptions); + project.setTypeAcquisition(newTypeAcquisition); + if (compileOnSave !== undefined) { + project.compileOnSaveEnabled = compileOnSave; + } + project.setProjectErrors(ts.concatenate(configFileErrors, projectErrors)); + project.updateGraph(); + }; + ProjectService.prototype.updateConfiguredProject = function (project) { + if (!this.host.fileExists(project.getConfigFilePath())) { + this.logger.info("Config file deleted"); + this.removeProject(project); + return; + } + var _a = this.convertConfigFileContentToProjectOptions(project.getConfigFilePath()), success = _a.success, projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; + if (!success) { + this.updateNonInferredProject(project, [], fileNamePropertyReader, {}, {}, false, configFileErrors); + return configFileErrors; + } + if (this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { + project.setCompilerOptions(projectOptions.compilerOptions); + if (!project.languageServiceEnabled) { + return configFileErrors; + } + project.disableLanguageService(); + project.stopWatchingDirectory(); + } + else { + project.enableLanguageService(); + this.watchConfigDirectoryForProject(project, projectOptions); + this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typeAcquisition, projectOptions.compileOnSave, configFileErrors); + } + return configFileErrors; + }; + ProjectService.prototype.createInferredProjectWithRootFileIfNecessary = function (root) { + var _this = this; + var useExistingProject = this.useSingleInferredProject && this.inferredProjects.length; + var project = useExistingProject + ? this.inferredProjects[0] + : new server.InferredProject(this, this.documentRegistry, this.compilerOptionsForInferredProjects); + project.addRoot(root); + this.directoryWatchers.startWatchingContainingDirectoriesForFile(root.fileName, project, function (fileName) { return _this.onConfigFileAddedForInferredProject(fileName); }); + project.updateGraph(); + if (!useExistingProject) { + this.inferredProjects.push(project); + } + return project; + }; + ProjectService.prototype.getOrCreateScriptInfo = function (uncheckedFileName, openedByClient, fileContent, scriptKind) { + return this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName), openedByClient, fileContent, scriptKind); + }; + ProjectService.prototype.getScriptInfo = function (uncheckedFileName) { + return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + }; + ProjectService.prototype.getOrCreateScriptInfoForNormalizedPath = function (fileName, openedByClient, fileContent, scriptKind, hasMixedContent) { + var _this = this; + var info = this.getScriptInfoForNormalizedPath(fileName); + if (!info) { + if (openedByClient || this.host.fileExists(fileName)) { + info = new server.ScriptInfo(this.host, fileName, scriptKind, hasMixedContent); + this.filenameToScriptInfo.set(info.path, info); + if (openedByClient) { + if (fileContent === undefined) { + fileContent = this.host.readFile(fileName) || ""; + } + } + else { + if (!hasMixedContent) { + info.setWatcher(this.host.watchFile(fileName, function (_) { return _this.onSourceFileChanged(fileName); })); + } + } + } + } + if (info) { + if (openedByClient && !info.isScriptOpen()) { + info.open(fileContent); + if (hasMixedContent) { + info.registerFileUpdate(); + } + } + else if (fileContent !== undefined) { + info.reload(fileContent); + } + } + return info; + }; + ProjectService.prototype.getScriptInfoForNormalizedPath = function (fileName) { + return this.getScriptInfoForPath(server.normalizedPathToPath(fileName, this.host.getCurrentDirectory(), this.toCanonicalFileName)); + }; + ProjectService.prototype.getScriptInfoForPath = function (fileName) { + return this.filenameToScriptInfo.get(fileName); + }; + ProjectService.prototype.setHostConfiguration = function (args) { + if (args.file) { + var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file)); + if (info) { + info.setFormatOptions(convertFormatOptions(args.formatOptions)); + this.logger.info("Host configuration update for file " + args.file); + } + } + else { + if (args.hostInfo !== undefined) { + this.hostConfiguration.hostInfo = args.hostInfo; + this.logger.info("Host information " + args.hostInfo); + } + if (args.formatOptions) { + server.mergeMapLikes(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); + this.logger.info("Format host information updated"); + } + if (args.extraFileExtensions) { + this.hostConfiguration.extraFileExtensions = args.extraFileExtensions; + this.logger.info("Host file extension mappings updated"); + } + } + }; + ProjectService.prototype.closeLog = function () { + this.logger.close(); + }; + ProjectService.prototype.reloadProjects = function () { + this.logger.info("reload projects."); + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var info = _a[_i]; + this.openOrUpdateConfiguredProjectForFile(info.fileName); + } + this.refreshInferredProjects(); + }; + ProjectService.prototype.refreshInferredProjects = function () { + this.logger.info("updating project structure from ..."); + this.printProjects(); + var orphantedFiles = []; + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var info = _a[_i]; + if (info.containingProjects.length === 0) { + orphantedFiles.push(info); + } + else { + if (isRootFileInInferredProject(info) && info.containingProjects.length > 1) { + var inferredProject = info.containingProjects[0]; + ts.Debug.assert(inferredProject.projectKind === server.ProjectKind.Inferred); + inferredProject.removeFile(info); + if (!inferredProject.hasRoots()) { + this.removeProject(inferredProject); + } + } + } + } + for (var _b = 0, orphantedFiles_1 = orphantedFiles; _b < orphantedFiles_1.length; _b++) { + var f = orphantedFiles_1[_b]; + this.assignScriptInfoToInferredProjectIfNecessary(f, false); + } + for (var _c = 0, _d = this.inferredProjects; _c < _d.length; _c++) { + var p = _d[_c]; + p.updateGraph(); + } + this.printProjects(); + }; + ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind) { + return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind); + }; + ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent) { + var configFileName; + var configFileErrors; + var project = this.findContainingExternalProject(fileName); + if (!project) { + (_a = this.openOrUpdateConfiguredProjectForFile(fileName), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors); + if (configFileName) { + project = this.findConfiguredProjectByProjectName(configFileName); + } + } + if (project && !project.languageServiceEnabled) { + project.markAsDirty(); + } + var info = this.getOrCreateScriptInfoForNormalizedPath(fileName, true, fileContent, scriptKind, hasMixedContent); + this.assignScriptInfoToInferredProjectIfNecessary(info, true); + this.printProjects(); + return { configFileName: configFileName, configFileErrors: configFileErrors }; + var _a; + }; + ProjectService.prototype.closeClientFile = function (uncheckedFileName) { + var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + if (info) { + this.closeOpenFile(info); + } + this.printProjects(); + }; + ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { + var _loop_6 = function (proj) { + var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); + result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); + }; + for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { + var proj = currentProjects_1[_i]; + _loop_6(proj); + } + }; + ProjectService.prototype.synchronizeProjectList = function (knownProjects) { + var files = []; + this.collectChanges(knownProjects, this.externalProjects, files); + this.collectChanges(knownProjects, this.configuredProjects, files); + this.collectChanges(knownProjects, this.inferredProjects, files); + return files; + }; + ProjectService.prototype.applyChangesInOpenFiles = function (openFiles, changedFiles, closedFiles) { + var recordChangedFiles = changedFiles && !openFiles && !closedFiles; + if (openFiles) { + for (var _i = 0, openFiles_1 = openFiles; _i < openFiles_1.length; _i++) { + var file = openFiles_1[_i]; + var scriptInfo = this.getScriptInfo(file.fileName); + ts.Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen()); + var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName); + this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent); + } + } + if (changedFiles) { + for (var _a = 0, changedFiles_2 = changedFiles; _a < changedFiles_2.length; _a++) { + var file = changedFiles_2[_a]; + var scriptInfo = this.getScriptInfo(file.fileName); + ts.Debug.assert(!!scriptInfo); + for (var i = file.changes.length - 1; i >= 0; i--) { + var change = file.changes[i]; + scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText); + } + if (recordChangedFiles) { + if (!this.changedFiles) { + this.changedFiles = [scriptInfo]; + } + else if (this.changedFiles.indexOf(scriptInfo) < 0) { + this.changedFiles.push(scriptInfo); + } + } + } + } + if (closedFiles) { + for (var _b = 0, closedFiles_1 = closedFiles; _b < closedFiles_1.length; _b++) { + var file = closedFiles_1[_b]; + this.closeClientFile(file); + } + } + if (openFiles || closedFiles) { + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.closeConfiguredProject = function (configFile) { + var configuredProject = this.findConfiguredProjectByProjectName(configFile); + if (configuredProject && configuredProject.deleteOpenRef() === 0) { + this.removeProject(configuredProject); + } + }; + ProjectService.prototype.closeExternalProject = function (uncheckedFileName, suppressRefresh) { + if (suppressRefresh === void 0) { suppressRefresh = false; } + var fileName = server.toNormalizedPath(uncheckedFileName); + var configFiles = this.externalProjectToConfiguredProjectMap.get(fileName); + if (configFiles) { + var shouldRefreshInferredProjects = false; + for (var _i = 0, configFiles_1 = configFiles; _i < configFiles_1.length; _i++) { + var configFile = configFiles_1[_i]; + if (this.closeConfiguredProject(configFile)) { + shouldRefreshInferredProjects = true; + } + } + this.externalProjectToConfiguredProjectMap.delete(fileName); + if (shouldRefreshInferredProjects && !suppressRefresh) { + this.refreshInferredProjects(); + } + } + else { + var externalProject = this.findExternalProjectByProjectName(uncheckedFileName); + if (externalProject) { + this.removeProject(externalProject); + if (!suppressRefresh) { + this.refreshInferredProjects(); + } + } + } + }; + ProjectService.prototype.openExternalProjects = function (projects) { + var _this = this; + var projectsToClose = ts.arrayToMap(this.externalProjects, function (p) { return p.getProjectName(); }, function (_) { return true; }); + ts.forEachKey(this.externalProjectToConfiguredProjectMap, function (externalProjectName) { + projectsToClose.set(externalProjectName, true); + }); + for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { + var externalProject = projects_4[_i]; + this.openExternalProject(externalProject, true); + projectsToClose.delete(externalProject.projectFileName); + } + ts.forEachKey(projectsToClose, function (externalProjectName) { + _this.closeExternalProject(externalProjectName, true); + }); + this.refreshInferredProjects(); + }; + ProjectService.prototype.openExternalProject = function (proj, suppressRefreshOfInferredProjects) { + if (suppressRefreshOfInferredProjects === void 0) { suppressRefreshOfInferredProjects = false; } + if (proj.typingOptions && !proj.typeAcquisition) { + var typeAcquisition = ts.convertEnableAutoDiscoveryToEnable(proj.typingOptions); + proj.typeAcquisition = typeAcquisition; + } + var tsConfigFiles; + var rootFiles = []; + for (var _i = 0, _a = proj.rootFiles; _i < _a.length; _i++) { + var file = _a[_i]; + var normalized = server.toNormalizedPath(file.fileName); + if (ts.getBaseFileName(normalized) === "tsconfig.json") { + if (this.host.fileExists(normalized)) { + (tsConfigFiles || (tsConfigFiles = [])).push(normalized); + } + } + else { + rootFiles.push(file); + } + } + if (tsConfigFiles) { + tsConfigFiles.sort(); + } + var externalProject = this.findExternalProjectByProjectName(proj.projectFileName); + var exisingConfigFiles; + if (externalProject) { + if (!tsConfigFiles) { + var compilerOptions = convertCompilerOptions(proj.options); + if (this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, proj.rootFiles, externalFilePropertyReader)) { + externalProject.disableLanguageService(); + } + else { + externalProject.enableLanguageService(); + } + this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, compilerOptions, proj.typeAcquisition, proj.options.compileOnSave, undefined); + return; + } + this.closeExternalProject(proj.projectFileName, true); + } + else if (this.externalProjectToConfiguredProjectMap.get(proj.projectFileName)) { + if (!tsConfigFiles) { + this.closeExternalProject(proj.projectFileName, true); + } + else { + var oldConfigFiles = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName); + var iNew = 0; + var iOld = 0; + while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { + var newConfig = tsConfigFiles[iNew]; + var oldConfig = oldConfigFiles[iOld]; + if (oldConfig < newConfig) { + this.closeConfiguredProject(oldConfig); + iOld++; + } + else if (oldConfig > newConfig) { + iNew++; + } + else { + (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig); + iOld++; + iNew++; + } + } + for (var i = iOld; i < oldConfigFiles.length; i++) { + this.closeConfiguredProject(oldConfigFiles[i]); + } + } + } + if (tsConfigFiles) { + this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, tsConfigFiles); + for (var _b = 0, tsConfigFiles_1 = tsConfigFiles; _b < tsConfigFiles_1.length; _b++) { + var tsconfigFile = tsConfigFiles_1[_b]; + var project = this.findConfiguredProjectByProjectName(tsconfigFile); + if (!project) { + var result = this.openConfigFile(tsconfigFile); + project = result.success && result.project; + } + if (project && !ts.contains(exisingConfigFiles, tsconfigFile)) { + project.addOpenRef(); + } + } + } + else { + this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName); + this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); + } + if (!suppressRefreshOfInferredProjects) { + this.refreshInferredProjects(); + } + }; + return ProjectService; + }()); + server.ProjectService = ProjectService; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + server.nullCancellationToken = { + isCancellationRequested: function () { return false; }, + setRequest: function () { return void 0; }, + resetRequest: function () { return void 0; } + }; + function hrTimeToMilliseconds(time) { + var seconds = time[0]; + var nanoseconds = time[1]; + return ((1e9 * seconds) + nanoseconds) / 1000000.0; + } + function shouldSkipSematicCheck(project) { + if (project.getCompilerOptions().skipLibCheck !== undefined) { + return false; + } + if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && project.isJsOnlyProject()) { + return true; + } + return false; + } + function compareNumber(a, b) { + return a - b; + } + function compareFileStart(a, b) { + if (a.file < b.file) { + return -1; + } + else if (a.file == b.file) { + var n = compareNumber(a.start.line, b.start.line); + if (n === 0) { + return compareNumber(a.start.offset, b.start.offset); + } + else + return n; + } + else { + return 1; + } + } + function formatDiag(fileName, project, diag) { + var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); + return { + start: scriptInfo.positionToLineOffset(diag.start), + end: scriptInfo.positionToLineOffset(diag.start + diag.length), + text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), + code: diag.code + }; + } + function formatConfigFileDiag(diag) { + return { + start: undefined, + end: undefined, + text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") + }; + } + function allEditsBeforePos(edits, pos) { + for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { + var edit = edits_1[_i]; + if (ts.textSpanEnd(edit.span) >= pos) { + return false; + } + } + return true; + } + var CommandNames; + (function (CommandNames) { + CommandNames.Brace = "brace"; + CommandNames.BraceFull = "brace-full"; + CommandNames.BraceCompletion = "braceCompletion"; + CommandNames.Change = "change"; + CommandNames.Close = "close"; + CommandNames.Completions = "completions"; + CommandNames.CompletionsFull = "completions-full"; + CommandNames.CompletionDetails = "completionEntryDetails"; + CommandNames.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + CommandNames.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + CommandNames.Configure = "configure"; + CommandNames.Definition = "definition"; + CommandNames.DefinitionFull = "definition-full"; + CommandNames.Exit = "exit"; + CommandNames.Format = "format"; + CommandNames.Formatonkey = "formatonkey"; + CommandNames.FormatFull = "format-full"; + CommandNames.FormatonkeyFull = "formatonkey-full"; + CommandNames.FormatRangeFull = "formatRange-full"; + CommandNames.Geterr = "geterr"; + CommandNames.GeterrForProject = "geterrForProject"; + CommandNames.Implementation = "implementation"; + CommandNames.ImplementationFull = "implementation-full"; + CommandNames.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + CommandNames.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + CommandNames.NavBar = "navbar"; + CommandNames.NavBarFull = "navbar-full"; + CommandNames.NavTree = "navtree"; + CommandNames.NavTreeFull = "navtree-full"; + CommandNames.Navto = "navto"; + CommandNames.NavtoFull = "navto-full"; + CommandNames.Occurrences = "occurrences"; + CommandNames.DocumentHighlights = "documentHighlights"; + CommandNames.DocumentHighlightsFull = "documentHighlights-full"; + CommandNames.Open = "open"; + CommandNames.Quickinfo = "quickinfo"; + CommandNames.QuickinfoFull = "quickinfo-full"; + CommandNames.References = "references"; + CommandNames.ReferencesFull = "references-full"; + CommandNames.Reload = "reload"; + CommandNames.Rename = "rename"; + CommandNames.RenameInfoFull = "rename-full"; + CommandNames.RenameLocationsFull = "renameLocations-full"; + CommandNames.Saveto = "saveto"; + CommandNames.SignatureHelp = "signatureHelp"; + CommandNames.SignatureHelpFull = "signatureHelp-full"; + CommandNames.TypeDefinition = "typeDefinition"; + CommandNames.ProjectInfo = "projectInfo"; + CommandNames.ReloadProjects = "reloadProjects"; + CommandNames.Unknown = "unknown"; + CommandNames.OpenExternalProject = "openExternalProject"; + CommandNames.OpenExternalProjects = "openExternalProjects"; + CommandNames.CloseExternalProject = "closeExternalProject"; + CommandNames.SynchronizeProjectList = "synchronizeProjectList"; + CommandNames.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; + CommandNames.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; + CommandNames.Cleanup = "cleanup"; + CommandNames.OutliningSpans = "outliningSpans"; + CommandNames.TodoComments = "todoComments"; + CommandNames.Indentation = "indentation"; + CommandNames.DocCommentTemplate = "docCommentTemplate"; + CommandNames.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; + CommandNames.NameOrDottedNameSpan = "nameOrDottedNameSpan"; + CommandNames.BreakpointStatement = "breakpointStatement"; + CommandNames.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + CommandNames.GetCodeFixes = "getCodeFixes"; + CommandNames.GetCodeFixesFull = "getCodeFixes-full"; + CommandNames.GetSupportedCodeFixes = "getSupportedCodeFixes"; + })(CommandNames = server.CommandNames || (server.CommandNames = {})); + function formatMessage(msg, logger, byteLength, newLine) { + var verboseLogging = logger.hasLevel(server.LogLevel.verbose); + var json = JSON.stringify(msg); + if (verboseLogging) { + logger.info(msg.type + ": " + json); + } + var len = byteLength(json, "utf8"); + return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; + } + server.formatMessage = formatMessage; + var MultistepOperation = (function () { + function MultistepOperation(operationHost) { + var _this = this; + this.operationHost = operationHost; + this.completed = true; + this.next = { + immediate: function (action) { return _this.immediate(action); }, + delay: function (ms, action) { return _this.delay(ms, action); } + }; + } + MultistepOperation.prototype.startNew = function (action) { + this.complete(); + this.requestId = this.operationHost.getCurrentRequestId(); + this.completed = false; + this.executeAction(action); + }; + MultistepOperation.prototype.complete = function () { + if (!this.completed) { + if (this.requestId) { + this.operationHost.sendRequestCompletedEvent(this.requestId); + } + this.completed = true; + } + this.setTimerHandle(undefined); + this.setImmediateId(undefined); + }; + MultistepOperation.prototype.immediate = function (action) { + var _this = this; + var requestId = this.requestId; + ts.Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "immediate: incorrect request id"); + this.setImmediateId(this.operationHost.getServerHost().setImmediate(function () { + _this.immediateId = undefined; + _this.operationHost.executeWithRequestId(requestId, function () { return _this.executeAction(action); }); + })); + }; + MultistepOperation.prototype.delay = function (ms, action) { + var _this = this; + var requestId = this.requestId; + ts.Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "delay: incorrect request id"); + this.setTimerHandle(this.operationHost.getServerHost().setTimeout(function () { + _this.timerHandle = undefined; + _this.operationHost.executeWithRequestId(requestId, function () { return _this.executeAction(action); }); + }, ms)); + }; + MultistepOperation.prototype.executeAction = function (action) { + var stop = false; + try { + if (this.operationHost.isCancellationRequested()) { + stop = true; + } + else { + action(this.next); + } + } + catch (e) { + stop = true; + if (!(e instanceof ts.OperationCanceledException)) { + this.operationHost.logError(e, "delayed processing of request " + this.requestId); + } + } + if (stop || !this.hasPendingWork()) { + this.complete(); + } + }; + MultistepOperation.prototype.setTimerHandle = function (timerHandle) { + ; + if (this.timerHandle !== undefined) { + this.operationHost.getServerHost().clearTimeout(this.timerHandle); + } + this.timerHandle = timerHandle; + }; + MultistepOperation.prototype.setImmediateId = function (immediateId) { + if (this.immediateId !== undefined) { + this.operationHost.getServerHost().clearImmediate(this.immediateId); + } + this.immediateId = immediateId; + }; + MultistepOperation.prototype.hasPendingWork = function () { + return !!this.timerHandle || !!this.immediateId; + }; + return MultistepOperation; + }()); + var Session = (function () { + function Session(host, cancellationToken, useSingleInferredProject, typingsInstaller, byteLength, hrtime, logger, canUseEvents, eventHandler) { + var _this = this; + this.host = host; + this.cancellationToken = cancellationToken; + this.typingsInstaller = typingsInstaller; + this.byteLength = byteLength; + this.hrtime = hrtime; + this.logger = logger; + this.canUseEvents = canUseEvents; + this.changeSeq = 0; + this.handlers = ts.createMapFromTemplate((_a = {}, + _a[CommandNames.OpenExternalProject] = function (request) { + _this.projectService.openExternalProject(request.arguments, false); + return _this.requiredResponse(true); + }, + _a[CommandNames.OpenExternalProjects] = function (request) { + _this.projectService.openExternalProjects(request.arguments.projects); + return _this.requiredResponse(true); + }, + _a[CommandNames.CloseExternalProject] = function (request) { + _this.projectService.closeExternalProject(request.arguments.projectFileName); + return _this.requiredResponse(true); + }, + _a[CommandNames.SynchronizeProjectList] = function (request) { + var result = _this.projectService.synchronizeProjectList(request.arguments.knownProjects); + if (!result.some(function (p) { return p.projectErrors && p.projectErrors.length !== 0; })) { + return _this.requiredResponse(result); + } + var converted = ts.map(result, function (p) { + if (!p.projectErrors || p.projectErrors.length === 0) { + return p; + } + return { + info: p.info, + changes: p.changes, + files: p.files, + projectErrors: _this.convertToDiagnosticsWithLinePosition(p.projectErrors, undefined) + }; + }); + return _this.requiredResponse(converted); + }, + _a[CommandNames.ApplyChangedToOpenFiles] = function (request) { + _this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles); + _this.changeSeq++; + return _this.requiredResponse(true); + }, + _a[CommandNames.Exit] = function () { + _this.exit(); + return _this.notRequired(); + }, + _a[CommandNames.Definition] = function (request) { + return _this.requiredResponse(_this.getDefinition(request.arguments, true)); + }, + _a[CommandNames.DefinitionFull] = function (request) { + return _this.requiredResponse(_this.getDefinition(request.arguments, false)); + }, + _a[CommandNames.TypeDefinition] = function (request) { + return _this.requiredResponse(_this.getTypeDefinition(request.arguments)); + }, + _a[CommandNames.Implementation] = function (request) { + return _this.requiredResponse(_this.getImplementation(request.arguments, true)); + }, + _a[CommandNames.ImplementationFull] = function (request) { + return _this.requiredResponse(_this.getImplementation(request.arguments, false)); + }, + _a[CommandNames.References] = function (request) { + return _this.requiredResponse(_this.getReferences(request.arguments, true)); + }, + _a[CommandNames.ReferencesFull] = function (request) { + return _this.requiredResponse(_this.getReferences(request.arguments, false)); + }, + _a[CommandNames.Rename] = function (request) { + return _this.requiredResponse(_this.getRenameLocations(request.arguments, true)); + }, + _a[CommandNames.RenameLocationsFull] = function (request) { + return _this.requiredResponse(_this.getRenameLocations(request.arguments, false)); + }, + _a[CommandNames.RenameInfoFull] = function (request) { + return _this.requiredResponse(_this.getRenameInfo(request.arguments)); + }, + _a[CommandNames.Open] = function (request) { + _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName)); + return _this.notRequired(); + }, + _a[CommandNames.Quickinfo] = function (request) { + return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, true)); + }, + _a[CommandNames.QuickinfoFull] = function (request) { + return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, false)); + }, + _a[CommandNames.OutliningSpans] = function (request) { + return _this.requiredResponse(_this.getOutliningSpans(request.arguments)); + }, + _a[CommandNames.TodoComments] = function (request) { + return _this.requiredResponse(_this.getTodoComments(request.arguments)); + }, + _a[CommandNames.Indentation] = function (request) { + return _this.requiredResponse(_this.getIndentation(request.arguments)); + }, + _a[CommandNames.NameOrDottedNameSpan] = function (request) { + return _this.requiredResponse(_this.getNameOrDottedNameSpan(request.arguments)); + }, + _a[CommandNames.BreakpointStatement] = function (request) { + return _this.requiredResponse(_this.getBreakpointStatement(request.arguments)); + }, + _a[CommandNames.BraceCompletion] = function (request) { + return _this.requiredResponse(_this.isValidBraceCompletion(request.arguments)); + }, + _a[CommandNames.DocCommentTemplate] = function (request) { + return _this.requiredResponse(_this.getDocCommentTemplate(request.arguments)); + }, + _a[CommandNames.Format] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsForRange(request.arguments)); + }, + _a[CommandNames.Formatonkey] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsAfterKeystroke(request.arguments)); + }, + _a[CommandNames.FormatFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsForDocumentFull(request.arguments)); + }, + _a[CommandNames.FormatonkeyFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsAfterKeystrokeFull(request.arguments)); + }, + _a[CommandNames.FormatRangeFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsForRangeFull(request.arguments)); + }, + _a[CommandNames.Completions] = function (request) { + return _this.requiredResponse(_this.getCompletions(request.arguments, true)); + }, + _a[CommandNames.CompletionsFull] = function (request) { + return _this.requiredResponse(_this.getCompletions(request.arguments, false)); + }, + _a[CommandNames.CompletionDetails] = function (request) { + return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments)); + }, + _a[CommandNames.CompileOnSaveAffectedFileList] = function (request) { + return _this.requiredResponse(_this.getCompileOnSaveAffectedFileList(request.arguments)); + }, + _a[CommandNames.CompileOnSaveEmitFile] = function (request) { + return _this.requiredResponse(_this.emitFile(request.arguments)); + }, + _a[CommandNames.SignatureHelp] = function (request) { + return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, true)); + }, + _a[CommandNames.SignatureHelpFull] = function (request) { + return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, false)); + }, + _a[CommandNames.CompilerOptionsDiagnosticsFull] = function (request) { + return _this.requiredResponse(_this.getCompilerOptionsDiagnostics(request.arguments)); + }, + _a[CommandNames.EncodedSemanticClassificationsFull] = function (request) { + return _this.requiredResponse(_this.getEncodedSemanticClassifications(request.arguments)); + }, + _a[CommandNames.Cleanup] = function () { + _this.cleanup(); + return _this.requiredResponse(true); + }, + _a[CommandNames.SemanticDiagnosticsSync] = function (request) { + return _this.requiredResponse(_this.getSemanticDiagnosticsSync(request.arguments)); + }, + _a[CommandNames.SyntacticDiagnosticsSync] = function (request) { + return _this.requiredResponse(_this.getSyntacticDiagnosticsSync(request.arguments)); + }, + _a[CommandNames.Geterr] = function (request) { + _this.errorCheck.startNew(function (next) { return _this.getDiagnostics(next, request.arguments.delay, request.arguments.files); }); + return _this.notRequired(); + }, + _a[CommandNames.GeterrForProject] = function (request) { + _this.errorCheck.startNew(function (next) { return _this.getDiagnosticsForProject(next, request.arguments.delay, request.arguments.file); }); + return _this.notRequired(); + }, + _a[CommandNames.Change] = function (request) { + _this.change(request.arguments); + return _this.notRequired(); + }, + _a[CommandNames.Configure] = function (request) { + _this.projectService.setHostConfiguration(request.arguments); + _this.output(undefined, CommandNames.Configure, request.seq); + return _this.notRequired(); + }, + _a[CommandNames.Reload] = function (request) { + _this.reload(request.arguments, request.seq); + return _this.requiredResponse({ reloadFinished: true }); + }, + _a[CommandNames.Saveto] = function (request) { + var savetoArgs = request.arguments; + _this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); + return _this.notRequired(); + }, + _a[CommandNames.Close] = function (request) { + var closeArgs = request.arguments; + _this.closeClientFile(closeArgs.file); + return _this.notRequired(); + }, + _a[CommandNames.Navto] = function (request) { + return _this.requiredResponse(_this.getNavigateToItems(request.arguments, true)); + }, + _a[CommandNames.NavtoFull] = function (request) { + return _this.requiredResponse(_this.getNavigateToItems(request.arguments, false)); + }, + _a[CommandNames.Brace] = function (request) { + return _this.requiredResponse(_this.getBraceMatching(request.arguments, true)); + }, + _a[CommandNames.BraceFull] = function (request) { + return _this.requiredResponse(_this.getBraceMatching(request.arguments, false)); + }, + _a[CommandNames.NavBar] = function (request) { + return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, true)); + }, + _a[CommandNames.NavBarFull] = function (request) { + return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, false)); + }, + _a[CommandNames.NavTree] = function (request) { + return _this.requiredResponse(_this.getNavigationTree(request.arguments, true)); + }, + _a[CommandNames.NavTreeFull] = function (request) { + return _this.requiredResponse(_this.getNavigationTree(request.arguments, false)); + }, + _a[CommandNames.Occurrences] = function (request) { + return _this.requiredResponse(_this.getOccurrences(request.arguments)); + }, + _a[CommandNames.DocumentHighlights] = function (request) { + return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, true)); + }, + _a[CommandNames.DocumentHighlightsFull] = function (request) { + return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, false)); + }, + _a[CommandNames.CompilerOptionsForInferredProjects] = function (request) { + _this.setCompilerOptionsForInferredProjects(request.arguments); + return _this.requiredResponse(true); + }, + _a[CommandNames.ProjectInfo] = function (request) { + return _this.requiredResponse(_this.getProjectInfo(request.arguments)); + }, + _a[CommandNames.ReloadProjects] = function () { + _this.projectService.reloadProjects(); + return _this.notRequired(); + }, + _a[CommandNames.GetCodeFixes] = function (request) { + return _this.requiredResponse(_this.getCodeFixes(request.arguments, true)); + }, + _a[CommandNames.GetCodeFixesFull] = function (request) { + return _this.requiredResponse(_this.getCodeFixes(request.arguments, false)); + }, + _a[CommandNames.GetSupportedCodeFixes] = function () { + return _this.requiredResponse(_this.getSupportedCodeFixes()); + }, + _a)); + this.eventHander = canUseEvents + ? eventHandler || (function (event) { return _this.defaultEventHandler(event); }) + : undefined; + var multistepOperationHost = { + executeWithRequestId: function (requestId, action) { return _this.executeWithRequestId(requestId, action); }, + getCurrentRequestId: function () { return _this.currentRequestId; }, + getServerHost: function () { return _this.host; }, + logError: function (err, cmd) { return _this.logError(err, cmd); }, + sendRequestCompletedEvent: function (requestId) { return _this.sendRequestCompletedEvent(requestId); }, + isCancellationRequested: function () { return cancellationToken.isCancellationRequested(); } + }; + this.errorCheck = new MultistepOperation(multistepOperationHost); + this.projectService = new server.ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); + this.gcTimer = new server.GcTimer(host, 7000, logger); + var _a; + } + Session.prototype.sendRequestCompletedEvent = function (requestId) { + var event = { + seq: 0, + type: "event", + event: "requestCompleted", + body: { request_seq: requestId } + }; + this.send(event); + }; + Session.prototype.defaultEventHandler = function (event) { + var _this = this; + switch (event.eventName) { + case server.ContextEvent: + var _a = event.data, project_1 = _a.project, fileName_1 = _a.fileName; + this.projectService.logger.info("got context event, updating diagnostics for " + fileName_1); + this.errorCheck.startNew(function (next) { return _this.updateErrorCheck(next, [{ fileName: fileName_1, project: project_1 }], _this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); }); + break; + case server.ConfigFileDiagEvent: + var _b = event.data, triggerFile = _b.triggerFile, configFileName = _b.configFileName, diagnostics = _b.diagnostics; + this.configFileDiagnosticEvent(triggerFile, configFileName, diagnostics); + break; + case server.ProjectLanguageServiceStateEvent: + var eventName = "projectLanguageServiceState"; + this.event({ + projectName: event.data.project.getProjectName(), + languageServiceEnabled: event.data.languageServiceEnabled + }, eventName); + break; + } + }; + Session.prototype.logError = function (err, cmd) { + var msg = "Exception on executing command " + cmd; + if (err.message) { + msg += ":\n" + err.message; + if (err.stack) { + msg += "\n" + err.stack; + } + } + this.logger.msg(msg, server.Msg.Err); + }; + Session.prototype.send = function (msg) { + if (msg.type === "event" && !this.canUseEvents) { + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("Session does not support events: ignored event: " + JSON.stringify(msg)); + } + return; + } + this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine)); + }; + Session.prototype.configFileDiagnosticEvent = function (triggerFile, configFile, diagnostics) { + var bakedDiags = ts.map(diagnostics, formatConfigFileDiag); + var ev = { + seq: 0, + type: "event", + event: "configFileDiag", + body: { + triggerFile: triggerFile, + configFile: configFile, + diagnostics: bakedDiags + } + }; + this.send(ev); + }; + Session.prototype.event = function (info, eventName) { + var ev = { + seq: 0, + type: "event", + event: eventName, + body: info + }; + this.send(ev); + }; + Session.prototype.output = function (info, cmdName, reqSeq, errorMsg) { + if (reqSeq === void 0) { reqSeq = 0; } + var res = { + seq: 0, + type: "response", + command: cmdName, + request_seq: reqSeq, + success: !errorMsg, + }; + if (!errorMsg) { + res.body = info; + } + else { + res.message = errorMsg; + } + this.send(res); + }; + Session.prototype.semanticCheck = function (file, project) { + try { + var diags = []; + if (!shouldSkipSematicCheck(project)) { + diags = project.getLanguageService().getSemanticDiagnostics(file); + } + var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); + this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); + } + catch (err) { + this.logError(err, "semantic check"); + } + }; + Session.prototype.syntacticCheck = function (file, project) { + try { + var diags = project.getLanguageService().getSyntacticDiagnostics(file); + if (diags) { + var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); + this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag"); + } + } + catch (err) { + this.logError(err, "syntactic check"); + } + }; + Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { + var _this = this; + if (ms === void 0) { ms = 1500; } + this.host.setTimeout(function () { + if (matchSeq(seq)) { + _this.projectService.refreshInferredProjects(); + } + }, ms); + }; + Session.prototype.updateErrorCheck = function (next, checkList, seq, matchSeq, ms, followMs, requireOpen) { + var _this = this; + if (ms === void 0) { ms = 1500; } + if (followMs === void 0) { followMs = 200; } + if (requireOpen === void 0) { requireOpen = true; } + if (followMs > ms) { + followMs = ms; + } + var index = 0; + var checkOne = function () { + if (matchSeq(seq)) { + var checkSpec_1 = checkList[index]; + index++; + if (checkSpec_1.project.containsFile(checkSpec_1.fileName, requireOpen)) { + _this.syntacticCheck(checkSpec_1.fileName, checkSpec_1.project); + next.immediate(function () { + _this.semanticCheck(checkSpec_1.fileName, checkSpec_1.project); + if (checkList.length > index) { + next.delay(followMs, checkOne); + } + }); + } + } + }; + if ((checkList.length > index) && (matchSeq(seq))) { + next.delay(ms, checkOne); + } + }; + Session.prototype.cleanProjects = function (caption, projects) { + if (!projects) { + return; + } + this.logger.info("cleaning " + caption); + for (var _i = 0, projects_5 = projects; _i < projects_5.length; _i++) { + var p = projects_5[_i]; + p.getLanguageService(false).cleanupSemanticCache(); + } + }; + Session.prototype.cleanup = function () { + this.cleanProjects("inferred projects", this.projectService.inferredProjects); + this.cleanProjects("configured projects", this.projectService.configuredProjects); + this.cleanProjects("external projects", this.projectService.externalProjects); + if (this.host.gc) { + this.logger.info("host.gc()"); + this.host.gc(); + } + }; + Session.prototype.getEncodedSemanticClassifications = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + return project.getLanguageService().getEncodedSemanticClassifications(file, args); + }; + Session.prototype.getProject = function (projectFileName) { + return projectFileName && this.projectService.findProject(projectFileName); + }; + Session.prototype.getCompilerOptionsDiagnostics = function (args) { + var project = this.getProject(args.projectFileName); + return this.convertToDiagnosticsWithLinePosition(project.getLanguageService().getCompilerOptionsDiagnostics(), undefined); + }; + Session.prototype.convertToDiagnosticsWithLinePosition = function (diagnostics, scriptInfo) { + var _this = this; + return diagnostics.map(function (d) { return ({ + message: ts.flattenDiagnosticMessageText(d.messageText, _this.host.newLine), + start: d.start, + length: d.length, + category: ts.DiagnosticCategory[d.category].toLowerCase(), + code: d.code, + startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start), + endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length) + }); }); + }; + Session.prototype.getDiagnosticsWorker = function (args, isSemantic, selector, includeLinePosition) { + var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; + if (isSemantic && shouldSkipSematicCheck(project)) { + return []; + } + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var diagnostics = selector(project, file); + return includeLinePosition + ? this.convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo) + : diagnostics.map(function (d) { return formatDiag(file, project, d); }); + }; + Session.prototype.getDefinition = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var definitions = project.getLanguageService().getDefinitionAtPosition(file, position); + if (!definitions) { + return undefined; + } + if (simplifiedResult) { + return definitions.map(function (def) { + var defScriptInfo = project.getScriptInfo(def.fileName); + return { + file: def.fileName, + start: defScriptInfo.positionToLineOffset(def.textSpan.start), + end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) + }; + }); + } + else { + return definitions; + } + }; + Session.prototype.getTypeDefinition = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var definitions = project.getLanguageService().getTypeDefinitionAtPosition(file, position); + if (!definitions) { + return undefined; + } + return definitions.map(function (def) { + var defScriptInfo = project.getScriptInfo(def.fileName); + return { + file: def.fileName, + start: defScriptInfo.positionToLineOffset(def.textSpan.start), + end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) + }; + }); + }; + Session.prototype.getImplementation = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + var implementations = project.getLanguageService().getImplementationAtPosition(file, position); + if (!implementations) { + return []; + } + if (simplifiedResult) { + return implementations.map(function (_a) { + var fileName = _a.fileName, textSpan = _a.textSpan; + var scriptInfo = project.getScriptInfo(fileName); + return { + file: fileName, + start: scriptInfo.positionToLineOffset(textSpan.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)) + }; + }); + } + else { + return implementations; + } + }; + Session.prototype.getOccurrences = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position); + if (!occurrences) { + return undefined; + } + return occurrences.map(function (occurrence) { + var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan; + var scriptInfo = project.getScriptInfo(fileName); + var start = scriptInfo.positionToLineOffset(textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); + return { + start: start, + end: end, + file: fileName, + isWriteAccess: isWriteAccess, + }; + }); + }; + Session.prototype.getSyntacticDiagnosticsSync = function (args) { + return this.getDiagnosticsWorker(args, false, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); + }; + Session.prototype.getSemanticDiagnosticsSync = function (args) { + return this.getDiagnosticsWorker(args, true, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, args.includeLinePosition); + }; + Session.prototype.getDocumentHighlights = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var documentHighlights = project.getLanguageService().getDocumentHighlights(file, position, args.filesToSearch); + if (!documentHighlights) { + return undefined; + } + if (simplifiedResult) { + return documentHighlights.map(convertToDocumentHighlightsItem); + } + else { + return documentHighlights; + } + function convertToDocumentHighlightsItem(documentHighlights) { + var fileName = documentHighlights.fileName, highlightSpans = documentHighlights.highlightSpans; + var scriptInfo = project.getScriptInfo(fileName); + return { + file: fileName, + highlightSpans: highlightSpans.map(convertHighlightSpan) + }; + function convertHighlightSpan(highlightSpan) { + var textSpan = highlightSpan.textSpan, kind = highlightSpan.kind; + var start = scriptInfo.positionToLineOffset(textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); + return { start: start, end: end, kind: kind }; + } + } + }; + Session.prototype.setCompilerOptionsForInferredProjects = function (args) { + this.projectService.setCompilerOptionsForInferredProjects(args.options); + }; + Session.prototype.getProjectInfo = function (args) { + return this.getProjectInfoWorker(args.file, args.projectFileName, args.needFileNameList); + }; + Session.prototype.getProjectInfoWorker = function (uncheckedFileName, projectFileName, needFileNameList) { + var project = this.getFileAndProjectWorker(uncheckedFileName, projectFileName, true, true).project; + var projectInfo = { + configFileName: project.getProjectName(), + languageServiceDisabled: !project.languageServiceEnabled, + fileNames: needFileNameList ? project.getFileNames() : undefined + }; + return projectInfo; + }; + Session.prototype.getRenameInfo = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + return project.getLanguageService().getRenameInfo(file, position); + }; + Session.prototype.getProjects = function (args) { + var projects; + if (args.projectFileName) { + var project = this.getProject(args.projectFileName); + if (project) { + projects = [project]; + } + } + else { + var scriptInfo = this.projectService.getScriptInfo(args.file); + projects = scriptInfo.containingProjects; + } + projects = ts.filter(projects, function (p) { return p.languageServiceEnabled; }); + if (!projects || !projects.length) { + return server.Errors.ThrowNoProject(); + } + return projects; + }; + Session.prototype.getRenameLocations = function (args, simplifiedResult) { + var file = server.toNormalizedPath(args.file); + var info = this.projectService.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, info); + var projects = this.getProjects(args); + if (simplifiedResult) { + var defaultProject = projects[0]; + var renameInfo = defaultProject.getLanguageService().getRenameInfo(file, position); + if (!renameInfo) { + return undefined; + } + if (!renameInfo.canRename) { + return { + info: renameInfo, + locs: [] + }; + } + var fileSpans = server.combineProjectOutput(projects, function (project) { + var renameLocations = project.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); + if (!renameLocations) { + return []; + } + return renameLocations.map(function (location) { + var locationScriptInfo = project.getScriptInfo(location.fileName); + return { + file: location.fileName, + start: locationScriptInfo.positionToLineOffset(location.textSpan.start), + end: locationScriptInfo.positionToLineOffset(ts.textSpanEnd(location.textSpan)), + }; + }); + }, compareRenameLocation, function (a, b) { return a.file === b.file && a.start.line === b.start.line && a.start.offset === b.start.offset; }); + var locs = fileSpans.reduce(function (accum, cur) { + var curFileAccum; + if (accum.length > 0) { + curFileAccum = accum[accum.length - 1]; + if (curFileAccum.file !== cur.file) { + curFileAccum = undefined; + } + } + if (!curFileAccum) { + curFileAccum = { file: cur.file, locs: [] }; + accum.push(curFileAccum); + } + curFileAccum.locs.push({ start: cur.start, end: cur.end }); + return accum; + }, []); + return { info: renameInfo, locs: locs }; + } + else { + return server.combineProjectOutput(projects, function (p) { return p.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); }, undefined, renameLocationIsEqualTo); + } + function renameLocationIsEqualTo(a, b) { + if (a === b) { + return true; + } + if (!a || !b) { + return false; + } + return a.fileName === b.fileName && + a.textSpan.start === b.textSpan.start && + a.textSpan.length === b.textSpan.length; + } + function compareRenameLocation(a, b) { + if (a.file < b.file) { + return -1; + } + else if (a.file > b.file) { + return 1; + } + else { + if (a.start.line < b.start.line) { + return 1; + } + else if (a.start.line > b.start.line) { + return -1; + } + else { + return b.start.offset - a.start.offset; + } + } + } + }; + Session.prototype.getReferences = function (args, simplifiedResult) { + var file = server.toNormalizedPath(args.file); + var projects = this.getProjects(args); + var defaultProject = projects[0]; + var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + if (simplifiedResult) { + var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); + if (!nameInfo) { + return undefined; + } + var displayString = ts.displayPartsToString(nameInfo.displayParts); + var nameSpan = nameInfo.textSpan; + var nameColStart = scriptInfo.positionToLineOffset(nameSpan.start).offset; + var nameText = scriptInfo.getSnapshot().getText(nameSpan.start, ts.textSpanEnd(nameSpan)); + var refs = server.combineProjectOutput(projects, function (project) { + var references = project.getLanguageService().getReferencesAtPosition(file, position); + if (!references) { + return []; + } + return references.map(function (ref) { + var refScriptInfo = project.getScriptInfo(ref.fileName); + var start = refScriptInfo.positionToLineOffset(ref.textSpan.start); + var refLineSpan = refScriptInfo.lineToTextSpan(start.line - 1); + var lineText = refScriptInfo.getSnapshot().getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); + return { + file: ref.fileName, + start: start, + lineText: lineText, + end: refScriptInfo.positionToLineOffset(ts.textSpanEnd(ref.textSpan)), + isWriteAccess: ref.isWriteAccess, + isDefinition: ref.isDefinition + }; + }); + }, compareFileStart, areReferencesResponseItemsForTheSameLocation); + return { + refs: refs, + symbolName: nameText, + symbolStartOffset: nameColStart, + symbolDisplayString: displayString + }; + } + else { + return server.combineProjectOutput(projects, function (project) { return project.getLanguageService().findReferences(file, position); }, undefined, undefined); + } + function areReferencesResponseItemsForTheSameLocation(a, b) { + if (a && b) { + return a.file === b.file && + a.start === b.start && + a.end === b.end; + } + return false; + } + }; + Session.prototype.openClientFile = function (fileName, fileContent, scriptKind) { + var _a = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; + if (this.eventHander) { + this.eventHander({ + eventName: "configFileDiag", + data: { triggerFile: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } + }); + } + }; + Session.prototype.getPosition = function (args, scriptInfo) { + return args.position !== undefined ? args.position : scriptInfo.lineOffsetToPosition(args.line, args.offset); + }; + Session.prototype.getFileAndProject = function (args, errorOnMissingProject) { + if (errorOnMissingProject === void 0) { errorOnMissingProject = true; } + return this.getFileAndProjectWorker(args.file, args.projectFileName, true, errorOnMissingProject); + }; + Session.prototype.getFileAndProjectWithoutRefreshingInferredProjects = function (args, errorOnMissingProject) { + if (errorOnMissingProject === void 0) { errorOnMissingProject = true; } + return this.getFileAndProjectWorker(args.file, args.projectFileName, false, errorOnMissingProject); + }; + Session.prototype.getFileAndProjectWorker = function (uncheckedFileName, projectFileName, refreshInferredProjects, errorOnMissingProject) { + var file = server.toNormalizedPath(uncheckedFileName); + var project = this.getProject(projectFileName) || this.projectService.getDefaultProjectForFile(file, refreshInferredProjects); + if (!project && errorOnMissingProject) { + return server.Errors.ThrowNoProject(); + } + return { file: file, project: project }; + }; + Session.prototype.getOutliningSpans = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + return project.getLanguageService(false).getOutliningSpans(file); + }; + Session.prototype.getTodoComments = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + return project.getLanguageService().getTodoComments(file, args.descriptors); + }; + Session.prototype.getDocCommentTemplate = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + return project.getLanguageService(false).getDocCommentTemplateAtPosition(file, position); + }; + Session.prototype.getIndentation = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); + var indentation = project.getLanguageService(false).getIndentationAtPosition(file, position, options); + return { position: position, indentation: indentation }; + }; + Session.prototype.getBreakpointStatement = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + return project.getLanguageService(false).getBreakpointStatementAtPosition(file, position); + }; + Session.prototype.getNameOrDottedNameSpan = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + return project.getLanguageService(false).getNameOrDottedNameSpan(file, position, position); + }; + Session.prototype.isValidBraceCompletion = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + return project.getLanguageService(false).isValidBraceCompletionAtPosition(file, position, args.openingBrace.charCodeAt(0)); + }; + Session.prototype.getQuickInfoWorker = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var quickInfo = project.getLanguageService().getQuickInfoAtPosition(file, this.getPosition(args, scriptInfo)); + if (!quickInfo) { + return undefined; + } + if (simplifiedResult) { + var displayString = ts.displayPartsToString(quickInfo.displayParts); + var docString = ts.displayPartsToString(quickInfo.documentation); + return { + kind: quickInfo.kind, + kindModifiers: quickInfo.kindModifiers, + start: scriptInfo.positionToLineOffset(quickInfo.textSpan.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), + displayString: displayString, + documentation: docString, + }; + } + else { + return quickInfo; + } + }; + Session.prototype.getFormattingEditsForRange = function (args) { + var _this = this; + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var startPosition = scriptInfo.lineOffsetToPosition(args.line, args.offset); + var endPosition = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); + var edits = project.getLanguageService(false).getFormattingEditsForRange(file, startPosition, endPosition, this.projectService.getFormatCodeOptions(file)); + if (!edits) { + return undefined; + } + return edits.map(function (edit) { return _this.convertTextChangeToCodeEdit(edit, scriptInfo); }); + }; + Session.prototype.getFormattingEditsForRangeFull = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); + return project.getLanguageService(false).getFormattingEditsForRange(file, args.position, args.endPosition, options); + }; + Session.prototype.getFormattingEditsForDocumentFull = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); + return project.getLanguageService(false).getFormattingEditsForDocument(file, options); + }; + Session.prototype.getFormattingEditsAfterKeystrokeFull = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); + return project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, args.position, args.key, options); + }; + Session.prototype.getFormattingEditsAfterKeystroke = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = scriptInfo.lineOffsetToPosition(args.line, args.offset); + var formatOptions = this.projectService.getFormatCodeOptions(file); + var edits = project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, position, args.key, formatOptions); + if ((args.key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { + var lineInfo = scriptInfo.getLineInfo(args.line); + if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { + var lineText = lineInfo.leaf.text; + if (lineText.search("\\S") < 0) { + var preferredIndent = project.getLanguageService(false).getIndentationAtPosition(file, position, formatOptions); + var hasIndent = 0; + var i = void 0, len = void 0; + for (i = 0, len = lineText.length; i < len; i++) { + if (lineText.charAt(i) == " ") { + hasIndent++; + } + else if (lineText.charAt(i) == "\t") { + hasIndent += formatOptions.tabSize; + } + else { + break; + } + } + if (preferredIndent !== hasIndent) { + var firstNoWhiteSpacePosition = lineInfo.offset + i; + edits.push({ + span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition), + newText: ts.formatting.getIndentationString(preferredIndent, formatOptions) + }); + } + } + } + } + if (!edits) { + return undefined; + } + return edits.map(function (edit) { + return { + start: scriptInfo.positionToLineOffset(edit.span.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(edit.span)), + newText: edit.newText ? edit.newText : "" + }; + }); + }; + Session.prototype.getCompletions = function (args, simplifiedResult) { + var _this = this; + var prefix = args.prefix || ""; + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var completions = project.getLanguageService().getCompletionsAtPosition(file, position); + if (!completions) { + return undefined; + } + if (simplifiedResult) { + return completions.entries.reduce(function (result, entry) { + if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { + var name = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; + var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; + result.push({ name: name, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); + } + return result; + }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); + } + else { + return completions; + } + }; + Session.prototype.getCompletionEntryDetails = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + return args.entryNames.reduce(function (accum, entryName) { + var details = project.getLanguageService().getCompletionEntryDetails(file, position, entryName); + if (details) { + accum.push(details); + } + return accum; + }, []); + }; + Session.prototype.getCompileOnSaveAffectedFileList = function (args) { + var info = this.projectService.getScriptInfo(args.file); + var result = []; + if (!info) { + return []; + } + var projectsToSearch = args.projectFileName ? [this.projectService.findProject(args.projectFileName)] : info.containingProjects; + for (var _i = 0, projectsToSearch_1 = projectsToSearch; _i < projectsToSearch_1.length; _i++) { + var project = projectsToSearch_1[_i]; + if (project.compileOnSaveEnabled && project.languageServiceEnabled) { + result.push({ + projectFileName: project.getProjectName(), + fileNames: project.getCompileOnSaveAffectedFileList(info), + projectUsesOutFile: !!project.getCompilerOptions().outFile || !!project.getCompilerOptions().out + }); + } + } + return result; + }; + Session.prototype.emitFile = function (args) { + var _this = this; + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + if (!project) { + server.Errors.ThrowNoProject(); + } + if (!project.languageServiceEnabled) { + return false; + } + var scriptInfo = project.getScriptInfo(file); + return project.builder.emitFile(scriptInfo, function (path, data, writeByteOrderMark) { return _this.host.writeFile(path, data, writeByteOrderMark); }); + }; + Session.prototype.getSignatureHelpItems = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var helpItems = project.getLanguageService().getSignatureHelpItems(file, position); + if (!helpItems) { + return undefined; + } + if (simplifiedResult) { + var span_16 = helpItems.applicableSpan; + return { + items: helpItems.items, + applicableSpan: { + start: scriptInfo.positionToLineOffset(span_16.start), + end: scriptInfo.positionToLineOffset(span_16.start + span_16.length) + }, + selectedItemIndex: helpItems.selectedItemIndex, + argumentIndex: helpItems.argumentIndex, + argumentCount: helpItems.argumentCount, + }; + } + else { + return helpItems; + } + }; + Session.prototype.getDiagnostics = function (next, delay, fileNames) { + var _this = this; + var checkList = fileNames.reduce(function (accum, uncheckedFileName) { + var fileName = server.toNormalizedPath(uncheckedFileName); + var project = _this.projectService.getDefaultProjectForFile(fileName, true); + if (project) { + accum.push({ fileName: fileName, project: project }); + } + return accum; + }, []); + if (checkList.length > 0) { + this.updateErrorCheck(next, checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); + } + }; + Session.prototype.change = function (args) { + var _this = this; + var _a = this.getFileAndProject(args, false), file = _a.file, project = _a.project; + if (project) { + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var start = scriptInfo.lineOffsetToPosition(args.line, args.offset); + var end = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); + if (start >= 0) { + scriptInfo.editContent(start, end, args.insertString); + this.changeSeq++; + } + this.updateProjectStructure(this.changeSeq, function (n) { return n === _this.changeSeq; }); + } + }; + Session.prototype.reload = function (args, reqSeq) { + var file = server.toNormalizedPath(args.file); + var tempFileName = args.tmpfile && server.toNormalizedPath(args.tmpfile); + var project = this.projectService.getDefaultProjectForFile(file, true); + if (project) { + this.changeSeq++; + if (project.reloadScript(file, tempFileName)) { + this.output(undefined, CommandNames.Reload, reqSeq); + } + } + }; + Session.prototype.saveToTmp = function (fileName, tempFileName) { + var scriptInfo = this.projectService.getScriptInfo(fileName); + if (scriptInfo) { + scriptInfo.saveTo(tempFileName); + } + }; + Session.prototype.closeClientFile = function (fileName) { + if (!fileName) { + return; + } + var file = ts.normalizePath(fileName); + this.projectService.closeClientFile(file); + }; + Session.prototype.decorateNavigationBarItems = function (items, scriptInfo) { + var _this = this; + return ts.map(items, function (item) { return ({ + text: item.text, + kind: item.kind, + kindModifiers: item.kindModifiers, + spans: item.spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }), + childItems: _this.decorateNavigationBarItems(item.childItems, scriptInfo), + indent: item.indent + }); }); + }; + Session.prototype.getNavigationBarItems = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var items = project.getLanguageService(false).getNavigationBarItems(file); + return !items + ? undefined + : simplifiedResult + ? this.decorateNavigationBarItems(items, project.getScriptInfoForNormalizedPath(file)) + : items; + }; + Session.prototype.decorateNavigationTree = function (tree, scriptInfo) { + var _this = this; + return { + text: tree.text, + kind: tree.kind, + kindModifiers: tree.kindModifiers, + spans: tree.spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }), + childItems: ts.map(tree.childItems, function (item) { return _this.decorateNavigationTree(item, scriptInfo); }) + }; + }; + Session.prototype.decorateSpan = function (span, scriptInfo) { + return { + start: scriptInfo.positionToLineOffset(span.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(span)) + }; + }; + Session.prototype.getNavigationTree = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var tree = project.getLanguageService(false).getNavigationTree(file); + return !tree + ? undefined + : simplifiedResult + ? this.decorateNavigationTree(tree, project.getScriptInfoForNormalizedPath(file)) + : tree; + }; + Session.prototype.getNavigateToItems = function (args, simplifiedResult) { + var projects = this.getProjects(args); + var fileName = args.currentFileOnly ? args.file && ts.normalizeSlashes(args.file) : undefined; + if (simplifiedResult) { + return server.combineProjectOutput(projects, function (project) { + var navItems = project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); + if (!navItems) { + return []; + } + return navItems.map(function (navItem) { + var scriptInfo = project.getScriptInfo(navItem.fileName); + var start = scriptInfo.positionToLineOffset(navItem.textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(navItem.textSpan)); + var bakedItem = { + name: navItem.name, + kind: navItem.kind, + file: navItem.fileName, + start: start, + end: end, + }; + if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { + bakedItem.kindModifiers = navItem.kindModifiers; + } + if (navItem.matchKind !== "none") { + bakedItem.matchKind = navItem.matchKind; + } + if (navItem.containerName && (navItem.containerName.length > 0)) { + bakedItem.containerName = navItem.containerName; + } + if (navItem.containerKind && (navItem.containerKind.length > 0)) { + bakedItem.containerKind = navItem.containerKind; + } + return bakedItem; + }); + }, undefined, areNavToItemsForTheSameLocation); + } + else { + return server.combineProjectOutput(projects, function (project) { return project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); }, undefined, navigateToItemIsEqualTo); + } + function navigateToItemIsEqualTo(a, b) { + if (a === b) { + return true; + } + if (!a || !b) { + return false; + } + return a.containerKind === b.containerKind && + a.containerName === b.containerName && + a.fileName === b.fileName && + a.isCaseSensitive === b.isCaseSensitive && + a.kind === b.kind && + a.kindModifiers === b.containerName && + a.matchKind === b.matchKind && + a.name === b.name && + a.textSpan.start === b.textSpan.start && + a.textSpan.length === b.textSpan.length; + } + function areNavToItemsForTheSameLocation(a, b) { + if (a && b) { + return a.file === b.file && + a.start === b.start && + a.end === b.end; + } + return false; + } + }; + Session.prototype.getSupportedCodeFixes = function () { + return ts.getSupportedCodeFixes(); + }; + Session.prototype.getCodeFixes = function (args, simplifiedResult) { + var _this = this; + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var startPosition = getStartPosition(); + var endPosition = getEndPosition(); + var codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes); + if (!codeActions) { + return undefined; + } + if (simplifiedResult) { + return codeActions.map(function (codeAction) { return _this.mapCodeAction(codeAction, scriptInfo); }); + } + else { + return codeActions; + } + function getStartPosition() { + return args.startPosition !== undefined ? args.startPosition : scriptInfo.lineOffsetToPosition(args.startLine, args.startOffset); + } + function getEndPosition() { + return args.endPosition !== undefined ? args.endPosition : scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); + } + }; + Session.prototype.mapCodeAction = function (codeAction, scriptInfo) { + var _this = this; + return { + description: codeAction.description, + changes: codeAction.changes.map(function (change) { return ({ + fileName: change.fileName, + textChanges: change.textChanges.map(function (textChange) { return _this.convertTextChangeToCodeEdit(textChange, scriptInfo); }) + }); }) + }; + }; + Session.prototype.convertTextChangeToCodeEdit = function (change, scriptInfo) { + return { + start: scriptInfo.positionToLineOffset(change.span.start), + end: scriptInfo.positionToLineOffset(change.span.start + change.span.length), + newText: change.newText ? change.newText : "" + }; + }; + Session.prototype.getBraceMatching = function (args, simplifiedResult) { + var _this = this; + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var spans = project.getLanguageService(false).getBraceMatchingAtPosition(file, position); + return !spans + ? undefined + : simplifiedResult + ? spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }) + : spans; + }; + Session.prototype.getDiagnosticsForProject = function (next, delay, fileName) { + var _this = this; + var _a = this.getProjectInfoWorker(fileName, undefined, true), fileNames = _a.fileNames, languageServiceDisabled = _a.languageServiceDisabled; + if (languageServiceDisabled) { + return; + } + var fileNamesInProject = fileNames.filter(function (value) { return value.indexOf("lib.d.ts") < 0; }); + var highPriorityFiles = []; + var mediumPriorityFiles = []; + var lowPriorityFiles = []; + var veryLowPriorityFiles = []; + var normalizedFileName = server.toNormalizedPath(fileName); + var project = this.projectService.getDefaultProjectForFile(normalizedFileName, true); + for (var _i = 0, fileNamesInProject_1 = fileNamesInProject; _i < fileNamesInProject_1.length; _i++) { + var fileNameInProject = fileNamesInProject_1[_i]; + if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) + highPriorityFiles.push(fileNameInProject); + else { + var info = this.projectService.getScriptInfo(fileNameInProject); + if (!info.isScriptOpen()) { + if (fileNameInProject.indexOf(".d.ts") > 0) + veryLowPriorityFiles.push(fileNameInProject); + else + lowPriorityFiles.push(fileNameInProject); + } + else + mediumPriorityFiles.push(fileNameInProject); + } + } + fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); + if (fileNamesInProject.length > 0) { + var checkList = fileNamesInProject.map(function (fileName) { return ({ fileName: fileName, project: project }); }); + this.updateErrorCheck(next, checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); + } + }; + Session.prototype.getCanonicalFileName = function (fileName) { + var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return ts.normalizePath(name); + }; + Session.prototype.exit = function () { + }; + Session.prototype.notRequired = function () { + return { responseRequired: false }; + }; + Session.prototype.requiredResponse = function (response) { + return { response: response, responseRequired: true }; + }; + Session.prototype.addProtocolHandler = function (command, handler) { + if (this.handlers.has(command)) { + throw new Error("Protocol handler already exists for command \"" + command + "\""); + } + this.handlers.set(command, handler); + }; + Session.prototype.setCurrentRequest = function (requestId) { + ts.Debug.assert(this.currentRequestId === undefined); + this.currentRequestId = requestId; + this.cancellationToken.setRequest(requestId); + }; + Session.prototype.resetCurrentRequest = function (requestId) { + ts.Debug.assert(this.currentRequestId === requestId); + this.currentRequestId = undefined; + this.cancellationToken.resetRequest(requestId); + }; + Session.prototype.executeWithRequestId = function (requestId, f) { + try { + this.setCurrentRequest(requestId); + return f(); + } + finally { + this.resetCurrentRequest(requestId); + } + }; + Session.prototype.executeCommand = function (request) { + var handler = this.handlers.get(request.command); + if (handler) { + return this.executeWithRequestId(request.seq, function () { return handler(request); }); + } + else { + this.logger.msg("Unrecognized JSON command: " + JSON.stringify(request), server.Msg.Err); + this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); + return { responseRequired: false }; + } + }; + Session.prototype.onMessage = function (message) { + this.gcTimer.scheduleCollect(); + var start; + if (this.logger.hasLevel(server.LogLevel.requestTime)) { + start = this.hrtime(); + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("request: " + message); + } + } + var request; + try { + request = JSON.parse(message); + var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; + if (this.logger.hasLevel(server.LogLevel.requestTime)) { + var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4); + if (responseRequired) { + this.logger.perftrc(request.seq + "::" + request.command + ": elapsed time (in milliseconds) " + elapsedTime); + } + else { + this.logger.perftrc(request.seq + "::" + request.command + ": async elapsed time (in milliseconds) " + elapsedTime); + } + } + if (response) { + this.output(response, request.command, request.seq); + } + else if (responseRequired) { + this.output(undefined, request.command, request.seq, "No content available."); + } + } + catch (err) { + if (err instanceof ts.OperationCanceledException) { + this.output({ canceled: true }, request.command, request.seq); + return; + } + this.logError(err, message); + this.output(undefined, request ? request.command : CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message + "\n" + err.stack); + } + }; + return Session; + }()); + server.Session = Session; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var server; (function (server) { @@ -66556,4207 +74565,6 @@ var ts; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var server; - (function (server) { - var TextStorage = (function () { - function TextStorage(host, fileName) { - this.host = host; - this.fileName = fileName; - this.svcVersion = 0; - this.textVersion = 0; - } - TextStorage.prototype.getVersion = function () { - return this.svc - ? "SVC-" + this.svcVersion + "-" + this.svc.getSnapshot().version - : "Text-" + this.textVersion; - }; - TextStorage.prototype.hasScriptVersionCache = function () { - return this.svc !== undefined; - }; - TextStorage.prototype.useScriptVersionCache = function (newText) { - this.switchToScriptVersionCache(newText); - }; - TextStorage.prototype.useText = function (newText) { - this.svc = undefined; - this.setText(newText); - }; - TextStorage.prototype.edit = function (start, end, newText) { - this.switchToScriptVersionCache().edit(start, end - start, newText); - }; - TextStorage.prototype.reload = function (text) { - if (this.svc) { - this.svc.reload(text); - } - else { - this.setText(text); - } - }; - TextStorage.prototype.reloadFromFile = function (tempFileName) { - if (this.svc || (tempFileName !== this.fileName)) { - this.reload(this.getFileText(tempFileName)); - } - else { - this.setText(undefined); - } - }; - TextStorage.prototype.getSnapshot = function () { - return this.svc - ? this.svc.getSnapshot() - : ts.ScriptSnapshot.fromString(this.getOrLoadText()); - }; - TextStorage.prototype.getLineInfo = function (line) { - return this.switchToScriptVersionCache().getSnapshot().index.lineNumberToInfo(line); - }; - TextStorage.prototype.lineToTextSpan = function (line) { - if (!this.svc) { - var lineMap = this.getLineMap(); - var start = lineMap[line]; - var end = line + 1 < lineMap.length ? lineMap[line + 1] : this.text.length; - return ts.createTextSpanFromBounds(start, end); - } - var index = this.svc.getSnapshot().index; - var lineInfo = index.lineNumberToInfo(line + 1); - var len; - if (lineInfo.leaf) { - len = lineInfo.leaf.text.length; - } - else { - var nextLineInfo = index.lineNumberToInfo(line + 2); - len = nextLineInfo.offset - lineInfo.offset; - } - return ts.createTextSpan(lineInfo.offset, len); - }; - TextStorage.prototype.lineOffsetToPosition = function (line, offset) { - if (!this.svc) { - return ts.computePositionOfLineAndCharacter(this.getLineMap(), line - 1, offset - 1); - } - var index = this.svc.getSnapshot().index; - var lineInfo = index.lineNumberToInfo(line); - return (lineInfo.offset + offset - 1); - }; - TextStorage.prototype.positionToLineOffset = function (position) { - if (!this.svc) { - var _a = ts.computeLineAndCharacterOfPosition(this.getLineMap(), position), line = _a.line, character = _a.character; - return { line: line + 1, offset: character + 1 }; - } - var index = this.svc.getSnapshot().index; - var lineOffset = index.charOffsetToLineNumberAndPos(position); - return { line: lineOffset.line, offset: lineOffset.offset + 1 }; - }; - TextStorage.prototype.getFileText = function (tempFileName) { - return this.host.readFile(tempFileName || this.fileName) || ""; - }; - TextStorage.prototype.ensureNoScriptVersionCache = function () { - ts.Debug.assert(!this.svc, "ScriptVersionCache should not be set"); - }; - TextStorage.prototype.switchToScriptVersionCache = function (newText) { - if (!this.svc) { - this.svc = server.ScriptVersionCache.fromString(this.host, newText !== undefined ? newText : this.getOrLoadText()); - this.svcVersion++; - this.text = undefined; - } - return this.svc; - }; - TextStorage.prototype.getOrLoadText = function () { - this.ensureNoScriptVersionCache(); - if (this.text === undefined) { - this.setText(this.getFileText()); - } - return this.text; - }; - TextStorage.prototype.getLineMap = function () { - this.ensureNoScriptVersionCache(); - return this.lineMap || (this.lineMap = ts.computeLineStarts(this.getOrLoadText())); - }; - TextStorage.prototype.setText = function (newText) { - this.ensureNoScriptVersionCache(); - if (newText === undefined || this.text !== newText) { - this.text = newText; - this.lineMap = undefined; - this.textVersion++; - } - }; - return TextStorage; - }()); - server.TextStorage = TextStorage; - var ScriptInfo = (function () { - function ScriptInfo(host, fileName, scriptKind, hasMixedContent) { - if (hasMixedContent === void 0) { hasMixedContent = false; } - this.host = host; - this.fileName = fileName; - this.scriptKind = scriptKind; - this.hasMixedContent = hasMixedContent; - this.containingProjects = []; - this.path = ts.toPath(fileName, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); - this.textStorage = new TextStorage(host, fileName); - if (hasMixedContent) { - this.textStorage.reload(""); - } - this.scriptKind = scriptKind - ? scriptKind - : ts.getScriptKindFromFileName(fileName); - } - ScriptInfo.prototype.isScriptOpen = function () { - return this.isOpen; - }; - ScriptInfo.prototype.open = function (newText) { - this.isOpen = true; - this.textStorage.useScriptVersionCache(newText); - this.markContainingProjectsAsDirty(); - }; - ScriptInfo.prototype.close = function () { - this.isOpen = false; - this.textStorage.useText(this.hasMixedContent ? "" : undefined); - this.markContainingProjectsAsDirty(); - }; - ScriptInfo.prototype.getSnapshot = function () { - return this.textStorage.getSnapshot(); - }; - ScriptInfo.prototype.getFormatCodeSettings = function () { - return this.formatCodeSettings; - }; - ScriptInfo.prototype.attachToProject = function (project) { - var isNew = !this.isAttached(project); - if (isNew) { - this.containingProjects.push(project); - } - return isNew; - }; - ScriptInfo.prototype.isAttached = function (project) { - switch (this.containingProjects.length) { - case 0: return false; - case 1: return this.containingProjects[0] === project; - case 2: return this.containingProjects[0] === project || this.containingProjects[1] === project; - default: return ts.contains(this.containingProjects, project); - } - }; - ScriptInfo.prototype.detachFromProject = function (project) { - switch (this.containingProjects.length) { - case 0: - return; - case 1: - if (this.containingProjects[0] === project) { - this.containingProjects.pop(); - } - break; - case 2: - if (this.containingProjects[0] === project) { - this.containingProjects[0] = this.containingProjects.pop(); - } - else if (this.containingProjects[1] === project) { - this.containingProjects.pop(); - } - break; - default: - server.removeItemFromSet(this.containingProjects, project); - break; - } - }; - ScriptInfo.prototype.detachAllProjects = function () { - for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - p.removeFile(this, false); - } - this.containingProjects.length = 0; - }; - ScriptInfo.prototype.getDefaultProject = function () { - if (this.containingProjects.length === 0) { - return server.Errors.ThrowNoProject(); - } - return this.containingProjects[0]; - }; - ScriptInfo.prototype.registerFileUpdate = function () { - for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - p.registerFileUpdate(this.path); - } - }; - ScriptInfo.prototype.setFormatOptions = function (formatSettings) { - if (formatSettings) { - if (!this.formatCodeSettings) { - this.formatCodeSettings = server.getDefaultFormatCodeSettings(this.host); - } - server.mergeMaps(this.formatCodeSettings, formatSettings); - } - }; - ScriptInfo.prototype.setWatcher = function (watcher) { - this.stopWatcher(); - this.fileWatcher = watcher; - }; - ScriptInfo.prototype.stopWatcher = function () { - if (this.fileWatcher) { - this.fileWatcher.close(); - this.fileWatcher = undefined; - } - }; - ScriptInfo.prototype.getLatestVersion = function () { - return this.textStorage.getVersion(); - }; - ScriptInfo.prototype.reload = function (script) { - this.textStorage.reload(script); - this.markContainingProjectsAsDirty(); - }; - ScriptInfo.prototype.saveTo = function (fileName) { - var snap = this.textStorage.getSnapshot(); - this.host.writeFile(fileName, snap.getText(0, snap.getLength())); - }; - ScriptInfo.prototype.reloadFromFile = function (tempFileName) { - if (this.hasMixedContent) { - this.reload(""); - } - else { - this.textStorage.reloadFromFile(tempFileName); - this.markContainingProjectsAsDirty(); - } - }; - ScriptInfo.prototype.getLineInfo = function (line) { - return this.textStorage.getLineInfo(line); - }; - ScriptInfo.prototype.editContent = function (start, end, newText) { - this.textStorage.edit(start, end, newText); - this.markContainingProjectsAsDirty(); - }; - ScriptInfo.prototype.markContainingProjectsAsDirty = function () { - for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - p.markAsDirty(); - } - }; - ScriptInfo.prototype.lineToTextSpan = function (line) { - return this.textStorage.lineToTextSpan(line); - }; - ScriptInfo.prototype.lineOffsetToPosition = function (line, offset) { - return this.textStorage.lineOffsetToPosition(line, offset); - }; - ScriptInfo.prototype.positionToLineOffset = function (position) { - return this.textStorage.positionToLineOffset(position); - }; - return ScriptInfo; - }()); - server.ScriptInfo = ScriptInfo; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var LSHost = (function () { - function LSHost(host, project, cancellationToken) { - var _this = this; - this.host = host; - this.project = project; - this.cancellationToken = cancellationToken; - this.resolvedModuleNames = ts.createFileMap(); - this.resolvedTypeReferenceDirectives = ts.createFileMap(); - this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); - if (host.trace) { - this.trace = function (s) { return host.trace(s); }; - } - this.resolveModuleName = function (moduleName, containingFile, compilerOptions, host) { - var globalCache = _this.project.getTypeAcquisition().enable - ? _this.project.projectService.typingsInstaller.globalTypingsCacheLocation - : undefined; - var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host); - if (!(primaryResult.resolvedModule && ts.extensionIsTypeScript(primaryResult.resolvedModule.extension)) && globalCache !== undefined) { - var _a = ts.loadModuleFromGlobalCache(moduleName, _this.project.getProjectName(), compilerOptions, host, globalCache), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; - if (resolvedModule) { - return { resolvedModule: resolvedModule, failedLookupLocations: primaryResult.failedLookupLocations.concat(failedLookupLocations) }; - } - } - return primaryResult; - }; - if (this.host.realpath) { - this.realpath = function (path) { return _this.host.realpath(path); }; - } - } - LSHost.prototype.startRecordingFilesWithChangedResolutions = function () { - this.filesWithChangedSetOfUnresolvedImports = []; - }; - LSHost.prototype.finishRecordingFilesWithChangedResolutions = function () { - var collected = this.filesWithChangedSetOfUnresolvedImports; - this.filesWithChangedSetOfUnresolvedImports = undefined; - return collected; - }; - LSHost.prototype.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult, getResultFileName, logChanges) { - var path = ts.toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); - var currentResolutionsInFile = cache.get(path); - var newResolutions = ts.createMap(); - var resolvedModules = []; - var compilerOptions = this.getCompilationSettings(); - var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; - for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_51 = names_2[_i]; - var resolution = newResolutions[name_51]; - if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_51]; - if (moduleResolutionIsValid(existingResolution)) { - resolution = existingResolution; - } - else { - newResolutions[name_51] = resolution = loader(name_51, containingFile, compilerOptions, this); - } - if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { - this.filesWithChangedSetOfUnresolvedImports.push(path); - logChanges = false; - } - } - ts.Debug.assert(resolution !== undefined); - resolvedModules.push(getResult(resolution)); - } - cache.set(path, newResolutions); - return resolvedModules; - function resolutionIsEqualTo(oldResolution, newResolution) { - if (oldResolution === newResolution) { - return true; - } - if (!oldResolution || !newResolution) { - return false; - } - var oldResult = getResult(oldResolution); - var newResult = getResult(newResolution); - if (oldResult === newResult) { - return true; - } - if (!oldResult || !newResult) { - return false; - } - return getResultFileName(oldResult) === getResultFileName(newResult); - } - function moduleResolutionIsValid(resolution) { - if (!resolution) { - return false; - } - var result = getResult(resolution); - if (result) { - return getResultFileName(result) !== lastDeletedFileName; - } - return resolution.failedLookupLocations.length === 0; - } - }; - LSHost.prototype.getNewLine = function () { - return this.host.newLine; - }; - LSHost.prototype.getProjectVersion = function () { - return this.project.getProjectVersion(); - }; - LSHost.prototype.getCompilationSettings = function () { - return this.compilationSettings; - }; - LSHost.prototype.useCaseSensitiveFileNames = function () { - return this.host.useCaseSensitiveFileNames; - }; - LSHost.prototype.getCancellationToken = function () { - return this.cancellationToken; - }; - LSHost.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, function (m) { return m.resolvedTypeReferenceDirective; }, function (r) { return r.resolvedFileName; }, false); - }; - LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { - return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, this.resolveModuleName, function (m) { return m.resolvedModule; }, function (r) { return r.resolvedFileName; }, true); - }; - LSHost.prototype.getDefaultLibFileName = function () { - var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); - return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings)); - }; - LSHost.prototype.getScriptSnapshot = function (filename) { - var scriptInfo = this.project.getScriptInfoLSHost(filename); - if (scriptInfo) { - return scriptInfo.getSnapshot(); - } - }; - LSHost.prototype.getScriptFileNames = function () { - return this.project.getRootFilesLSHost(); - }; - LSHost.prototype.getTypeRootsVersion = function () { - return this.project.typesVersion; - }; - LSHost.prototype.getScriptKind = function (fileName) { - var info = this.project.getScriptInfoLSHost(fileName); - return info && info.scriptKind; - }; - LSHost.prototype.getScriptVersion = function (filename) { - var info = this.project.getScriptInfoLSHost(filename); - return info && info.getLatestVersion(); - }; - LSHost.prototype.getCurrentDirectory = function () { - return this.host.getCurrentDirectory(); - }; - LSHost.prototype.resolvePath = function (path) { - return this.host.resolvePath(path); - }; - LSHost.prototype.fileExists = function (path) { - return this.host.fileExists(path); - }; - LSHost.prototype.readFile = function (fileName) { - return this.host.readFile(fileName); - }; - LSHost.prototype.directoryExists = function (path) { - return this.host.directoryExists(path); - }; - LSHost.prototype.readDirectory = function (path, extensions, exclude, include) { - return this.host.readDirectory(path, extensions, exclude, include); - }; - LSHost.prototype.getDirectories = function (path) { - return this.host.getDirectories(path); - }; - LSHost.prototype.notifyFileRemoved = function (info) { - this.resolvedModuleNames.remove(info.path); - this.resolvedTypeReferenceDirectives.remove(info.path); - }; - LSHost.prototype.setCompilationSettings = function (opt) { - if (ts.changesAffectModuleResolution(this.compilationSettings, opt)) { - this.resolvedModuleNames.clear(); - this.resolvedTypeReferenceDirectives.clear(); - } - this.compilationSettings = opt; - }; - return LSHost; - }()); - server.LSHost = LSHost; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - server.nullTypingsInstaller = { - enqueueInstallTypingsRequest: ts.noop, - attach: ts.noop, - onProjectClosed: ts.noop, - globalTypingsCacheLocation: undefined - }; - var TypingsCacheEntry = (function () { - function TypingsCacheEntry() { - } - return TypingsCacheEntry; - }()); - function setIsEqualTo(arr1, arr2) { - if (arr1 === arr2) { - return true; - } - if ((arr1 || server.emptyArray).length === 0 && (arr2 || server.emptyArray).length === 0) { - return true; - } - var set = ts.createMap(); - var unique = 0; - for (var _i = 0, arr1_1 = arr1; _i < arr1_1.length; _i++) { - var v = arr1_1[_i]; - if (set[v] !== true) { - set[v] = true; - unique++; - } - } - for (var _a = 0, arr2_1 = arr2; _a < arr2_1.length; _a++) { - var v = arr2_1[_a]; - if (!ts.hasProperty(set, v)) { - return false; - } - if (set[v] === true) { - set[v] = false; - unique--; - } - } - return unique === 0; - } - function typeAcquisitionChanged(opt1, opt2) { - return opt1.enable !== opt2.enable || - !setIsEqualTo(opt1.include, opt2.include) || - !setIsEqualTo(opt1.exclude, opt2.exclude); - } - function compilerOptionsChanged(opt1, opt2) { - return opt1.allowJs != opt2.allowJs; - } - function unresolvedImportsChanged(imports1, imports2) { - if (imports1 === imports2) { - return false; - } - return !ts.arrayIsEqualTo(imports1, imports2); - } - var TypingsCache = (function () { - function TypingsCache(installer) { - this.installer = installer; - this.perProjectCache = ts.createMap(); - } - TypingsCache.prototype.getTypingsForProject = function (project, unresolvedImports, forceRefresh) { - var typeAcquisition = project.getTypeAcquisition(); - if (!typeAcquisition || !typeAcquisition.enable) { - return server.emptyArray; - } - var entry = this.perProjectCache[project.getProjectName()]; - var result = entry ? entry.typings : server.emptyArray; - if (forceRefresh || - !entry || - typeAcquisitionChanged(typeAcquisition, entry.typeAcquisition) || - compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions) || - unresolvedImportsChanged(unresolvedImports, entry.unresolvedImports)) { - this.perProjectCache[project.getProjectName()] = { - compilerOptions: project.getCompilerOptions(), - typeAcquisition: typeAcquisition, - typings: result, - unresolvedImports: unresolvedImports, - poisoned: true - }; - this.installer.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports); - } - return result; - }; - TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typeAcquisition, unresolvedImports, newTypings) { - this.perProjectCache[projectName] = { - compilerOptions: compilerOptions, - typeAcquisition: typeAcquisition, - typings: server.toSortedReadonlyArray(newTypings), - unresolvedImports: unresolvedImports, - poisoned: false - }; - }; - TypingsCache.prototype.deleteTypingsForProject = function (projectName) { - delete this.perProjectCache[projectName]; - }; - TypingsCache.prototype.onProjectClosed = function (project) { - delete this.perProjectCache[project.getProjectName()]; - this.installer.onProjectClosed(project); - }; - return TypingsCache; - }()); - server.TypingsCache = TypingsCache; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - function shouldEmitFile(scriptInfo) { - return !scriptInfo.hasMixedContent; - } - server.shouldEmitFile = shouldEmitFile; - var BuilderFileInfo = (function () { - function BuilderFileInfo(scriptInfo, project) { - this.scriptInfo = scriptInfo; - this.project = project; - } - BuilderFileInfo.prototype.isExternalModuleOrHasOnlyAmbientExternalModules = function () { - var sourceFile = this.getSourceFile(); - return ts.isExternalModule(sourceFile) || this.containsOnlyAmbientModules(sourceFile); - }; - BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (statement.kind !== 231 || statement.name.kind !== 9) { - return false; - } - } - return true; - }; - BuilderFileInfo.prototype.computeHash = function (text) { - return this.project.projectService.host.createHash(text); - }; - BuilderFileInfo.prototype.getSourceFile = function () { - return this.project.getSourceFile(this.scriptInfo.path); - }; - BuilderFileInfo.prototype.updateShapeSignature = function () { - var sourceFile = this.getSourceFile(); - if (!sourceFile) { - return true; - } - var lastSignature = this.lastCheckedShapeSignature; - if (sourceFile.isDeclarationFile) { - this.lastCheckedShapeSignature = this.computeHash(sourceFile.text); - } - else { - var emitOutput = this.project.getFileEmitOutput(this.scriptInfo, true); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - this.lastCheckedShapeSignature = this.computeHash(emitOutput.outputFiles[0].text); - } - } - return !lastSignature || this.lastCheckedShapeSignature !== lastSignature; - }; - return BuilderFileInfo; - }()); - server.BuilderFileInfo = BuilderFileInfo; - var AbstractBuilder = (function () { - function AbstractBuilder(project, ctor) { - this.project = project; - this.ctor = ctor; - } - AbstractBuilder.prototype.getFileInfos = function () { - return this.fileInfos_doNotAccessDirectly || (this.fileInfos_doNotAccessDirectly = ts.createFileMap()); - }; - AbstractBuilder.prototype.clear = function () { - this.fileInfos_doNotAccessDirectly = undefined; - }; - AbstractBuilder.prototype.getFileInfo = function (path) { - return this.getFileInfos().get(path); - }; - AbstractBuilder.prototype.getOrCreateFileInfo = function (path) { - var fileInfo = this.getFileInfo(path); - if (!fileInfo) { - var scriptInfo = this.project.getScriptInfo(path); - fileInfo = new this.ctor(scriptInfo, this.project); - this.setFileInfo(path, fileInfo); - } - return fileInfo; - }; - AbstractBuilder.prototype.getFileInfoPaths = function () { - return this.getFileInfos().getKeys(); - }; - AbstractBuilder.prototype.setFileInfo = function (path, info) { - this.getFileInfos().set(path, info); - }; - AbstractBuilder.prototype.removeFileInfo = function (path) { - this.getFileInfos().remove(path); - }; - AbstractBuilder.prototype.forEachFileInfo = function (action) { - this.getFileInfos().forEachValue(function (_path, value) { return action(value); }); - }; - AbstractBuilder.prototype.emitFile = function (scriptInfo, writeFile) { - var fileInfo = this.getFileInfo(scriptInfo.path); - if (!fileInfo) { - return false; - } - var _a = this.project.getFileEmitOutput(fileInfo.scriptInfo, false), emitSkipped = _a.emitSkipped, outputFiles = _a.outputFiles; - if (!emitSkipped) { - var projectRootPath = this.project.getProjectRootPath(); - for (var _i = 0, outputFiles_1 = outputFiles; _i < outputFiles_1.length; _i++) { - var outputFile = outputFiles_1[_i]; - var outputFileAbsoluteFileName = ts.getNormalizedAbsolutePath(outputFile.name, projectRootPath ? projectRootPath : ts.getDirectoryPath(scriptInfo.fileName)); - writeFile(outputFileAbsoluteFileName, outputFile.text, outputFile.writeByteOrderMark); - } - } - return !emitSkipped; - }; - return AbstractBuilder; - }()); - var NonModuleBuilder = (function (_super) { - __extends(NonModuleBuilder, _super); - function NonModuleBuilder(project) { - var _this = _super.call(this, project, BuilderFileInfo) || this; - _this.project = project; - return _this; - } - NonModuleBuilder.prototype.onProjectUpdateGraph = function () { - }; - NonModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { - var info = this.getOrCreateFileInfo(scriptInfo.path); - var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; - if (info.updateShapeSignature()) { - var options = this.project.getCompilerOptions(); - if (options && (options.out || options.outFile)) { - return singleFileResult; - } - return this.project.getAllEmittableFiles(); - } - return singleFileResult; - }; - return NonModuleBuilder; - }(AbstractBuilder)); - var ModuleBuilderFileInfo = (function (_super) { - __extends(ModuleBuilderFileInfo, _super); - function ModuleBuilderFileInfo() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.references = []; - _this.referencedBy = []; - return _this; - } - ModuleBuilderFileInfo.compareFileInfos = function (lf, rf) { - var l = lf.scriptInfo.fileName; - var r = rf.scriptInfo.fileName; - return (l < r ? -1 : (l > r ? 1 : 0)); - }; - ; - ModuleBuilderFileInfo.addToReferenceList = function (array, fileInfo) { - if (array.length === 0) { - array.push(fileInfo); - return; - } - var insertIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); - if (insertIndex < 0) { - array.splice(~insertIndex, 0, fileInfo); - } - }; - ModuleBuilderFileInfo.removeFromReferenceList = function (array, fileInfo) { - if (!array || array.length === 0) { - return; - } - if (array[0] === fileInfo) { - array.splice(0, 1); - return; - } - var removeIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); - if (removeIndex >= 0) { - array.splice(removeIndex, 1); - } - }; - ModuleBuilderFileInfo.prototype.addReferencedBy = function (fileInfo) { - ModuleBuilderFileInfo.addToReferenceList(this.referencedBy, fileInfo); - }; - ModuleBuilderFileInfo.prototype.removeReferencedBy = function (fileInfo) { - ModuleBuilderFileInfo.removeFromReferenceList(this.referencedBy, fileInfo); - }; - ModuleBuilderFileInfo.prototype.removeFileReferences = function () { - for (var _i = 0, _a = this.references; _i < _a.length; _i++) { - var reference = _a[_i]; - reference.removeReferencedBy(this); - } - this.references = []; - }; - return ModuleBuilderFileInfo; - }(BuilderFileInfo)); - var ModuleBuilder = (function (_super) { - __extends(ModuleBuilder, _super); - function ModuleBuilder(project) { - var _this = _super.call(this, project, ModuleBuilderFileInfo) || this; - _this.project = project; - return _this; - } - ModuleBuilder.prototype.clear = function () { - this.projectVersionForDependencyGraph = undefined; - _super.prototype.clear.call(this); - }; - ModuleBuilder.prototype.getReferencedFileInfos = function (fileInfo) { - var _this = this; - if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { - return []; - } - var referencedFilePaths = this.project.getReferencedFiles(fileInfo.scriptInfo.path); - if (referencedFilePaths.length > 0) { - return ts.map(referencedFilePaths, function (f) { return _this.getOrCreateFileInfo(f); }).sort(ModuleBuilderFileInfo.compareFileInfos); - } - return []; - }; - ModuleBuilder.prototype.onProjectUpdateGraph = function () { - this.ensureProjectDependencyGraphUpToDate(); - }; - ModuleBuilder.prototype.ensureProjectDependencyGraphUpToDate = function () { - var _this = this; - if (!this.projectVersionForDependencyGraph || this.project.getProjectVersion() !== this.projectVersionForDependencyGraph) { - var currentScriptInfos = this.project.getScriptInfos(); - for (var _i = 0, currentScriptInfos_1 = currentScriptInfos; _i < currentScriptInfos_1.length; _i++) { - var scriptInfo = currentScriptInfos_1[_i]; - var fileInfo = this.getOrCreateFileInfo(scriptInfo.path); - this.updateFileReferences(fileInfo); - } - this.forEachFileInfo(function (fileInfo) { - if (!_this.project.containsScriptInfo(fileInfo.scriptInfo)) { - fileInfo.removeFileReferences(); - _this.removeFileInfo(fileInfo.scriptInfo.path); - } - }); - this.projectVersionForDependencyGraph = this.project.getProjectVersion(); - } - }; - ModuleBuilder.prototype.updateFileReferences = function (fileInfo) { - if (fileInfo.scriptVersionForReferences === fileInfo.scriptInfo.getLatestVersion()) { - return; - } - var newReferences = this.getReferencedFileInfos(fileInfo); - var oldReferences = fileInfo.references; - var oldIndex = 0; - var newIndex = 0; - while (oldIndex < oldReferences.length && newIndex < newReferences.length) { - var oldReference = oldReferences[oldIndex]; - var newReference = newReferences[newIndex]; - var compare = ModuleBuilderFileInfo.compareFileInfos(oldReference, newReference); - if (compare < 0) { - oldReference.removeReferencedBy(fileInfo); - oldIndex++; - } - else if (compare > 0) { - newReference.addReferencedBy(fileInfo); - newIndex++; - } - else { - oldIndex++; - newIndex++; - } - } - for (var i = oldIndex; i < oldReferences.length; i++) { - oldReferences[i].removeReferencedBy(fileInfo); - } - for (var i = newIndex; i < newReferences.length; i++) { - newReferences[i].addReferencedBy(fileInfo); - } - fileInfo.references = newReferences; - fileInfo.scriptVersionForReferences = fileInfo.scriptInfo.getLatestVersion(); - }; - ModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { - this.ensureProjectDependencyGraphUpToDate(); - var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; - var fileInfo = this.getFileInfo(scriptInfo.path); - if (!fileInfo || !fileInfo.updateShapeSignature()) { - return singleFileResult; - } - if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { - return this.project.getAllEmittableFiles(); - } - var options = this.project.getCompilerOptions(); - if (options && (options.isolatedModules || options.out || options.outFile)) { - return singleFileResult; - } - var queue = fileInfo.referencedBy.slice(0); - var fileNameSet = ts.createMap(); - fileNameSet[scriptInfo.fileName] = scriptInfo; - while (queue.length > 0) { - var processingFileInfo = queue.pop(); - if (processingFileInfo.updateShapeSignature() && processingFileInfo.referencedBy.length > 0) { - for (var _i = 0, _a = processingFileInfo.referencedBy; _i < _a.length; _i++) { - var potentialFileInfo = _a[_i]; - if (!fileNameSet[potentialFileInfo.scriptInfo.fileName]) { - queue.push(potentialFileInfo); - } - } - } - fileNameSet[processingFileInfo.scriptInfo.fileName] = processingFileInfo.scriptInfo; - } - var result = []; - for (var fileName in fileNameSet) { - if (shouldEmitFile(fileNameSet[fileName])) { - result.push(fileName); - } - } - return result; - }; - return ModuleBuilder; - }(AbstractBuilder)); - function createBuilder(project) { - var moduleKind = project.getCompilerOptions().module; - switch (moduleKind) { - case ts.ModuleKind.None: - return new NonModuleBuilder(project); - default: - return new ModuleBuilder(project); - } - } - server.createBuilder = createBuilder; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var ProjectKind; - (function (ProjectKind) { - ProjectKind[ProjectKind["Inferred"] = 0] = "Inferred"; - ProjectKind[ProjectKind["Configured"] = 1] = "Configured"; - ProjectKind[ProjectKind["External"] = 2] = "External"; - })(ProjectKind = server.ProjectKind || (server.ProjectKind = {})); - function remove(items, item) { - var index = items.indexOf(item); - if (index >= 0) { - items.splice(index, 1); - } - } - function countEachFileTypes(infos) { - var result = { js: 0, jsx: 0, ts: 0, tsx: 0, dts: 0 }; - for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { - var info = infos_1[_i]; - switch (info.scriptKind) { - case 1: - result.js += 1; - break; - case 2: - result.jsx += 1; - break; - case 3: - ts.fileExtensionIs(info.fileName, ".d.ts") - ? result.dts += 1 - : result.ts += 1; - break; - case 4: - result.tsx += 1; - break; - } - } - return result; - } - function hasOneOrMoreJsAndNoTsFiles(project) { - var counts = countEachFileTypes(project.getScriptInfos()); - return counts.js > 0 && counts.ts === 0 && counts.tsx === 0; - } - function allRootFilesAreJsOrDts(project) { - var counts = countEachFileTypes(project.getRootScriptInfos()); - return counts.ts === 0 && counts.tsx === 0; - } - server.allRootFilesAreJsOrDts = allRootFilesAreJsOrDts; - function allFilesAreJsOrDts(project) { - var counts = countEachFileTypes(project.getScriptInfos()); - return counts.ts === 0 && counts.tsx === 0; - } - server.allFilesAreJsOrDts = allFilesAreJsOrDts; - var UnresolvedImportsMap = (function () { - function UnresolvedImportsMap() { - this.perFileMap = ts.createFileMap(); - this.version = 0; - } - UnresolvedImportsMap.prototype.clear = function () { - this.perFileMap.clear(); - this.version = 0; - }; - UnresolvedImportsMap.prototype.getVersion = function () { - return this.version; - }; - UnresolvedImportsMap.prototype.remove = function (path) { - this.perFileMap.remove(path); - this.version++; - }; - UnresolvedImportsMap.prototype.get = function (path) { - return this.perFileMap.get(path); - }; - UnresolvedImportsMap.prototype.set = function (path, value) { - this.perFileMap.set(path, value); - this.version++; - }; - return UnresolvedImportsMap; - }()); - server.UnresolvedImportsMap = UnresolvedImportsMap; - var Project = (function () { - function Project(projectName, projectKind, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { - this.projectName = projectName; - this.projectKind = projectKind; - this.projectService = projectService; - this.documentRegistry = documentRegistry; - this.compilerOptions = compilerOptions; - this.compileOnSaveEnabled = compileOnSaveEnabled; - this.rootFiles = []; - this.rootFilesMap = ts.createFileMap(); - this.cachedUnresolvedImportsPerFile = new UnresolvedImportsMap(); - this.languageServiceEnabled = true; - this.lastReportedVersion = 0; - this.projectStructureVersion = 0; - this.projectStateVersion = 0; - this.typesVersion = 0; - if (!this.compilerOptions) { - this.compilerOptions = ts.getDefaultCompilerOptions(); - this.compilerOptions.allowNonTsExtensions = true; - this.compilerOptions.allowJs = true; - } - else if (hasExplicitListOfFiles) { - this.compilerOptions.allowNonTsExtensions = true; - } - this.setInternalCompilerOptionsForEmittingJsFiles(); - this.lsHost = new server.LSHost(this.projectService.host, this, this.projectService.cancellationToken); - this.lsHost.setCompilationSettings(this.compilerOptions); - this.languageService = ts.createLanguageService(this.lsHost, this.documentRegistry); - if (!languageServiceEnabled) { - this.disableLanguageService(); - } - this.builder = server.createBuilder(this); - this.markAsDirty(); - } - Project.prototype.isNonTsProject = function () { - this.updateGraph(); - return allFilesAreJsOrDts(this); - }; - Project.prototype.isJsOnlyProject = function () { - this.updateGraph(); - return hasOneOrMoreJsAndNoTsFiles(this); - }; - Project.prototype.getCachedUnresolvedImportsPerFile_TestOnly = function () { - return this.cachedUnresolvedImportsPerFile; - }; - Project.prototype.setInternalCompilerOptionsForEmittingJsFiles = function () { - if (this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) { - this.compilerOptions.noEmitForJsFiles = true; - } - }; - Project.prototype.getProjectErrors = function () { - return this.projectErrors; - }; - Project.prototype.getLanguageService = function (ensureSynchronized) { - if (ensureSynchronized === void 0) { ensureSynchronized = true; } - if (ensureSynchronized) { - this.updateGraph(); - } - return this.languageService; - }; - Project.prototype.getCompileOnSaveAffectedFileList = function (scriptInfo) { - if (!this.languageServiceEnabled) { - return []; - } - this.updateGraph(); - return this.builder.getFilesAffectedBy(scriptInfo); - }; - Project.prototype.getProjectVersion = function () { - return this.projectStateVersion.toString(); - }; - Project.prototype.enableLanguageService = function () { - if (this.languageServiceEnabled) { - return; - } - this.languageServiceEnabled = true; - this.projectService.onUpdateLanguageServiceStateForProject(this, true); - }; - Project.prototype.disableLanguageService = function () { - if (!this.languageServiceEnabled) { - return; - } - this.languageService.cleanupSemanticCache(); - this.languageServiceEnabled = false; - this.projectService.onUpdateLanguageServiceStateForProject(this, false); - }; - Project.prototype.getProjectName = function () { - return this.projectName; - }; - Project.prototype.getSourceFile = function (path) { - if (!this.program) { - return undefined; - } - return this.program.getSourceFileByPath(path); - }; - Project.prototype.updateTypes = function () { - this.typesVersion++; - this.markAsDirty(); - this.updateGraph(); - }; - Project.prototype.close = function () { - if (this.program) { - for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { - var f = _a[_i]; - var info = this.projectService.getScriptInfo(f.fileName); - info.detachFromProject(this); - } - } - if (!this.program || !this.languageServiceEnabled) { - for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { - var root = _c[_b]; - root.detachFromProject(this); - } - } - this.rootFiles = undefined; - this.rootFilesMap = undefined; - this.program = undefined; - this.languageService.dispose(); - }; - Project.prototype.getCompilerOptions = function () { - return this.compilerOptions; - }; - Project.prototype.hasRoots = function () { - return this.rootFiles && this.rootFiles.length > 0; - }; - Project.prototype.getRootFiles = function () { - return this.rootFiles && this.rootFiles.map(function (info) { return info.fileName; }); - }; - Project.prototype.getRootFilesLSHost = function () { - var result = []; - if (this.rootFiles) { - for (var _i = 0, _a = this.rootFiles; _i < _a.length; _i++) { - var f = _a[_i]; - if (this.languageServiceEnabled || f.isScriptOpen()) { - result.push(f.fileName); - } - } - if (this.typingFiles) { - for (var _b = 0, _c = this.typingFiles; _b < _c.length; _b++) { - var f = _c[_b]; - result.push(f); - } - } - } - return result; - }; - Project.prototype.getRootScriptInfos = function () { - return this.rootFiles; - }; - Project.prototype.getScriptInfos = function () { - var _this = this; - if (!this.languageServiceEnabled) { - return this.rootFiles; - } - return ts.map(this.program.getSourceFiles(), function (sourceFile) { - var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.path); - if (!scriptInfo) { - ts.Debug.assert(false, "scriptInfo for a file '" + sourceFile.fileName + "' is missing."); - } - return scriptInfo; - }); - }; - Project.prototype.getFileEmitOutput = function (info, emitOnlyDtsFiles) { - if (!this.languageServiceEnabled) { - return undefined; - } - return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); - }; - Project.prototype.getFileNames = function (excludeFilesFromExternalLibraries) { - if (!this.program) { - return []; - } - if (!this.languageServiceEnabled) { - var rootFiles = this.getRootFiles(); - if (this.compilerOptions) { - var defaultLibrary = ts.getDefaultLibFilePath(this.compilerOptions); - if (defaultLibrary) { - (rootFiles || (rootFiles = [])).push(server.asNormalizedPath(defaultLibrary)); - } - } - return rootFiles; - } - var result = []; - for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { - var f = _a[_i]; - if (excludeFilesFromExternalLibraries && this.program.isSourceFileFromExternalLibrary(f)) { - continue; - } - result.push(server.asNormalizedPath(f.fileName)); - } - return result; - }; - Project.prototype.getAllEmittableFiles = function () { - if (!this.languageServiceEnabled) { - return []; - } - var defaultLibraryFileName = ts.getDefaultLibFileName(this.compilerOptions); - var infos = this.getScriptInfos(); - var result = []; - for (var _i = 0, infos_2 = infos; _i < infos_2.length; _i++) { - var info = infos_2[_i]; - if (ts.getBaseFileName(info.fileName) !== defaultLibraryFileName && server.shouldEmitFile(info)) { - result.push(info.fileName); - } - } - return result; - }; - Project.prototype.containsScriptInfo = function (info) { - return this.isRoot(info) || (this.program && this.program.getSourceFileByPath(info.path) !== undefined); - }; - Project.prototype.containsFile = function (filename, requireOpen) { - var info = this.projectService.getScriptInfoForNormalizedPath(filename); - if (info && (info.isScriptOpen() || !requireOpen)) { - return this.containsScriptInfo(info); - } - }; - Project.prototype.isRoot = function (info) { - return this.rootFilesMap && this.rootFilesMap.contains(info.path); - }; - Project.prototype.addRoot = function (info) { - if (!this.isRoot(info)) { - this.rootFiles.push(info); - this.rootFilesMap.set(info.path, info); - info.attachToProject(this); - this.markAsDirty(); - } - }; - Project.prototype.removeFile = function (info, detachFromProject) { - if (detachFromProject === void 0) { detachFromProject = true; } - this.removeRootFileIfNecessary(info); - this.lsHost.notifyFileRemoved(info); - this.cachedUnresolvedImportsPerFile.remove(info.path); - if (detachFromProject) { - info.detachFromProject(this); - } - this.markAsDirty(); - }; - Project.prototype.registerFileUpdate = function (fileName) { - (this.updatedFileNames || (this.updatedFileNames = ts.createMap()))[fileName] = fileName; - }; - Project.prototype.markAsDirty = function () { - this.projectStateVersion++; - }; - Project.prototype.extractUnresolvedImportsFromSourceFile = function (file, result) { - var cached = this.cachedUnresolvedImportsPerFile.get(file.path); - if (cached) { - for (var _i = 0, cached_1 = cached; _i < cached_1.length; _i++) { - var f = cached_1[_i]; - result.push(f); - } - return; - } - var unresolvedImports; - if (file.resolvedModules) { - for (var name_52 in file.resolvedModules) { - if (!file.resolvedModules[name_52] && !ts.isExternalModuleNameRelative(name_52)) { - var trimmed = name_52.trim(); - var i = trimmed.indexOf("/"); - if (i !== -1 && trimmed.charCodeAt(0) === 64) { - i = trimmed.indexOf("/", i + 1); - } - if (i !== -1) { - trimmed = trimmed.substr(0, i); - } - (unresolvedImports || (unresolvedImports = [])).push(trimmed); - result.push(trimmed); - } - } - } - this.cachedUnresolvedImportsPerFile.set(file.path, unresolvedImports || server.emptyArray); - }; - Project.prototype.updateGraph = function () { - this.lsHost.startRecordingFilesWithChangedResolutions(); - var hasChanges = this.updateGraphWorker(); - var changedFiles = this.lsHost.finishRecordingFilesWithChangedResolutions() || server.emptyArray; - for (var _i = 0, changedFiles_1 = changedFiles; _i < changedFiles_1.length; _i++) { - var file = changedFiles_1[_i]; - this.cachedUnresolvedImportsPerFile.remove(file); - } - var unresolvedImports; - if (hasChanges || changedFiles.length) { - var result = []; - for (var _a = 0, _b = this.program.getSourceFiles(); _a < _b.length; _a++) { - var sourceFile = _b[_a]; - this.extractUnresolvedImportsFromSourceFile(sourceFile, result); - } - this.lastCachedUnresolvedImportsList = server.toSortedReadonlyArray(result); - } - unresolvedImports = this.lastCachedUnresolvedImportsList; - var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, unresolvedImports, hasChanges); - if (this.setTypings(cachedTypings)) { - hasChanges = this.updateGraphWorker() || hasChanges; - } - if (this.languageServiceEnabled) { - this.builder.onProjectUpdateGraph(); - } - else { - this.builder.clear(); - } - if (hasChanges) { - this.projectStructureVersion++; - } - return !hasChanges; - }; - Project.prototype.setTypings = function (typings) { - if (ts.arrayIsEqualTo(this.typingFiles, typings)) { - return false; - } - this.typingFiles = typings; - this.markAsDirty(); - return true; - }; - Project.prototype.updateGraphWorker = function () { - var oldProgram = this.program; - this.program = this.languageService.getProgram(); - var hasChanges = false; - if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) { - hasChanges = true; - if (oldProgram) { - for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { - var f = _a[_i]; - if (this.program.getSourceFileByPath(f.path)) { - continue; - } - var scriptInfoToDetach = this.projectService.getScriptInfo(f.fileName); - if (scriptInfoToDetach) { - scriptInfoToDetach.detachFromProject(this); - } - } - } - } - return hasChanges; - }; - Project.prototype.getScriptInfoLSHost = function (fileName) { - var scriptInfo = this.projectService.getOrCreateScriptInfo(fileName, false); - if (scriptInfo) { - scriptInfo.attachToProject(this); - } - return scriptInfo; - }; - Project.prototype.getScriptInfoForNormalizedPath = function (fileName) { - var scriptInfo = this.projectService.getOrCreateScriptInfoForNormalizedPath(fileName, false); - if (scriptInfo && !scriptInfo.isAttached(this)) { - return server.Errors.ThrowProjectDoesNotContainDocument(fileName, this); - } - return scriptInfo; - }; - Project.prototype.getScriptInfo = function (uncheckedFileName) { - return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); - }; - Project.prototype.filesToString = function () { - if (!this.program) { - return ""; - } - var strBuilder = ""; - for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { - var file = _a[_i]; - strBuilder += file.fileName + "\n"; - } - return strBuilder; - }; - Project.prototype.setCompilerOptions = function (compilerOptions) { - if (compilerOptions) { - if (this.projectKind === ProjectKind.Inferred) { - compilerOptions.allowJs = true; - } - compilerOptions.allowNonTsExtensions = true; - if (ts.changesAffectModuleResolution(this.compilerOptions, compilerOptions)) { - this.cachedUnresolvedImportsPerFile.clear(); - this.lastCachedUnresolvedImportsList = undefined; - } - this.compilerOptions = compilerOptions; - this.setInternalCompilerOptionsForEmittingJsFiles(); - this.lsHost.setCompilationSettings(compilerOptions); - this.markAsDirty(); - } - }; - Project.prototype.reloadScript = function (filename, tempFileName) { - var script = this.projectService.getScriptInfoForNormalizedPath(filename); - if (script) { - ts.Debug.assert(script.isAttached(this)); - script.reloadFromFile(tempFileName); - return true; - } - return false; - }; - Project.prototype.getChangesSinceVersion = function (lastKnownVersion) { - this.updateGraph(); - var info = { - projectName: this.getProjectName(), - version: this.projectStructureVersion, - isInferred: this.projectKind === ProjectKind.Inferred, - options: this.getCompilerOptions(), - languageServiceDisabled: !this.languageServiceEnabled - }; - var updatedFileNames = this.updatedFileNames; - this.updatedFileNames = undefined; - if (this.lastReportedFileNames && lastKnownVersion === this.lastReportedVersion) { - if (this.projectStructureVersion == this.lastReportedVersion && !updatedFileNames) { - return { info: info, projectErrors: this.projectErrors }; - } - var lastReportedFileNames = this.lastReportedFileNames; - var currentFiles = ts.arrayToMap(this.getFileNames(), function (x) { return x; }); - var added = []; - var removed = []; - var updated = ts.getOwnKeys(updatedFileNames); - for (var id in currentFiles) { - if (!ts.hasProperty(lastReportedFileNames, id)) { - added.push(id); - } - } - for (var id in lastReportedFileNames) { - if (!ts.hasProperty(currentFiles, id)) { - removed.push(id); - } - } - this.lastReportedFileNames = currentFiles; - this.lastReportedVersion = this.projectStructureVersion; - return { info: info, changes: { added: added, removed: removed, updated: updated }, projectErrors: this.projectErrors }; - } - else { - var projectFileNames = this.getFileNames(); - this.lastReportedFileNames = ts.arrayToMap(projectFileNames, function (x) { return x; }); - this.lastReportedVersion = this.projectStructureVersion; - return { info: info, files: projectFileNames, projectErrors: this.projectErrors }; - } - }; - Project.prototype.getReferencedFiles = function (path) { - var _this = this; - if (!this.languageServiceEnabled) { - return []; - } - var sourceFile = this.getSourceFile(path); - if (!sourceFile) { - return []; - } - var referencedFiles = ts.createMap(); - if (sourceFile.imports && sourceFile.imports.length > 0) { - var checker = this.program.getTypeChecker(); - for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { - var importName = _a[_i]; - var symbol = checker.getSymbolAtLocation(importName); - if (symbol && symbol.declarations && symbol.declarations[0]) { - var declarationSourceFile = symbol.declarations[0].getSourceFile(); - if (declarationSourceFile) { - referencedFiles[declarationSourceFile.path] = true; - } - } - } - } - var currentDirectory = ts.getDirectoryPath(path); - var getCanonicalFileName = ts.createGetCanonicalFileName(this.projectService.host.useCaseSensitiveFileNames); - if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) { - for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) { - var referencedFile = _c[_b]; - var referencedPath = ts.toPath(referencedFile.fileName, currentDirectory, getCanonicalFileName); - referencedFiles[referencedPath] = true; - } - } - if (sourceFile.resolvedTypeReferenceDirectiveNames) { - for (var typeName in sourceFile.resolvedTypeReferenceDirectiveNames) { - var resolvedTypeReferenceDirective = sourceFile.resolvedTypeReferenceDirectiveNames[typeName]; - if (!resolvedTypeReferenceDirective) { - continue; - } - var fileName = resolvedTypeReferenceDirective.resolvedFileName; - var typeFilePath = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - referencedFiles[typeFilePath] = true; - } - } - var allFileNames = ts.map(Object.keys(referencedFiles), function (key) { return key; }); - return ts.filter(allFileNames, function (file) { return _this.projectService.host.fileExists(file); }); - }; - Project.prototype.removeRootFileIfNecessary = function (info) { - if (this.isRoot(info)) { - remove(this.rootFiles, info); - this.rootFilesMap.remove(info.path); - } - }; - return Project; - }()); - server.Project = Project; - var InferredProject = (function (_super) { - __extends(InferredProject, _super); - function InferredProject(projectService, documentRegistry, compilerOptions) { - var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, undefined, true, compilerOptions, false) || this; - _this.directoriesWatchedForTsconfig = []; - return _this; - } - InferredProject.prototype.getProjectRootPath = function () { - if (this.projectService.useSingleInferredProject) { - return undefined; - } - var rootFiles = this.getRootFiles(); - return ts.getDirectoryPath(rootFiles[0]); - }; - InferredProject.prototype.close = function () { - _super.prototype.close.call(this); - for (var _i = 0, _a = this.directoriesWatchedForTsconfig; _i < _a.length; _i++) { - var directory = _a[_i]; - this.projectService.stopWatchingDirectory(directory); - } - }; - InferredProject.prototype.getTypeAcquisition = function () { - return { - enable: allRootFilesAreJsOrDts(this), - include: [], - exclude: [] - }; - }; - return InferredProject; - }(Project)); - InferredProject.newName = (function () { - var nextId = 1; - return function () { - var id = nextId; - nextId++; - return server.makeInferredProjectName(id); - }; - })(); - server.InferredProject = InferredProject; - var ConfiguredProject = (function (_super) { - __extends(ConfiguredProject, _super); - function ConfiguredProject(configFileName, projectService, documentRegistry, hasExplicitListOfFiles, compilerOptions, wildcardDirectories, languageServiceEnabled, compileOnSaveEnabled) { - var _this = _super.call(this, configFileName, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; - _this.wildcardDirectories = wildcardDirectories; - _this.compileOnSaveEnabled = compileOnSaveEnabled; - _this.openRefCount = 0; - _this.canonicalConfigFilePath = server.asNormalizedPath(projectService.toCanonicalFileName(configFileName)); - return _this; - } - ConfiguredProject.prototype.getConfigFilePath = function () { - return this.getProjectName(); - }; - ConfiguredProject.prototype.getProjectRootPath = function () { - return ts.getDirectoryPath(this.getConfigFilePath()); - }; - ConfiguredProject.prototype.setProjectErrors = function (projectErrors) { - this.projectErrors = projectErrors; - }; - ConfiguredProject.prototype.setTypeAcquisition = function (newTypeAcquisition) { - this.typeAcquisition = newTypeAcquisition; - }; - ConfiguredProject.prototype.getTypeAcquisition = function () { - return this.typeAcquisition; - }; - ConfiguredProject.prototype.watchConfigFile = function (callback) { - var _this = this; - this.projectFileWatcher = this.projectService.host.watchFile(this.getConfigFilePath(), function (_) { return callback(_this); }); - }; - ConfiguredProject.prototype.watchTypeRoots = function (callback) { - var _this = this; - var roots = this.getEffectiveTypeRoots(); - var watchers = []; - for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { - var root = roots_1[_i]; - this.projectService.logger.info("Add type root watcher for: " + root); - watchers.push(this.projectService.host.watchDirectory(root, function (path) { return callback(_this, path); }, false)); - } - this.typeRootsWatchers = watchers; - }; - ConfiguredProject.prototype.watchConfigDirectory = function (callback) { - var _this = this; - if (this.directoryWatcher) { - return; - } - var directoryToWatch = ts.getDirectoryPath(this.getConfigFilePath()); - this.projectService.logger.info("Add recursive watcher for: " + directoryToWatch); - this.directoryWatcher = this.projectService.host.watchDirectory(directoryToWatch, function (path) { return callback(_this, path); }, true); - }; - ConfiguredProject.prototype.watchWildcards = function (callback) { - var _this = this; - if (!this.wildcardDirectories) { - return; - } - var configDirectoryPath = ts.getDirectoryPath(this.getConfigFilePath()); - this.directoriesWatchedForWildcards = ts.reduceProperties(this.wildcardDirectories, function (watchers, flag, directory) { - if (ts.comparePaths(configDirectoryPath, directory, ".", !_this.projectService.host.useCaseSensitiveFileNames) !== 0) { - var recursive = (flag & 1) !== 0; - _this.projectService.logger.info("Add " + (recursive ? "recursive " : "") + "watcher for: " + directory); - watchers[directory] = _this.projectService.host.watchDirectory(directory, function (path) { return callback(_this, path); }, recursive); - } - return watchers; - }, {}); - }; - ConfiguredProject.prototype.stopWatchingDirectory = function () { - if (this.directoryWatcher) { - this.directoryWatcher.close(); - this.directoryWatcher = undefined; - } - }; - ConfiguredProject.prototype.close = function () { - _super.prototype.close.call(this); - if (this.projectFileWatcher) { - this.projectFileWatcher.close(); - } - if (this.typeRootsWatchers) { - for (var _i = 0, _a = this.typeRootsWatchers; _i < _a.length; _i++) { - var watcher = _a[_i]; - watcher.close(); - } - this.typeRootsWatchers = undefined; - } - for (var id in this.directoriesWatchedForWildcards) { - this.directoriesWatchedForWildcards[id].close(); - } - this.directoriesWatchedForWildcards = undefined; - this.stopWatchingDirectory(); - }; - ConfiguredProject.prototype.addOpenRef = function () { - this.openRefCount++; - }; - ConfiguredProject.prototype.deleteOpenRef = function () { - this.openRefCount--; - return this.openRefCount; - }; - ConfiguredProject.prototype.getEffectiveTypeRoots = function () { - return ts.getEffectiveTypeRoots(this.getCompilerOptions(), this.projectService.host) || []; - }; - return ConfiguredProject; - }(Project)); - server.ConfiguredProject = ConfiguredProject; - var ExternalProject = (function (_super) { - __extends(ExternalProject, _super); - function ExternalProject(externalProjectName, projectService, documentRegistry, compilerOptions, languageServiceEnabled, compileOnSaveEnabled, projectFilePath) { - var _this = _super.call(this, externalProjectName, ProjectKind.External, projectService, documentRegistry, true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; - _this.compileOnSaveEnabled = compileOnSaveEnabled; - _this.projectFilePath = projectFilePath; - return _this; - } - ExternalProject.prototype.getProjectRootPath = function () { - if (this.projectFilePath) { - return ts.getDirectoryPath(this.projectFilePath); - } - return ts.getDirectoryPath(ts.normalizeSlashes(this.getProjectName())); - }; - ExternalProject.prototype.getTypeAcquisition = function () { - return this.typeAcquisition; - }; - ExternalProject.prototype.setProjectErrors = function (projectErrors) { - this.projectErrors = projectErrors; - }; - ExternalProject.prototype.setTypeAcquisition = function (newTypeAcquisition) { - if (!newTypeAcquisition) { - newTypeAcquisition = { - enable: allRootFilesAreJsOrDts(this), - include: [], - exclude: [] - }; - } - else { - if (newTypeAcquisition.enable === undefined) { - newTypeAcquisition.enable = allRootFilesAreJsOrDts(this); - } - if (!newTypeAcquisition.include) { - newTypeAcquisition.include = []; - } - if (!newTypeAcquisition.exclude) { - newTypeAcquisition.exclude = []; - } - } - this.typeAcquisition = newTypeAcquisition; - }; - return ExternalProject; - }(Project)); - server.ExternalProject = ExternalProject; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; - server.ContextEvent = "context"; - server.ConfigFileDiagEvent = "configFileDiag"; - server.ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; - function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions) { - var map = ts.createMap(); - for (var _i = 0, commandLineOptions_1 = commandLineOptions; _i < commandLineOptions_1.length; _i++) { - var option = commandLineOptions_1[_i]; - if (typeof option.type === "object") { - var optionMap = option.type; - for (var id in optionMap) { - ts.Debug.assert(typeof optionMap[id] === "number"); - } - map[option.name] = optionMap; - } - } - return map; - } - var compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(ts.optionDeclarations); - var indentStyle = ts.createMap({ - "none": ts.IndentStyle.None, - "block": ts.IndentStyle.Block, - "smart": ts.IndentStyle.Smart - }); - function convertFormatOptions(protocolOptions) { - if (typeof protocolOptions.indentStyle === "string") { - protocolOptions.indentStyle = indentStyle[protocolOptions.indentStyle.toLowerCase()]; - ts.Debug.assert(protocolOptions.indentStyle !== undefined); - } - return protocolOptions; - } - server.convertFormatOptions = convertFormatOptions; - function convertCompilerOptions(protocolOptions) { - for (var id in compilerOptionConverters) { - var propertyValue = protocolOptions[id]; - if (typeof propertyValue === "string") { - var mappedValues = compilerOptionConverters[id]; - protocolOptions[id] = mappedValues[propertyValue.toLowerCase()]; - } - } - return protocolOptions; - } - server.convertCompilerOptions = convertCompilerOptions; - function tryConvertScriptKindName(scriptKindName) { - return typeof scriptKindName === "string" - ? convertScriptKindName(scriptKindName) - : scriptKindName; - } - server.tryConvertScriptKindName = tryConvertScriptKindName; - function convertScriptKindName(scriptKindName) { - switch (scriptKindName) { - case "JS": - return 1; - case "JSX": - return 2; - case "TS": - return 3; - case "TSX": - return 4; - default: - return 0; - } - } - server.convertScriptKindName = convertScriptKindName; - function combineProjectOutput(projects, action, comparer, areEqual) { - var result = projects.reduce(function (previous, current) { return ts.concatenate(previous, action(current)); }, []).sort(comparer); - return projects.length > 1 ? ts.deduplicate(result, areEqual) : result; - } - server.combineProjectOutput = combineProjectOutput; - var fileNamePropertyReader = { - getFileName: function (x) { return x; }, - getScriptKind: function (_) { return undefined; }, - hasMixedContent: function (fileName, extraFileExtensions) { - var mixedContentExtensions = ts.map(ts.filter(extraFileExtensions, function (item) { return item.isMixedContent; }), function (item) { return item.extension; }); - return ts.forEach(mixedContentExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - }; - var externalFilePropertyReader = { - getFileName: function (x) { return x.fileName; }, - getScriptKind: function (x) { return tryConvertScriptKindName(x.scriptKind); }, - hasMixedContent: function (x) { return x.hasMixedContent; } - }; - function findProjectByName(projectName, projects) { - for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) { - var proj = projects_1[_i]; - if (proj.getProjectName() === projectName) { - return proj; - } - } - } - function createFileNotFoundDiagnostic(fileName) { - return ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName); - } - function isRootFileInInferredProject(info) { - if (info.containingProjects.length === 0) { - return false; - } - return info.containingProjects[0].projectKind === server.ProjectKind.Inferred && info.containingProjects[0].isRoot(info); - } - var DirectoryWatchers = (function () { - function DirectoryWatchers(projectService) { - this.projectService = projectService; - this.directoryWatchersForTsconfig = ts.createMap(); - this.directoryWatchersRefCount = ts.createMap(); - } - DirectoryWatchers.prototype.stopWatchingDirectory = function (directory) { - this.directoryWatchersRefCount[directory]--; - if (this.directoryWatchersRefCount[directory] === 0) { - this.projectService.logger.info("Close directory watcher for: " + directory); - this.directoryWatchersForTsconfig[directory].close(); - delete this.directoryWatchersForTsconfig[directory]; - } - }; - DirectoryWatchers.prototype.startWatchingContainingDirectoriesForFile = function (fileName, project, callback) { - var currentPath = ts.getDirectoryPath(fileName); - var parentPath = ts.getDirectoryPath(currentPath); - while (currentPath != parentPath) { - if (!this.directoryWatchersForTsconfig[currentPath]) { - this.projectService.logger.info("Add watcher for: " + currentPath); - this.directoryWatchersForTsconfig[currentPath] = this.projectService.host.watchDirectory(currentPath, callback); - this.directoryWatchersRefCount[currentPath] = 1; - } - else { - this.directoryWatchersRefCount[currentPath] += 1; - } - project.directoriesWatchedForTsconfig.push(currentPath); - currentPath = parentPath; - parentPath = ts.getDirectoryPath(parentPath); - } - }; - return DirectoryWatchers; - }()); - var ProjectService = (function () { - function ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, eventHandler) { - if (typingsInstaller === void 0) { typingsInstaller = server.nullTypingsInstaller; } - this.host = host; - this.logger = logger; - this.cancellationToken = cancellationToken; - this.useSingleInferredProject = useSingleInferredProject; - this.typingsInstaller = typingsInstaller; - this.eventHandler = eventHandler; - this.filenameToScriptInfo = ts.createFileMap(); - this.externalProjectToConfiguredProjectMap = ts.createMap(); - this.externalProjects = []; - this.inferredProjects = []; - this.configuredProjects = []; - this.openFiles = []; - ts.Debug.assert(!!host.createHash, "'ServerHost.createHash' is required for ProjectService"); - this.toCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - this.directoryWatchers = new DirectoryWatchers(this); - this.throttledOperations = new server.ThrottledOperations(host); - this.typingsInstaller.attach(this); - this.typingsCache = new server.TypingsCache(this.typingsInstaller); - this.hostConfiguration = { - formatCodeOptions: server.getDefaultFormatCodeSettings(this.host), - hostInfo: "Unknown host", - extraFileExtensions: [] - }; - this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory()); - } - ProjectService.prototype.getChangedFiles_TestOnly = function () { - return this.changedFiles; - }; - ProjectService.prototype.ensureInferredProjectsUpToDate_TestOnly = function () { - this.ensureInferredProjectsUpToDate(); - }; - ProjectService.prototype.getCompilerOptionsForInferredProjects = function () { - return this.compilerOptionsForInferredProjects; - }; - ProjectService.prototype.onUpdateLanguageServiceStateForProject = function (project, languageServiceEnabled) { - if (!this.eventHandler) { - return; - } - this.eventHandler({ - eventName: server.ProjectLanguageServiceStateEvent, - data: { project: project, languageServiceEnabled: languageServiceEnabled } - }); - }; - ProjectService.prototype.updateTypingsForProject = function (response) { - var project = this.findProject(response.projectName); - if (!project) { - return; - } - switch (response.kind) { - case server.ActionSet: - this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typeAcquisition, response.unresolvedImports, response.typings); - break; - case server.ActionInvalidate: - this.typingsCache.deleteTypingsForProject(response.projectName); - break; - } - project.updateGraph(); - }; - ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions) { - this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions); - this.compilerOptionsForInferredProjects.allowNonTsExtensions = true; - this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; - for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { - var proj = _a[_i]; - proj.setCompilerOptions(this.compilerOptionsForInferredProjects); - proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave; - } - this.updateProjectGraphs(this.inferredProjects); - }; - ProjectService.prototype.stopWatchingDirectory = function (directory) { - this.directoryWatchers.stopWatchingDirectory(directory); - }; - ProjectService.prototype.findProject = function (projectName) { - if (projectName === undefined) { - return undefined; - } - if (server.isInferredProjectName(projectName)) { - this.ensureInferredProjectsUpToDate(); - return findProjectByName(projectName, this.inferredProjects); - } - return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(server.toNormalizedPath(projectName)); - }; - ProjectService.prototype.getDefaultProjectForFile = function (fileName, refreshInferredProjects) { - if (refreshInferredProjects) { - this.ensureInferredProjectsUpToDate(); - } - var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); - return scriptInfo && scriptInfo.getDefaultProject(); - }; - ProjectService.prototype.ensureInferredProjectsUpToDate = function () { - if (this.changedFiles) { - var projectsToUpdate = void 0; - if (this.changedFiles.length === 1) { - projectsToUpdate = this.changedFiles[0].containingProjects; - } - else { - projectsToUpdate = []; - for (var _i = 0, _a = this.changedFiles; _i < _a.length; _i++) { - var f = _a[_i]; - projectsToUpdate = projectsToUpdate.concat(f.containingProjects); - } - } - this.updateProjectGraphs(projectsToUpdate); - this.changedFiles = undefined; - } - }; - ProjectService.prototype.findContainingExternalProject = function (fileName) { - for (var _i = 0, _a = this.externalProjects; _i < _a.length; _i++) { - var proj = _a[_i]; - if (proj.containsFile(fileName)) { - return proj; - } - } - return undefined; - }; - ProjectService.prototype.getFormatCodeOptions = function (file) { - var formatCodeSettings; - if (file) { - var info = this.getScriptInfoForNormalizedPath(file); - if (info) { - formatCodeSettings = info.getFormatCodeSettings(); - } - } - return formatCodeSettings || this.hostConfiguration.formatCodeOptions; - }; - ProjectService.prototype.updateProjectGraphs = function (projects) { - var shouldRefreshInferredProjects = false; - for (var _i = 0, projects_2 = projects; _i < projects_2.length; _i++) { - var p = projects_2[_i]; - if (!p.updateGraph()) { - shouldRefreshInferredProjects = true; - } - } - if (shouldRefreshInferredProjects) { - this.refreshInferredProjects(); - } - }; - ProjectService.prototype.onSourceFileChanged = function (fileName) { - var info = this.getScriptInfoForNormalizedPath(fileName); - if (!info) { - this.logger.info("Error: got watch notification for unknown file: " + fileName); - return; - } - if (!this.host.fileExists(fileName)) { - this.handleDeletedFile(info); - } - else { - if (info && (!info.isScriptOpen())) { - info.reloadFromFile(); - this.updateProjectGraphs(info.containingProjects); - } - } - }; - ProjectService.prototype.handleDeletedFile = function (info) { - this.logger.info(info.fileName + " deleted"); - info.stopWatcher(); - if (!info.isScriptOpen()) { - this.filenameToScriptInfo.remove(info.path); - this.lastDeletedFile = info; - var containingProjects = info.containingProjects.slice(); - info.detachAllProjects(); - this.updateProjectGraphs(containingProjects); - this.lastDeletedFile = undefined; - if (!this.eventHandler) { - return; - } - for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { - var openFile = _a[_i]; - this.eventHandler({ - eventName: server.ContextEvent, - data: { project: openFile.getDefaultProject(), fileName: openFile.fileName } - }); - } - } - this.printProjects(); - }; - ProjectService.prototype.onTypeRootFileChanged = function (project, fileName) { - var _this = this; - this.logger.info("Type root file " + fileName + " changed"); - this.throttledOperations.schedule(project.getConfigFilePath() + " * type root", 250, function () { - project.updateTypes(); - _this.updateConfiguredProject(project); - _this.refreshInferredProjects(); - }); - }; - ProjectService.prototype.onSourceFileInDirectoryChangedForConfiguredProject = function (project, fileName) { - var _this = this; - if (fileName && !ts.isSupportedSourceFileName(fileName, project.getCompilerOptions(), this.hostConfiguration.extraFileExtensions)) { - return; - } - this.logger.info("Detected source file changes: " + fileName); - this.throttledOperations.schedule(project.getConfigFilePath(), 250, function () { return _this.handleChangeInSourceFileForConfiguredProject(project, fileName); }); - }; - ProjectService.prototype.handleChangeInSourceFileForConfiguredProject = function (project, triggerFile) { - var _this = this; - var _a = this.convertConfigFileContentToProjectOptions(project.getConfigFilePath()), projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; - this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors, triggerFile); - var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); })); - var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); })); - if (!ts.arrayIsEqualTo(currentRootFiles.sort(), newRootFiles.sort())) { - this.logger.info("Updating configured project"); - this.updateConfiguredProject(project); - this.refreshInferredProjects(); - } - }; - ProjectService.prototype.onConfigChangedForConfiguredProject = function (project) { - var configFileName = project.getConfigFilePath(); - this.logger.info("Config file changed: " + configFileName); - var configFileErrors = this.updateConfiguredProject(project); - this.reportConfigFileDiagnostics(configFileName, configFileErrors, configFileName); - this.refreshInferredProjects(); - }; - ProjectService.prototype.onConfigFileAddedForInferredProject = function (fileName) { - if (ts.getBaseFileName(fileName) != "tsconfig.json") { - this.logger.info(fileName + " is not tsconfig.json"); - return; - } - var configFileErrors = this.convertConfigFileContentToProjectOptions(fileName).configFileErrors; - this.reportConfigFileDiagnostics(fileName, configFileErrors, fileName); - this.logger.info("Detected newly added tsconfig file: " + fileName); - this.reloadProjects(); - }; - ProjectService.prototype.getCanonicalFileName = function (fileName) { - var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - return ts.normalizePath(name); - }; - ProjectService.prototype.removeProject = function (project) { - this.logger.info("remove project: " + project.getRootFiles().toString()); - project.close(); - switch (project.projectKind) { - case server.ProjectKind.External: - server.removeItemFromSet(this.externalProjects, project); - break; - case server.ProjectKind.Configured: - server.removeItemFromSet(this.configuredProjects, project); - break; - case server.ProjectKind.Inferred: - server.removeItemFromSet(this.inferredProjects, project); - break; - } - }; - ProjectService.prototype.assignScriptInfoToInferredProjectIfNecessary = function (info, addToListOfOpenFiles) { - var externalProject = this.findContainingExternalProject(info.fileName); - if (externalProject) { - if (addToListOfOpenFiles) { - this.openFiles.push(info); - } - return; - } - var foundConfiguredProject = false; - for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - if (p.projectKind === server.ProjectKind.Configured) { - foundConfiguredProject = true; - if (addToListOfOpenFiles) { - (p).addOpenRef(); - } - } - } - if (foundConfiguredProject) { - if (addToListOfOpenFiles) { - this.openFiles.push(info); - } - return; - } - if (info.containingProjects.length === 0) { - var inferredProject = this.createInferredProjectWithRootFileIfNecessary(info); - if (!this.useSingleInferredProject) { - for (var _b = 0, _c = this.openFiles; _b < _c.length; _b++) { - var f = _c[_b]; - if (f.containingProjects.length === 0) { - continue; - } - var defaultProject = f.getDefaultProject(); - if (isRootFileInInferredProject(info) && defaultProject !== inferredProject && inferredProject.containsScriptInfo(f)) { - this.removeProject(defaultProject); - f.attachToProject(inferredProject); - } - } - } - } - if (addToListOfOpenFiles) { - this.openFiles.push(info); - } - }; - ProjectService.prototype.closeOpenFile = function (info) { - info.close(); - server.removeItemFromSet(this.openFiles, info); - var projectsToRemove; - for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - if (p.projectKind === server.ProjectKind.Configured) { - if (info.hasMixedContent) { - info.registerFileUpdate(); - } - if (p.deleteOpenRef() === 0) { - (projectsToRemove || (projectsToRemove = [])).push(p); - } - } - else if (p.projectKind === server.ProjectKind.Inferred && p.isRoot(info)) { - (projectsToRemove || (projectsToRemove = [])).push(p); - } - if (!p.languageServiceEnabled) { - p.markAsDirty(); - } - } - if (projectsToRemove) { - for (var _b = 0, projectsToRemove_1 = projectsToRemove; _b < projectsToRemove_1.length; _b++) { - var project = projectsToRemove_1[_b]; - this.removeProject(project); - } - var orphanFiles = void 0; - for (var _c = 0, _d = this.openFiles; _c < _d.length; _c++) { - var f = _d[_c]; - if (f.containingProjects.length === 0) { - (orphanFiles || (orphanFiles = [])).push(f); - } - } - if (orphanFiles) { - for (var _e = 0, orphanFiles_1 = orphanFiles; _e < orphanFiles_1.length; _e++) { - var f = orphanFiles_1[_e]; - this.assignScriptInfoToInferredProjectIfNecessary(f, false); - } - } - } - if (info.containingProjects.length === 0) { - this.filenameToScriptInfo.remove(info.path); - } - }; - ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { - var searchPath = ts.getDirectoryPath(fileName); - this.logger.info("Search path: " + searchPath); - var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath)); - if (!configFileName) { - this.logger.info("No config files found."); - return {}; - } - this.logger.info("Config file name: " + configFileName); - var project = this.findConfiguredProjectByProjectName(configFileName); - if (!project) { - var _a = this.openConfigFile(configFileName, fileName), success = _a.success, errors = _a.errors; - if (!success) { - return { configFileName: configFileName, configFileErrors: errors }; - } - this.logger.info("Opened configuration file " + configFileName); - if (errors && errors.length > 0) { - return { configFileName: configFileName, configFileErrors: errors }; - } - } - else { - this.updateConfiguredProject(project); - } - return { configFileName: configFileName }; - }; - ProjectService.prototype.findConfigFile = function (searchPath) { - while (true) { - var tsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "tsconfig.json")); - if (this.host.fileExists(tsconfigFileName)) { - return tsconfigFileName; - } - var jsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "jsconfig.json")); - if (this.host.fileExists(jsconfigFileName)) { - return jsconfigFileName; - } - var parentPath = server.asNormalizedPath(ts.getDirectoryPath(searchPath)); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - return undefined; - }; - ProjectService.prototype.printProjects = function () { - if (!this.logger.hasLevel(server.LogLevel.verbose)) { - return; - } - this.logger.startGroup(); - var counter = 0; - counter = printProjects(this.logger, this.externalProjects, counter); - counter = printProjects(this.logger, this.configuredProjects, counter); - counter = printProjects(this.logger, this.inferredProjects, counter); - this.logger.info("Open files: "); - for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { - var rootFile = _a[_i]; - this.logger.info(rootFile.fileName); - } - this.logger.endGroup(); - function printProjects(logger, projects, counter) { - for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { - var project = projects_3[_i]; - project.updateGraph(); - logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); - logger.info(project.filesToString()); - logger.info("-----------------------------------------------"); - counter++; - } - return counter; - } - }; - ProjectService.prototype.findConfiguredProjectByProjectName = function (configFileName) { - configFileName = server.asNormalizedPath(this.toCanonicalFileName(configFileName)); - for (var _i = 0, _a = this.configuredProjects; _i < _a.length; _i++) { - var proj = _a[_i]; - if (proj.canonicalConfigFilePath === configFileName) { - return proj; - } - } - }; - ProjectService.prototype.findExternalProjectByProjectName = function (projectFileName) { - return findProjectByName(projectFileName, this.externalProjects); - }; - ProjectService.prototype.convertConfigFileContentToProjectOptions = function (configFilename) { - configFilename = ts.normalizePath(configFilename); - var configFileContent = this.host.readFile(configFilename); - var errors; - var result = ts.parseConfigFileTextToJson(configFilename, configFileContent); - var config = result.config; - if (result.error) { - var _a = ts.sanitizeConfigFile(configFilename, configFileContent), sanitizedConfig = _a.configJsonObject, diagnostics = _a.diagnostics; - config = sanitizedConfig; - errors = diagnostics.length ? diagnostics : [result.error]; - } - var parsedCommandLine = ts.parseJsonConfigFileContent(config, this.host, ts.getDirectoryPath(configFilename), {}, configFilename, [], this.hostConfiguration.extraFileExtensions); - if (parsedCommandLine.errors.length) { - errors = ts.concatenate(errors, parsedCommandLine.errors); - } - ts.Debug.assert(!!parsedCommandLine.fileNames); - if (parsedCommandLine.fileNames.length === 0) { - (errors || (errors = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename)); - return { success: false, configFileErrors: errors }; - } - var projectOptions = { - files: parsedCommandLine.fileNames, - compilerOptions: parsedCommandLine.options, - configHasFilesProperty: config["files"] !== undefined, - wildcardDirectories: ts.createMap(parsedCommandLine.wildcardDirectories), - typeAcquisition: parsedCommandLine.typeAcquisition, - compileOnSave: parsedCommandLine.compileOnSave - }; - return { success: true, projectOptions: projectOptions, configFileErrors: errors }; - }; - ProjectService.prototype.exceededTotalSizeLimitForNonTsFiles = function (options, fileNames, propertyReader) { - if (options && options.disableSizeLimit || !this.host.getFileSize) { - return false; - } - var totalNonTsFileSize = 0; - for (var _i = 0, fileNames_3 = fileNames; _i < fileNames_3.length; _i++) { - var f = fileNames_3[_i]; - var fileName = propertyReader.getFileName(f); - if (ts.hasTypeScriptFileExtension(fileName)) { - continue; - } - totalNonTsFileSize += this.host.getFileSize(fileName); - if (totalNonTsFileSize > server.maxProgramSizeForNonTsFiles) { - return true; - } - } - return false; - }; - ProjectService.prototype.createAndAddExternalProject = function (projectFileName, files, options, typeAcquisition) { - var compilerOptions = convertCompilerOptions(options); - var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, compilerOptions, !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); - this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, undefined, typeAcquisition, undefined); - this.externalProjects.push(project); - return project; - }; - ProjectService.prototype.reportConfigFileDiagnostics = function (configFileName, diagnostics, triggerFile) { - if (!this.eventHandler) { - return; - } - this.eventHandler({ - eventName: server.ConfigFileDiagEvent, - data: { configFileName: configFileName, diagnostics: diagnostics || [], triggerFile: triggerFile } - }); - }; - ProjectService.prototype.createAndAddConfiguredProject = function (configFileName, projectOptions, configFileErrors, clientFileName) { - var _this = this; - var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); - var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, projectOptions.wildcardDirectories, !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); - this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); - project.watchConfigFile(function (project) { return _this.onConfigChangedForConfiguredProject(project); }); - if (!sizeLimitExceeded) { - this.watchConfigDirectoryForProject(project, projectOptions); - } - project.watchWildcards(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); - project.watchTypeRoots(function (project, path) { return _this.onTypeRootFileChanged(project, path); }); - this.configuredProjects.push(project); - return project; - }; - ProjectService.prototype.watchConfigDirectoryForProject = function (project, options) { - var _this = this; - if (!options.configHasFilesProperty) { - project.watchConfigDirectory(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); - } - }; - ProjectService.prototype.addFilesToProjectAndUpdateGraph = function (project, files, propertyReader, clientFileName, typeAcquisition, configFileErrors) { - var errors; - for (var _i = 0, files_4 = files; _i < files_4.length; _i++) { - var f = files_4[_i]; - var rootFilename = propertyReader.getFileName(f); - var scriptKind = propertyReader.getScriptKind(f); - var hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); - if (this.host.fileExists(rootFilename)) { - var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFilename), clientFileName == rootFilename, undefined, scriptKind, hasMixedContent); - project.addRoot(info); - } - else { - (errors || (errors = [])).push(createFileNotFoundDiagnostic(rootFilename)); - } - } - project.setProjectErrors(ts.concatenate(configFileErrors, errors)); - project.setTypeAcquisition(typeAcquisition); - project.updateGraph(); - }; - ProjectService.prototype.openConfigFile = function (configFileName, clientFileName) { - var conversionResult = this.convertConfigFileContentToProjectOptions(configFileName); - var projectOptions = conversionResult.success - ? conversionResult.projectOptions - : { files: [], compilerOptions: {} }; - var project = this.createAndAddConfiguredProject(configFileName, projectOptions, conversionResult.configFileErrors, clientFileName); - return { - success: conversionResult.success, - project: project, - errors: project.getProjectErrors() - }; - }; - ProjectService.prototype.updateNonInferredProject = function (project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave, configFileErrors) { - var oldRootScriptInfos = project.getRootScriptInfos(); - var newRootScriptInfos = []; - var newRootScriptInfoMap = server.createNormalizedPathMap(); - var projectErrors; - var rootFilesChanged = false; - for (var _i = 0, newUncheckedFiles_1 = newUncheckedFiles; _i < newUncheckedFiles_1.length; _i++) { - var f = newUncheckedFiles_1[_i]; - var newRootFile = propertyReader.getFileName(f); - if (!this.host.fileExists(newRootFile)) { - (projectErrors || (projectErrors = [])).push(createFileNotFoundDiagnostic(newRootFile)); - continue; - } - var normalizedPath = server.toNormalizedPath(newRootFile); - var scriptInfo = this.getScriptInfoForNormalizedPath(normalizedPath); - if (!scriptInfo || !project.isRoot(scriptInfo)) { - rootFilesChanged = true; - if (!scriptInfo) { - var scriptKind = propertyReader.getScriptKind(f); - var hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); - scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, false, undefined, scriptKind, hasMixedContent); - } - } - newRootScriptInfos.push(scriptInfo); - newRootScriptInfoMap.set(scriptInfo.fileName, scriptInfo); - } - if (rootFilesChanged || newRootScriptInfos.length !== oldRootScriptInfos.length) { - var toAdd = void 0; - var toRemove = void 0; - for (var _a = 0, oldRootScriptInfos_1 = oldRootScriptInfos; _a < oldRootScriptInfos_1.length; _a++) { - var oldFile = oldRootScriptInfos_1[_a]; - if (!newRootScriptInfoMap.contains(oldFile.fileName)) { - (toRemove || (toRemove = [])).push(oldFile); - } - } - for (var _b = 0, newRootScriptInfos_1 = newRootScriptInfos; _b < newRootScriptInfos_1.length; _b++) { - var newFile = newRootScriptInfos_1[_b]; - if (!project.isRoot(newFile)) { - (toAdd || (toAdd = [])).push(newFile); - } - } - if (toRemove) { - for (var _c = 0, toRemove_1 = toRemove; _c < toRemove_1.length; _c++) { - var f = toRemove_1[_c]; - project.removeFile(f); - } - } - if (toAdd) { - for (var _d = 0, toAdd_1 = toAdd; _d < toAdd_1.length; _d++) { - var f = toAdd_1[_d]; - if (f.isScriptOpen() && isRootFileInInferredProject(f)) { - var inferredProject = f.containingProjects[0]; - inferredProject.removeFile(f); - if (!inferredProject.hasRoots()) { - this.removeProject(inferredProject); - } - } - project.addRoot(f); - } - } - } - project.setCompilerOptions(newOptions); - project.setTypeAcquisition(newTypeAcquisition); - if (compileOnSave !== undefined) { - project.compileOnSaveEnabled = compileOnSave; - } - project.setProjectErrors(ts.concatenate(configFileErrors, projectErrors)); - project.updateGraph(); - }; - ProjectService.prototype.updateConfiguredProject = function (project) { - if (!this.host.fileExists(project.getConfigFilePath())) { - this.logger.info("Config file deleted"); - this.removeProject(project); - return; - } - var _a = this.convertConfigFileContentToProjectOptions(project.getConfigFilePath()), success = _a.success, projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; - if (!success) { - this.updateNonInferredProject(project, [], fileNamePropertyReader, {}, {}, false, configFileErrors); - return configFileErrors; - } - if (this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { - project.setCompilerOptions(projectOptions.compilerOptions); - if (!project.languageServiceEnabled) { - return configFileErrors; - } - project.disableLanguageService(); - project.stopWatchingDirectory(); - } - else { - project.enableLanguageService(); - this.watchConfigDirectoryForProject(project, projectOptions); - this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typeAcquisition, projectOptions.compileOnSave, configFileErrors); - } - return configFileErrors; - }; - ProjectService.prototype.createInferredProjectWithRootFileIfNecessary = function (root) { - var _this = this; - var useExistingProject = this.useSingleInferredProject && this.inferredProjects.length; - var project = useExistingProject - ? this.inferredProjects[0] - : new server.InferredProject(this, this.documentRegistry, this.compilerOptionsForInferredProjects); - project.addRoot(root); - this.directoryWatchers.startWatchingContainingDirectoriesForFile(root.fileName, project, function (fileName) { return _this.onConfigFileAddedForInferredProject(fileName); }); - project.updateGraph(); - if (!useExistingProject) { - this.inferredProjects.push(project); - } - return project; - }; - ProjectService.prototype.getOrCreateScriptInfo = function (uncheckedFileName, openedByClient, fileContent, scriptKind) { - return this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName), openedByClient, fileContent, scriptKind); - }; - ProjectService.prototype.getScriptInfo = function (uncheckedFileName) { - return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); - }; - ProjectService.prototype.getOrCreateScriptInfoForNormalizedPath = function (fileName, openedByClient, fileContent, scriptKind, hasMixedContent) { - var _this = this; - var info = this.getScriptInfoForNormalizedPath(fileName); - if (!info) { - if (openedByClient || this.host.fileExists(fileName)) { - info = new server.ScriptInfo(this.host, fileName, scriptKind, hasMixedContent); - this.filenameToScriptInfo.set(info.path, info); - if (openedByClient) { - if (fileContent === undefined) { - fileContent = this.host.readFile(fileName) || ""; - } - } - else { - if (!hasMixedContent) { - info.setWatcher(this.host.watchFile(fileName, function (_) { return _this.onSourceFileChanged(fileName); })); - } - } - } - } - if (info) { - if (openedByClient && !info.isScriptOpen()) { - info.open(fileContent); - if (hasMixedContent) { - info.registerFileUpdate(); - } - } - else if (fileContent !== undefined) { - info.reload(fileContent); - } - } - return info; - }; - ProjectService.prototype.getScriptInfoForNormalizedPath = function (fileName) { - return this.getScriptInfoForPath(server.normalizedPathToPath(fileName, this.host.getCurrentDirectory(), this.toCanonicalFileName)); - }; - ProjectService.prototype.getScriptInfoForPath = function (fileName) { - return this.filenameToScriptInfo.get(fileName); - }; - ProjectService.prototype.setHostConfiguration = function (args) { - if (args.file) { - var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file)); - if (info) { - info.setFormatOptions(convertFormatOptions(args.formatOptions)); - this.logger.info("Host configuration update for file " + args.file); - } - } - else { - if (args.hostInfo !== undefined) { - this.hostConfiguration.hostInfo = args.hostInfo; - this.logger.info("Host information " + args.hostInfo); - } - if (args.formatOptions) { - server.mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); - this.logger.info("Format host information updated"); - } - if (args.extraFileExtensions) { - this.hostConfiguration.extraFileExtensions = args.extraFileExtensions; - this.logger.info("Host file extension mappings updated"); - } - } - }; - ProjectService.prototype.closeLog = function () { - this.logger.close(); - }; - ProjectService.prototype.reloadProjects = function () { - this.logger.info("reload projects."); - for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { - var info = _a[_i]; - this.openOrUpdateConfiguredProjectForFile(info.fileName); - } - this.refreshInferredProjects(); - }; - ProjectService.prototype.refreshInferredProjects = function () { - this.logger.info("updating project structure from ..."); - this.printProjects(); - var orphantedFiles = []; - for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { - var info = _a[_i]; - if (info.containingProjects.length === 0) { - orphantedFiles.push(info); - } - else { - if (isRootFileInInferredProject(info) && info.containingProjects.length > 1) { - var inferredProject = info.containingProjects[0]; - ts.Debug.assert(inferredProject.projectKind === server.ProjectKind.Inferred); - inferredProject.removeFile(info); - if (!inferredProject.hasRoots()) { - this.removeProject(inferredProject); - } - } - } - } - for (var _b = 0, orphantedFiles_1 = orphantedFiles; _b < orphantedFiles_1.length; _b++) { - var f = orphantedFiles_1[_b]; - this.assignScriptInfoToInferredProjectIfNecessary(f, false); - } - for (var _c = 0, _d = this.inferredProjects; _c < _d.length; _c++) { - var p = _d[_c]; - p.updateGraph(); - } - this.printProjects(); - }; - ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind); - }; - ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent) { - var configFileName; - var configFileErrors; - var project = this.findContainingExternalProject(fileName); - if (!project) { - (_a = this.openOrUpdateConfiguredProjectForFile(fileName), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors); - if (configFileName) { - project = this.findConfiguredProjectByProjectName(configFileName); - } - } - if (project && !project.languageServiceEnabled) { - project.markAsDirty(); - } - var info = this.getOrCreateScriptInfoForNormalizedPath(fileName, true, fileContent, scriptKind, hasMixedContent); - this.assignScriptInfoToInferredProjectIfNecessary(info, true); - this.printProjects(); - return { configFileName: configFileName, configFileErrors: configFileErrors }; - var _a; - }; - ProjectService.prototype.closeClientFile = function (uncheckedFileName) { - var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); - if (info) { - this.closeOpenFile(info); - } - this.printProjects(); - }; - ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_4 = function (proj) { - var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); - result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); - }; - for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { - var proj = currentProjects_1[_i]; - _loop_4(proj); - } - }; - ProjectService.prototype.synchronizeProjectList = function (knownProjects) { - var files = []; - this.collectChanges(knownProjects, this.externalProjects, files); - this.collectChanges(knownProjects, this.configuredProjects, files); - this.collectChanges(knownProjects, this.inferredProjects, files); - return files; - }; - ProjectService.prototype.applyChangesInOpenFiles = function (openFiles, changedFiles, closedFiles) { - var recordChangedFiles = changedFiles && !openFiles && !closedFiles; - if (openFiles) { - for (var _i = 0, openFiles_1 = openFiles; _i < openFiles_1.length; _i++) { - var file = openFiles_1[_i]; - var scriptInfo = this.getScriptInfo(file.fileName); - ts.Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen()); - var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName); - this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent); - } - } - if (changedFiles) { - for (var _a = 0, changedFiles_2 = changedFiles; _a < changedFiles_2.length; _a++) { - var file = changedFiles_2[_a]; - var scriptInfo = this.getScriptInfo(file.fileName); - ts.Debug.assert(!!scriptInfo); - for (var i = file.changes.length - 1; i >= 0; i--) { - var change = file.changes[i]; - scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText); - } - if (recordChangedFiles) { - if (!this.changedFiles) { - this.changedFiles = [scriptInfo]; - } - else if (this.changedFiles.indexOf(scriptInfo) < 0) { - this.changedFiles.push(scriptInfo); - } - } - } - } - if (closedFiles) { - for (var _b = 0, closedFiles_1 = closedFiles; _b < closedFiles_1.length; _b++) { - var file = closedFiles_1[_b]; - this.closeClientFile(file); - } - } - if (openFiles || closedFiles) { - this.refreshInferredProjects(); - } - }; - ProjectService.prototype.closeConfiguredProject = function (configFile) { - var configuredProject = this.findConfiguredProjectByProjectName(configFile); - if (configuredProject && configuredProject.deleteOpenRef() === 0) { - this.removeProject(configuredProject); - } - }; - ProjectService.prototype.closeExternalProject = function (uncheckedFileName, suppressRefresh) { - if (suppressRefresh === void 0) { suppressRefresh = false; } - var fileName = server.toNormalizedPath(uncheckedFileName); - var configFiles = this.externalProjectToConfiguredProjectMap[fileName]; - if (configFiles) { - var shouldRefreshInferredProjects = false; - for (var _i = 0, configFiles_1 = configFiles; _i < configFiles_1.length; _i++) { - var configFile = configFiles_1[_i]; - if (this.closeConfiguredProject(configFile)) { - shouldRefreshInferredProjects = true; - } - } - delete this.externalProjectToConfiguredProjectMap[fileName]; - if (shouldRefreshInferredProjects && !suppressRefresh) { - this.refreshInferredProjects(); - } - } - else { - var externalProject = this.findExternalProjectByProjectName(uncheckedFileName); - if (externalProject) { - this.removeProject(externalProject); - if (!suppressRefresh) { - this.refreshInferredProjects(); - } - } - } - }; - ProjectService.prototype.openExternalProjects = function (projects) { - var projectsToClose = ts.arrayToMap(this.externalProjects, function (p) { return p.getProjectName(); }, function (_) { return true; }); - for (var externalProjectName in this.externalProjectToConfiguredProjectMap) { - projectsToClose[externalProjectName] = true; - } - for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { - var externalProject = projects_4[_i]; - this.openExternalProject(externalProject, true); - delete projectsToClose[externalProject.projectFileName]; - } - for (var externalProjectName in projectsToClose) { - this.closeExternalProject(externalProjectName, true); - } - this.refreshInferredProjects(); - }; - ProjectService.prototype.openExternalProject = function (proj, suppressRefreshOfInferredProjects) { - if (suppressRefreshOfInferredProjects === void 0) { suppressRefreshOfInferredProjects = false; } - if (proj.typingOptions && !proj.typeAcquisition) { - var typeAcquisition = ts.convertEnableAutoDiscoveryToEnable(proj.typingOptions); - proj.typeAcquisition = typeAcquisition; - } - var tsConfigFiles; - var rootFiles = []; - for (var _i = 0, _a = proj.rootFiles; _i < _a.length; _i++) { - var file = _a[_i]; - var normalized = server.toNormalizedPath(file.fileName); - if (ts.getBaseFileName(normalized) === "tsconfig.json") { - if (this.host.fileExists(normalized)) { - (tsConfigFiles || (tsConfigFiles = [])).push(normalized); - } - } - else { - rootFiles.push(file); - } - } - if (tsConfigFiles) { - tsConfigFiles.sort(); - } - var externalProject = this.findExternalProjectByProjectName(proj.projectFileName); - var exisingConfigFiles; - if (externalProject) { - if (!tsConfigFiles) { - var compilerOptions = convertCompilerOptions(proj.options); - if (this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, proj.rootFiles, externalFilePropertyReader)) { - externalProject.disableLanguageService(); - } - else { - externalProject.enableLanguageService(); - } - this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, compilerOptions, proj.typeAcquisition, proj.options.compileOnSave, undefined); - return; - } - this.closeExternalProject(proj.projectFileName, true); - } - else if (this.externalProjectToConfiguredProjectMap[proj.projectFileName]) { - if (!tsConfigFiles) { - this.closeExternalProject(proj.projectFileName, true); - } - else { - var oldConfigFiles = this.externalProjectToConfiguredProjectMap[proj.projectFileName]; - var iNew = 0; - var iOld = 0; - while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { - var newConfig = tsConfigFiles[iNew]; - var oldConfig = oldConfigFiles[iOld]; - if (oldConfig < newConfig) { - this.closeConfiguredProject(oldConfig); - iOld++; - } - else if (oldConfig > newConfig) { - iNew++; - } - else { - (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig); - iOld++; - iNew++; - } - } - for (var i = iOld; i < oldConfigFiles.length; i++) { - this.closeConfiguredProject(oldConfigFiles[i]); - } - } - } - if (tsConfigFiles) { - this.externalProjectToConfiguredProjectMap[proj.projectFileName] = tsConfigFiles; - for (var _b = 0, tsConfigFiles_1 = tsConfigFiles; _b < tsConfigFiles_1.length; _b++) { - var tsconfigFile = tsConfigFiles_1[_b]; - var project = this.findConfiguredProjectByProjectName(tsconfigFile); - if (!project) { - var result = this.openConfigFile(tsconfigFile); - project = result.success && result.project; - } - if (project && !ts.contains(exisingConfigFiles, tsconfigFile)) { - project.addOpenRef(); - } - } - } - else { - delete this.externalProjectToConfiguredProjectMap[proj.projectFileName]; - this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); - } - if (!suppressRefreshOfInferredProjects) { - this.refreshInferredProjects(); - } - }; - return ProjectService; - }()); - server.ProjectService = ProjectService; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - function hrTimeToMilliseconds(time) { - var seconds = time[0]; - var nanoseconds = time[1]; - return ((1e9 * seconds) + nanoseconds) / 1000000.0; - } - function shouldSkipSematicCheck(project) { - if (project.getCompilerOptions().skipLibCheck !== undefined) { - return false; - } - if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && project.isJsOnlyProject()) { - return true; - } - return false; - } - function compareNumber(a, b) { - return a - b; - } - function compareFileStart(a, b) { - if (a.file < b.file) { - return -1; - } - else if (a.file == b.file) { - var n = compareNumber(a.start.line, b.start.line); - if (n === 0) { - return compareNumber(a.start.offset, b.start.offset); - } - else - return n; - } - else { - return 1; - } - } - function formatDiag(fileName, project, diag) { - var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); - return { - start: scriptInfo.positionToLineOffset(diag.start), - end: scriptInfo.positionToLineOffset(diag.start + diag.length), - text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), - code: diag.code - }; - } - function formatConfigFileDiag(diag) { - return { - start: undefined, - end: undefined, - text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") - }; - } - function allEditsBeforePos(edits, pos) { - for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { - var edit = edits_1[_i]; - if (ts.textSpanEnd(edit.span) >= pos) { - return false; - } - } - return true; - } - var CommandNames; - (function (CommandNames) { - CommandNames.Brace = "brace"; - CommandNames.BraceFull = "brace-full"; - CommandNames.BraceCompletion = "braceCompletion"; - CommandNames.Change = "change"; - CommandNames.Close = "close"; - CommandNames.Completions = "completions"; - CommandNames.CompletionsFull = "completions-full"; - CommandNames.CompletionDetails = "completionEntryDetails"; - CommandNames.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; - CommandNames.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; - CommandNames.Configure = "configure"; - CommandNames.Definition = "definition"; - CommandNames.DefinitionFull = "definition-full"; - CommandNames.Exit = "exit"; - CommandNames.Format = "format"; - CommandNames.Formatonkey = "formatonkey"; - CommandNames.FormatFull = "format-full"; - CommandNames.FormatonkeyFull = "formatonkey-full"; - CommandNames.FormatRangeFull = "formatRange-full"; - CommandNames.Geterr = "geterr"; - CommandNames.GeterrForProject = "geterrForProject"; - CommandNames.Implementation = "implementation"; - CommandNames.ImplementationFull = "implementation-full"; - CommandNames.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; - CommandNames.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; - CommandNames.NavBar = "navbar"; - CommandNames.NavBarFull = "navbar-full"; - CommandNames.NavTree = "navtree"; - CommandNames.NavTreeFull = "navtree-full"; - CommandNames.Navto = "navto"; - CommandNames.NavtoFull = "navto-full"; - CommandNames.Occurrences = "occurrences"; - CommandNames.DocumentHighlights = "documentHighlights"; - CommandNames.DocumentHighlightsFull = "documentHighlights-full"; - CommandNames.Open = "open"; - CommandNames.Quickinfo = "quickinfo"; - CommandNames.QuickinfoFull = "quickinfo-full"; - CommandNames.References = "references"; - CommandNames.ReferencesFull = "references-full"; - CommandNames.Reload = "reload"; - CommandNames.Rename = "rename"; - CommandNames.RenameInfoFull = "rename-full"; - CommandNames.RenameLocationsFull = "renameLocations-full"; - CommandNames.Saveto = "saveto"; - CommandNames.SignatureHelp = "signatureHelp"; - CommandNames.SignatureHelpFull = "signatureHelp-full"; - CommandNames.TypeDefinition = "typeDefinition"; - CommandNames.ProjectInfo = "projectInfo"; - CommandNames.ReloadProjects = "reloadProjects"; - CommandNames.Unknown = "unknown"; - CommandNames.OpenExternalProject = "openExternalProject"; - CommandNames.OpenExternalProjects = "openExternalProjects"; - CommandNames.CloseExternalProject = "closeExternalProject"; - CommandNames.SynchronizeProjectList = "synchronizeProjectList"; - CommandNames.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; - CommandNames.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; - CommandNames.Cleanup = "cleanup"; - CommandNames.OutliningSpans = "outliningSpans"; - CommandNames.TodoComments = "todoComments"; - CommandNames.Indentation = "indentation"; - CommandNames.DocCommentTemplate = "docCommentTemplate"; - CommandNames.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; - CommandNames.NameOrDottedNameSpan = "nameOrDottedNameSpan"; - CommandNames.BreakpointStatement = "breakpointStatement"; - CommandNames.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; - CommandNames.GetCodeFixes = "getCodeFixes"; - CommandNames.GetCodeFixesFull = "getCodeFixes-full"; - CommandNames.GetSupportedCodeFixes = "getSupportedCodeFixes"; - })(CommandNames = server.CommandNames || (server.CommandNames = {})); - function formatMessage(msg, logger, byteLength, newLine) { - var verboseLogging = logger.hasLevel(server.LogLevel.verbose); - var json = JSON.stringify(msg); - if (verboseLogging) { - logger.info(msg.type + ": " + json); - } - var len = byteLength(json, "utf8"); - return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; - } - server.formatMessage = formatMessage; - var Session = (function () { - function Session(host, cancellationToken, useSingleInferredProject, typingsInstaller, byteLength, hrtime, logger, canUseEvents, eventHandler) { - var _this = this; - this.host = host; - this.typingsInstaller = typingsInstaller; - this.byteLength = byteLength; - this.hrtime = hrtime; - this.logger = logger; - this.canUseEvents = canUseEvents; - this.changeSeq = 0; - this.handlers = ts.createMap((_a = {}, - _a[CommandNames.OpenExternalProject] = function (request) { - _this.projectService.openExternalProject(request.arguments, false); - return _this.requiredResponse(true); - }, - _a[CommandNames.OpenExternalProjects] = function (request) { - _this.projectService.openExternalProjects(request.arguments.projects); - return _this.requiredResponse(true); - }, - _a[CommandNames.CloseExternalProject] = function (request) { - _this.projectService.closeExternalProject(request.arguments.projectFileName); - return _this.requiredResponse(true); - }, - _a[CommandNames.SynchronizeProjectList] = function (request) { - var result = _this.projectService.synchronizeProjectList(request.arguments.knownProjects); - if (!result.some(function (p) { return p.projectErrors && p.projectErrors.length !== 0; })) { - return _this.requiredResponse(result); - } - var converted = ts.map(result, function (p) { - if (!p.projectErrors || p.projectErrors.length === 0) { - return p; - } - return { - info: p.info, - changes: p.changes, - files: p.files, - projectErrors: _this.convertToDiagnosticsWithLinePosition(p.projectErrors, undefined) - }; - }); - return _this.requiredResponse(converted); - }, - _a[CommandNames.ApplyChangedToOpenFiles] = function (request) { - _this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles); - _this.changeSeq++; - return _this.requiredResponse(true); - }, - _a[CommandNames.Exit] = function () { - _this.exit(); - return _this.notRequired(); - }, - _a[CommandNames.Definition] = function (request) { - return _this.requiredResponse(_this.getDefinition(request.arguments, true)); - }, - _a[CommandNames.DefinitionFull] = function (request) { - return _this.requiredResponse(_this.getDefinition(request.arguments, false)); - }, - _a[CommandNames.TypeDefinition] = function (request) { - return _this.requiredResponse(_this.getTypeDefinition(request.arguments)); - }, - _a[CommandNames.Implementation] = function (request) { - return _this.requiredResponse(_this.getImplementation(request.arguments, true)); - }, - _a[CommandNames.ImplementationFull] = function (request) { - return _this.requiredResponse(_this.getImplementation(request.arguments, false)); - }, - _a[CommandNames.References] = function (request) { - return _this.requiredResponse(_this.getReferences(request.arguments, true)); - }, - _a[CommandNames.ReferencesFull] = function (request) { - return _this.requiredResponse(_this.getReferences(request.arguments, false)); - }, - _a[CommandNames.Rename] = function (request) { - return _this.requiredResponse(_this.getRenameLocations(request.arguments, true)); - }, - _a[CommandNames.RenameLocationsFull] = function (request) { - return _this.requiredResponse(_this.getRenameLocations(request.arguments, false)); - }, - _a[CommandNames.RenameInfoFull] = function (request) { - return _this.requiredResponse(_this.getRenameInfo(request.arguments)); - }, - _a[CommandNames.Open] = function (request) { - _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName)); - return _this.notRequired(); - }, - _a[CommandNames.Quickinfo] = function (request) { - return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, true)); - }, - _a[CommandNames.QuickinfoFull] = function (request) { - return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, false)); - }, - _a[CommandNames.OutliningSpans] = function (request) { - return _this.requiredResponse(_this.getOutliningSpans(request.arguments)); - }, - _a[CommandNames.TodoComments] = function (request) { - return _this.requiredResponse(_this.getTodoComments(request.arguments)); - }, - _a[CommandNames.Indentation] = function (request) { - return _this.requiredResponse(_this.getIndentation(request.arguments)); - }, - _a[CommandNames.NameOrDottedNameSpan] = function (request) { - return _this.requiredResponse(_this.getNameOrDottedNameSpan(request.arguments)); - }, - _a[CommandNames.BreakpointStatement] = function (request) { - return _this.requiredResponse(_this.getBreakpointStatement(request.arguments)); - }, - _a[CommandNames.BraceCompletion] = function (request) { - return _this.requiredResponse(_this.isValidBraceCompletion(request.arguments)); - }, - _a[CommandNames.DocCommentTemplate] = function (request) { - return _this.requiredResponse(_this.getDocCommentTemplate(request.arguments)); - }, - _a[CommandNames.Format] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsForRange(request.arguments)); - }, - _a[CommandNames.Formatonkey] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsAfterKeystroke(request.arguments)); - }, - _a[CommandNames.FormatFull] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsForDocumentFull(request.arguments)); - }, - _a[CommandNames.FormatonkeyFull] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsAfterKeystrokeFull(request.arguments)); - }, - _a[CommandNames.FormatRangeFull] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsForRangeFull(request.arguments)); - }, - _a[CommandNames.Completions] = function (request) { - return _this.requiredResponse(_this.getCompletions(request.arguments, true)); - }, - _a[CommandNames.CompletionsFull] = function (request) { - return _this.requiredResponse(_this.getCompletions(request.arguments, false)); - }, - _a[CommandNames.CompletionDetails] = function (request) { - return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments)); - }, - _a[CommandNames.CompileOnSaveAffectedFileList] = function (request) { - return _this.requiredResponse(_this.getCompileOnSaveAffectedFileList(request.arguments)); - }, - _a[CommandNames.CompileOnSaveEmitFile] = function (request) { - return _this.requiredResponse(_this.emitFile(request.arguments)); - }, - _a[CommandNames.SignatureHelp] = function (request) { - return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, true)); - }, - _a[CommandNames.SignatureHelpFull] = function (request) { - return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, false)); - }, - _a[CommandNames.CompilerOptionsDiagnosticsFull] = function (request) { - return _this.requiredResponse(_this.getCompilerOptionsDiagnostics(request.arguments)); - }, - _a[CommandNames.EncodedSemanticClassificationsFull] = function (request) { - return _this.requiredResponse(_this.getEncodedSemanticClassifications(request.arguments)); - }, - _a[CommandNames.Cleanup] = function () { - _this.cleanup(); - return _this.requiredResponse(true); - }, - _a[CommandNames.SemanticDiagnosticsSync] = function (request) { - return _this.requiredResponse(_this.getSemanticDiagnosticsSync(request.arguments)); - }, - _a[CommandNames.SyntacticDiagnosticsSync] = function (request) { - return _this.requiredResponse(_this.getSyntacticDiagnosticsSync(request.arguments)); - }, - _a[CommandNames.Geterr] = function (request) { - var geterrArgs = request.arguments; - return { response: _this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; - }, - _a[CommandNames.GeterrForProject] = function (request) { - var _a = request.arguments, file = _a.file, delay = _a.delay; - return { response: _this.getDiagnosticsForProject(delay, file), responseRequired: false }; - }, - _a[CommandNames.Change] = function (request) { - _this.change(request.arguments); - return _this.notRequired(); - }, - _a[CommandNames.Configure] = function (request) { - _this.projectService.setHostConfiguration(request.arguments); - _this.output(undefined, CommandNames.Configure, request.seq); - return _this.notRequired(); - }, - _a[CommandNames.Reload] = function (request) { - _this.reload(request.arguments, request.seq); - return _this.requiredResponse({ reloadFinished: true }); - }, - _a[CommandNames.Saveto] = function (request) { - var savetoArgs = request.arguments; - _this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); - return _this.notRequired(); - }, - _a[CommandNames.Close] = function (request) { - var closeArgs = request.arguments; - _this.closeClientFile(closeArgs.file); - return _this.notRequired(); - }, - _a[CommandNames.Navto] = function (request) { - return _this.requiredResponse(_this.getNavigateToItems(request.arguments, true)); - }, - _a[CommandNames.NavtoFull] = function (request) { - return _this.requiredResponse(_this.getNavigateToItems(request.arguments, false)); - }, - _a[CommandNames.Brace] = function (request) { - return _this.requiredResponse(_this.getBraceMatching(request.arguments, true)); - }, - _a[CommandNames.BraceFull] = function (request) { - return _this.requiredResponse(_this.getBraceMatching(request.arguments, false)); - }, - _a[CommandNames.NavBar] = function (request) { - return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, true)); - }, - _a[CommandNames.NavBarFull] = function (request) { - return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, false)); - }, - _a[CommandNames.NavTree] = function (request) { - return _this.requiredResponse(_this.getNavigationTree(request.arguments, true)); - }, - _a[CommandNames.NavTreeFull] = function (request) { - return _this.requiredResponse(_this.getNavigationTree(request.arguments, false)); - }, - _a[CommandNames.Occurrences] = function (request) { - return _this.requiredResponse(_this.getOccurrences(request.arguments)); - }, - _a[CommandNames.DocumentHighlights] = function (request) { - return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, true)); - }, - _a[CommandNames.DocumentHighlightsFull] = function (request) { - return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, false)); - }, - _a[CommandNames.CompilerOptionsForInferredProjects] = function (request) { - _this.setCompilerOptionsForInferredProjects(request.arguments); - return _this.requiredResponse(true); - }, - _a[CommandNames.ProjectInfo] = function (request) { - return _this.requiredResponse(_this.getProjectInfo(request.arguments)); - }, - _a[CommandNames.ReloadProjects] = function () { - _this.projectService.reloadProjects(); - return _this.notRequired(); - }, - _a[CommandNames.GetCodeFixes] = function (request) { - return _this.requiredResponse(_this.getCodeFixes(request.arguments, true)); - }, - _a[CommandNames.GetCodeFixesFull] = function (request) { - return _this.requiredResponse(_this.getCodeFixes(request.arguments, false)); - }, - _a[CommandNames.GetSupportedCodeFixes] = function () { - return _this.requiredResponse(_this.getSupportedCodeFixes()); - }, - _a)); - this.eventHander = canUseEvents - ? eventHandler || (function (event) { return _this.defaultEventHandler(event); }) - : undefined; - this.projectService = new server.ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); - this.gcTimer = new server.GcTimer(host, 7000, logger); - var _a; - } - Session.prototype.defaultEventHandler = function (event) { - var _this = this; - switch (event.eventName) { - case server.ContextEvent: - var _a = event.data, project = _a.project, fileName = _a.fileName; - this.projectService.logger.info("got context event, updating diagnostics for " + fileName); - this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); - break; - case server.ConfigFileDiagEvent: - var _b = event.data, triggerFile = _b.triggerFile, configFileName = _b.configFileName, diagnostics = _b.diagnostics; - this.configFileDiagnosticEvent(triggerFile, configFileName, diagnostics); - break; - case server.ProjectLanguageServiceStateEvent: - var eventName = "projectLanguageServiceState"; - this.event({ - projectName: event.data.project.getProjectName(), - languageServiceEnabled: event.data.languageServiceEnabled - }, eventName); - break; - } - }; - Session.prototype.logError = function (err, cmd) { - var msg = "Exception on executing command " + cmd; - if (err.message) { - msg += ":\n" + err.message; - if (err.stack) { - msg += "\n" + err.stack; - } - } - this.logger.msg(msg, server.Msg.Err); - }; - Session.prototype.send = function (msg) { - if (msg.type === "event" && !this.canUseEvents) { - if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Session does not support events: ignored event: " + JSON.stringify(msg)); - } - return; - } - this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine)); - }; - Session.prototype.configFileDiagnosticEvent = function (triggerFile, configFile, diagnostics) { - var bakedDiags = ts.map(diagnostics, formatConfigFileDiag); - var ev = { - seq: 0, - type: "event", - event: "configFileDiag", - body: { - triggerFile: triggerFile, - configFile: configFile, - diagnostics: bakedDiags - } - }; - this.send(ev); - }; - Session.prototype.event = function (info, eventName) { - var ev = { - seq: 0, - type: "event", - event: eventName, - body: info, - }; - this.send(ev); - }; - Session.prototype.output = function (info, cmdName, reqSeq, errorMsg) { - if (reqSeq === void 0) { reqSeq = 0; } - var res = { - seq: 0, - type: "response", - command: cmdName, - request_seq: reqSeq, - success: !errorMsg, - }; - if (!errorMsg) { - res.body = info; - } - else { - res.message = errorMsg; - } - this.send(res); - }; - Session.prototype.semanticCheck = function (file, project) { - try { - var diags = []; - if (!shouldSkipSematicCheck(project)) { - diags = project.getLanguageService().getSemanticDiagnostics(file); - } - var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); - this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); - } - catch (err) { - this.logError(err, "semantic check"); - } - }; - Session.prototype.syntacticCheck = function (file, project) { - try { - var diags = project.getLanguageService().getSyntacticDiagnostics(file); - if (diags) { - var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); - this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag"); - } - } - catch (err) { - this.logError(err, "syntactic check"); - } - }; - Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { - var _this = this; - if (ms === void 0) { ms = 1500; } - this.host.setTimeout(function () { - if (matchSeq(seq)) { - _this.projectService.refreshInferredProjects(); - } - }, ms); - }; - Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs, requireOpen) { - var _this = this; - if (ms === void 0) { ms = 1500; } - if (followMs === void 0) { followMs = 200; } - if (requireOpen === void 0) { requireOpen = true; } - if (followMs > ms) { - followMs = ms; - } - if (this.errorTimer) { - this.host.clearTimeout(this.errorTimer); - } - if (this.immediateId) { - this.host.clearImmediate(this.immediateId); - this.immediateId = undefined; - } - var index = 0; - var checkOne = function () { - if (matchSeq(seq)) { - var checkSpec_1 = checkList[index]; - index++; - if (checkSpec_1.project.containsFile(checkSpec_1.fileName, requireOpen)) { - _this.syntacticCheck(checkSpec_1.fileName, checkSpec_1.project); - _this.immediateId = _this.host.setImmediate(function () { - _this.semanticCheck(checkSpec_1.fileName, checkSpec_1.project); - _this.immediateId = undefined; - if (checkList.length > index) { - _this.errorTimer = _this.host.setTimeout(checkOne, followMs); - } - else { - _this.errorTimer = undefined; - } - }); - } - } - }; - if ((checkList.length > index) && (matchSeq(seq))) { - this.errorTimer = this.host.setTimeout(checkOne, ms); - } - }; - Session.prototype.cleanProjects = function (caption, projects) { - if (!projects) { - return; - } - this.logger.info("cleaning " + caption); - for (var _i = 0, projects_5 = projects; _i < projects_5.length; _i++) { - var p = projects_5[_i]; - p.getLanguageService(false).cleanupSemanticCache(); - } - }; - Session.prototype.cleanup = function () { - this.cleanProjects("inferred projects", this.projectService.inferredProjects); - this.cleanProjects("configured projects", this.projectService.configuredProjects); - this.cleanProjects("external projects", this.projectService.externalProjects); - if (this.host.gc) { - this.logger.info("host.gc()"); - this.host.gc(); - } - }; - Session.prototype.getEncodedSemanticClassifications = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - return project.getLanguageService().getEncodedSemanticClassifications(file, args); - }; - Session.prototype.getProject = function (projectFileName) { - return projectFileName && this.projectService.findProject(projectFileName); - }; - Session.prototype.getCompilerOptionsDiagnostics = function (args) { - var project = this.getProject(args.projectFileName); - return this.convertToDiagnosticsWithLinePosition(project.getLanguageService().getCompilerOptionsDiagnostics(), undefined); - }; - Session.prototype.convertToDiagnosticsWithLinePosition = function (diagnostics, scriptInfo) { - var _this = this; - return diagnostics.map(function (d) { return ({ - message: ts.flattenDiagnosticMessageText(d.messageText, _this.host.newLine), - start: d.start, - length: d.length, - category: ts.DiagnosticCategory[d.category].toLowerCase(), - code: d.code, - startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start), - endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length) - }); }); - }; - Session.prototype.getDiagnosticsWorker = function (args, isSemantic, selector, includeLinePosition) { - var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; - if (isSemantic && shouldSkipSematicCheck(project)) { - return []; - } - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var diagnostics = selector(project, file); - return includeLinePosition - ? this.convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo) - : diagnostics.map(function (d) { return formatDiag(file, project, d); }); - }; - Session.prototype.getDefinition = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var definitions = project.getLanguageService().getDefinitionAtPosition(file, position); - if (!definitions) { - return undefined; - } - if (simplifiedResult) { - return definitions.map(function (def) { - var defScriptInfo = project.getScriptInfo(def.fileName); - return { - file: def.fileName, - start: defScriptInfo.positionToLineOffset(def.textSpan.start), - end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) - }; - }); - } - else { - return definitions; - } - }; - Session.prototype.getTypeDefinition = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var definitions = project.getLanguageService().getTypeDefinitionAtPosition(file, position); - if (!definitions) { - return undefined; - } - return definitions.map(function (def) { - var defScriptInfo = project.getScriptInfo(def.fileName); - return { - file: def.fileName, - start: defScriptInfo.positionToLineOffset(def.textSpan.start), - end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) - }; - }); - }; - Session.prototype.getImplementation = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var implementations = project.getLanguageService().getImplementationAtPosition(file, position); - if (!implementations) { - return []; - } - if (simplifiedResult) { - return implementations.map(function (impl) { return ({ - file: impl.fileName, - start: scriptInfo.positionToLineOffset(impl.textSpan.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(impl.textSpan)) - }); }); - } - else { - return implementations; - } - }; - Session.prototype.getOccurrences = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position); - if (!occurrences) { - return undefined; - } - return occurrences.map(function (occurrence) { - var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan; - var scriptInfo = project.getScriptInfo(fileName); - var start = scriptInfo.positionToLineOffset(textSpan.start); - var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); - return { - start: start, - end: end, - file: fileName, - isWriteAccess: isWriteAccess, - }; - }); - }; - Session.prototype.getSyntacticDiagnosticsSync = function (args) { - return this.getDiagnosticsWorker(args, false, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); - }; - Session.prototype.getSemanticDiagnosticsSync = function (args) { - return this.getDiagnosticsWorker(args, true, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, args.includeLinePosition); - }; - Session.prototype.getDocumentHighlights = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var documentHighlights = project.getLanguageService().getDocumentHighlights(file, position, args.filesToSearch); - if (!documentHighlights) { - return undefined; - } - if (simplifiedResult) { - return documentHighlights.map(convertToDocumentHighlightsItem); - } - else { - return documentHighlights; - } - function convertToDocumentHighlightsItem(documentHighlights) { - var fileName = documentHighlights.fileName, highlightSpans = documentHighlights.highlightSpans; - var scriptInfo = project.getScriptInfo(fileName); - return { - file: fileName, - highlightSpans: highlightSpans.map(convertHighlightSpan) - }; - function convertHighlightSpan(highlightSpan) { - var textSpan = highlightSpan.textSpan, kind = highlightSpan.kind; - var start = scriptInfo.positionToLineOffset(textSpan.start); - var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); - return { start: start, end: end, kind: kind }; - } - } - }; - Session.prototype.setCompilerOptionsForInferredProjects = function (args) { - this.projectService.setCompilerOptionsForInferredProjects(args.options); - }; - Session.prototype.getProjectInfo = function (args) { - return this.getProjectInfoWorker(args.file, args.projectFileName, args.needFileNameList); - }; - Session.prototype.getProjectInfoWorker = function (uncheckedFileName, projectFileName, needFileNameList) { - var project = this.getFileAndProjectWorker(uncheckedFileName, projectFileName, true, true).project; - var projectInfo = { - configFileName: project.getProjectName(), - languageServiceDisabled: !project.languageServiceEnabled, - fileNames: needFileNameList ? project.getFileNames() : undefined - }; - return projectInfo; - }; - Session.prototype.getRenameInfo = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - return project.getLanguageService().getRenameInfo(file, position); - }; - Session.prototype.getProjects = function (args) { - var projects; - if (args.projectFileName) { - var project = this.getProject(args.projectFileName); - if (project) { - projects = [project]; - } - } - else { - var scriptInfo = this.projectService.getScriptInfo(args.file); - projects = scriptInfo.containingProjects; - } - projects = ts.filter(projects, function (p) { return p.languageServiceEnabled; }); - if (!projects || !projects.length) { - return server.Errors.ThrowNoProject(); - } - return projects; - }; - Session.prototype.getRenameLocations = function (args, simplifiedResult) { - var file = server.toNormalizedPath(args.file); - var info = this.projectService.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, info); - var projects = this.getProjects(args); - if (simplifiedResult) { - var defaultProject = projects[0]; - var renameInfo = defaultProject.getLanguageService().getRenameInfo(file, position); - if (!renameInfo) { - return undefined; - } - if (!renameInfo.canRename) { - return { - info: renameInfo, - locs: [] - }; - } - var fileSpans = server.combineProjectOutput(projects, function (project) { - var renameLocations = project.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); - if (!renameLocations) { - return []; - } - return renameLocations.map(function (location) { - var locationScriptInfo = project.getScriptInfo(location.fileName); - return { - file: location.fileName, - start: locationScriptInfo.positionToLineOffset(location.textSpan.start), - end: locationScriptInfo.positionToLineOffset(ts.textSpanEnd(location.textSpan)), - }; - }); - }, compareRenameLocation, function (a, b) { return a.file === b.file && a.start.line === b.start.line && a.start.offset === b.start.offset; }); - var locs = fileSpans.reduce(function (accum, cur) { - var curFileAccum; - if (accum.length > 0) { - curFileAccum = accum[accum.length - 1]; - if (curFileAccum.file !== cur.file) { - curFileAccum = undefined; - } - } - if (!curFileAccum) { - curFileAccum = { file: cur.file, locs: [] }; - accum.push(curFileAccum); - } - curFileAccum.locs.push({ start: cur.start, end: cur.end }); - return accum; - }, []); - return { info: renameInfo, locs: locs }; - } - else { - return server.combineProjectOutput(projects, function (p) { return p.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); }, undefined, renameLocationIsEqualTo); - } - function renameLocationIsEqualTo(a, b) { - if (a === b) { - return true; - } - if (!a || !b) { - return false; - } - return a.fileName === b.fileName && - a.textSpan.start === b.textSpan.start && - a.textSpan.length === b.textSpan.length; - } - function compareRenameLocation(a, b) { - if (a.file < b.file) { - return -1; - } - else if (a.file > b.file) { - return 1; - } - else { - if (a.start.line < b.start.line) { - return 1; - } - else if (a.start.line > b.start.line) { - return -1; - } - else { - return b.start.offset - a.start.offset; - } - } - } - }; - Session.prototype.getReferences = function (args, simplifiedResult) { - var file = server.toNormalizedPath(args.file); - var projects = this.getProjects(args); - var defaultProject = projects[0]; - var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - if (simplifiedResult) { - var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); - if (!nameInfo) { - return undefined; - } - var displayString = ts.displayPartsToString(nameInfo.displayParts); - var nameSpan = nameInfo.textSpan; - var nameColStart = scriptInfo.positionToLineOffset(nameSpan.start).offset; - var nameText = scriptInfo.getSnapshot().getText(nameSpan.start, ts.textSpanEnd(nameSpan)); - var refs = server.combineProjectOutput(projects, function (project) { - var references = project.getLanguageService().getReferencesAtPosition(file, position); - if (!references) { - return []; - } - return references.map(function (ref) { - var refScriptInfo = project.getScriptInfo(ref.fileName); - var start = refScriptInfo.positionToLineOffset(ref.textSpan.start); - var refLineSpan = refScriptInfo.lineToTextSpan(start.line - 1); - var lineText = refScriptInfo.getSnapshot().getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); - return { - file: ref.fileName, - start: start, - lineText: lineText, - end: refScriptInfo.positionToLineOffset(ts.textSpanEnd(ref.textSpan)), - isWriteAccess: ref.isWriteAccess, - isDefinition: ref.isDefinition - }; - }); - }, compareFileStart, areReferencesResponseItemsForTheSameLocation); - return { - refs: refs, - symbolName: nameText, - symbolStartOffset: nameColStart, - symbolDisplayString: displayString - }; - } - else { - return server.combineProjectOutput(projects, function (project) { return project.getLanguageService().findReferences(file, position); }, undefined, undefined); - } - function areReferencesResponseItemsForTheSameLocation(a, b) { - if (a && b) { - return a.file === b.file && - a.start === b.start && - a.end === b.end; - } - return false; - } - }; - Session.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - var _a = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; - if (this.eventHander) { - this.eventHander({ - eventName: "configFileDiag", - data: { triggerFile: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } - }); - } - }; - Session.prototype.getPosition = function (args, scriptInfo) { - return args.position !== undefined ? args.position : scriptInfo.lineOffsetToPosition(args.line, args.offset); - }; - Session.prototype.getFileAndProject = function (args, errorOnMissingProject) { - if (errorOnMissingProject === void 0) { errorOnMissingProject = true; } - return this.getFileAndProjectWorker(args.file, args.projectFileName, true, errorOnMissingProject); - }; - Session.prototype.getFileAndProjectWithoutRefreshingInferredProjects = function (args, errorOnMissingProject) { - if (errorOnMissingProject === void 0) { errorOnMissingProject = true; } - return this.getFileAndProjectWorker(args.file, args.projectFileName, false, errorOnMissingProject); - }; - Session.prototype.getFileAndProjectWorker = function (uncheckedFileName, projectFileName, refreshInferredProjects, errorOnMissingProject) { - var file = server.toNormalizedPath(uncheckedFileName); - var project = this.getProject(projectFileName) || this.projectService.getDefaultProjectForFile(file, refreshInferredProjects); - if (!project && errorOnMissingProject) { - return server.Errors.ThrowNoProject(); - } - return { file: file, project: project }; - }; - Session.prototype.getOutliningSpans = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - return project.getLanguageService(false).getOutliningSpans(file); - }; - Session.prototype.getTodoComments = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - return project.getLanguageService().getTodoComments(file, args.descriptors); - }; - Session.prototype.getDocCommentTemplate = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - return project.getLanguageService(false).getDocCommentTemplateAtPosition(file, position); - }; - Session.prototype.getIndentation = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); - var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); - var indentation = project.getLanguageService(false).getIndentationAtPosition(file, position, options); - return { position: position, indentation: indentation }; - }; - Session.prototype.getBreakpointStatement = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); - return project.getLanguageService(false).getBreakpointStatementAtPosition(file, position); - }; - Session.prototype.getNameOrDottedNameSpan = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); - return project.getLanguageService(false).getNameOrDottedNameSpan(file, position, position); - }; - Session.prototype.isValidBraceCompletion = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); - return project.getLanguageService(false).isValidBraceCompletionAtPosition(file, position, args.openingBrace.charCodeAt(0)); - }; - Session.prototype.getQuickInfoWorker = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var quickInfo = project.getLanguageService().getQuickInfoAtPosition(file, this.getPosition(args, scriptInfo)); - if (!quickInfo) { - return undefined; - } - if (simplifiedResult) { - var displayString = ts.displayPartsToString(quickInfo.displayParts); - var docString = ts.displayPartsToString(quickInfo.documentation); - return { - kind: quickInfo.kind, - kindModifiers: quickInfo.kindModifiers, - start: scriptInfo.positionToLineOffset(quickInfo.textSpan.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), - displayString: displayString, - documentation: docString, - }; - } - else { - return quickInfo; - } - }; - Session.prototype.getFormattingEditsForRange = function (args) { - var _this = this; - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var startPosition = scriptInfo.lineOffsetToPosition(args.line, args.offset); - var endPosition = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); - var edits = project.getLanguageService(false).getFormattingEditsForRange(file, startPosition, endPosition, this.projectService.getFormatCodeOptions(file)); - if (!edits) { - return undefined; - } - return edits.map(function (edit) { return _this.convertTextChangeToCodeEdit(edit, scriptInfo); }); - }; - Session.prototype.getFormattingEditsForRangeFull = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); - return project.getLanguageService(false).getFormattingEditsForRange(file, args.position, args.endPosition, options); - }; - Session.prototype.getFormattingEditsForDocumentFull = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); - return project.getLanguageService(false).getFormattingEditsForDocument(file, options); - }; - Session.prototype.getFormattingEditsAfterKeystrokeFull = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); - return project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, args.position, args.key, options); - }; - Session.prototype.getFormattingEditsAfterKeystroke = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = scriptInfo.lineOffsetToPosition(args.line, args.offset); - var formatOptions = this.projectService.getFormatCodeOptions(file); - var edits = project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, position, args.key, formatOptions); - if ((args.key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { - var lineInfo = scriptInfo.getLineInfo(args.line); - if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { - var lineText = lineInfo.leaf.text; - if (lineText.search("\\S") < 0) { - var preferredIndent = project.getLanguageService(false).getIndentationAtPosition(file, position, formatOptions); - var hasIndent = 0; - var i = void 0, len = void 0; - for (i = 0, len = lineText.length; i < len; i++) { - if (lineText.charAt(i) == " ") { - hasIndent++; - } - else if (lineText.charAt(i) == "\t") { - hasIndent += formatOptions.tabSize; - } - else { - break; - } - } - if (preferredIndent !== hasIndent) { - var firstNoWhiteSpacePosition = lineInfo.offset + i; - edits.push({ - span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition), - newText: ts.formatting.getIndentationString(preferredIndent, formatOptions) - }); - } - } - } - } - if (!edits) { - return undefined; - } - return edits.map(function (edit) { - return { - start: scriptInfo.positionToLineOffset(edit.span.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(edit.span)), - newText: edit.newText ? edit.newText : "" - }; - }); - }; - Session.prototype.getCompletions = function (args, simplifiedResult) { - var _this = this; - var prefix = args.prefix || ""; - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var completions = project.getLanguageService().getCompletionsAtPosition(file, position); - if (!completions) { - return undefined; - } - if (simplifiedResult) { - return completions.entries.reduce(function (result, entry) { - if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_53 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; - var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; - result.push({ name: name_53, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); - } - return result; - }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); - } - else { - return completions; - } - }; - Session.prototype.getCompletionEntryDetails = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - return args.entryNames.reduce(function (accum, entryName) { - var details = project.getLanguageService().getCompletionEntryDetails(file, position, entryName); - if (details) { - accum.push(details); - } - return accum; - }, []); - }; - Session.prototype.getCompileOnSaveAffectedFileList = function (args) { - var info = this.projectService.getScriptInfo(args.file); - var result = []; - if (!info) { - return []; - } - var projectsToSearch = args.projectFileName ? [this.projectService.findProject(args.projectFileName)] : info.containingProjects; - for (var _i = 0, projectsToSearch_1 = projectsToSearch; _i < projectsToSearch_1.length; _i++) { - var project = projectsToSearch_1[_i]; - if (project.compileOnSaveEnabled && project.languageServiceEnabled) { - result.push({ - projectFileName: project.getProjectName(), - fileNames: project.getCompileOnSaveAffectedFileList(info) - }); - } - } - return result; - }; - Session.prototype.emitFile = function (args) { - var _this = this; - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - if (!project) { - server.Errors.ThrowNoProject(); - } - if (!project.languageServiceEnabled) { - return false; - } - var scriptInfo = project.getScriptInfo(file); - return project.builder.emitFile(scriptInfo, function (path, data, writeByteOrderMark) { return _this.host.writeFile(path, data, writeByteOrderMark); }); - }; - Session.prototype.getSignatureHelpItems = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var helpItems = project.getLanguageService().getSignatureHelpItems(file, position); - if (!helpItems) { - return undefined; - } - if (simplifiedResult) { - var span_16 = helpItems.applicableSpan; - return { - items: helpItems.items, - applicableSpan: { - start: scriptInfo.positionToLineOffset(span_16.start), - end: scriptInfo.positionToLineOffset(span_16.start + span_16.length) - }, - selectedItemIndex: helpItems.selectedItemIndex, - argumentIndex: helpItems.argumentIndex, - argumentCount: helpItems.argumentCount, - }; - } - else { - return helpItems; - } - }; - Session.prototype.getDiagnostics = function (delay, fileNames) { - var _this = this; - var checkList = fileNames.reduce(function (accum, uncheckedFileName) { - var fileName = server.toNormalizedPath(uncheckedFileName); - var project = _this.projectService.getDefaultProjectForFile(fileName, true); - if (project) { - accum.push({ fileName: fileName, project: project }); - } - return accum; - }, []); - if (checkList.length > 0) { - this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); - } - }; - Session.prototype.change = function (args) { - var _this = this; - var _a = this.getFileAndProject(args, false), file = _a.file, project = _a.project; - if (project) { - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var start = scriptInfo.lineOffsetToPosition(args.line, args.offset); - var end = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); - if (start >= 0) { - scriptInfo.editContent(start, end, args.insertString); - this.changeSeq++; - } - this.updateProjectStructure(this.changeSeq, function (n) { return n === _this.changeSeq; }); - } - }; - Session.prototype.reload = function (args, reqSeq) { - var file = server.toNormalizedPath(args.file); - var tempFileName = args.tmpfile && server.toNormalizedPath(args.tmpfile); - var project = this.projectService.getDefaultProjectForFile(file, true); - if (project) { - this.changeSeq++; - if (project.reloadScript(file, tempFileName)) { - this.output(undefined, CommandNames.Reload, reqSeq); - } - } - }; - Session.prototype.saveToTmp = function (fileName, tempFileName) { - var scriptInfo = this.projectService.getScriptInfo(fileName); - if (scriptInfo) { - scriptInfo.saveTo(tempFileName); - } - }; - Session.prototype.closeClientFile = function (fileName) { - if (!fileName) { - return; - } - var file = ts.normalizePath(fileName); - this.projectService.closeClientFile(file); - }; - Session.prototype.decorateNavigationBarItems = function (items, scriptInfo) { - var _this = this; - return ts.map(items, function (item) { return ({ - text: item.text, - kind: item.kind, - kindModifiers: item.kindModifiers, - spans: item.spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }), - childItems: _this.decorateNavigationBarItems(item.childItems, scriptInfo), - indent: item.indent - }); }); - }; - Session.prototype.getNavigationBarItems = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var items = project.getLanguageService(false).getNavigationBarItems(file); - return !items - ? undefined - : simplifiedResult - ? this.decorateNavigationBarItems(items, project.getScriptInfoForNormalizedPath(file)) - : items; - }; - Session.prototype.decorateNavigationTree = function (tree, scriptInfo) { - var _this = this; - return { - text: tree.text, - kind: tree.kind, - kindModifiers: tree.kindModifiers, - spans: tree.spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }), - childItems: ts.map(tree.childItems, function (item) { return _this.decorateNavigationTree(item, scriptInfo); }) - }; - }; - Session.prototype.decorateSpan = function (span, scriptInfo) { - return { - start: scriptInfo.positionToLineOffset(span.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(span)) - }; - }; - Session.prototype.getNavigationTree = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var tree = project.getLanguageService(false).getNavigationTree(file); - return !tree - ? undefined - : simplifiedResult - ? this.decorateNavigationTree(tree, project.getScriptInfoForNormalizedPath(file)) - : tree; - }; - Session.prototype.getNavigateToItems = function (args, simplifiedResult) { - var projects = this.getProjects(args); - var fileName = args.currentFileOnly ? args.file && ts.normalizeSlashes(args.file) : undefined; - if (simplifiedResult) { - return server.combineProjectOutput(projects, function (project) { - var navItems = project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); - if (!navItems) { - return []; - } - return navItems.map(function (navItem) { - var scriptInfo = project.getScriptInfo(navItem.fileName); - var start = scriptInfo.positionToLineOffset(navItem.textSpan.start); - var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(navItem.textSpan)); - var bakedItem = { - name: navItem.name, - kind: navItem.kind, - file: navItem.fileName, - start: start, - end: end, - }; - if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { - bakedItem.kindModifiers = navItem.kindModifiers; - } - if (navItem.matchKind !== "none") { - bakedItem.matchKind = navItem.matchKind; - } - if (navItem.containerName && (navItem.containerName.length > 0)) { - bakedItem.containerName = navItem.containerName; - } - if (navItem.containerKind && (navItem.containerKind.length > 0)) { - bakedItem.containerKind = navItem.containerKind; - } - return bakedItem; - }); - }, undefined, areNavToItemsForTheSameLocation); - } - else { - return server.combineProjectOutput(projects, function (project) { return project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); }, undefined, navigateToItemIsEqualTo); - } - function navigateToItemIsEqualTo(a, b) { - if (a === b) { - return true; - } - if (!a || !b) { - return false; - } - return a.containerKind === b.containerKind && - a.containerName === b.containerName && - a.fileName === b.fileName && - a.isCaseSensitive === b.isCaseSensitive && - a.kind === b.kind && - a.kindModifiers === b.containerName && - a.matchKind === b.matchKind && - a.name === b.name && - a.textSpan.start === b.textSpan.start && - a.textSpan.length === b.textSpan.length; - } - function areNavToItemsForTheSameLocation(a, b) { - if (a && b) { - return a.file === b.file && - a.start === b.start && - a.end === b.end; - } - return false; - } - }; - Session.prototype.getSupportedCodeFixes = function () { - return ts.getSupportedCodeFixes(); - }; - Session.prototype.getCodeFixes = function (args, simplifiedResult) { - var _this = this; - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var startPosition = getStartPosition(); - var endPosition = getEndPosition(); - var codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes); - if (!codeActions) { - return undefined; - } - if (simplifiedResult) { - return codeActions.map(function (codeAction) { return _this.mapCodeAction(codeAction, scriptInfo); }); - } - else { - return codeActions; - } - function getStartPosition() { - return args.startPosition !== undefined ? args.startPosition : scriptInfo.lineOffsetToPosition(args.startLine, args.startOffset); - } - function getEndPosition() { - return args.endPosition !== undefined ? args.endPosition : scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); - } - }; - Session.prototype.mapCodeAction = function (codeAction, scriptInfo) { - var _this = this; - return { - description: codeAction.description, - changes: codeAction.changes.map(function (change) { return ({ - fileName: change.fileName, - textChanges: change.textChanges.map(function (textChange) { return _this.convertTextChangeToCodeEdit(textChange, scriptInfo); }) - }); }) - }; - }; - Session.prototype.convertTextChangeToCodeEdit = function (change, scriptInfo) { - return { - start: scriptInfo.positionToLineOffset(change.span.start), - end: scriptInfo.positionToLineOffset(change.span.start + change.span.length), - newText: change.newText ? change.newText : "" - }; - }; - Session.prototype.getBraceMatching = function (args, simplifiedResult) { - var _this = this; - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var spans = project.getLanguageService(false).getBraceMatchingAtPosition(file, position); - return !spans - ? undefined - : simplifiedResult - ? spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }) - : spans; - }; - Session.prototype.getDiagnosticsForProject = function (delay, fileName) { - var _this = this; - var _a = this.getProjectInfoWorker(fileName, undefined, true), fileNames = _a.fileNames, languageServiceDisabled = _a.languageServiceDisabled; - if (languageServiceDisabled) { - return; - } - var fileNamesInProject = fileNames.filter(function (value) { return value.indexOf("lib.d.ts") < 0; }); - var highPriorityFiles = []; - var mediumPriorityFiles = []; - var lowPriorityFiles = []; - var veryLowPriorityFiles = []; - var normalizedFileName = server.toNormalizedPath(fileName); - var project = this.projectService.getDefaultProjectForFile(normalizedFileName, true); - for (var _i = 0, fileNamesInProject_1 = fileNamesInProject; _i < fileNamesInProject_1.length; _i++) { - var fileNameInProject = fileNamesInProject_1[_i]; - if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) - highPriorityFiles.push(fileNameInProject); - else { - var info = this.projectService.getScriptInfo(fileNameInProject); - if (!info.isScriptOpen()) { - if (fileNameInProject.indexOf(".d.ts") > 0) - veryLowPriorityFiles.push(fileNameInProject); - else - lowPriorityFiles.push(fileNameInProject); - } - else - mediumPriorityFiles.push(fileNameInProject); - } - } - fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); - if (fileNamesInProject.length > 0) { - var checkList = fileNamesInProject.map(function (fileName) { return ({ fileName: fileName, project: project }); }); - this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); - } - }; - Session.prototype.getCanonicalFileName = function (fileName) { - var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - return ts.normalizePath(name); - }; - Session.prototype.exit = function () { - }; - Session.prototype.notRequired = function () { - return { responseRequired: false }; - }; - Session.prototype.requiredResponse = function (response) { - return { response: response, responseRequired: true }; - }; - Session.prototype.addProtocolHandler = function (command, handler) { - if (command in this.handlers) { - throw new Error("Protocol handler already exists for command \"" + command + "\""); - } - this.handlers[command] = handler; - }; - Session.prototype.executeCommand = function (request) { - var handler = this.handlers[request.command]; - if (handler) { - return handler(request); - } - else { - this.logger.msg("Unrecognized JSON command: " + JSON.stringify(request), server.Msg.Err); - this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); - return { responseRequired: false }; - } - }; - Session.prototype.onMessage = function (message) { - this.gcTimer.scheduleCollect(); - var start; - if (this.logger.hasLevel(server.LogLevel.requestTime)) { - start = this.hrtime(); - if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("request: " + message); - } - } - var request; - try { - request = JSON.parse(message); - var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; - if (this.logger.hasLevel(server.LogLevel.requestTime)) { - var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4); - if (responseRequired) { - this.logger.perftrc(request.seq + "::" + request.command + ": elapsed time (in milliseconds) " + elapsedTime); - } - else { - this.logger.perftrc(request.seq + "::" + request.command + ": async elapsed time (in milliseconds) " + elapsedTime); - } - } - if (response) { - this.output(response, request.command, request.seq); - } - else if (responseRequired) { - this.output(undefined, request.command, request.seq, "No content available."); - } - } - catch (err) { - if (err instanceof ts.OperationCanceledException) { - this.output({ canceled: true }, request.command, request.seq); - return; - } - this.logError(err, message); - this.output(undefined, request ? request.command : CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message + "\n" + err.stack); - } - }; - return Session; - }()); - server.Session = Session; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var server; (function (server) { @@ -71187,15 +74995,22 @@ var ts; if (typeof global !== "undefined" && global.gc) { sys.gc = function () { return global.gc(); }; } + sys.require = function (initialDir, moduleName) { + var result = ts.nodeModuleNameResolverWorker(moduleName, initialDir + "/program.ts", { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, sys, undefined, true); + try { + return { module: require(result.resolvedModule.resolvedFileName), error: undefined }; + } + catch (e) { + return { module: undefined, error: e }; + } + }; var cancellationToken; try { var factory = require("./cancellationToken"); cancellationToken = factory(sys.args); } catch (e) { - cancellationToken = { - isCancellationRequested: function () { return false; } - }; + cancellationToken = server.nullCancellationToken; } ; var eventPort; @@ -71221,701 +75036,3 @@ var ts; ioSession.listen(); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -var debugObjectHost = (function () { return 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; - } - 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); - }; - ScriptSnapshotShimAdapter.prototype.dispose = function () { - if ("dispose" in this.scriptSnapshotShim) { - this.scriptSnapshotShim.dispose(); - } - }; - return ScriptSnapshotShimAdapter; - }()); - var LanguageServiceShimHostAdapter = (function () { - function LanguageServiceShimHostAdapter(shimHost) { - var _this = this; - this.shimHost = shimHost; - this.loggingEnabled = false; - this.tracingEnabled = false; - if ("getModuleResolutionsForFile" in this.shimHost) { - this.resolveModuleNames = function (moduleNames, containingFile) { - var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); - return ts.map(moduleNames, function (name) { - var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; - }); - }; - } - if ("directoryExists" in this.shimHost) { - this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; - } - if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { - this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); - return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); - }; - } - } - 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.getTypeRootsVersion = function () { - if (!this.shimHost.getTypeRootsVersion) { - return 0; - } - return this.shimHost.getTypeRootsVersion(); - }; - 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 JSON.parse(settingsJson); - }; - LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { - var encoded = this.shimHost.getScriptFileNames(); - return this.files = JSON.parse(encoded); - }; - LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { - var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); - return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); - }; - LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { - if ("getScriptKind" in this.shimHost) { - return this.shimHost.getScriptKind(fileName); - } - else { - return 0; - } - }; - 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.getDirectories = function (path) { - return JSON.parse(this.shimHost.getDirectories(path)); - }; - LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { - return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); - }; - LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); - return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); - }; - LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { - return this.shimHost.readFile(path, encoding); - }; - LanguageServiceShimHostAdapter.prototype.fileExists = function (path) { - return this.shimHost.fileExists(path); - }; - return LanguageServiceShimHostAdapter; - }()); - ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - var ThrottledCancellationToken = (function () { - function ThrottledCancellationToken(hostCancellationToken) { - this.hostCancellationToken = hostCancellationToken; - this.lastCancellationCheckTime = 0; - } - ThrottledCancellationToken.prototype.isCancellationRequested = function () { - var time = ts.timestamp(); - 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) { - var _this = this; - this.shimHost = shimHost; - this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - if ("directoryExists" in this.shimHost) { - this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; - } - if ("realpath" in this.shimHost) { - this.realpath = function (path) { return _this.shimHost.realpath(path); }; - } - } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { - try { - var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); - return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); - } - catch (e) { - var results = []; - for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { - var extension = extensions_2[_i]; - for (var _a = 0, _b = this.readDirectoryFallback(rootDir, extension, exclude); _a < _b.length; _a++) { - var file = _b[_a]; - if (!ts.contains(results, file)) { - results.push(file); - } - } - } - return results; - } - }; - CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { - return this.shimHost.fileExists(fileName); - }; - CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { - return this.shimHost.readFile(fileName); - }; - CoreServicesShimHostAdapter.prototype.readDirectoryFallback = function (rootDir, extension, exclude) { - return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); - }; - CoreServicesShimHostAdapter.prototype.getDirectories = function (path) { - return JSON.parse(this.shimHost.getDirectories(path)); - }; - return CoreServicesShimHostAdapter; - }()); - ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action, logPerformance) { - var start; - if (logPerformance) { - logger.log(actionDescription); - start = ts.timestamp(); - } - var result = action(); - if (logPerformance) { - var end = ts.timestamp(); - 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) { - return forwardCall(logger, actionDescription, true, action, logPerformance); - } - function forwardCall(logger, actionDescription, returnJson, action, logPerformance) { - try { - var result = simpleForwardCall(logger, actionDescription, action, logPerformance); - return returnJson ? JSON.stringify({ result: 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) { - var _this = _super.call(this, factory) || this; - _this.host = host; - _this.languageService = languageService; - _this.logPerformance = false; - _this.logger = _this.host; - return _this; - } - 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 = ts.getNewLineOrDefaultFromHost(this.host); - return ts.realizeDiagnostics(diagnostics, newLine); - }; - LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); - }; - LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); - }; - 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.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 () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { - var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); - }; - LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); - }; - 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.getImplementationAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(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 () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { - var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); - }; - 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 () { - var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); - var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); - return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); - }); - }; - LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { - var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { - var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); - }; - LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); - }; - LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); - }; - LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { - var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); - }; - LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { - var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); - }; - LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { - var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); - }; - LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { - var _this = this; - return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); - }; - 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) { - var _this = _super.call(this, factory) || this; - _this.logger = logger; - _this.logPerformance = false; - _this.classifier = ts.createClassifier(); - return _this; - } - 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 result = ""; - for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { - var item = _a[_i]; - result += item.length + "\n"; - result += item.classification + "\n"; - } - result += classification.finalLexState; - return result; - }; - return ClassifierShimObject; - }(ShimBase)); - var CoreServicesShimObject = (function (_super) { - __extends(CoreServicesShimObject, _super); - function CoreServicesShimObject(factory, logger, host) { - var _this = _super.call(this, factory) || this; - _this.logger = logger; - _this.host = host; - _this.logPerformance = false; - return _this; - } - CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); - var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (resolvedFileName && !compilerOptions.allowJs && ts.fileExtensionIs(resolvedFileName, ".js")) { - return { - resolvedFileName: undefined, - failedLookupLocations: [] - }; - } - return { - resolvedFileName: resolvedFileName, - failedLookupLocations: result.failedLookupLocations - }; - }); - }; - CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); - return { - resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined, - primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true, - failedLookupLocations: result.failedLookupLocations - }; - }); - }; - CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { - var _this = this; - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); - return { - referencedFiles: _this.convertFileReferences(result.referencedFiles), - importedFiles: _this.convertFileReferences(result.importedFiles), - ambientExternalModules: result.ambientExternalModules, - isLibFile: result.isLibFile, - typeReferenceDirectives: _this.convertFileReferences(result.typeReferenceDirectives) - }; - }); - }; - CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); - }); - }; - CoreServicesShimObject.prototype.convertFileReferences = function (refs) { - if (!refs) { - return undefined; - } - var result = []; - for (var _i = 0, refs_2 = refs; _i < refs_2.length; _i++) { - var ref = refs_2[_i]; - result.push({ - path: ts.normalizeSlashes(ref.fileName), - position: ref.pos, - length: ref.end - ref.pos - }); - } - return result; - }; - 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.parseConfigFileTextToJson(fileName, text); - if (result.error) { - return { - options: {}, - typeAcquisition: {}, - files: [], - raw: {}, - errors: [realizeDiagnostic(result.error, "\r\n")] - }; - } - var normalizedFileName = ts.normalizeSlashes(fileName); - var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); - return { - options: configFile.options, - typeAcquisition: configFile.typeAcquisition, - files: configFile.fileNames, - raw: configFile.raw, - errors: realizeDiagnostics(configFile.errors, "\r\n") - }; - }); - }; - CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { - return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); }); - }; - CoreServicesShimObject.prototype.discoverTypings = function (discoverTypingsJson) { - var _this = this; - var getCanonicalFileName = ts.createGetCanonicalFileName(false); - return this.forwardJSONCall("discoverTypings()", function () { - var info = JSON.parse(discoverTypingsJson); - return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typeAcquisition, info.unresolvedImports); - }); - }; - 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(), host.getCurrentDirectory()); - } - 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 = undefined; - }; - TypeScriptServicesFactory.prototype.registerShim = function (shim) { - this._shims.push(shim); - }; - TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0; i < this._shims.length; 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 = "2.2"; diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index 232684eedc6..90350104cae 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -17,8 +17,26 @@ declare namespace ts { interface MapLike { [index: string]: T; } - interface Map extends MapLike { - __mapBrand: any; + interface Map { + get(key: string): T; + has(key: string): boolean; + set(key: string, value: T): this; + delete(key: string): boolean; + clear(): void; + forEach(action: (value: T, key: string) => void): void; + readonly size: number; + keys(): Iterator; + values(): Iterator; + entries(): Iterator<[string, T]>; + } + interface Iterator { + next(): { + value: T; + done: false; + } | { + value: never; + done: true; + }; } type Path = string & { __pathBrand: any; @@ -170,172 +188,175 @@ declare namespace ts { ReadonlyKeyword = 130, RequireKeyword = 131, NumberKeyword = 132, - SetKeyword = 133, - StringKeyword = 134, - SymbolKeyword = 135, - TypeKeyword = 136, - UndefinedKeyword = 137, - FromKeyword = 138, - GlobalKeyword = 139, - OfKeyword = 140, - QualifiedName = 141, - ComputedPropertyName = 142, - TypeParameter = 143, - Parameter = 144, - Decorator = 145, - PropertySignature = 146, - PropertyDeclaration = 147, - MethodSignature = 148, - MethodDeclaration = 149, - Constructor = 150, - GetAccessor = 151, - SetAccessor = 152, - CallSignature = 153, - ConstructSignature = 154, - IndexSignature = 155, - TypePredicate = 156, - TypeReference = 157, - FunctionType = 158, - ConstructorType = 159, - TypeQuery = 160, - TypeLiteral = 161, - ArrayType = 162, - TupleType = 163, - UnionType = 164, - IntersectionType = 165, - ParenthesizedType = 166, - ThisType = 167, - TypeOperator = 168, - IndexedAccessType = 169, - MappedType = 170, - LiteralType = 171, - ObjectBindingPattern = 172, - ArrayBindingPattern = 173, - BindingElement = 174, - ArrayLiteralExpression = 175, - ObjectLiteralExpression = 176, - PropertyAccessExpression = 177, - ElementAccessExpression = 178, - CallExpression = 179, - NewExpression = 180, - TaggedTemplateExpression = 181, - TypeAssertionExpression = 182, - ParenthesizedExpression = 183, - FunctionExpression = 184, - ArrowFunction = 185, - DeleteExpression = 186, - TypeOfExpression = 187, - VoidExpression = 188, - AwaitExpression = 189, - PrefixUnaryExpression = 190, - PostfixUnaryExpression = 191, - BinaryExpression = 192, - ConditionalExpression = 193, - TemplateExpression = 194, - YieldExpression = 195, - SpreadElement = 196, - ClassExpression = 197, - OmittedExpression = 198, - ExpressionWithTypeArguments = 199, - AsExpression = 200, - NonNullExpression = 201, - MetaProperty = 202, - TemplateSpan = 203, - SemicolonClassElement = 204, - Block = 205, - VariableStatement = 206, - EmptyStatement = 207, - ExpressionStatement = 208, - IfStatement = 209, - DoStatement = 210, - WhileStatement = 211, - ForStatement = 212, - ForInStatement = 213, - ForOfStatement = 214, - ContinueStatement = 215, - BreakStatement = 216, - ReturnStatement = 217, - WithStatement = 218, - SwitchStatement = 219, - LabeledStatement = 220, - ThrowStatement = 221, - TryStatement = 222, - DebuggerStatement = 223, - VariableDeclaration = 224, - VariableDeclarationList = 225, - FunctionDeclaration = 226, - ClassDeclaration = 227, - InterfaceDeclaration = 228, - TypeAliasDeclaration = 229, - EnumDeclaration = 230, - ModuleDeclaration = 231, - ModuleBlock = 232, - CaseBlock = 233, - NamespaceExportDeclaration = 234, - ImportEqualsDeclaration = 235, - ImportDeclaration = 236, - ImportClause = 237, - NamespaceImport = 238, - NamedImports = 239, - ImportSpecifier = 240, - ExportAssignment = 241, - ExportDeclaration = 242, - NamedExports = 243, - ExportSpecifier = 244, - MissingDeclaration = 245, - ExternalModuleReference = 246, - JsxElement = 247, - JsxSelfClosingElement = 248, - JsxOpeningElement = 249, - JsxClosingElement = 250, - JsxAttribute = 251, - JsxSpreadAttribute = 252, - JsxExpression = 253, - CaseClause = 254, - DefaultClause = 255, - HeritageClause = 256, - CatchClause = 257, - PropertyAssignment = 258, - ShorthandPropertyAssignment = 259, - SpreadAssignment = 260, - EnumMember = 261, - SourceFile = 262, - JSDocTypeExpression = 263, - JSDocAllType = 264, - JSDocUnknownType = 265, - JSDocArrayType = 266, - JSDocUnionType = 267, - JSDocTupleType = 268, - JSDocNullableType = 269, - JSDocNonNullableType = 270, - JSDocRecordType = 271, - JSDocRecordMember = 272, - JSDocTypeReference = 273, - JSDocOptionalType = 274, - JSDocFunctionType = 275, - JSDocVariadicType = 276, - JSDocConstructorType = 277, - JSDocThisType = 278, - JSDocComment = 279, - JSDocTag = 280, - JSDocAugmentsTag = 281, - JSDocParameterTag = 282, - JSDocReturnTag = 283, - JSDocTypeTag = 284, - JSDocTemplateTag = 285, - JSDocTypedefTag = 286, - JSDocPropertyTag = 287, - JSDocTypeLiteral = 288, - JSDocLiteralType = 289, - JSDocNullKeyword = 290, - JSDocUndefinedKeyword = 291, - JSDocNeverKeyword = 292, - SyntaxList = 293, - NotEmittedStatement = 294, - PartiallyEmittedExpression = 295, - MergeDeclarationMarker = 296, - EndOfDeclarationMarker = 297, - Count = 298, + ObjectKeyword = 133, + SetKeyword = 134, + StringKeyword = 135, + SymbolKeyword = 136, + TypeKeyword = 137, + UndefinedKeyword = 138, + FromKeyword = 139, + GlobalKeyword = 140, + OfKeyword = 141, + QualifiedName = 142, + ComputedPropertyName = 143, + TypeParameter = 144, + Parameter = 145, + Decorator = 146, + PropertySignature = 147, + PropertyDeclaration = 148, + MethodSignature = 149, + MethodDeclaration = 150, + Constructor = 151, + GetAccessor = 152, + SetAccessor = 153, + CallSignature = 154, + ConstructSignature = 155, + IndexSignature = 156, + TypePredicate = 157, + TypeReference = 158, + FunctionType = 159, + ConstructorType = 160, + TypeQuery = 161, + TypeLiteral = 162, + ArrayType = 163, + TupleType = 164, + UnionType = 165, + IntersectionType = 166, + ParenthesizedType = 167, + ThisType = 168, + TypeOperator = 169, + IndexedAccessType = 170, + MappedType = 171, + LiteralType = 172, + ObjectBindingPattern = 173, + ArrayBindingPattern = 174, + BindingElement = 175, + ArrayLiteralExpression = 176, + ObjectLiteralExpression = 177, + PropertyAccessExpression = 178, + ElementAccessExpression = 179, + CallExpression = 180, + NewExpression = 181, + TaggedTemplateExpression = 182, + TypeAssertionExpression = 183, + ParenthesizedExpression = 184, + FunctionExpression = 185, + ArrowFunction = 186, + DeleteExpression = 187, + TypeOfExpression = 188, + VoidExpression = 189, + AwaitExpression = 190, + PrefixUnaryExpression = 191, + PostfixUnaryExpression = 192, + BinaryExpression = 193, + ConditionalExpression = 194, + TemplateExpression = 195, + YieldExpression = 196, + SpreadElement = 197, + ClassExpression = 198, + OmittedExpression = 199, + ExpressionWithTypeArguments = 200, + AsExpression = 201, + NonNullExpression = 202, + MetaProperty = 203, + TemplateSpan = 204, + SemicolonClassElement = 205, + Block = 206, + VariableStatement = 207, + EmptyStatement = 208, + ExpressionStatement = 209, + IfStatement = 210, + DoStatement = 211, + WhileStatement = 212, + ForStatement = 213, + ForInStatement = 214, + ForOfStatement = 215, + ContinueStatement = 216, + BreakStatement = 217, + ReturnStatement = 218, + WithStatement = 219, + SwitchStatement = 220, + LabeledStatement = 221, + ThrowStatement = 222, + TryStatement = 223, + DebuggerStatement = 224, + VariableDeclaration = 225, + VariableDeclarationList = 226, + FunctionDeclaration = 227, + ClassDeclaration = 228, + InterfaceDeclaration = 229, + TypeAliasDeclaration = 230, + EnumDeclaration = 231, + ModuleDeclaration = 232, + ModuleBlock = 233, + CaseBlock = 234, + NamespaceExportDeclaration = 235, + ImportEqualsDeclaration = 236, + ImportDeclaration = 237, + ImportClause = 238, + NamespaceImport = 239, + NamedImports = 240, + ImportSpecifier = 241, + ExportAssignment = 242, + ExportDeclaration = 243, + NamedExports = 244, + ExportSpecifier = 245, + MissingDeclaration = 246, + ExternalModuleReference = 247, + JsxElement = 248, + JsxSelfClosingElement = 249, + JsxOpeningElement = 250, + JsxClosingElement = 251, + JsxAttribute = 252, + JsxAttributes = 253, + JsxSpreadAttribute = 254, + JsxExpression = 255, + CaseClause = 256, + DefaultClause = 257, + HeritageClause = 258, + CatchClause = 259, + PropertyAssignment = 260, + ShorthandPropertyAssignment = 261, + SpreadAssignment = 262, + EnumMember = 263, + SourceFile = 264, + Bundle = 265, + JSDocTypeExpression = 266, + JSDocAllType = 267, + JSDocUnknownType = 268, + JSDocArrayType = 269, + JSDocUnionType = 270, + JSDocTupleType = 271, + JSDocNullableType = 272, + JSDocNonNullableType = 273, + JSDocRecordType = 274, + JSDocRecordMember = 275, + JSDocTypeReference = 276, + JSDocOptionalType = 277, + JSDocFunctionType = 278, + JSDocVariadicType = 279, + JSDocConstructorType = 280, + JSDocThisType = 281, + JSDocComment = 282, + JSDocTag = 283, + JSDocAugmentsTag = 284, + JSDocParameterTag = 285, + JSDocReturnTag = 286, + JSDocTypeTag = 287, + JSDocTemplateTag = 288, + JSDocTypedefTag = 289, + JSDocPropertyTag = 290, + JSDocTypeLiteral = 291, + JSDocLiteralType = 292, + JSDocNullKeyword = 293, + JSDocUndefinedKeyword = 294, + JSDocNeverKeyword = 295, + SyntaxList = 296, + NotEmittedStatement = 297, + PartiallyEmittedExpression = 298, + MergeDeclarationMarker = 299, + EndOfDeclarationMarker = 300, + Count = 301, FirstAssignment = 57, LastAssignment = 69, FirstCompoundAssignment = 58, @@ -343,15 +364,15 @@ declare namespace ts { FirstReservedWord = 71, LastReservedWord = 106, FirstKeyword = 71, - LastKeyword = 140, + LastKeyword = 141, FirstFutureReservedWord = 107, LastFutureReservedWord = 115, - FirstTypeNode = 156, - LastTypeNode = 171, + FirstTypeNode = 157, + LastTypeNode = 172, FirstPunctuation = 16, LastPunctuation = 69, FirstToken = 0, - LastToken = 140, + LastToken = 141, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -360,11 +381,11 @@ declare namespace ts { LastTemplateToken = 15, FirstBinaryOperator = 26, LastBinaryOperator = 69, - FirstNode = 141, - FirstJSDocNode = 263, - LastJSDocNode = 289, - FirstJSDocTagNode = 279, - LastJSDocTagNode = 292, + FirstNode = 142, + FirstJSDocNode = 266, + LastJSDocNode = 295, + FirstJSDocTagNode = 282, + LastJSDocTagNode = 295, } const enum NodeFlags { None = 0, @@ -479,6 +500,7 @@ declare namespace ts { kind: SyntaxKind.TypeParameter; name: Identifier; constraint?: TypeNode; + default?: TypeNode; expression?: Expression; } interface SignatureDeclaration extends Declaration { @@ -622,7 +644,7 @@ declare namespace ts { _typeNodeBrand: any; } interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; + kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; } interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; @@ -707,6 +729,10 @@ declare namespace ts { interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } + interface PartiallyEmittedExpression extends LeftHandSideExpression { + kind: SyntaxKind.PartiallyEmittedExpression; + expression: Expression; + } interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } @@ -936,7 +962,7 @@ declare namespace ts { tag: LeftHandSideExpression; template: TemplateLiteral; } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; + type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; interface AsExpression extends Expression { kind: SyntaxKind.AsExpression; expression: Expression; @@ -963,25 +989,27 @@ declare namespace ts { children: NodeArray; closingElement: JsxClosingElement; } + type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + interface JsxAttributes extends ObjectLiteralExpressionBase { + } interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; tagName: JsxTagNameExpression; - attributes: NodeArray; + attributes: JsxAttributes; } interface JsxSelfClosingElement extends PrimaryExpression { kind: SyntaxKind.JsxSelfClosingElement; tagName: JsxTagNameExpression; - attributes: NodeArray; + attributes: JsxAttributes; } - type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; - type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - interface JsxAttribute extends Node { + interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; name: Identifier; initializer?: StringLiteral | JsxExpression; } - interface JsxSpreadAttribute extends Node { + interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; expression: Expression; } @@ -1001,6 +1029,9 @@ declare namespace ts { interface Statement extends Node { _statementBrand: any; } + interface NotEmittedStatement extends Statement { + kind: SyntaxKind.NotEmittedStatement; + } interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } @@ -1167,20 +1198,22 @@ declare namespace ts { name: Identifier; members: NodeArray; } - type ModuleBody = ModuleBlock | ModuleDeclaration; type ModuleName = Identifier | StringLiteral; + type ModuleBody = NamespaceBody | JSDocNamespaceBody; interface ModuleDeclaration extends DeclarationStatement { kind: SyntaxKind.ModuleDeclaration; name: Identifier | StringLiteral; - body?: ModuleBlock | NamespaceDeclaration | JSDocNamespaceDeclaration | Identifier; + body?: ModuleBody | JSDocNamespaceDeclaration | Identifier; } + type NamespaceBody = ModuleBlock | NamespaceDeclaration; interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: ModuleBlock | NamespaceDeclaration; + body: NamespaceBody; } + type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: JSDocNamespaceDeclaration | Identifier; + body: JSDocNamespaceBody; } interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; @@ -1392,9 +1425,21 @@ declare namespace ts { ArrayMutation = 256, Referenced = 512, Shared = 1024, + PreFinally = 2048, + AfterFinally = 4096, Label = 12, Condition = 96, } + interface FlowLock { + locked?: boolean; + } + interface AfterFinallyFlow extends FlowNode, FlowLock { + antecedent: FlowNode; + } + interface PreFinallyFlow extends FlowNode { + antecedent: FlowNode; + lock: FlowLock; + } interface FlowNode { flags: FlowFlags; id?: number; @@ -1448,6 +1493,10 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; } + interface Bundle extends Node { + kind: SyntaxKind.Bundle; + sourceFiles: SourceFile[]; + } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; getSourceFile(fileName: string): SourceFile; @@ -1518,7 +1567,7 @@ declare namespace ts { getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; - getBaseTypes(type: InterfaceType): ObjectType[]; + getBaseTypes(type: InterfaceType): BaseType[]; getReturnTypeOfSignature(signature: Signature): Type; getNonNullableType(type: Type): Type; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; @@ -1547,7 +1596,7 @@ declare namespace ts { isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; - getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; + getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; @@ -1582,6 +1631,7 @@ declare namespace ts { clear(): void; trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError(): void; + reportIllegalExtends(): void; } const enum TypeFormatFlags { None = 0, @@ -1597,6 +1647,7 @@ declare namespace ts { InTypeAlias = 512, UseTypeAliasValue = 1024, SuppressAnyReturnType = 2048, + AddUndefined = 4096, } const enum SymbolFormatFlags { None = 0, @@ -1646,13 +1697,10 @@ declare namespace ts { ExportType = 2097152, ExportNamespace = 4194304, Alias = 8388608, - Instantiated = 16777216, - Merged = 33554432, - Transient = 67108864, - Prototype = 134217728, - SyntheticProperty = 268435456, - Optional = 536870912, - ExportStar = 1073741824, + Prototype = 16777216, + ExportStar = 33554432, + Optional = 67108864, + Transient = 134217728, Enum = 384, Variable = 3, Value = 107455, @@ -1718,6 +1766,7 @@ declare namespace ts { Intersection = 131072, Index = 262144, IndexedAccess = 524288, + NonPrimitive = 16777216, Literal = 480, StringOrNumberLiteral = 96, PossiblyFalsy = 7406, @@ -1727,10 +1776,10 @@ declare namespace ts { EnumLike = 272, UnionOrIntersection = 196608, StructuredType = 229376, - StructuredOrTypeParameter = 507904, + StructuredOrTypeVariable = 1032192, TypeVariable = 540672, - Narrowable = 1033215, - NotUnionOrUnit = 33281, + Narrowable = 17810431, + NotUnionOrUnit = 16810497, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -1746,7 +1795,7 @@ declare namespace ts { regularType?: LiteralType; } interface EnumType extends Type { - memberTypes: Map; + memberTypes: EnumLiteralType[]; } interface EnumLiteralType extends LiteralType { baseType: EnumType & UnionType; @@ -1762,6 +1811,7 @@ declare namespace ts { ObjectLiteral = 128, EvolvingArray = 256, ObjectLiteralPatternWithComputedProperties = 512, + NonPrimitive = 1024, ClassOrInterface = 3, } interface ObjectType extends Type { @@ -1773,6 +1823,7 @@ declare namespace ts { localTypeParameters: TypeParameter[]; thisType: TypeParameter; } + type BaseType = ObjectType | IntersectionType; interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; @@ -1802,6 +1853,7 @@ declare namespace ts { } interface TypeParameter extends TypeVariable { constraint: Type; + default?: Type; } interface IndexedAccessType extends TypeVariable { objectType: Type; @@ -1829,9 +1881,8 @@ declare namespace ts { isReadonly: boolean; declaration?: SignatureDeclaration; } - interface FileExtensionInfo { + interface JsFileExtensionInfo { extension: string; - scriptKind: ScriptKind; isMixedContent: boolean; } interface DiagnosticMessage { @@ -1863,7 +1914,10 @@ declare namespace ts { Classic = 1, NodeJs = 2, } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; + interface PluginImport { + name: string; + } + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; interface CompilerOptions { allowJs?: boolean; allowSyntheticDefaultImports?: boolean; @@ -1956,6 +2010,7 @@ declare namespace ts { None = 0, Preserve = 1, React = 2, + ReactNative = 3, } const enum NewLineKind { CarriageReturnLineFeed = 0, @@ -1971,6 +2026,7 @@ declare namespace ts { JSX = 2, TS = 3, TSX = 4, + External = 5, } const enum ScriptTarget { ES3 = 0, @@ -2053,6 +2109,60 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getEnvironmentVariable?(name: string): string; } + const enum EmitFlags { + SingleLine = 1, + AdviseOnEmitNode = 2, + NoSubstitution = 4, + CapturesThis = 8, + NoLeadingSourceMap = 16, + NoTrailingSourceMap = 32, + NoSourceMap = 48, + NoNestedSourceMaps = 64, + NoTokenLeadingSourceMaps = 128, + NoTokenTrailingSourceMaps = 256, + NoTokenSourceMaps = 384, + NoLeadingComments = 512, + NoTrailingComments = 1024, + NoComments = 1536, + NoNestedComments = 2048, + HelperName = 4096, + ExportName = 8192, + LocalName = 16384, + Indented = 32768, + NoIndentation = 65536, + AsyncFunctionBody = 131072, + ReuseTempVariableScope = 262144, + CustomPrologue = 524288, + NoHoisting = 1048576, + HasEndOfDeclarationMarker = 2097152, + } + interface EmitHelper { + readonly name: string; + readonly scoped: boolean; + readonly text: string; + readonly priority?: number; + } + const enum EmitHint { + SourceFile = 0, + Expression = 1, + IdentifierName = 2, + Unspecified = 3, + } + interface Printer { + printNode(hint: EmitHint, node: Node, sourceFile: SourceFile): string; + printFile(sourceFile: SourceFile): string; + printBundle(bundle: Bundle): string; + } + interface PrintHandlers { + hasGlobalName?(name: string): boolean; + onEmitNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + onSubstituteNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + } + interface PrinterOptions { + target?: ScriptTarget; + removeComments?: boolean; + newLine?: NewLineKind; + } interface TextSpan { start: number; length: number; @@ -2066,8 +2176,10 @@ declare namespace ts { } } declare namespace ts { - const version = "2.2.0"; + const version = "2.3.0"; } +declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; +declare function clearTimeout(handle: any): void; declare namespace ts { type FileWatcherCallback = (fileName: string, removed?: boolean) => void; type DirectoryWatcherCallback = (fileName: string) => void; @@ -2157,8 +2269,8 @@ declare namespace ts { function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; - function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; - function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined; + function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; function getShebang(text: string): string; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; @@ -2174,7 +2286,7 @@ declare namespace ts { config?: any; error?: Diagnostic; }; - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: FileExtensionInfo[]): ParsedCommandLine; + function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: JsFileExtensionInfo[]): ParsedCommandLine; function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; @@ -2186,6 +2298,9 @@ declare namespace ts { }; } declare namespace ts { + interface Push { + push(value: T): void; + } function moduleHasNonRelativeName(moduleName: string): boolean; function getEffectiveTypeRoots(options: CompilerOptions, host: { directoryExists?: (directoryName: string) => boolean; @@ -2238,6 +2353,258 @@ declare namespace ts { fileExists(fileName: string): boolean; readFile(fileName: string): string; }, errors?: Diagnostic[]): void; + function getOriginalNode(node: Node): Node; + function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; + function isParseTreeNode(node: Node): boolean; + function getParseTreeNode(node: Node): Node; + function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; + function unescapeIdentifier(identifier: string): string; +} +declare namespace ts { + function createNodeArray(elements?: T[], hasTrailingComma?: boolean): NodeArray; + function createLiteral(value: string): StringLiteral; + function createLiteral(value: number): NumericLiteral; + function createLiteral(value: boolean): BooleanLiteral; + function createLiteral(sourceNode: StringLiteral | NumericLiteral | Identifier): StringLiteral; + function createLiteral(value: string | number | boolean): PrimaryExpression; + function createNumericLiteral(value: string): NumericLiteral; + function createIdentifier(text: string): Identifier; + function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier; + function createLoopVariable(): Identifier; + function createUniqueName(text: string): Identifier; + function getGeneratedNameForNode(node: Node): Identifier; + function createToken(token: TKind): Token; + function createSuper(): PrimaryExpression; + function createThis(): PrimaryExpression; + function createNull(): PrimaryExpression; + function createTrue(): BooleanLiteral; + function createFalse(): BooleanLiteral; + function createQualifiedName(left: EntityName, right: string | Identifier): QualifiedName; + function updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName; + function createComputedPropertyName(expression: Expression): ComputedPropertyName; + function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; + function createParameter(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: BindingName, type: TypeNode, initializer: Expression): ParameterDeclaration; + function createDecorator(expression: Expression): Decorator; + function updateDecorator(node: Decorator, expression: Expression): Decorator; + function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, type: TypeNode, initializer: Expression): PropertyDeclaration; + function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; + function createConstructor(decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; + function createGetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; + function createSetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; + function createObjectBindingPattern(elements: BindingElement[]): ObjectBindingPattern; + function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern; + function createArrayBindingPattern(elements: ArrayBindingElement[]): ArrayBindingPattern; + function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ArrayBindingElement[]): ArrayBindingPattern; + function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression): BindingElement; + function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken, propertyName: PropertyName, name: BindingName, initializer: Expression): BindingElement; + function createArrayLiteral(elements?: Expression[], multiLine?: boolean): ArrayLiteralExpression; + function updateArrayLiteral(node: ArrayLiteralExpression, elements: Expression[]): ArrayLiteralExpression; + function createObjectLiteral(properties?: ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; + function updateObjectLiteral(node: ObjectLiteralExpression, properties: ObjectLiteralElementLike[]): ObjectLiteralExpression; + function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; + function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; + function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; + function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; + function createCall(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; + function createNew(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; + function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; + function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; + function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; + function createParen(expression: Expression): ParenthesizedExpression; + function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; + function createFunctionExpression(modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; + function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: ConciseBody): ArrowFunction; + function createDelete(expression: Expression): DeleteExpression; + function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; + function createTypeOf(expression: Expression): TypeOfExpression; + function updateTypeOf(node: TypeOfExpression, expression: Expression): TypeOfExpression; + function createVoid(expression: Expression): VoidExpression; + function updateVoid(node: VoidExpression, expression: Expression): VoidExpression; + function createAwait(expression: Expression): AwaitExpression; + function updateAwait(node: AwaitExpression, expression: Expression): AwaitExpression; + function createPrefix(operator: PrefixUnaryOperator, operand: Expression): PrefixUnaryExpression; + function updatePrefix(node: PrefixUnaryExpression, operand: Expression): PrefixUnaryExpression; + function createPostfix(operand: Expression, operator: PostfixUnaryOperator): PostfixUnaryExpression; + function updatePostfix(node: PostfixUnaryExpression, operand: Expression): PostfixUnaryExpression; + function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression): BinaryExpression; + function updateBinary(node: BinaryExpression, left: Expression, right: Expression): BinaryExpression; + function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; + function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + function createTemplateExpression(head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; + function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; + function createYield(expression?: Expression): YieldExpression; + function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; + function updateYield(node: YieldExpression, expression: Expression): YieldExpression; + function createSpread(expression: Expression): SpreadElement; + function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; + function createClassExpression(modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; + function createOmittedExpression(): OmittedExpression; + function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; + function createAsExpression(expression: Expression, type: TypeNode): AsExpression; + function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; + function createNonNullExpression(expression: Expression): NonNullExpression; + function updateNonNullExpression(node: NonNullExpression, expression: Expression): NonNullExpression; + function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; + function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; + function createBlock(statements: Statement[], multiLine?: boolean): Block; + function updateBlock(node: Block, statements: Statement[]): Block; + function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList | VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: Modifier[], declarationList: VariableDeclarationList): VariableStatement; + function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; + function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList; + function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; + function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode, initializer: Expression): VariableDeclaration; + function createEmptyStatement(): EmptyStatement; + function createStatement(expression: Expression): ExpressionStatement; + function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; + function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement): IfStatement; + function createDo(statement: Statement, expression: Expression): DoStatement; + function updateDo(node: DoStatement, statement: Statement, expression: Expression): DoStatement; + function createWhile(expression: Expression, statement: Statement): WhileStatement; + function updateWhile(node: WhileStatement, expression: Expression, statement: Statement): WhileStatement; + function createFor(initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; + function updateFor(node: ForStatement, initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; + function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; + function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; + function createForOf(initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function createContinue(label?: string | Identifier): ContinueStatement; + function updateContinue(node: ContinueStatement, label: Identifier): ContinueStatement; + function createBreak(label?: string | Identifier): BreakStatement; + function updateBreak(node: BreakStatement, label: Identifier): BreakStatement; + function createReturn(expression?: Expression): ReturnStatement; + function updateReturn(node: ReturnStatement, expression: Expression): ReturnStatement; + function createWith(expression: Expression, statement: Statement): WithStatement; + function updateWith(node: WithStatement, expression: Expression, statement: Statement): WithStatement; + function createSwitch(expression: Expression, caseBlock: CaseBlock): SwitchStatement; + function updateSwitch(node: SwitchStatement, expression: Expression, caseBlock: CaseBlock): SwitchStatement; + function createLabel(label: string | Identifier, statement: Statement): LabeledStatement; + function updateLabel(node: LabeledStatement, label: Identifier, statement: Statement): LabeledStatement; + function createThrow(expression: Expression): ThrowStatement; + function updateThrow(node: ThrowStatement, expression: Expression): ThrowStatement; + function createTry(tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; + function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; + function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; + function createClassDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function createEnumDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, members: EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, members: EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody): ModuleDeclaration; + function createModuleBlock(statements: Statement[]): ModuleBlock; + function updateModuleBlock(node: ModuleBlock, statements: Statement[]): ModuleBlock; + function createCaseBlock(clauses: CaseOrDefaultClause[]): CaseBlock; + function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock; + function createImportEqualsDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier?: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier: Expression): ImportDeclaration; + function createImportClause(name: Identifier, namedBindings: NamedImportBindings): ImportClause; + function updateImportClause(node: ImportClause, name: Identifier, namedBindings: NamedImportBindings): ImportClause; + function createNamespaceImport(name: Identifier): NamespaceImport; + function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; + function createNamedImports(elements: ImportSpecifier[]): NamedImports; + function updateNamedImports(node: NamedImports, elements: ImportSpecifier[]): NamedImports; + function createImportSpecifier(propertyName: Identifier, name: Identifier): ImportSpecifier; + function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier, name: Identifier): ImportSpecifier; + function createExportAssignment(decorators: Decorator[], modifiers: Modifier[], isExportEquals: boolean, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: Decorator[], modifiers: Modifier[], expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier: Expression): ExportDeclaration; + function createNamedExports(elements: ExportSpecifier[]): NamedExports; + function updateNamedExports(node: NamedExports, elements: ExportSpecifier[]): NamedExports; + function createExportSpecifier(name: string | Identifier, propertyName?: string | Identifier): ExportSpecifier; + function updateExportSpecifier(node: ExportSpecifier, name: Identifier, propertyName: Identifier): ExportSpecifier; + function createExternalModuleReference(expression: Expression): ExternalModuleReference; + function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; + function createJsxElement(openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; + function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; + function createJsxSelfClosingElement(tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxSelfClosingElement; + function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxSelfClosingElement; + function createJsxOpeningElement(tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxOpeningElement; + function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxOpeningElement; + function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement; + function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; + function createJsxAttributes(properties: JsxAttributeLike[]): JsxAttributes; + function updateJsxAttributes(jsxAttributes: JsxAttributes, properties: JsxAttributeLike[]): JsxAttributes; + function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; + function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; + function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; + function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; + function createJsxExpression(expression: Expression, dotDotDotToken: DotDotDotToken): JsxExpression; + function updateJsxExpression(node: JsxExpression, expression: Expression): JsxExpression; + function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[]): HeritageClause; + function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause; + function createCaseClause(expression: Expression, statements: Statement[]): CaseClause; + function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]): CaseClause; + function createDefaultClause(statements: Statement[]): DefaultClause; + function updateDefaultClause(node: DefaultClause, statements: Statement[]): DefaultClause; + function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block): CatchClause; + function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause; + function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; + function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; + function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; + function createSpreadAssignment(expression: Expression): SpreadAssignment; + function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; + function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; + function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; + function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; + function updateSourceFileNode(node: SourceFile, statements: Statement[]): SourceFile; + function getMutableClone(node: T): T; + function createNotEmittedStatement(original: Node): NotEmittedStatement; + function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression; + function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; + function createBundle(sourceFiles: SourceFile[]): Bundle; + function updateBundle(node: Bundle, sourceFiles: SourceFile[]): Bundle; + function createComma(left: Expression, right: Expression): Expression; + function createLessThan(left: Expression, right: Expression): Expression; + function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; + function createAssignment(left: Expression, right: Expression): BinaryExpression; + function createStrictEquality(left: Expression, right: Expression): BinaryExpression; + function createStrictInequality(left: Expression, right: Expression): BinaryExpression; + function createAdd(left: Expression, right: Expression): BinaryExpression; + function createSubtract(left: Expression, right: Expression): BinaryExpression; + function createPostfixIncrement(operand: Expression): PostfixUnaryExpression; + function createLogicalAnd(left: Expression, right: Expression): BinaryExpression; + function createLogicalOr(left: Expression, right: Expression): BinaryExpression; + function createLogicalNot(operand: Expression): PrefixUnaryExpression; + function createVoidZero(): VoidExpression; + function createExportDefault(expression: Expression): ExportAssignment; + function createExternalModuleExport(exportName: Identifier): ExportDeclaration; + function disposeEmitNodes(sourceFile: SourceFile): void; + function setTextRange(range: T, location: TextRange | undefined): T; + function getEmitFlags(node: Node): EmitFlags; + function setEmitFlags(node: T, emitFlags: EmitFlags): T; + function getSourceMapRange(node: Node): TextRange; + function setSourceMapRange(node: T, range: TextRange): T; + function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange; + function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange): T; + function getCommentRange(node: Node): TextRange; + function setCommentRange(node: T, range: TextRange): T; + function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; + function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number): PropertyAccessExpression | ElementAccessExpression; + function addEmitHelper(node: T, helper: EmitHelper): T; + function addEmitHelpers(node: T, helpers: EmitHelper[] | undefined): T; + function removeEmitHelper(node: Node, helper: EmitHelper): boolean; + function getEmitHelpers(node: Node): EmitHelper[] | undefined; + function moveEmitHelpers(source: Node, target: Node, predicate: (helper: EmitHelper) => boolean): void; + function setOriginalNode(node: T, original: Node): T; } declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; @@ -2247,6 +2614,9 @@ declare namespace ts { function isExternalModule(file: SourceFile): boolean; function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } +declare namespace ts { + function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; +} declare namespace ts { function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; function resolveTripleslashReference(moduleName: string, containingFile: string): string; @@ -2294,7 +2664,7 @@ declare namespace ts { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; - getBaseTypes(): ObjectType[]; + getBaseTypes(): BaseType[]; getNonNullableType(): Type; } interface Signature { @@ -2727,6 +3097,7 @@ declare namespace ts { const letElement = "let"; const directory = "directory"; const externalModuleName = "external module name"; + const jsxAttribute = "JSX attribute"; } namespace ScriptElementKindModifier { const none = ""; @@ -2843,6 +3214,172 @@ declare namespace ts { function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; function getDefaultLibFilePath(options: CompilerOptions): string; } +declare namespace ts.server { + interface CompressedData { + length: number; + compressionKind: string; + data: any; + } + type RequireResult = { + module: {}; + error: undefined; + } | { + module: undefined; + error: {}; + }; + interface ServerHost extends System { + setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; + clearTimeout(timeoutId: any): void; + setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; + clearImmediate(timeoutId: any): void; + gc?(): void; + trace?(s: string): void; + require?(initialPath: string, moduleName: string): RequireResult; + } + interface SortedReadonlyArray extends ReadonlyArray { + " __sortedReadonlyArrayBrand": any; + } + interface TypingInstallerRequest { + readonly projectName: string; + readonly kind: "discover" | "closeProject"; + } + interface DiscoverTypings extends TypingInstallerRequest { + readonly fileNames: string[]; + readonly projectRootPath: ts.Path; + readonly compilerOptions: ts.CompilerOptions; + readonly typeAcquisition: ts.TypeAcquisition; + readonly unresolvedImports: SortedReadonlyArray; + readonly cachePath?: string; + readonly kind: "discover"; + } + interface CloseProject extends TypingInstallerRequest { + readonly kind: "closeProject"; + } + type ActionSet = "action::set"; + type ActionInvalidate = "action::invalidate"; + type EventBeginInstallTypes = "event::beginInstallTypes"; + type EventEndInstallTypes = "event::endInstallTypes"; + interface TypingInstallerResponse { + readonly kind: ActionSet | ActionInvalidate | EventBeginInstallTypes | EventEndInstallTypes; + } + interface ProjectResponse extends TypingInstallerResponse { + readonly projectName: string; + } + interface SetTypings extends ProjectResponse { + readonly typeAcquisition: ts.TypeAcquisition; + readonly compilerOptions: ts.CompilerOptions; + readonly typings: string[]; + readonly unresolvedImports: SortedReadonlyArray; + readonly kind: ActionSet; + } + interface InvalidateCachedTypings extends ProjectResponse { + readonly kind: ActionInvalidate; + } + interface InstallTypes extends ProjectResponse { + readonly kind: EventBeginInstallTypes | EventEndInstallTypes; + readonly eventId: number; + readonly typingsInstallerVersion: string; + readonly packagesToInstall: ReadonlyArray; + } + interface BeginInstallTypes extends InstallTypes { + readonly kind: EventBeginInstallTypes; + } + interface EndInstallTypes extends InstallTypes { + readonly kind: EventEndInstallTypes; + readonly installSuccess: boolean; + } +} +declare namespace ts.server { + const ActionSet: ActionSet; + const ActionInvalidate: ActionInvalidate; + const EventBeginInstallTypes: EventBeginInstallTypes; + const EventEndInstallTypes: EventEndInstallTypes; + namespace Arguments { + const GlobalCacheLocation = "--globalTypingsCacheLocation"; + const LogFile = "--logFile"; + const EnableTelemetry = "--enableTelemetry"; + } + function hasArgument(argumentName: string): boolean; + function findArgument(argumentName: string): string; +} +declare namespace ts.server { + enum LogLevel { + terse = 0, + normal = 1, + requestTime = 2, + verbose = 3, + } + const emptyArray: ReadonlyArray; + interface Logger { + close(): void; + hasLevel(level: LogLevel): boolean; + loggingEnabled(): boolean; + perftrc(s: string): void; + info(s: string): void; + startGroup(): void; + endGroup(): void; + msg(s: string, type?: Msg.Types): void; + getLogFileName(): string; + } + namespace Msg { + type Err = "Err"; + const Err: Err; + type Info = "Info"; + const Info: Info; + type Perf = "Perf"; + const Perf: Perf; + type Types = Err | Info | Perf; + } + function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, cachePath?: string): DiscoverTypings; + namespace Errors { + function ThrowNoProject(): never; + function ThrowProjectLanguageServiceDisabled(): never; + function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never; + } + function getDefaultFormatCodeSettings(host: ServerHost): FormatCodeSettings; + function mergeMapLikes(target: MapLike, source: MapLike): void; + function removeItemFromSet(items: T[], itemToRemove: T): void; + type NormalizedPath = string & { + __normalizedPathTag: any; + }; + function toNormalizedPath(fileName: string): NormalizedPath; + function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path; + function asNormalizedPath(fileName: string): NormalizedPath; + interface NormalizedPathMap { + get(path: NormalizedPath): T; + set(path: NormalizedPath, value: T): void; + contains(path: NormalizedPath): boolean; + remove(path: NormalizedPath): void; + } + function createNormalizedPathMap(): NormalizedPathMap; + interface ProjectOptions { + configHasFilesProperty?: boolean; + files?: string[]; + wildcardDirectories?: Map; + compilerOptions?: CompilerOptions; + typeAcquisition?: TypeAcquisition; + compileOnSave?: boolean; + } + function isInferredProjectName(name: string): boolean; + function makeInferredProjectName(counter: number): string; + function toSortedReadonlyArray(arr: string[]): SortedReadonlyArray; + class ThrottledOperations { + private readonly host; + private pendingTimeouts; + constructor(host: ServerHost); + schedule(operationId: string, delay: number, cb: () => void): void; + private static run(self, operationId, cb); + } + class GcTimer { + private readonly host; + private readonly delay; + private readonly logger; + private timerId; + constructor(host: ServerHost, delay: number, logger: Logger); + scheduleCollect(): void; + private static run(self); + } +} declare namespace ts.server.protocol { namespace CommandTypes { type Brace = "brace"; @@ -3142,7 +3679,7 @@ declare namespace ts.server.protocol { hostInfo?: string; file?: string; formatOptions?: FormatCodeSettings; - extraFileExtensions?: FileExtensionInfo[]; + extraFileExtensions?: JsFileExtensionInfo[]; } interface ConfigureRequest extends Request { command: CommandTypes.Configure; @@ -3205,6 +3742,7 @@ declare namespace ts.server.protocol { interface CompileOnSaveAffectedFileListSingleProject { projectFileName: string; fileNames: string[]; + projectUsesOutFile: boolean; } interface CompileOnSaveAffectedFileListResponse extends Response { body: CompileOnSaveAffectedFileListSingleProject[]; @@ -3370,6 +3908,14 @@ declare namespace ts.server.protocol { command: CommandTypes.Geterr; arguments: GeterrRequestArgs; } + type RequestCompletedEventName = "requestCompleted"; + interface RequestCompletedEvent extends Event { + event: RequestCompletedEventName; + body: RequestCompletedEventBody; + } + interface RequestCompletedEventBody { + request_seq: number; + } interface Diagnostic { start: Location; end: Location; @@ -3591,6 +4137,7 @@ declare namespace ts.server.protocol { outDir?: string; outFile?: string; paths?: MapLike; + plugins?: PluginImport[]; preserveConstEnums?: boolean; project?: string; reactNamespace?: string; @@ -3613,9 +4160,10 @@ declare namespace ts.server.protocol { namespace JsxEmit { type None = "None"; type Preserve = "Preserve"; + type ReactNative = "ReactNative"; type React = "React"; } - type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; + type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.ReactNative; namespace ModuleKind { type None = "None"; type CommonJS = "CommonJS"; @@ -3645,161 +4193,169 @@ declare namespace ts.server.protocol { type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015; } declare namespace ts.server { - interface CompressedData { - length: number; - compressionKind: string; - data: any; + interface ServerCancellationToken extends HostCancellationToken { + setRequest(requestId: number): void; + resetRequest(requestId: number): void; } - interface ServerHost extends System { - setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; - clearTimeout(timeoutId: any): void; - setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; - clearImmediate(timeoutId: any): void; - gc?(): void; - trace?(s: string): void; + const nullCancellationToken: ServerCancellationToken; + interface PendingErrorCheck { + fileName: NormalizedPath; + project: Project; } - interface SortedReadonlyArray extends ReadonlyArray { - " __sortedReadonlyArrayBrand": any; + interface EventSender { + event(payload: any, eventName: string): void; } - interface TypingInstallerRequest { - readonly projectName: string; - readonly kind: "discover" | "closeProject"; + namespace CommandNames { + const Brace: protocol.CommandTypes.Brace; + const BraceCompletion: protocol.CommandTypes.BraceCompletion; + const Change: protocol.CommandTypes.Change; + const Close: protocol.CommandTypes.Close; + const Completions: protocol.CommandTypes.Completions; + const CompletionDetails: protocol.CommandTypes.CompletionDetails; + const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList; + const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile; + const Configure: protocol.CommandTypes.Configure; + const Definition: protocol.CommandTypes.Definition; + const Exit: protocol.CommandTypes.Exit; + const Format: protocol.CommandTypes.Format; + const Formatonkey: protocol.CommandTypes.Formatonkey; + const Geterr: protocol.CommandTypes.Geterr; + const GeterrForProject: protocol.CommandTypes.GeterrForProject; + const Implementation: protocol.CommandTypes.Implementation; + const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync; + const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync; + const NavBar: protocol.CommandTypes.NavBar; + const NavTree: protocol.CommandTypes.NavTree; + const NavTreeFull: protocol.CommandTypes.NavTreeFull; + const Navto: protocol.CommandTypes.Navto; + const Occurrences: protocol.CommandTypes.Occurrences; + const DocumentHighlights: protocol.CommandTypes.DocumentHighlights; + const Open: protocol.CommandTypes.Open; + const Quickinfo: protocol.CommandTypes.Quickinfo; + const References: protocol.CommandTypes.References; + const Reload: protocol.CommandTypes.Reload; + const Rename: protocol.CommandTypes.Rename; + const Saveto: protocol.CommandTypes.Saveto; + const SignatureHelp: protocol.CommandTypes.SignatureHelp; + const TypeDefinition: protocol.CommandTypes.TypeDefinition; + const ProjectInfo: protocol.CommandTypes.ProjectInfo; + const ReloadProjects: protocol.CommandTypes.ReloadProjects; + const Unknown: protocol.CommandTypes.Unknown; + const OpenExternalProject: protocol.CommandTypes.OpenExternalProject; + const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects; + const CloseExternalProject: protocol.CommandTypes.CloseExternalProject; + const TodoComments: protocol.CommandTypes.TodoComments; + const Indentation: protocol.CommandTypes.Indentation; + const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate; + const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects; + const GetCodeFixes: protocol.CommandTypes.GetCodeFixes; + const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes; } - interface DiscoverTypings extends TypingInstallerRequest { - readonly fileNames: string[]; - readonly projectRootPath: ts.Path; - readonly compilerOptions: ts.CompilerOptions; - readonly typeAcquisition: ts.TypeAcquisition; - readonly unresolvedImports: SortedReadonlyArray; - readonly cachePath?: string; - readonly kind: "discover"; - } - interface CloseProject extends TypingInstallerRequest { - readonly kind: "closeProject"; - } - type ActionSet = "action::set"; - type ActionInvalidate = "action::invalidate"; - type EventBeginInstallTypes = "event::beginInstallTypes"; - type EventEndInstallTypes = "event::endInstallTypes"; - interface TypingInstallerResponse { - readonly kind: ActionSet | ActionInvalidate | EventBeginInstallTypes | EventEndInstallTypes; - } - interface ProjectResponse extends TypingInstallerResponse { - readonly projectName: string; - } - interface SetTypings extends ProjectResponse { - readonly typeAcquisition: ts.TypeAcquisition; - readonly compilerOptions: ts.CompilerOptions; - readonly typings: string[]; - readonly unresolvedImports: SortedReadonlyArray; - readonly kind: ActionSet; - } - interface InvalidateCachedTypings extends ProjectResponse { - readonly kind: ActionInvalidate; - } - interface InstallTypes extends ProjectResponse { - readonly kind: EventBeginInstallTypes | EventEndInstallTypes; - readonly eventId: number; - readonly typingsInstallerVersion: string; - readonly packagesToInstall: ReadonlyArray; - } - interface BeginInstallTypes extends InstallTypes { - readonly kind: EventBeginInstallTypes; - } - interface EndInstallTypes extends InstallTypes { - readonly kind: EventEndInstallTypes; - readonly installSuccess: boolean; - } -} -declare namespace ts.server { - const ActionSet: ActionSet; - const ActionInvalidate: ActionInvalidate; - const EventBeginInstallTypes: EventBeginInstallTypes; - const EventEndInstallTypes: EventEndInstallTypes; - namespace Arguments { - const GlobalCacheLocation = "--globalTypingsCacheLocation"; - const LogFile = "--logFile"; - const EnableTelemetry = "--enableTelemetry"; - } - function hasArgument(argumentName: string): boolean; - function findArgument(argumentName: string): string; -} -declare namespace ts.server { - enum LogLevel { - terse = 0, - normal = 1, - requestTime = 2, - verbose = 3, - } - const emptyArray: ReadonlyArray; - interface Logger { - close(): void; - hasLevel(level: LogLevel): boolean; - loggingEnabled(): boolean; - perftrc(s: string): void; - info(s: string): void; - startGroup(): void; - endGroup(): void; - msg(s: string, type?: Msg.Types): void; - getLogFileName(): string; - } - namespace Msg { - type Err = "Err"; - const Err: Err; - type Info = "Info"; - const Info: Info; - type Perf = "Perf"; - const Perf: Perf; - type Types = Err | Info | Perf; - } - function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, cachePath?: string): DiscoverTypings; - namespace Errors { - function ThrowNoProject(): never; - function ThrowProjectLanguageServiceDisabled(): never; - function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never; - } - function getDefaultFormatCodeSettings(host: ServerHost): FormatCodeSettings; - function mergeMaps(target: MapLike, source: MapLike): void; - function removeItemFromSet(items: T[], itemToRemove: T): void; - type NormalizedPath = string & { - __normalizedPathTag: any; - }; - function toNormalizedPath(fileName: string): NormalizedPath; - function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path; - function asNormalizedPath(fileName: string): NormalizedPath; - interface NormalizedPathMap { - get(path: NormalizedPath): T; - set(path: NormalizedPath, value: T): void; - contains(path: NormalizedPath): boolean; - remove(path: NormalizedPath): void; - } - function createNormalizedPathMap(): NormalizedPathMap; - interface ProjectOptions { - configHasFilesProperty?: boolean; - files?: string[]; - wildcardDirectories?: Map; - compilerOptions?: CompilerOptions; - typeAcquisition?: TypeAcquisition; - compileOnSave?: boolean; - } - function isInferredProjectName(name: string): boolean; - function makeInferredProjectName(counter: number): string; - function toSortedReadonlyArray(arr: string[]): SortedReadonlyArray; - class ThrottledOperations { - private readonly host; - private pendingTimeouts; - constructor(host: ServerHost); - schedule(operationId: string, delay: number, cb: () => void): void; - private static run(self, operationId, cb); - } - class GcTimer { - private readonly host; - private readonly delay; - private readonly logger; - private timerId; - constructor(host: ServerHost, delay: number, logger: Logger); - scheduleCollect(): void; - private static run(self); + function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string; + class Session implements EventSender { + private host; + private readonly cancellationToken; + protected readonly typingsInstaller: ITypingsInstaller; + private byteLength; + private hrtime; + protected logger: Logger; + protected readonly canUseEvents: boolean; + private readonly gcTimer; + protected projectService: ProjectService; + private changeSeq; + private currentRequestId; + private errorCheck; + private eventHander; + constructor(host: ServerHost, cancellationToken: ServerCancellationToken, useSingleInferredProject: boolean, typingsInstaller: ITypingsInstaller, byteLength: (buf: string, encoding?: string) => number, hrtime: (start?: number[]) => number[], logger: Logger, canUseEvents: boolean, eventHandler?: ProjectServiceEventHandler); + private sendRequestCompletedEvent(requestId); + private defaultEventHandler(event); + logError(err: Error, cmd: string): void; + send(msg: protocol.Message): void; + configFileDiagnosticEvent(triggerFile: string, configFile: string, diagnostics: ts.Diagnostic[]): void; + event(info: any, eventName: string): void; + output(info: any, cmdName: string, reqSeq?: number, errorMsg?: string): void; + private semanticCheck(file, project); + private syntacticCheck(file, project); + private updateProjectStructure(seq, matchSeq, ms?); + private updateErrorCheck(next, checkList, seq, matchSeq, ms?, followMs?, requireOpen?); + private cleanProjects(caption, projects); + private cleanup(); + private getEncodedSemanticClassifications(args); + private getProject(projectFileName); + private getCompilerOptionsDiagnostics(args); + private convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo); + private getDiagnosticsWorker(args, isSemantic, selector, includeLinePosition); + private getDefinition(args, simplifiedResult); + private getTypeDefinition(args); + private getImplementation(args, simplifiedResult); + private getOccurrences(args); + private getSyntacticDiagnosticsSync(args); + private getSemanticDiagnosticsSync(args); + private getDocumentHighlights(args, simplifiedResult); + private setCompilerOptionsForInferredProjects(args); + private getProjectInfo(args); + private getProjectInfoWorker(uncheckedFileName, projectFileName, needFileNameList); + private getRenameInfo(args); + private getProjects(args); + private getRenameLocations(args, simplifiedResult); + private getReferences(args, simplifiedResult); + private openClientFile(fileName, fileContent?, scriptKind?); + private getPosition(args, scriptInfo); + private getFileAndProject(args, errorOnMissingProject?); + private getFileAndProjectWithoutRefreshingInferredProjects(args, errorOnMissingProject?); + private getFileAndProjectWorker(uncheckedFileName, projectFileName, refreshInferredProjects, errorOnMissingProject); + private getOutliningSpans(args); + private getTodoComments(args); + private getDocCommentTemplate(args); + private getIndentation(args); + private getBreakpointStatement(args); + private getNameOrDottedNameSpan(args); + private isValidBraceCompletion(args); + private getQuickInfoWorker(args, simplifiedResult); + private getFormattingEditsForRange(args); + private getFormattingEditsForRangeFull(args); + private getFormattingEditsForDocumentFull(args); + private getFormattingEditsAfterKeystrokeFull(args); + private getFormattingEditsAfterKeystroke(args); + private getCompletions(args, simplifiedResult); + private getCompletionEntryDetails(args); + private getCompileOnSaveAffectedFileList(args); + private emitFile(args); + private getSignatureHelpItems(args, simplifiedResult); + private getDiagnostics(next, delay, fileNames); + private change(args); + private reload(args, reqSeq); + private saveToTmp(fileName, tempFileName); + private closeClientFile(fileName); + private decorateNavigationBarItems(items, scriptInfo); + private getNavigationBarItems(args, simplifiedResult); + private decorateNavigationTree(tree, scriptInfo); + private decorateSpan(span, scriptInfo); + private getNavigationTree(args, simplifiedResult); + private getNavigateToItems(args, simplifiedResult); + private getSupportedCodeFixes(); + private getCodeFixes(args, simplifiedResult); + private mapCodeAction(codeAction, scriptInfo); + private convertTextChangeToCodeEdit(change, scriptInfo); + private getBraceMatching(args, simplifiedResult); + private getDiagnosticsForProject(next, delay, fileName); + getCanonicalFileName(fileName: string): string; + exit(): void; + private notRequired(); + private requiredResponse(response); + private handlers; + addProtocolHandler(command: string, handler: (request: protocol.Request) => { + response?: any; + responseRequired: boolean; + }): void; + private setCurrentRequest(requestId); + private resetCurrentRequest(requestId); + executeWithRequestId(requestId: number, f: () => T): T; + executeCommand(request: protocol.Request): { + response?: any; + responseRequired?: boolean; + }; + onMessage(message: string): void; } } declare namespace ts.server { @@ -3964,6 +4520,7 @@ declare namespace ts.server { lineToTextSpan(line: number): TextSpan; lineOffsetToPosition(line: number, offset: number): number; positionToLineOffset(position: number): ILineInfo; + isJavaScript(): boolean; } } declare namespace ts.server { @@ -4025,6 +4582,28 @@ declare namespace ts.server { onProjectClosed(project: Project): void; } } +declare namespace ts.server { + function shouldEmitFile(scriptInfo: ScriptInfo): boolean; + class BuilderFileInfo { + readonly scriptInfo: ScriptInfo; + readonly project: Project; + private lastCheckedShapeSignature; + constructor(scriptInfo: ScriptInfo, project: Project); + isExternalModuleOrHasOnlyAmbientExternalModules(): boolean; + private containsOnlyAmbientModules(sourceFile); + private computeHash(text); + private getSourceFile(); + updateShapeSignature(): boolean; + } + interface Builder { + readonly project: Project; + getFilesAffectedBy(scriptInfo: ScriptInfo): string[]; + onProjectUpdateGraph(): void; + emitFile(scriptInfo: ScriptInfo, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => void): boolean; + clear(): void; + } + function createBuilder(project: Project): Builder; +} declare namespace ts.server { enum ProjectKind { Inferred = 0, @@ -4042,6 +4621,22 @@ declare namespace ts.server { get(path: Path): ReadonlyArray; set(path: Path, value: ReadonlyArray): void; } + interface PluginCreateInfo { + project: Project; + languageService: LanguageService; + languageServiceHost: LanguageServiceHost; + serverHost: ServerHost; + config: any; + } + interface PluginModule { + create(createInfo: PluginCreateInfo): LanguageService; + getExternalFiles?(proj: Project): string[]; + } + interface PluginModuleFactory { + (mod: { + typescript: typeof ts; + }): PluginModule; + } abstract class Project { private readonly projectName; readonly projectKind: ProjectKind; @@ -4051,12 +4646,12 @@ declare namespace ts.server { compileOnSaveEnabled: boolean; private rootFiles; private rootFilesMap; - private lsHost; private program; private cachedUnresolvedImportsPerFile; private lastCachedUnresolvedImportsList; - private readonly languageService; + protected languageService: LanguageService; languageServiceEnabled: boolean; + protected readonly lsHost: LSHost; builder: Builder; private updatedFileNames; private lastReportedFileNames; @@ -4069,6 +4664,7 @@ declare namespace ts.server { isNonTsProject(): boolean; isJsOnlyProject(): boolean; getCachedUnresolvedImportsPerFile_TestOnly(): UnresolvedImportsMap; + static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void): {}; constructor(projectName: string, projectKind: ProjectKind, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, languageServiceEnabled: boolean, compilerOptions: CompilerOptions, compileOnSaveEnabled: boolean); private setInternalCompilerOptionsForEmittingJsFiles(); getProjectErrors(): Diagnostic[]; @@ -4080,6 +4676,7 @@ declare namespace ts.server { getProjectName(): string; abstract getProjectRootPath(): string | undefined; abstract getTypeAcquisition(): TypeAcquisition; + getExternalFiles(): string[]; getSourceFile(path: Path): SourceFile; updateTypes(): void; close(): void; @@ -4110,17 +4707,23 @@ declare namespace ts.server { setCompilerOptions(compilerOptions: CompilerOptions): void; reloadScript(filename: NormalizedPath, tempFileName?: NormalizedPath): boolean; getReferencedFiles(path: Path): Path[]; - private removeRootFileIfNecessary(info); + protected removeRoot(info: ScriptInfo): void; } class InferredProject extends Project { private static newName; + private _isJsInferredProject; + toggleJsInferredProject(isJsInferredProject: boolean): void; + setCompilerOptions(options?: CompilerOptions): void; directoriesWatchedForTsconfig: string[]; constructor(projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions); + addRoot(info: ScriptInfo): void; + removeRoot(info: ScriptInfo): void; getProjectRootPath(): string; close(): void; getTypeAcquisition(): TypeAcquisition; } class ConfiguredProject extends Project { + private configFileName; private wildcardDirectories; compileOnSaveEnabled: boolean; private typeAcquisition; @@ -4129,13 +4732,17 @@ declare namespace ts.server { private directoriesWatchedForWildcards; private typeRootsWatchers; readonly canonicalConfigFilePath: NormalizedPath; + private plugins; openRefCount: number; constructor(configFileName: NormalizedPath, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, compilerOptions: CompilerOptions, wildcardDirectories: Map, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean); getConfigFilePath(): string; + enablePlugins(): void; + private enableProxy(pluginModuleFactory, configEntry); getProjectRootPath(): string; setProjectErrors(projectErrors: Diagnostic[]): void; setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; getTypeAcquisition(): TypeAcquisition; + getExternalFiles(): string[]; watchConfigFile(callback: (project: ConfiguredProject) => void): void; watchTypeRoots(callback: (project: ConfiguredProject, path: string) => void): void; watchConfigDirectory(callback: (project: ConfiguredProject, path: string) => void): void; @@ -4191,12 +4798,12 @@ declare namespace ts.server { function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings; function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin; function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind; - function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind; + function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind.Unknown | ScriptKind.JS | ScriptKind.JSX | ScriptKind.TS | ScriptKind.TSX; function combineProjectOutput(projects: Project[], action: (project: Project) => T[], comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean): T[]; interface HostConfiguration { formatCodeOptions: FormatCodeSettings; hostInfo: string; - extraFileExtensions?: FileExtensionInfo[]; + extraFileExtensions?: JsFileExtensionInfo[]; } interface OpenConfiguredProjectResult { configFileName?: NormalizedPath; @@ -4284,184 +4891,6 @@ declare namespace ts.server { openExternalProject(proj: protocol.ExternalProject, suppressRefreshOfInferredProjects?: boolean): void; } } -declare namespace ts.server { - interface PendingErrorCheck { - fileName: NormalizedPath; - project: Project; - } - interface EventSender { - event(payload: any, eventName: string): void; - } - namespace CommandNames { - const Brace: protocol.CommandTypes.Brace; - const BraceCompletion: protocol.CommandTypes.BraceCompletion; - const Change: protocol.CommandTypes.Change; - const Close: protocol.CommandTypes.Close; - const Completions: protocol.CommandTypes.Completions; - const CompletionDetails: protocol.CommandTypes.CompletionDetails; - const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList; - const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile; - const Configure: protocol.CommandTypes.Configure; - const Definition: protocol.CommandTypes.Definition; - const Exit: protocol.CommandTypes.Exit; - const Format: protocol.CommandTypes.Format; - const Formatonkey: protocol.CommandTypes.Formatonkey; - const Geterr: protocol.CommandTypes.Geterr; - const GeterrForProject: protocol.CommandTypes.GeterrForProject; - const Implementation: protocol.CommandTypes.Implementation; - const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync; - const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync; - const NavBar: protocol.CommandTypes.NavBar; - const NavTree: protocol.CommandTypes.NavTree; - const NavTreeFull: protocol.CommandTypes.NavTreeFull; - const Navto: protocol.CommandTypes.Navto; - const Occurrences: protocol.CommandTypes.Occurrences; - const DocumentHighlights: protocol.CommandTypes.DocumentHighlights; - const Open: protocol.CommandTypes.Open; - const Quickinfo: protocol.CommandTypes.Quickinfo; - const References: protocol.CommandTypes.References; - const Reload: protocol.CommandTypes.Reload; - const Rename: protocol.CommandTypes.Rename; - const Saveto: protocol.CommandTypes.Saveto; - const SignatureHelp: protocol.CommandTypes.SignatureHelp; - const TypeDefinition: protocol.CommandTypes.TypeDefinition; - const ProjectInfo: protocol.CommandTypes.ProjectInfo; - const ReloadProjects: protocol.CommandTypes.ReloadProjects; - const Unknown: protocol.CommandTypes.Unknown; - const OpenExternalProject: protocol.CommandTypes.OpenExternalProject; - const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects; - const CloseExternalProject: protocol.CommandTypes.CloseExternalProject; - const TodoComments: protocol.CommandTypes.TodoComments; - const Indentation: protocol.CommandTypes.Indentation; - const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate; - const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects; - const GetCodeFixes: protocol.CommandTypes.GetCodeFixes; - const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes; - } - function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string; - class Session implements EventSender { - private host; - protected readonly typingsInstaller: ITypingsInstaller; - private byteLength; - private hrtime; - protected logger: Logger; - protected readonly canUseEvents: boolean; - private readonly gcTimer; - protected projectService: ProjectService; - private errorTimer; - private immediateId; - private changeSeq; - private eventHander; - constructor(host: ServerHost, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller: ITypingsInstaller, byteLength: (buf: string, encoding?: string) => number, hrtime: (start?: number[]) => number[], logger: Logger, canUseEvents: boolean, eventHandler?: ProjectServiceEventHandler); - private defaultEventHandler(event); - logError(err: Error, cmd: string): void; - send(msg: protocol.Message): void; - configFileDiagnosticEvent(triggerFile: string, configFile: string, diagnostics: ts.Diagnostic[]): void; - event(info: any, eventName: string): void; - output(info: any, cmdName: string, reqSeq?: number, errorMsg?: string): void; - private semanticCheck(file, project); - private syntacticCheck(file, project); - private updateProjectStructure(seq, matchSeq, ms?); - private updateErrorCheck(checkList, seq, matchSeq, ms?, followMs?, requireOpen?); - private cleanProjects(caption, projects); - private cleanup(); - private getEncodedSemanticClassifications(args); - private getProject(projectFileName); - private getCompilerOptionsDiagnostics(args); - private convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo); - private getDiagnosticsWorker(args, isSemantic, selector, includeLinePosition); - private getDefinition(args, simplifiedResult); - private getTypeDefinition(args); - private getImplementation(args, simplifiedResult); - private getOccurrences(args); - private getSyntacticDiagnosticsSync(args); - private getSemanticDiagnosticsSync(args); - private getDocumentHighlights(args, simplifiedResult); - private setCompilerOptionsForInferredProjects(args); - private getProjectInfo(args); - private getProjectInfoWorker(uncheckedFileName, projectFileName, needFileNameList); - private getRenameInfo(args); - private getProjects(args); - private getRenameLocations(args, simplifiedResult); - private getReferences(args, simplifiedResult); - private openClientFile(fileName, fileContent?, scriptKind?); - private getPosition(args, scriptInfo); - private getFileAndProject(args, errorOnMissingProject?); - private getFileAndProjectWithoutRefreshingInferredProjects(args, errorOnMissingProject?); - private getFileAndProjectWorker(uncheckedFileName, projectFileName, refreshInferredProjects, errorOnMissingProject); - private getOutliningSpans(args); - private getTodoComments(args); - private getDocCommentTemplate(args); - private getIndentation(args); - private getBreakpointStatement(args); - private getNameOrDottedNameSpan(args); - private isValidBraceCompletion(args); - private getQuickInfoWorker(args, simplifiedResult); - private getFormattingEditsForRange(args); - private getFormattingEditsForRangeFull(args); - private getFormattingEditsForDocumentFull(args); - private getFormattingEditsAfterKeystrokeFull(args); - private getFormattingEditsAfterKeystroke(args); - private getCompletions(args, simplifiedResult); - private getCompletionEntryDetails(args); - private getCompileOnSaveAffectedFileList(args); - private emitFile(args); - private getSignatureHelpItems(args, simplifiedResult); - private getDiagnostics(delay, fileNames); - private change(args); - private reload(args, reqSeq); - private saveToTmp(fileName, tempFileName); - private closeClientFile(fileName); - private decorateNavigationBarItems(items, scriptInfo); - private getNavigationBarItems(args, simplifiedResult); - private decorateNavigationTree(tree, scriptInfo); - private decorateSpan(span, scriptInfo); - private getNavigationTree(args, simplifiedResult); - private getNavigateToItems(args, simplifiedResult); - private getSupportedCodeFixes(); - private getCodeFixes(args, simplifiedResult); - private mapCodeAction(codeAction, scriptInfo); - private convertTextChangeToCodeEdit(change, scriptInfo); - private getBraceMatching(args, simplifiedResult); - getDiagnosticsForProject(delay: number, fileName: string): void; - getCanonicalFileName(fileName: string): string; - exit(): void; - private notRequired(); - private requiredResponse(response); - private handlers; - addProtocolHandler(command: string, handler: (request: protocol.Request) => { - response?: any; - responseRequired: boolean; - }): void; - executeCommand(request: protocol.Request): { - response?: any; - responseRequired?: boolean; - }; - onMessage(message: string): void; - } -} -declare namespace ts.server { - function shouldEmitFile(scriptInfo: ScriptInfo): boolean; - class BuilderFileInfo { - readonly scriptInfo: ScriptInfo; - readonly project: Project; - private lastCheckedShapeSignature; - constructor(scriptInfo: ScriptInfo, project: Project); - isExternalModuleOrHasOnlyAmbientExternalModules(): boolean; - private containsOnlyAmbientModules(sourceFile); - private computeHash(text); - private getSourceFile(); - updateShapeSignature(): boolean; - } - interface Builder { - readonly project: Project; - getFilesAffectedBy(scriptInfo: ScriptInfo): string[]; - onProjectUpdateGraph(): void; - emitFile(scriptInfo: ScriptInfo, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => void): boolean; - clear(): void; - } - function createBuilder(project: Project): Builder; -} export = ts; export as namespace ts; \ No newline at end of file diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index ab1a5cdfe05..38fcfa5c6b5 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -25,6 +25,428 @@ var __extends = (this && this.__extends) || (function () { })(); var ts; (function (ts) { + var SyntaxKind; + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 126] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 127] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 128] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 129] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 130] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 131] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 132] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 133] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 134] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 135] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 136] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 137] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 138] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 139] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 140] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 141] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 142] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 143] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 144] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 145] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 146] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 147] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 148] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 149] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 150] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 151] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 152] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 153] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 154] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 155] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 156] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 157] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 158] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 159] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 160] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 161] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 162] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 163] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 164] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 165] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 166] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 167] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 168] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 169] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 170] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 171] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 172] = "LiteralType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 173] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 174] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 175] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 176] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 177] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 178] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 179] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 180] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 181] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 182] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 183] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 184] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 185] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 186] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 187] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 188] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 189] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 190] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 191] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 192] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 193] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 194] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 195] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 196] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 197] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 198] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 199] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 200] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 201] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 202] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 203] = "MetaProperty"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 204] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 205] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 206] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 207] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 208] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 209] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 210] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 211] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 212] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 213] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 214] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 215] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 216] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 217] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 218] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 219] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 220] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 221] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 222] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 223] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 224] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 225] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 226] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 227] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 228] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 229] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 230] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 231] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 232] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 233] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 234] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 235] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 236] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 237] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 238] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 239] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 240] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 241] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 242] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 243] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 244] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 245] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 246] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 247] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 248] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 249] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 250] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 251] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 252] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 253] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 254] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 255] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 256] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 257] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 258] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 259] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 260] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 261] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 262] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 263] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 264] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 265] = "Bundle"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 266] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 267] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 268] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 269] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 270] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 271] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 272] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 273] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 274] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 275] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 276] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 277] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 278] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 279] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 280] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 281] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 282] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 283] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 284] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 285] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 286] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 287] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 288] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 289] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 290] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 291] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 292] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 293] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 294] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 295] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["SyntaxList"] = 296] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 297] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 298] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 299] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 300] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["Count"] = 301] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 141] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 157] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 172] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 141] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 142] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 266] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 295] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 282] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 295] = "LastJSDocTagNode"; + })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); + var NodeFlags; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Let"] = 1] = "Let"; + NodeFlags[NodeFlags["Const"] = 2] = "Const"; + NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; + NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; + NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 96256] = "ContextFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; + })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); + var ModifierFlags; + (function (ModifierFlags) { + ModifierFlags[ModifierFlags["None"] = 0] = "None"; + ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; + ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; + ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; + ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; + ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; + ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; + ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; + ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; + ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; + ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; + ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; + ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault"; + })(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {})); + var JsxFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(JsxFlags = ts.JsxFlags || (ts.JsxFlags = {})); + var RelationComparisonResult; + (function (RelationComparisonResult) { + RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; + RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; + RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); + var GeneratedIdentifierKind; + (function (GeneratedIdentifierKind) { + GeneratedIdentifierKind[GeneratedIdentifierKind["None"] = 0] = "None"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Auto"] = 1] = "Auto"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Loop"] = 2] = "Loop"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; + })(GeneratedIdentifierKind = ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var FlowFlags; + (function (FlowFlags) { + FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; + FlowFlags[FlowFlags["Start"] = 2] = "Start"; + FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; + FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; + FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; + FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; + FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; + FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; + FlowFlags[FlowFlags["Label"] = 12] = "Label"; + FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; + })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -37,6 +459,45 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var TypeFormatFlags; + (function (TypeFormatFlags) { + TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; + TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; + TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; + TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; + TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; + TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; + TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; + TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; + TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 2048] = "SuppressAnyReturnType"; + TypeFormatFlags[TypeFormatFlags["AddUndefined"] = 4096] = "AddUndefined"; + })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var SymbolFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(SymbolFormatFlags = ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolAccessibility; + (function (SymbolAccessibility) { + SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; + SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; + SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; + })(SymbolAccessibility = ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + var SyntheticSymbolKind; + (function (SyntheticSymbolKind) { + SyntheticSymbolKind[SyntheticSymbolKind["UnionOrIntersection"] = 0] = "UnionOrIntersection"; + SyntheticSymbolKind[SyntheticSymbolKind["Spread"] = 1] = "Spread"; + })(SyntheticSymbolKind = ts.SyntheticSymbolKind || (ts.SyntheticSymbolKind = {})); + var TypePredicateKind; + (function (TypePredicateKind) { + TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; + TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; @@ -51,6 +512,189 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var SymbolFlags; + (function (SymbolFlags) { + SymbolFlags[SymbolFlags["None"] = 0] = "None"; + SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; + SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; + SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; + SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; + SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; + SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; + SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; + SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; + SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; + SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; + SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; + SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; + SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; + SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; + SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; + SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; + SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; + SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; + SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; + SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; + SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; + SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; + SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; + SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; + SymbolFlags[SymbolFlags["Prototype"] = 16777216] = "Prototype"; + SymbolFlags[SymbolFlags["ExportStar"] = 33554432] = "ExportStar"; + SymbolFlags[SymbolFlags["Optional"] = 67108864] = "Optional"; + SymbolFlags[SymbolFlags["Transient"] = 134217728] = "Transient"; + SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; + SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; + SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; + SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; + SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; + SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; + SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; + SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; + SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; + SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; + SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; + })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); + var CheckFlags; + (function (CheckFlags) { + CheckFlags[CheckFlags["Instantiated"] = 1] = "Instantiated"; + CheckFlags[CheckFlags["SyntheticProperty"] = 2] = "SyntheticProperty"; + CheckFlags[CheckFlags["Readonly"] = 4] = "Readonly"; + CheckFlags[CheckFlags["Partial"] = 8] = "Partial"; + CheckFlags[CheckFlags["HasNonUniformType"] = 16] = "HasNonUniformType"; + CheckFlags[CheckFlags["ContainsPublic"] = 32] = "ContainsPublic"; + CheckFlags[CheckFlags["ContainsProtected"] = 64] = "ContainsProtected"; + CheckFlags[CheckFlags["ContainsPrivate"] = 128] = "ContainsPrivate"; + CheckFlags[CheckFlags["ContainsStatic"] = 256] = "ContainsStatic"; + })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); + var NodeCheckFlags; + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["CaptureNewTarget"] = 8] = "CaptureNewTarget"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; + NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; + NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; + NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; + })(NodeCheckFlags = ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var TypeFlags; + (function (TypeFlags) { + TypeFlags[TypeFlags["Any"] = 1] = "Any"; + TypeFlags[TypeFlags["String"] = 2] = "String"; + TypeFlags[TypeFlags["Number"] = 4] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; + TypeFlags[TypeFlags["Void"] = 1024] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 4096] = "Null"; + TypeFlags[TypeFlags["Never"] = 8192] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; + TypeFlags[TypeFlags["Object"] = 32768] = "Object"; + TypeFlags[TypeFlags["Union"] = 65536] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 131072] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 262144] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 524288] = "IndexedAccess"; + TypeFlags[TypeFlags["FreshLiteral"] = 1048576] = "FreshLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 2097152] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; + TypeFlags[TypeFlags["JsxAttributes"] = 33554432] = "JsxAttributes"; + TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; + TypeFlags[TypeFlags["Intrinsic"] = 16793231] = "Intrinsic"; + TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 262178] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 196608] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 229376] = "StructuredType"; + TypeFlags[TypeFlags["StructuredOrTypeVariable"] = 1032192] = "StructuredOrTypeVariable"; + TypeFlags[TypeFlags["TypeVariable"] = 540672] = "TypeVariable"; + TypeFlags[TypeFlags["Narrowable"] = 17810431] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 16810497] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; + TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; + })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); + var ObjectFlags; + (function (ObjectFlags) { + ObjectFlags[ObjectFlags["Class"] = 1] = "Class"; + ObjectFlags[ObjectFlags["Interface"] = 2] = "Interface"; + ObjectFlags[ObjectFlags["Reference"] = 4] = "Reference"; + ObjectFlags[ObjectFlags["Tuple"] = 8] = "Tuple"; + ObjectFlags[ObjectFlags["Anonymous"] = 16] = "Anonymous"; + ObjectFlags[ObjectFlags["Mapped"] = 32] = "Mapped"; + ObjectFlags[ObjectFlags["Instantiated"] = 64] = "Instantiated"; + ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; + ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; + ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; + ObjectFlags[ObjectFlags["NonPrimitive"] = 1024] = "NonPrimitive"; + ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; + })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); + var SignatureKind; + (function (SignatureKind) { + SignatureKind[SignatureKind["Call"] = 0] = "Call"; + SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; + })(SignatureKind = ts.SignatureKind || (ts.SignatureKind = {})); + var IndexKind; + (function (IndexKind) { + IndexKind[IndexKind["String"] = 0] = "String"; + IndexKind[IndexKind["Number"] = 1] = "Number"; + })(IndexKind = ts.IndexKind || (ts.IndexKind = {})); + var SpecialPropertyAssignmentKind; + (function (SpecialPropertyAssignmentKind) { + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + })(SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); var DiagnosticCategory; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; @@ -71,6 +715,179 @@ var ts; ModuleKind[ModuleKind["System"] = 4] = "System"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); + var JsxEmit; + (function (JsxEmit) { + JsxEmit[JsxEmit["None"] = 0] = "None"; + JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; + JsxEmit[JsxEmit["React"] = 2] = "React"; + JsxEmit[JsxEmit["ReactNative"] = 3] = "ReactNative"; + })(JsxEmit = ts.JsxEmit || (ts.JsxEmit = {})); + var NewLineKind; + (function (NewLineKind) { + NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; + NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; + })(NewLineKind = ts.NewLineKind || (ts.NewLineKind = {})); + var ScriptKind; + (function (ScriptKind) { + ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; + ScriptKind[ScriptKind["JS"] = 1] = "JS"; + ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; + ScriptKind[ScriptKind["TS"] = 3] = "TS"; + ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + ScriptKind[ScriptKind["External"] = 5] = "External"; + })(ScriptKind = ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptTarget; + (function (ScriptTarget) { + ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; + ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; + ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["ESNext"] = 5] = "ESNext"; + ScriptTarget[ScriptTarget["Latest"] = 5] = "Latest"; + })(ScriptTarget = ts.ScriptTarget || (ts.ScriptTarget = {})); + var LanguageVariant; + (function (LanguageVariant) { + LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; + LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; + })(LanguageVariant = ts.LanguageVariant || (ts.LanguageVariant = {})); + var DiagnosticStyle; + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(DiagnosticStyle = ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var WatchDirectoryFlags; + (function (WatchDirectoryFlags) { + WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; + WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; + })(WatchDirectoryFlags = ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); + var CharacterCodes; + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; + CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; + CharacterCodes[CharacterCodes["space"] = 32] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; + CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; + CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; + CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; + CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; + CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; + CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; + CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["j"] = 106] = "j"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["B"] = 66] = "B"; + CharacterCodes[CharacterCodes["C"] = 67] = "C"; + CharacterCodes[CharacterCodes["D"] = 68] = "D"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["G"] = 71] = "G"; + CharacterCodes[CharacterCodes["H"] = 72] = "H"; + CharacterCodes[CharacterCodes["I"] = 73] = "I"; + CharacterCodes[CharacterCodes["J"] = 74] = "J"; + CharacterCodes[CharacterCodes["K"] = 75] = "K"; + CharacterCodes[CharacterCodes["L"] = 76] = "L"; + CharacterCodes[CharacterCodes["M"] = 77] = "M"; + CharacterCodes[CharacterCodes["N"] = 78] = "N"; + CharacterCodes[CharacterCodes["O"] = 79] = "O"; + CharacterCodes[CharacterCodes["P"] = 80] = "P"; + CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; + CharacterCodes[CharacterCodes["R"] = 82] = "R"; + CharacterCodes[CharacterCodes["S"] = 83] = "S"; + CharacterCodes[CharacterCodes["T"] = 84] = "T"; + CharacterCodes[CharacterCodes["U"] = 85] = "U"; + CharacterCodes[CharacterCodes["V"] = 86] = "V"; + CharacterCodes[CharacterCodes["W"] = 87] = "W"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(CharacterCodes = ts.CharacterCodes || (ts.CharacterCodes = {})); var Extension; (function (Extension) { Extension[Extension["Ts"] = 0] = "Ts"; @@ -80,6 +897,111 @@ var ts; Extension[Extension["Jsx"] = 4] = "Jsx"; Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension"; })(Extension = ts.Extension || (ts.Extension = {})); + var TransformFlags; + (function (TransformFlags) { + TransformFlags[TransformFlags["None"] = 0] = "None"; + TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; + TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; + TransformFlags[TransformFlags["ContainsJsx"] = 4] = "ContainsJsx"; + TransformFlags[TransformFlags["ContainsESNext"] = 8] = "ContainsESNext"; + TransformFlags[TransformFlags["ContainsES2017"] = 16] = "ContainsES2017"; + TransformFlags[TransformFlags["ContainsES2016"] = 32] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 64] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 128] = "ContainsES2015"; + TransformFlags[TransformFlags["Generator"] = 256] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 512] = "ContainsGenerator"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 2048] = "ContainsDestructuringAssignment"; + TransformFlags[TransformFlags["ContainsDecorators"] = 4096] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 8192] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 16384] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 32768] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 65536] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 131072] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 262144] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpread"] = 524288] = "ContainsSpread"; + TransformFlags[TransformFlags["ContainsObjectSpread"] = 1048576] = "ContainsObjectSpread"; + TransformFlags[TransformFlags["ContainsRest"] = 524288] = "ContainsRest"; + TransformFlags[TransformFlags["ContainsObjectRest"] = 1048576] = "ContainsObjectRest"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; + TransformFlags[TransformFlags["AssertJsx"] = 4] = "AssertJsx"; + TransformFlags[TransformFlags["AssertESNext"] = 8] = "AssertESNext"; + TransformFlags[TransformFlags["AssertES2017"] = 16] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 32] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 192] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 768] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 3072] = "AssertDestructuringAssignment"; + TransformFlags[TransformFlags["NodeExcludes"] = 536872257] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 601249089] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 601281857] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 601015617] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 601015617] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539358529] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574674241] = "ModuleExcludes"; + TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 540087617] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537396545] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 546309441] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 536872257] = "ParameterExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = 537920833] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = 537396545] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 274432] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 163840] = "ES2015FunctionSyntaxMask"; + })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); + var EmitFlags; + (function (EmitFlags) { + EmitFlags[EmitFlags["SingleLine"] = 1] = "SingleLine"; + EmitFlags[EmitFlags["AdviseOnEmitNode"] = 2] = "AdviseOnEmitNode"; + EmitFlags[EmitFlags["NoSubstitution"] = 4] = "NoSubstitution"; + EmitFlags[EmitFlags["CapturesThis"] = 8] = "CapturesThis"; + EmitFlags[EmitFlags["NoLeadingSourceMap"] = 16] = "NoLeadingSourceMap"; + EmitFlags[EmitFlags["NoTrailingSourceMap"] = 32] = "NoTrailingSourceMap"; + EmitFlags[EmitFlags["NoSourceMap"] = 48] = "NoSourceMap"; + EmitFlags[EmitFlags["NoNestedSourceMaps"] = 64] = "NoNestedSourceMaps"; + EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 128] = "NoTokenLeadingSourceMaps"; + EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 256] = "NoTokenTrailingSourceMaps"; + EmitFlags[EmitFlags["NoTokenSourceMaps"] = 384] = "NoTokenSourceMaps"; + EmitFlags[EmitFlags["NoLeadingComments"] = 512] = "NoLeadingComments"; + EmitFlags[EmitFlags["NoTrailingComments"] = 1024] = "NoTrailingComments"; + EmitFlags[EmitFlags["NoComments"] = 1536] = "NoComments"; + EmitFlags[EmitFlags["NoNestedComments"] = 2048] = "NoNestedComments"; + EmitFlags[EmitFlags["HelperName"] = 4096] = "HelperName"; + EmitFlags[EmitFlags["ExportName"] = 8192] = "ExportName"; + EmitFlags[EmitFlags["LocalName"] = 16384] = "LocalName"; + EmitFlags[EmitFlags["Indented"] = 32768] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 65536] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 131072] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 262144] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 524288] = "CustomPrologue"; + EmitFlags[EmitFlags["NoHoisting"] = 1048576] = "NoHoisting"; + EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 2097152] = "HasEndOfDeclarationMarker"; + })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); + var ExternalEmitHelpers; + (function (ExternalEmitHelpers) { + ExternalEmitHelpers[ExternalEmitHelpers["Extends"] = 1] = "Extends"; + ExternalEmitHelpers[ExternalEmitHelpers["Assign"] = 2] = "Assign"; + ExternalEmitHelpers[ExternalEmitHelpers["Rest"] = 4] = "Rest"; + ExternalEmitHelpers[ExternalEmitHelpers["Decorate"] = 8] = "Decorate"; + ExternalEmitHelpers[ExternalEmitHelpers["Metadata"] = 16] = "Metadata"; + ExternalEmitHelpers[ExternalEmitHelpers["Param"] = 32] = "Param"; + ExternalEmitHelpers[ExternalEmitHelpers["Awaiter"] = 64] = "Awaiter"; + ExternalEmitHelpers[ExternalEmitHelpers["Generator"] = 128] = "Generator"; + ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; + ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 128] = "LastEmitHelper"; + })(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {})); + var EmitHint; + (function (EmitHint) { + EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile"; + EmitHint[EmitHint["Expression"] = 1] = "Expression"; + EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; + EmitHint[EmitHint["Unspecified"] = 3] = "Unspecified"; + })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -98,32 +1020,32 @@ var ts; var measures; function mark(markName) { if (enabled) { - marks[markName] = ts.timestamp(); - counts[markName] = (counts[markName] || 0) + 1; + marks.set(markName, ts.timestamp()); + counts.set(markName, (counts.get(markName) || 0) + 1); profilerEvent(markName); } } performance.mark = mark; function measure(measureName, startMarkName, endMarkName) { if (enabled) { - var end = endMarkName && marks[endMarkName] || ts.timestamp(); - var start = startMarkName && marks[startMarkName] || profilerStart; - measures[measureName] = (measures[measureName] || 0) + (end - start); + var end = endMarkName && marks.get(endMarkName) || ts.timestamp(); + var start = startMarkName && marks.get(startMarkName) || profilerStart; + measures.set(measureName, (measures.get(measureName) || 0) + (end - start)); } } performance.measure = measure; function getCount(markName) { - return counts && counts[markName] || 0; + return counts && counts.get(markName) || 0; } performance.getCount = getCount; function getDuration(measureName) { - return measures && measures[measureName] || 0; + return measures && measures.get(measureName) || 0; } performance.getDuration = getDuration; function forEachMeasure(cb) { - for (var key in measures) { - cb(key, measures[key]); - } + measures.forEach(function (measure, key) { + cb(key, measure); + }); } performance.forEachMeasure = forEachMeasure; function enable() { @@ -142,22 +1064,102 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.2.0"; + ts.version = "2.3.0"; })(ts || (ts = {})); (function (ts) { - var createObject = Object.create; - ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - function createMap(template) { - var map = createObject(null); + var Ternary; + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(Ternary = ts.Ternary || (ts.Ternary = {})); + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(undefined, { usage: "sort", sensitivity: "accent" }) : undefined; + ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + function createDictionaryObject() { + var map = Object.create(null); map["__"] = undefined; delete map["__"]; + return map; + } + function createMap() { + return new MapCtr(); + } + ts.createMap = createMap; + function createMapFromTemplate(template) { + var map = new MapCtr(); for (var key in template) if (hasOwnProperty.call(template, key)) { - map[key] = template[key]; + map.set(key, template[key]); } return map; } - ts.createMap = createMap; + ts.createMapFromTemplate = createMapFromTemplate; + var MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); + function shimMap() { + var MapIterator = (function () { + function MapIterator(data, selector) { + this.index = 0; + this.data = data; + this.selector = selector; + this.keys = Object.keys(data); + } + MapIterator.prototype.next = function () { + var index = this.index; + if (index < this.keys.length) { + this.index++; + return { value: this.selector(this.data, this.keys[index]), done: false }; + } + return { value: undefined, done: true }; + }; + return MapIterator; + }()); + return (function () { + function class_1() { + this.data = createDictionaryObject(); + this.size = 0; + } + class_1.prototype.get = function (key) { + return this.data[key]; + }; + class_1.prototype.set = function (key, value) { + if (!this.has(key)) { + this.size++; + } + this.data[key] = value; + return this; + }; + class_1.prototype.has = function (key) { + return key in this.data; + }; + class_1.prototype.delete = function (key) { + if (this.has(key)) { + this.size--; + delete this.data[key]; + return true; + } + return false; + }; + class_1.prototype.clear = function () { + this.data = createDictionaryObject(); + this.size = 0; + }; + class_1.prototype.keys = function () { + return new MapIterator(this.data, function (_data, key) { return key; }); + }; + class_1.prototype.values = function () { + return new MapIterator(this.data, function (data, key) { return data[key]; }); + }; + class_1.prototype.entries = function () { + return new MapIterator(this.data, function (data, key) { return [key, data[key]]; }); + }; + class_1.prototype.forEach = function (action) { + for (var key in this.data) { + action(this.data[key], key); + } + }; + return class_1; + }()); + } function createFileMap(keyMapper) { var files = createMap(); return { @@ -170,32 +1172,27 @@ var ts; clear: clear, }; function forEachValueInMap(f) { - for (var key in files) { - f(key, files[key]); - } + files.forEach(function (file, key) { + f(key, file); + }); } function getKeys() { - var keys = []; - for (var key in files) { - keys.push(key); - } - return keys; + return arrayFrom(files.keys()); } function get(path) { - return files[toKey(path)]; + return files.get(toKey(path)); } function set(path, value) { - files[toKey(path)] = value; + files.set(toKey(path), value); } function contains(path) { - return toKey(path) in files; + return files.has(toKey(path)); } function remove(path) { - var key = toKey(path); - delete files[key]; + files.delete(toKey(path)); } function clear() { - files = createMap(); + files.clear(); } function toKey(path) { return keyMapper ? keyMapper(path) : path; @@ -209,6 +1206,16 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + var Comparison; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(Comparison = ts.Comparison || (ts.Comparison = {})); + function length(array) { + return array ? array.length : 0; + } + ts.length = length; function forEach(array, callback) { if (array) { for (var i = 0; i < array.length; i++) { @@ -249,6 +1256,15 @@ var ts; return undefined; } ts.find = find; + function findIndex(array, predicate) { + for (var i = 0; i < array.length; i++) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; + } + ts.findIndex = findIndex; function findMap(array, callback) { for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); @@ -470,21 +1486,18 @@ var ts; return result; } ts.spanMap = spanMap; - function mapObject(object, f) { - var result; - if (object) { - result = {}; - for (var _i = 0, _a = getOwnKeys(object); _i < _a.length; _i++) { - var v = _a[_i]; - var _b = f(v, object[v]) || [undefined, undefined], key = _b[0], value = _b[1]; - if (key !== undefined) { - result[key] = value; - } - } + function mapEntries(map, f) { + if (!map) { + return undefined; } + var result = createMap(); + map.forEach(function (value, key) { + var _a = f(key, value), newKey = _a[0], newValue = _a[1]; + result.set(newKey, newValue); + }); return result; } - ts.mapObject = mapObject; + ts.mapEntries = mapEntries; function some(array, predicate) { if (array) { if (predicate) { @@ -768,38 +1781,55 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - function forEachProperty(map, callback) { - var result; - for (var key in map) { - if (result = callback(map[key], key)) - break; + function arrayFrom(iterator) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(value); } return result; + var _b; } - ts.forEachProperty = forEachProperty; - function someProperties(map, predicate) { - for (var key in map) { - if (!predicate || predicate(map[key], key)) - return true; + ts.arrayFrom = arrayFrom; + function convertToArray(iterator, f) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(f(value)); } - return false; + return result; + var _b; } - ts.someProperties = someProperties; - function copyProperties(source, target) { - for (var key in source) { - target[key] = source[key]; + ts.convertToArray = convertToArray; + function forEachEntry(map, callback) { + var iterator = map.entries(); + for (var _a = iterator.next(), pair = _a.value, done = _a.done; !done; _b = iterator.next(), pair = _b.value, done = _b.done, _b) { + var key = pair[0], value = pair[1]; + var result = callback(value, key); + if (result) { + return result; + } } + return undefined; + var _b; } - ts.copyProperties = copyProperties; - function appendProperty(map, key, value) { - if (key === undefined || value === undefined) - return map; - if (map === undefined) - map = createMap(); - map[key] = value; - return map; + ts.forEachEntry = forEachEntry; + function forEachKey(map, callback) { + var iterator = map.keys(); + for (var _a = iterator.next(), key = _a.value, done = _a.done; !done; _b = iterator.next(), key = _b.value, done = _b.done, _b) { + var result = callback(key); + if (result) { + return result; + } + } + return undefined; + var _b; } - ts.appendProperty = appendProperty; + ts.forEachKey = forEachKey; + function copyEntries(source, target) { + source.forEach(function (value, key) { + target.set(key, value); + }); + } + ts.copyEntries = copyEntries; function assign(t) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -815,14 +1845,6 @@ var ts; return t; } ts.assign = assign; - function reduceProperties(map, callback, initial) { - var result = initial; - for (var key in map) { - result = callback(result, map[key], String(key)); - } - return result; - } - ts.reduceProperties = reduceProperties; function equalOwnProperties(left, right, equalityComparer) { if (left === right) return true; @@ -847,23 +1869,14 @@ var ts; var result = createMap(); for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { var value = array_8[_i]; - result[makeKey(value)] = makeValue ? makeValue(value) : value; + result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; } ts.arrayToMap = arrayToMap; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; function cloneMap(map) { var clone = createMap(); - copyProperties(map, clone); + copyEntries(map, clone); return clone; } ts.cloneMap = cloneMap; @@ -890,27 +1903,32 @@ var ts; return result; } ts.extend = extend; - function multiMapAdd(map, key, value) { - var values = map[key]; + function createMultiMap() { + var map = createMap(); + map.add = multiMapAdd; + map.remove = multiMapRemove; + return map; + } + ts.createMultiMap = createMultiMap; + function multiMapAdd(key, value) { + var values = this.get(key); if (values) { values.push(value); - return values; } else { - return map[key] = [value]; + this.set(key, values = [value]); } + return values; } - ts.multiMapAdd = multiMapAdd; - function multiMapRemove(map, key, value) { - var values = map[key]; + function multiMapRemove(key, value) { + var values = this.get(key); if (values) { unorderedRemoveItem(values, value); if (!values.length) { - delete map[key]; + this.delete(key); } } } - ts.multiMapRemove = multiMapRemove; function isArray(value) { return Array.isArray ? Array.isArray(value) : value instanceof Array; } @@ -1088,8 +2106,10 @@ var ts; if (b === undefined) return 1; if (ignoreCase) { - if (ts.collator && String.prototype.localeCompare) { - var result = a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); + if (ts.collator) { + var result = ts.localeCompareIsCorrect ? + ts.collator.compare(a, b) : + a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 : result > 0 ? 1 : 0; } a = a.toUpperCase(); @@ -1471,36 +2491,26 @@ var ts; var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; var singleAsteriskRegexFragmentOther = "[^/]*"; function getRegularExpressionForWildcard(specs, basePath, usage) { + var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); + if (!patterns || !patterns.length) { + return undefined; + } + var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; + } + ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + function getRegularExpressionsForWildcards(specs, basePath, usage) { if (specs === undefined || specs.length === 0) { return undefined; } var replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther; var singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther; var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; - var pattern = ""; - var hasWrittenSubpattern = false; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!spec) { - continue; - } - var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); - if (subPattern === undefined) { - continue; - } - if (hasWrittenSubpattern) { - pattern += "|"; - } - pattern += "(" + subPattern + ")"; - hasWrittenSubpattern = true; - } - if (!pattern) { - return undefined; - } - var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return flatMap(specs, function (spec) { + return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + }); } - ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function isImplicitGlob(lastPathComponent) { return !/[.*?]/.test(lastPathComponent); } @@ -1570,6 +2580,7 @@ var ts; currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); return { + includeFilePatterns: map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -1582,34 +2593,48 @@ var ts; currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); - var result = []; + var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; + var comparer = useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive; for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; visitDirectory(basePath, combinePaths(currentDirectory, basePath)); } - return result; + return flatten(results); function visitDirectory(path, absolutePath) { var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; + files = files.slice().sort(comparer); + directories = directories.slice().sort(comparer); + var _loop_1 = function (current) { + var name = combinePaths(path, current); + var absoluteName = combinePaths(absolutePath, current); + if (extensions && !fileExtensionIsAny(name, extensions)) + return "continue"; + if (excludeRegex && excludeRegex.test(absoluteName)) + return "continue"; + if (!includeFileRegexes) { + results[0].push(name); + } + else { + var includeIndex = findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); }); + if (includeIndex !== -1) { + results[includeIndex].push(name); + } + } + }; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var current = files_1[_i]; - var name_1 = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); - if ((!extensions || fileExtensionIsAny(name_1, extensions)) && - (!includeFileRegex || includeFileRegex.test(absoluteName)) && - (!excludeRegex || !excludeRegex.test(absoluteName))) { - result.push(name_1); - } + _loop_1(current); } for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var current = directories_1[_b]; - var name_2 = combinePaths(path, current); + var name = combinePaths(path, current); var absoluteName = combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { - visitDirectory(name_2, absoluteName); + visitDirectory(name, absoluteName); } } } @@ -1625,14 +2650,14 @@ var ts; includeBasePaths.push(getIncludeBasePath(absolute)); } includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); - var _loop_1 = function (includeBasePath) { + var _loop_2 = function (includeBasePath) { if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } }; for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { var includeBasePath = includeBasePaths_1[_a]; - _loop_1(includeBasePath); + _loop_2(includeBasePath); } } return basePaths; @@ -1672,13 +2697,13 @@ var ts; var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions); function getSupportedExtensions(options, extraFileExtensions) { var needAllExtensions = options && options.allowJs; - if (!extraFileExtensions || extraFileExtensions.length === 0) { + if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = (needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions).slice(0); + var extensions = allSupportedExtensions.slice(0); for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { var extInfo = extraFileExtensions_1[_i]; - if (needAllExtensions || extInfo.scriptKind === 3) { + if (extensions.indexOf(extInfo.extension) === -1) { extensions.push(extInfo.extension); } } @@ -1706,33 +2731,40 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + var ExtensionPriority; + (function (ExtensionPriority) { + ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; + ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; + ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; + ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; + })(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {})); function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { - return adjustExtensionPriority(i); + return adjustExtensionPriority(i, supportedExtensions); } } return 0; } ts.getExtensionPriority = getExtensionPriority; - function adjustExtensionPriority(extensionPriority) { + function adjustExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2) { return 0; } - else if (extensionPriority < 5) { + else if (extensionPriority < supportedExtensions.length) { return 2; } else { - return 5; + return supportedExtensions.length; } } ts.adjustExtensionPriority = adjustExtensionPriority; - function getNextLowestExtensionPriority(extensionPriority) { + function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2) { return 2; } else { - return 5; + return supportedExtensions.length; } } ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority; @@ -1790,6 +2822,13 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; + var AssertionLevel; + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(AssertionLevel = ts.AssertionLevel || (ts.AssertionLevel = {})); var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -2079,32 +3118,32 @@ var ts; var useNonPollingWatchers = process.env["TSC_NONPOLLING_WATCHER"]; function createWatchedFileSet() { var dirWatchers = ts.createMap(); - var fileWatcherCallbacks = ts.createMap(); + var fileWatcherCallbacks = ts.createMultiMap(); return { addFile: addFile, removeFile: removeFile }; function reduceDirWatcherRefCountForFile(fileName) { var dirName = ts.getDirectoryPath(fileName); - var watcher = dirWatchers[dirName]; + var watcher = dirWatchers.get(dirName); if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); - delete dirWatchers[dirName]; + dirWatchers.delete(dirName); } } } function addDirWatcher(dirPath) { - var watcher = dirWatchers[dirPath]; + var watcher = dirWatchers.get(dirPath); if (watcher) { watcher.referenceCount += 1; return; } watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; - dirWatchers[dirPath] = watcher; + dirWatchers.set(dirPath, watcher); return; } function addFileWatcherCallback(filePath, callback) { - ts.multiMapAdd(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.add(filePath, callback); } function addFile(fileName, callback) { addFileWatcherCallback(fileName, callback); @@ -2116,16 +3155,19 @@ var ts; reduceDirWatcherRefCountForFile(watchedFile.fileName); } function removeFileWatcherCallback(filePath, callback) { - ts.multiMapRemove(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.remove(filePath, callback); } function fileEventHandler(eventName, relativeFileName, baseDirPath) { var fileName = typeof relativeFileName !== "string" ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); - if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { - for (var _i = 0, _a = fileWatcherCallbacks[fileName]; _i < _a.length; _i++) { - var fileCallback = _a[_i]; - fileCallback(fileName); + if ((eventName === "change" || eventName === "rename")) { + var callbacks = fileWatcherCallbacks.get(fileName); + if (callbacks) { + for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) { + var fileCallback = callbacks_1[_i]; + fileCallback(fileName); + } } } } @@ -2190,10 +3232,10 @@ var ts; if (entry === "." || entry === "..") { continue; } - var name_3 = ts.combinePaths(path, entry); + var name = ts.combinePaths(path, entry); var stat = void 0; try { - stat = _fs.statSync(name_3); + stat = _fs.statSync(name); } catch (e) { continue; @@ -2214,6 +3256,11 @@ var ts; function readDirectory(path, extensions, excludes, includes) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries); } + var FileSystemEntryKind; + (function (FileSystemEntryKind) { + FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; + FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; + })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -2267,7 +3314,7 @@ var ts; }, watchDirectory: function (directoryName, callback, recursive) { var options; - if (!directoryExists(directoryName)) { + if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { @@ -2282,6 +3329,9 @@ var ts; } ; }); + function isUNCPath(s) { + return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47; + } }, resolvePath: function (path) { return _path.resolve(path); @@ -2592,6 +3642,7 @@ var ts; Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", message: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", message: "Invalid use of '{0}'. Modules are automatically in strict mode." }, + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", message: "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export_assignment_is_not_supported_when_module_flag_is_system_1218", message: "Export assignment is not supported when '--module' flag is 'system'." }, Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", message: "Generators are only available when targeting ECMAScript 2015 or higher." }, @@ -2870,6 +3921,8 @@ var ts; Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, + A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, + Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union 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_2601", message: "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_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2880,6 +3933,7 @@ var ts; 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_2607", message: "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_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, + Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -2928,11 +3982,15 @@ var ts; The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: { code: 2699, category: ts.DiagnosticCategory.Error, key: "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", message: "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'." }, Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, + Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, + Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "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_4002", message: "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_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2943,8 +4001,8 @@ var ts; Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4014", message: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_function_has_or_is_using_private_name_1_4016", message: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019", message: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "'extends' clause of exported class '{0}' has or is using private name '{1}'." }, + extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "'extends' clause of exported interface '{0}' has or is using private name '{1}'." }, Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023", message: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024", message: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_private_name_1_4025", message: "Exported variable '{0}' has or is using private name '{1}'." }, @@ -3007,6 +4065,7 @@ var ts; Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced: { code: 4093, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced_4093", message: "'extends' clause of exported class '{0}' refers to a type whose name cannot be referenced." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -3052,7 +4111,7 @@ var ts; Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, - Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_in_the_given_directory_6020", message: "Compile the project in the given directory." }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, @@ -3067,6 +4126,7 @@ var ts; LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, STRATEGY: { code: 6039, category: ts.DiagnosticCategory.Message, key: "STRATEGY_6039", message: "STRATEGY" }, + FILE_OR_DIRECTORY: { code: 6040, category: ts.DiagnosticCategory.Message, key: "FILE_OR_DIRECTORY_6040", message: "FILE OR DIRECTORY" }, Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation_complete_Watching_for_file_changes_6042", message: "Compilation complete. Watching for file changes." }, Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_map_file_6043", message: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_expects_an_argument_6044", message: "Compiler option '{0}' expects an argument." }, @@ -3100,7 +4160,7 @@ var ts; Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, @@ -3120,7 +4180,7 @@ var ts; File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, + package_json_does_not_have_a_0_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_0_field_6100", message: "'package.json' does not have a '{0}' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -3157,7 +4217,6 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, @@ -3210,7 +4269,7 @@ var ts; parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: ts.DiagnosticCategory.Error, key: "parameter_modifiers_can_only_be_used_in_a_ts_file_8012", message: "'parameter modifiers' 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_8015", message: "'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_8016", message: "'type assertion expressions' 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_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause." }, class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "class_expressions_are_not_currently_supported_9003", message: "'class' expressions are not currently supported." }, Language_service_is_disabled: { code: 9004, category: ts.DiagnosticCategory.Error, key: "Language_service_is_disabled_9004", message: "Language service is disabled." }, 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_17000", message: "JSX attributes must only be assigned a non-empty 'expression'." }, @@ -3234,9 +4293,10 @@ var ts; Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, + Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, @@ -3252,7 +4312,7 @@ var ts; return token >= 70; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = ts.createMap({ + var textToToken = ts.createMapFromTemplate({ "abstract": 116, "any": 118, "as": 117, @@ -3276,7 +4336,7 @@ var ts; "false": 85, "finally": 86, "for": 87, - "from": 138, + "from": 139, "function": 88, "get": 124, "if": 89, @@ -3294,27 +4354,28 @@ var ts; "new": 93, "null": 94, "number": 132, + "object": 133, "package": 110, "private": 111, "protected": 112, "public": 113, "readonly": 130, "require": 131, - "global": 139, + "global": 140, "return": 95, - "set": 133, + "set": 134, "static": 114, - "string": 134, + "string": 135, "super": 96, "switch": 97, - "symbol": 135, + "symbol": 136, "this": 98, "throw": 99, "true": 100, "try": 101, - "type": 136, + "type": 137, "typeof": 102, - "undefined": 137, + "undefined": 138, "var": 103, "void": 104, "while": 105, @@ -3322,7 +4383,7 @@ var ts; "yield": 115, "async": 119, "await": 120, - "of": 140, + "of": 141, "{": 16, "}": 17, "(": 18, @@ -3417,9 +4478,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_4 in source) { - result[source[name_4]] = name_4; - } + source.forEach(function (value, name) { + result[value] = name; + }); return result; } var tokenStrings = makeReverseMap(textToToken); @@ -3428,7 +4489,7 @@ var ts; } ts.tokenToString = tokenToString; function stringToToken(s) { - return textToToken[s]; + return textToToken.get(s); } ts.stringToToken = stringToToken; function computeLineStarts(text) { @@ -3488,7 +4549,6 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - var hasOwnProperty = Object.prototype.hasOwnProperty; function isWhiteSpace(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } @@ -4147,8 +5207,11 @@ var ts; var len = tokenValue.length; if (len >= 2 && len <= 11) { var ch = tokenValue.charCodeAt(0); - if (ch >= 97 && ch <= 122 && hasOwnProperty.call(textToToken, tokenValue)) { - return token = textToToken[tokenValue]; + if (ch >= 97 && ch <= 122) { + token = textToToken.get(tokenValue); + if (token !== undefined) { + return token; + } } } return token = 70; @@ -4858,12 +5921,13 @@ var ts; }, { name: "jsx", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "preserve": 1, + "react-native": 3, "react": 2 }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, }, { name: "reactNamespace", @@ -4893,7 +5957,7 @@ var ts; { name: "module", shortName: "m", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "none": ts.ModuleKind.None, "commonjs": ts.ModuleKind.CommonJS, "amd": ts.ModuleKind.AMD, @@ -4907,7 +5971,7 @@ var ts; }, { name: "newLine", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "crlf": 0, "lf": 1 }), @@ -5004,8 +6068,8 @@ var ts; shortName: "p", type: "string", isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY + description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY }, { name: "removeComments", @@ -5055,7 +6119,7 @@ var ts; { name: "target", shortName: "t", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "es3": 0, "es5": 1, "es6": 2, @@ -5092,7 +6156,7 @@ var ts; }, { name: "moduleResolution", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "node": ts.ModuleResolutionKind.NodeJs, "classic": ts.ModuleResolutionKind.Classic, }), @@ -5197,7 +6261,7 @@ var ts; type: "list", element: { name: "lib", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "es5": "lib.es5.d.ts", "es6": "lib.es2015.d.ts", "es2015": "lib.es2015.d.ts", @@ -5243,6 +6307,15 @@ var ts; name: "alwaysStrict", type: "boolean", description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + }, + { + name: "plugins", + type: "list", + isTSConfigOnly: true, + element: { + name: "plugin", + type: "object" + } } ]; ts.typeAcquisitionDeclarations = [ @@ -5297,9 +6370,9 @@ var ts; var optionNameMap = ts.createMap(); var shortOptionNames = ts.createMap(); ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; + optionNameMap.set(option.name.toLowerCase(), option); if (option.shortName) { - shortOptionNames[option.shortName] = option.name; + shortOptionNames.set(option.shortName, option.name); } }); optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; @@ -5307,7 +6380,7 @@ var ts; } ts.getOptionNameMap = getOptionNameMap; function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -5356,11 +6429,12 @@ var ts; } else if (s.charCodeAt(0) === 45) { s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); - if (s in shortOptionNames) { - s = shortOptionNames[s]; + var short = shortOptionNames.get(s); + if (short !== undefined) { + s = short; } - if (s in optionNameMap) { - var opt = optionNameMap[s]; + var opt = optionNameMap.get(s); + if (opt) { if (opt.isTSConfigOnly) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } @@ -5486,19 +6560,18 @@ var ts; } } function getNameOfCompilerOptionValue(value, customTypeMap) { - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { return key; } - } - return undefined; + }); } function serializeCompilerOptions(options) { - var result = ts.createMap(); + var result = {}; var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_5 in options) { - if (ts.hasProperty(options, name_5)) { - switch (name_5) { + for (var name in options) { + if (ts.hasProperty(options, name)) { + switch (name) { case "init": case "watch": case "version": @@ -5506,12 +6579,12 @@ var ts; case "project": break; default: - var value = options[name_5]; - var optionDefinition = optionsNameMap[name_5.toLowerCase()]; + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { - result[name_5] = value; + result[name] = value; } else { if (optionDefinition.type === "list") { @@ -5520,10 +6593,10 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_5] = convertedValue; + result[name] = convertedValue; } else { - result[name_5] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -5730,8 +6803,8 @@ var ts; } var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; + var opt = optionNameMap.get(id); + if (opt) { defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); } else { @@ -5765,8 +6838,9 @@ var ts; } function convertJsonOptionOfCustomType(opt, value, errors) { var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; + var val = opt.type.get(key); + if (val !== undefined) { + return val; } else { errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); @@ -5800,7 +6874,7 @@ var ts; for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { var fileName = fileNames_1[_i]; var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; + literalFileMap.set(keyMapper(file), file); } } if (include && include.length > 0) { @@ -5811,14 +6885,13 @@ var ts; } removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; + if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) { + wildcardFileMap.set(key, file); } } } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); + var literalFiles = ts.arrayFrom(literalFileMap.values()); + var wildcardFiles = ts.arrayFrom(wildcardFileMap.values()); return { fileNames: literalFiles.concat(wildcardFiles), wildcardDirectories: wildcardDirectories @@ -5826,8 +6899,8 @@ var ts; } function validateSpecs(specs, errors, allowTrailingRecursion) { var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + var spec = specs_1[_i]; if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); } @@ -5846,7 +6919,7 @@ var ts; function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); + var wildcardDirectories = {}; if (include !== undefined) { var recursiveKeys = []; for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { @@ -5867,14 +6940,16 @@ var ts; } } } - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; + for (var key in wildcardDirectories) + if (ts.hasProperty(wildcardDirectories, key)) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } } } - } + ; } return wildcardDirectories; } @@ -5893,11 +6968,11 @@ var ts; } function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); + var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions); for (var i = 0; i < adjustedExtensionPriority; i++) { var higherPriorityExtension = extensions[i]; var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { return true; } } @@ -5905,17 +6980,13 @@ var ts; } function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions); for (var i = nextExtensionPriority; i < extensions.length; i++) { var lowerPriorityExtension = extensions[i]; var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; + wildcardFiles.delete(lowerPriorityPath); } } - function addFileToOutput(output, file) { - output.push(file); - return output; - } function caseSensitiveKeyMapper(key) { return key; } @@ -5957,37 +7028,28 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { + function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); - switch (extensions) { - case Extensions.DtsOnly: - case Extensions.TypeScript: - return tryReadFromField("typings") || tryReadFromField("types"); - case Extensions.JavaScript: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; - } + return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); - } - return typesFilePath; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } + if (!ts.hasProperty(jsonContent, fieldName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName); } + return; } + var fileName = jsonContent[fieldName]; + if (typeof fileName !== "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof fileName); + } + return; + } + var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path); + } + return path; } } function readJson(path, host) { @@ -6159,9 +7221,10 @@ var ts; if (!moduleHasNonRelativeName(nonRelativeModuleName)) { return undefined; } - var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); if (!perModuleNameCache) { - moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + perModuleNameCache = createPerModuleNameCache(); + moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); } return perModuleNameCache; } @@ -6181,12 +7244,12 @@ var ts; var commonPrefix = getCommonPrefix(path, resolvedFileName); var current = path; while (true) { - var parent_1 = ts.getDirectoryPath(current); - if (parent_1 === current || directoryPathMap.contains(parent_1)) { + var parent = ts.getDirectoryPath(current); + if (parent === current || directoryPathMap.contains(parent)) { break; } - directoryPathMap.set(parent_1, result); - current = parent_1; + directoryPathMap.set(parent, result); + current = parent; if (current == commonPrefix) { break; } @@ -6217,7 +7280,7 @@ var ts; } var containingDirectory = ts.getDirectoryPath(containingFile); var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); - var result = perFolderCache && perFolderCache[moduleName]; + var result = perFolderCache && perFolderCache.get(moduleName); if (result) { if (traceEnabled) { trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); @@ -6245,7 +7308,7 @@ var ts; break; } if (perFolderCache) { - perFolderCache[moduleName] = result; + perFolderCache.set(moduleName, result); var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); if (perModuleNameCache) { perModuleNameCache.set(containingDirectory, result); @@ -6376,18 +7439,24 @@ var ts; } } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, false); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, jsOnly) { + if (jsOnly === void 0) { jsOnly = false; } var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + var result = jsOnly ? tryResolve(Extensions.JavaScript) : (tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript)); if (result && result.value) { var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { - var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + var loader = function (extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, true); }; + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); if (resolved) { return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } @@ -6400,12 +7469,12 @@ var ts; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state, true); return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } - ts.nodeModuleNameResolver = nodeModuleNameResolver; + ts.nodeModuleNameResolverWorker = nodeModuleNameResolverWorker; function realpath(path, host, traceEnabled) { if (!host.realpath) { return path; @@ -6416,7 +7485,7 @@ var ts; } return real; } - function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } @@ -6444,7 +7513,7 @@ var ts; onlyRecordFailures = true; } } - return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); @@ -6501,45 +7570,48 @@ var ts; failedLookupLocations.push(fileName); return undefined; } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { + if (considerPackageJson === void 0) { considerPackageJson = true; } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); - if (mainOrTypesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); - var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromExactFile) { - var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); - if (resolved_3) { - return resolved_3; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); - } - } - var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); - if (resolved) { - return resolved; + if (considerPackageJson) { + var packageJsonPath = pathToPackageJson(candidate); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; } } else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); + if (directoryExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + failedLookupLocations.push(packageJsonPath); } } - else { - if (directoryExists && state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - failedLookupLocations.push(packageJsonPath); - } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + if (!file) { + return undefined; + } + var onlyRecordFailures = !directoryProbablyExists(ts.getDirectoryPath(file), state.host); + var fromFile = tryFile(file, failedLookupLocations, onlyRecordFailures, state); + if (fromFile) { + var resolved = fromFile && resolvedIfExtensionMatches(extensions, fromFile); + if (resolved) { + return resolved; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile); + } + } + var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; + return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, false); + } function resolvedIfExtensionMatches(extensions, path) { var extension = ts.tryGetExtensionFromPath(path); return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; @@ -6626,7 +7698,7 @@ var ts; } var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { - var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); if (resolutionFromCache) { return resolutionFromCache; @@ -6634,8 +7706,8 @@ var ts; var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); - if (resolved_4) { - return resolved_4; + if (resolved_3) { + return resolved_3; } if (extensions === Extensions.TypeScript) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); @@ -6692,6 +7764,19 @@ var ts; return undefined; } ts.getDeclarationOfKind = getDeclarationOfKind; + function findDeclaration(symbol, predicate) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; + if (predicate(declaration)) { + return declaration; + } + } + } + return undefined; + } + ts.findDeclaration = findDeclaration; var stringWriters = []; function getSingleLineStringWriter() { if (stringWriters.length === 0) { @@ -6712,7 +7797,8 @@ var ts; decreaseIndent: ts.noop, clear: function () { return str_1 = ""; }, trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop }; } return stringWriters.pop(); @@ -6728,25 +7814,25 @@ var ts; } ts.getFullWidth = getFullWidth; function hasResolvedModule(sourceFile, moduleNameText) { - return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText)); } ts.hasResolvedModule = hasResolvedModule; function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules.get(moduleNameText) : undefined; } ts.getResolvedModule = getResolvedModule; function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { if (!sourceFile.resolvedModules) { sourceFile.resolvedModules = ts.createMap(); } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; + sourceFile.resolvedModules.set(moduleNameText, resolvedModule); } ts.setResolvedModule = setResolvedModule; function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { if (!sourceFile.resolvedTypeReferenceDirectiveNames) { sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; + sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective); } ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; function moduleResolutionIsEqualTo(oldResolution, newResolution) { @@ -6765,7 +7851,7 @@ var ts; } for (var i = 0; i < names.length; i++) { var newResolution = newResolutions[i]; - var oldResolution = oldResolutions && oldResolutions[names[i]]; + var oldResolution = oldResolutions && oldResolutions.get(names[i]); var changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) : newResolution; @@ -6792,7 +7878,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 262) { + while (node && node.kind !== 264) { node = node.parent; } return node; @@ -6800,11 +7886,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 205: - case 233: - case 212: + case 206: + case 234: case 213: case 214: + case 215: return true; } return false; @@ -6869,18 +7955,18 @@ var ts; if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 293 && node._children.length > 0) { + if (node.kind === 296 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 263 && node.kind <= 289; + return node.kind >= 266 && node.kind <= 295; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 279 && node.kind <= 292; + return node.kind >= 282 && node.kind <= 295; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6940,18 +8026,47 @@ var ts; } ts.getLiteralText = getLiteralText; function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 && text.length > 1) { + return node.kind === 8 + && (getNumericLiteralFlags(text, 6) & 6) !== 0; + } + ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + var NumericLiteralFlags; + (function (NumericLiteralFlags) { + NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; + NumericLiteralFlags[NumericLiteralFlags["Hexadecimal"] = 1] = "Hexadecimal"; + NumericLiteralFlags[NumericLiteralFlags["Binary"] = 2] = "Binary"; + NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; + NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 8] = "Scientific"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctal"] = 6] = "BinaryOrOctal"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalOrHexadecimal"] = 7] = "BinaryOrOctalOrHexadecimal"; + NumericLiteralFlags[NumericLiteralFlags["All"] = 15] = "All"; + })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); + function getNumericLiteralFlags(text, hint) { + if (text.length > 1) { switch (text.charCodeAt(1)) { case 98: case 66: + return 2; case 111: case 79: - return true; + return 4; + case 120: + case 88: + return 1; + } + if (hint & 8) { + for (var i = text.length - 1; i >= 0; i--) { + switch (text.charCodeAt(i)) { + case 101: + case 69: + return 8; + } + } } } - return false; + return 0; } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + ts.getNumericLiteralFlags = getNumericLiteralFlags; function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; } @@ -6959,10 +8074,6 @@ var ts; return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; } ts.escapeIdentifier = escapeIdentifier; - function unescapeIdentifier(identifier) { - return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; - } - ts.unescapeIdentifier = unescapeIdentifier; function makeIdentifierFromModuleName(moduleName) { return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } @@ -6974,11 +8085,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 224 && node.parent.kind === 257; + return node.kind === 225 && node.parent.kind === 259; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 231 && + return node && node.kind === 232 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6987,11 +8098,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 231 && (!node.body); + return node && node.kind === 232 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 262 || - node.kind === 231 || + return node.kind === 264 || + node.kind === 232 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -7004,9 +8115,9 @@ var ts; return false; } switch (node.parent.kind) { - case 262: + case 264: return ts.isExternalModule(node.parent); - case 232: + case 233: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -7018,22 +8129,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 262: - case 233: - case 257: - case 231: - case 212: + case 264: + case 234: + case 259: + case 232: case 213: case 214: - case 150: - case 149: + case 215: case 151: + case 150: case 152: - case 226: - case 184: + case 153: + case 227: case 185: + case 186: return true; - case 205: + case 206: return parentNode && !isFunctionLike(parentNode); } return false; @@ -7060,7 +8171,7 @@ var ts; case 9: case 8: return name.text; - case 142: + case 143: if (isStringOrNumericLiteral(name.expression)) { return name.expression.text; } @@ -7071,10 +8182,10 @@ var ts; function entityNameToString(name) { switch (name.kind) { case 70: - return getFullWidth(name) === 0 ? unescapeIdentifier(name.text) : getTextOfNode(name); - case 141: + return getFullWidth(name) === 0 ? ts.unescapeIdentifier(name.text) : getTextOfNode(name); + case 142: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 177: + case 178: return entityNameToString(name.expression) + "." + entityNameToString(name.name); } } @@ -7111,7 +8222,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 205) { + if (node.body && node.body.kind === 206) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -7123,29 +8234,29 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 262: + case 264: 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 224: - case 174: - case 227: - case 197: + case 225: + case 175: case 228: - case 231: - case 230: - case 261: - case 226: - case 184: - case 149: - case 151: - case 152: + case 198: case 229: + case 232: + case 231: + case 263: + case 227: + case 185: + case 150: + case 152: + case 153: + case 230: errorNode = node.name; break; - case 185: + case 186: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -7166,7 +8277,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 230 && isConst(node); + return node.kind === 231 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -7179,11 +8290,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 179 && n.expression.kind === 96; + return n.kind === 180 && n.expression.kind === 96; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 208 + return node.kind === 209 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -7196,10 +8307,10 @@ var ts; } ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 144 || - node.kind === 143 || - node.kind === 184 || - node.kind === 185) ? + var commentRanges = (node.kind === 145 || + node.kind === 144 || + node.kind === 185 || + node.kind === 186) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, function (comment) { @@ -7213,69 +8324,69 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (156 <= node.kind && node.kind <= 171) { + if (157 <= node.kind && node.kind <= 172) { return true; } switch (node.kind) { case 118: case 132: - case 134: - case 121: case 135: - case 137: + case 121: + case 136: + case 138: case 129: return true; case 104: - return node.parent.kind !== 188; - case 199: + return node.parent.kind !== 189; + case 200: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 70: - if (node.parent.kind === 141 && node.parent.right === node) { + if (node.parent.kind === 142 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 177 && node.parent.name === node) { + else if (node.parent.kind === 178 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 70 || node.kind === 141 || node.kind === 177, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 141: - case 177: + ts.Debug.assert(node.kind === 70 || node.kind === 142 || node.kind === 178, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 142: + case 178: case 98: - var parent_2 = node.parent; - if (parent_2.kind === 160) { + var parent = node.parent; + if (parent.kind === 161) { return false; } - if (156 <= parent_2.kind && parent_2.kind <= 171) { + if (157 <= parent.kind && parent.kind <= 172) { return true; } - switch (parent_2.kind) { - case 199: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); - case 143: - return node === parent_2.constraint; - case 147: - case 146: + switch (parent.kind) { + case 200: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 144: - case 224: - return node === parent_2.type; - case 226: - case 184: + return node === parent.constraint; + case 148: + case 147: + case 145: + case 225: + return node === parent.type; + case 227: case 185: + case 186: + case 151: case 150: case 149: - case 148: - case 151: case 152: - return node === parent_2.type; case 153: + return node === parent.type; case 154: case 155: - return node === parent_2.type; - case 182: - return node === parent_2.type; - case 179: + case 156: + return node === parent.type; + case 183: + return node === parent.type; case 180: - return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; case 181: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 182: return false; } } @@ -7293,30 +8404,30 @@ var ts; } ts.isChildOfNodeWithKind = isChildOfNodeWithKind; function isPrefixUnaryExpression(node) { - return node.kind === 190; + return node.kind === 191; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 217: + case 218: return visitor(node); - case 233: - case 205: - case 209: + case 234: + case 206: case 210: case 211: case 212: case 213: case 214: - case 218: + case 215: case 219: - case 254: - case 255: case 220: - case 222: + case 256: case 257: + case 221: + case 223: + case 259: return ts.forEachChild(node, traverse); } } @@ -7326,24 +8437,24 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 195: + case 196: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 230: - case 228: case 231: case 229: - case 227: - case 197: + case 232: + case 230: + case 228: + case 198: return; default: if (isFunctionLike(node)) { - var name_6 = node.name; - if (name_6 && name_6.kind === 142) { - traverse(name_6.expression); + var name = node.name; + if (name && name.kind === 143) { + traverse(name.expression); return; } } @@ -7355,10 +8466,10 @@ var ts; } ts.forEachYieldExpression = forEachYieldExpression; function getRestParameterElementType(node) { - if (node && node.kind === 162) { + if (node && node.kind === 163) { return node.elementType; } - else if (node && node.kind === 157) { + else if (node && node.kind === 158) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -7369,14 +8480,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 174: - case 261: - case 144: - case 258: + case 175: + case 263: + case 145: + case 260: + case 148: case 147: - case 146: - case 259: - case 224: + case 261: + case 225: return true; } } @@ -7384,11 +8495,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 151 || node.kind === 152); + return node && (node.kind === 152 || node.kind === 153); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 227 || node.kind === 197); + return node && (node.kind === 228 || node.kind === 198); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7397,19 +8508,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 150: - case 184: - case 226: - case 185: - case 149: - case 148: case 151: + case 185: + case 227: + case 186: + case 150: + case 149: case 152: case 153: case 154: case 155: - case 158: + case 156: case 159: + case 160: return true; } return false; @@ -7417,13 +8528,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 226: - case 184: + case 153: + case 227: + case 185: return true; } return false; @@ -7431,13 +8542,13 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 212: case 213: case 214: - case 210: + case 215: case 211: + case 212: return true; - case 220: + case 221: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -7448,7 +8559,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 220) { + if (node.statement.kind !== 221) { return node.statement; } node = node.statement; @@ -7456,17 +8567,17 @@ var ts; } ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 205 && isFunctionLike(node.parent); + return node && node.kind === 206 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 149 && node.parent.kind === 176; + return node && node.kind === 150 && node.parent.kind === 177; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 149 && - (node.parent.kind === 176 || - node.parent.kind === 197); + return node.kind === 150 && + (node.parent.kind === 177 || + node.parent.kind === 198); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -7502,39 +8613,39 @@ var ts; return undefined; } switch (node.kind) { - case 142: + case 143: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 145: - if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { + case 146: + if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 185: + case 186: if (!includeArrowFunctions) { continue; } - case 226: - case 184: - case 231: - case 147: - case 146: - case 149: + case 227: + case 185: + case 232: case 148: + case 147: case 150: + case 149: case 151: case 152: case 153: case 154: case 155: - case 230: - case 262: + case 156: + case 231: + case 264: return node; } } @@ -7544,9 +8655,9 @@ var ts; var container = getThisContainer(node, false); if (container) { switch (container.kind) { - case 150: - case 226: - case 184: + case 151: + case 227: + case 185: return container; } } @@ -7560,25 +8671,25 @@ var ts; return node; } switch (node.kind) { - case 142: + case 143: node = node.parent; break; - case 226: - case 184: + case 227: case 185: + case 186: if (!stopOnFunctions) { continue; } - case 147: - case 146: - case 149: case 148: + case 147: case 150: + case 149: case 151: case 152: + case 153: return node; - case 145: - if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { + case 146: + if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -7590,36 +8701,36 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 184 || func.kind === 185) { + if (func.kind === 185 || func.kind === 186) { var prev = func; - var parent_3 = func.parent; - while (parent_3.kind === 183) { - prev = parent_3; - parent_3 = parent_3.parent; + var parent = func.parent; + while (parent.kind === 184) { + prev = parent; + parent = parent.parent; } - if (parent_3.kind === 179 && parent_3.expression === prev) { - return parent_3; + if (parent.kind === 180 && parent.expression === prev) { + return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 177 || kind === 178) + return (kind === 178 || kind === 179) && node.expression.kind === 96; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 157: - case 273: + case 158: + case 276: return node.typeName; - case 199: + case 200: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 70: - case 141: + case 142: return node; } return undefined; @@ -7627,10 +8738,12 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 179: + case 250: + case 249: case 180: case 181: - case 145: + case 182: + case 146: return true; default: return false; @@ -7638,29 +8751,32 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 181) { + if (node.kind === 182) { return node.tag; } + else if (isJsxOpeningLikeElement(node)) { + return node.tagName; + } return node.expression; } ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 227: + case 228: return true; - case 147: - return node.parent.kind === 227; - case 151: + case 148: + return node.parent.kind === 228; case 152: - case 149: + case 153: + case 150: return node.body !== undefined - && node.parent.kind === 227; - case 144: + && node.parent.kind === 228; + case 145: return node.parent.body !== undefined - && (node.parent.kind === 150 - || node.parent.kind === 149 - || node.parent.kind === 152) - && node.parent.parent.kind === 227; + && (node.parent.kind === 151 + || node.parent.kind === 150 + || node.parent.kind === 153) + && node.parent.parent.kind === 228; } return false; } @@ -7676,19 +8792,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 227: + case 228: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 149: - case 152: + case 150: + case 153: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 249 || - parent.kind === 248 || - parent.kind === 250) { + if (parent.kind === 250 || + parent.kind === 249 || + parent.kind === 251) { return parent.tagName === node; } return false; @@ -7702,96 +8818,96 @@ var ts; case 100: case 85: case 11: - case 175: case 176: case 177: case 178: case 179: case 180: case 181: - case 200: case 182: case 201: case 183: + case 202: case 184: - case 197: case 185: - case 188: + case 198: case 186: + case 189: case 187: - case 190: + case 188: case 191: case 192: case 193: - case 196: case 194: - case 12: - case 198: - case 247: - case 248: + case 197: case 195: - case 189: - case 202: + case 12: + case 199: + case 248: + case 249: + case 196: + case 190: + case 203: return true; - case 141: - while (node.parent.kind === 141) { + case 142: + while (node.parent.kind === 142) { node = node.parent; } - return node.parent.kind === 160 || isJSXTagName(node); + return node.parent.kind === 161 || isJSXTagName(node); case 70: - if (node.parent.kind === 160 || isJSXTagName(node)) { + if (node.parent.kind === 161 || isJSXTagName(node)) { return true; } case 8: case 9: case 98: - var parent_4 = node.parent; - switch (parent_4.kind) { - case 224: - case 144: + var parent = node.parent; + switch (parent.kind) { + case 225: + case 145: + case 148: case 147: - case 146: - case 261: - case 258: - case 174: - return parent_4.initializer === node; - case 208: + case 263: + case 260: + case 175: + return parent.initializer === node; case 209: case 210: case 211: - case 217: + case 212: case 218: case 219: - case 254: - case 221: - case 219: - return parent_4.expression === node; - case 212: - var forStatement = parent_4; - return (forStatement.initializer === node && forStatement.initializer.kind !== 225) || + case 220: + case 256: + case 222: + case 220: + return parent.expression === node; + case 213: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 226) || forStatement.condition === node || forStatement.incrementor === node; - case 213: case 214: - var forInStatement = parent_4; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 225) || + case 215: + var forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 226) || forInStatement.expression === node; - case 182: - case 200: - return node === parent_4.expression; - case 203: - return node === parent_4.expression; - case 142: - return node === parent_4.expression; - case 145: - case 253: - case 252: - case 260: + case 183: + case 201: + return node === parent.expression; + case 204: + return node === parent.expression; + case 143: + return node === parent.expression; + case 146: + case 255: + case 254: + case 262: return true; - case 199: - return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); + case 200: + return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: - if (isPartOfExpression(parent_4)) { + if (isPartOfExpression(parent)) { return true; } } @@ -7806,7 +8922,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 235 && node.moduleReference.kind === 246; + return node.kind === 236 && node.moduleReference.kind === 247; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7815,7 +8931,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 235 && node.moduleReference.kind !== 246; + return node.kind === 236 && node.moduleReference.kind !== 247; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7827,7 +8943,7 @@ var ts; } ts.isInJavaScriptFile = isInJavaScriptFile; function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 179 && + var isRequire = expression.kind === 180 && expression.expression.kind === 70 && expression.expression.text === "require" && expression.arguments.length === 1; @@ -7839,9 +8955,9 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 224) { + if (s.valueDeclaration && s.valueDeclaration.kind === 225) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 184; + return declaration.initializer && declaration.initializer.kind === 185; } return false; } @@ -7850,11 +8966,11 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0; } - if (expression.kind !== 192) { + if (expression.kind !== 193) { return 0; } var expr = expression; - if (expr.operatorToken.kind !== 57 || expr.left.kind !== 177) { + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 178) { return 0; } var lhs = expr.left; @@ -7870,7 +8986,7 @@ var ts; else if (lhs.expression.kind === 98) { return 4; } - else if (lhs.expression.kind === 177) { + else if (lhs.expression.kind === 178) { var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 70) { var innerPropertyAccessIdentifier = innerPropertyAccess.expression; @@ -7886,35 +9002,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 236) { + if (node.kind === 237) { return node.moduleSpecifier; } - if (node.kind === 235) { + if (node.kind === 236) { var reference = node.moduleReference; - if (reference.kind === 246) { + if (reference.kind === 247) { return reference.expression; } } - if (node.kind === 242) { + if (node.kind === 243) { return node.moduleSpecifier; } - if (node.kind === 231 && node.name.kind === 9) { + if (node.kind === 232 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 235) { + if (node.kind === 236) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 238) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 239) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 236 + return node.kind === 237 && node.importClause && !!node.importClause.name; } @@ -7922,13 +9038,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 144: + case 145: + case 150: case 149: + case 261: + case 260: case 148: - case 259: - case 258: case 147: - case 146: return node.questionToken !== undefined; } } @@ -7936,22 +9052,27 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 275 && + return node.kind === 278 && node.parameters.length > 0 && - node.parameters[0].type.kind === 277; + node.parameters[0].type.kind === 280; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { return ts.map(getJSDocs(node), function (doc) { return doc.comment; }); } ts.getCommentsFromJSDoc = getCommentsFromJSDoc; + function hasJSDocParameterTags(node) { + var parameterTags = getJSDocTags(node, 285); + return parameterTags && parameterTags.length > 0; + } + ts.hasJSDocParameterTags = hasJSDocParameterTags; function getJSDocTags(node, kind) { var docs = getJSDocs(node); if (docs) { var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 282) { + if (doc.kind === 285) { if (doc.kind === kind) { result.push(doc); } @@ -7977,9 +9098,9 @@ var ts; var parent = node.parent; var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 206; + parent.parent.parent.kind === 207; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 206; + parent.parent.kind === 207; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -7987,19 +9108,19 @@ var ts; getJSDocsWorker(variableStatementNode); } var isSourceOfAssignmentExpressionStatement = parent && parent.parent && - parent.kind === 192 && + parent.kind === 193 && parent.operatorToken.kind === 57 && - parent.parent.kind === 208; + parent.parent.kind === 209; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 231 && - parent && parent.kind === 231; - var isPropertyAssignmentExpression = parent && parent.kind === 258; + var isModuleDeclaration = node.kind === 232 && + parent && parent.kind === 232; + var isPropertyAssignmentExpression = parent && parent.kind === 260; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } - if (node.kind === 144) { + if (node.kind === 145) { cache = ts.concatenate(cache, getJSDocParameterTags(node)); } if (isVariableLike(node) && node.initializer) { @@ -8013,17 +9134,17 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 282); + var tags = getJSDocTags(func, 285); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 282; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 285; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70) { - var name_7 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 282 && tag.parameterName.text === name_7; }); + var name_1 = param.name.text; + return ts.filter(tags, function (tag) { return tag.kind === 285 && tag.parameterName.text === name_1; }); } else { return undefined; @@ -8031,8 +9152,8 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 284); - if (!tag && node.kind === 144) { + var tag = getFirstJSDocTag(node, 287); + if (!tag && node.kind === 145) { var paramTags = getJSDocParameterTags(node); if (paramTags) { tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); @@ -8042,15 +9163,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 281); + return getFirstJSDocTag(node, 284); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 283); + return getFirstJSDocTag(node, 286); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 285); + return getFirstJSDocTag(node, 288); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -8063,8 +9184,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536)) { - if (node.type && node.type.kind === 276 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 276; })) { + if (node.type && node.type.kind === 279 || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 279; })) { return true; } } @@ -8075,32 +9196,43 @@ var ts; return node && node.dotDotDotToken !== undefined; } ts.isDeclaredRestParam = isDeclaredRestParam; + var AssignmentKind; + (function (AssignmentKind) { + AssignmentKind[AssignmentKind["None"] = 0] = "None"; + AssignmentKind[AssignmentKind["Definite"] = 1] = "Definite"; + AssignmentKind[AssignmentKind["Compound"] = 2] = "Compound"; + })(AssignmentKind = ts.AssignmentKind || (ts.AssignmentKind = {})); function getAssignmentTargetKind(node) { var parent = node.parent; while (true) { switch (parent.kind) { - case 192: + case 193: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 57 ? 1 : 2 : 0; - case 190: case 191: + case 192: var unaryOperator = parent.operator; return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; - case 213: case 214: + case 215: return parent.initializer === node ? 1 : 0; - case 183: - case 175: - case 196: + case 184: + case 176: + case 197: node = parent; break; - case 259: + case 261: if (parent.name !== node) { return 0; } - case 258: + node = parent.parent; + break; + case 260: + if (parent.name === node) { + return 0; + } node = parent.parent; break; default: @@ -8115,14 +9247,14 @@ var ts; } ts.isAssignmentTarget = isAssignmentTarget; function isDeleteTarget(node) { - if (node.kind !== 177 && node.kind !== 178) { + if (node.kind !== 178 && node.kind !== 179) { return false; } node = node.parent; - while (node && node.kind === 183) { + while (node && node.kind === 184) { node = node.parent; } - return node && node.kind === 186; + return node && node.kind === 187; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -8136,7 +9268,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2) || (node.kind === 262 && node.isDeclarationFile)) { + if (hasModifier(node, 2) || (node.kind === 264 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -8149,7 +9281,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 240 || parent.kind === 244) { + if (parent.kind === 241 || parent.kind === 245) { if (parent.propertyName) { return true; } @@ -8162,48 +9294,48 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 142 && + node.parent.kind === 143 && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 147: - case 146: - case 149: case 148: - case 151: + case 147: + case 150: + case 149: case 152: - case 261: - case 258: - case 177: + case 153: + case 263: + case 260: + case 178: return parent.name === node; - case 141: + case 142: if (parent.right === node) { - while (parent.kind === 141) { + while (parent.kind === 142) { parent = parent.parent; } - return parent.kind === 160; + return parent.kind === 161; } return false; - case 174: - case 240: + case 175: + case 241: return parent.propertyName === node; - case 244: + case 245: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 235 || - node.kind === 234 || - node.kind === 237 && !!node.name || - node.kind === 238 || - node.kind === 240 || - node.kind === 244 || - node.kind === 241 && exportAssignmentIsAlias(node); + return node.kind === 236 || + node.kind === 235 || + node.kind === 238 && !!node.name || + node.kind === 239 || + node.kind === 241 || + node.kind === 245 || + node.kind === 242 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8289,7 +9421,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 <= token && token <= 140; + return 71 <= token && token <= 141; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -8311,7 +9443,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 142 && + return name.kind === 143 && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -8321,10 +9453,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 144) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 145) { return name.text; } - if (name.kind === 142) { + if (name.kind === 143) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -8369,11 +9501,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 144; + return root.kind === 145; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 174) { + while (node.kind === 175) { node = node.parent.parent; } return node; @@ -8381,15 +9513,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 150 - || kind === 184 - || kind === 226 + return kind === 151 || kind === 185 - || kind === 149 - || kind === 151 + || kind === 227 + || kind === 186 + || kind === 150 || kind === 152 - || kind === 231 - || kind === 262; + || kind === 153 + || kind === 232 + || kind === 264; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8397,66 +9529,49 @@ var ts; || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node, nodeTest) { - if (node) { - while (node.original !== undefined) { - node = node.original; - } + function getOriginalSourceFileOrBundle(sourceFileOrBundle) { + if (sourceFileOrBundle.kind === 265) { + return ts.updateBundle(sourceFileOrBundle, ts.sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile)); } - return !nodeTest || nodeTest(node) ? node : undefined; + return getOriginalSourceFile(sourceFileOrBundle); } - ts.getOriginalNode = getOriginalNode; - function isParseTreeNode(node) { - return (node.flags & 8) === 0; + ts.getOriginalSourceFileOrBundle = getOriginalSourceFileOrBundle; + function getOriginalSourceFile(sourceFile) { + return ts.getParseTreeNode(sourceFile, isSourceFile) || sourceFile; } - ts.isParseTreeNode = isParseTreeNode; - function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { - return node; - } - node = getOriginalNode(node); - if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { - return node; - } - return undefined; - } - ts.getParseTreeNode = getParseTreeNode; function getOriginalSourceFiles(sourceFiles) { - var originalSourceFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); - if (originalSourceFile) { - originalSourceFiles.push(originalSourceFile); - } - } - return originalSourceFiles; + return ts.sameMap(sourceFiles, getOriginalSourceFile); } ts.getOriginalSourceFiles = getOriginalSourceFiles; function getOriginalNodeId(node) { - node = getOriginalNode(node); + node = ts.getOriginalNode(node); return node ? ts.getNodeId(node) : 0; } ts.getOriginalNodeId = getOriginalNodeId; + var Associativity; + (function (Associativity) { + Associativity[Associativity["Left"] = 0] = "Left"; + Associativity[Associativity["Right"] = 1] = "Right"; + })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 180 && expression.arguments !== undefined; + var hasArguments = expression.kind === 181 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 180: + case 181: return hasArguments ? 0 : 1; - case 190: - case 187: + case 191: case 188: - case 186: case 189: - case 193: - case 195: + case 187: + case 190: + case 194: + case 196: return 1; - case 192: + case 193: switch (operator) { case 39: case 57: @@ -8480,15 +9595,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 180 && expression.arguments !== undefined; + var hasArguments = expression.kind === 181 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 192) { + if (expression.kind === 193) { return expression.operatorToken.kind; } - else if (expression.kind === 190 || expression.kind === 191) { + else if (expression.kind === 191 || expression.kind === 192) { return expression.operator; } else { @@ -8506,36 +9621,36 @@ var ts; case 85: case 8: case 9: - case 175: case 176: - case 184: + case 177: case 185: - case 197: - case 247: + case 186: + case 198: case 248: + case 249: case 11: case 12: - case 194: - case 183: - case 198: + case 195: + case 184: + case 199: return 19; - case 181: - case 177: + case 182: case 178: - return 18; - case 180: - return hasArguments ? 18 : 17; case 179: + return 18; + case 181: + return hasArguments ? 18 : 17; + case 180: return 17; - case 191: - return 16; - case 190: - case 187: - case 188: - case 186: - case 189: - return 15; case 192: + return 16; + case 191: + case 188: + case 189: + case 187: + case 190: + return 15; + case 193: switch (operatorKind) { case 50: case 51: @@ -8593,11 +9708,11 @@ var ts; default: return -1; } - case 193: + case 194: return 4; - case 195: - return 2; case 196: + return 2; + case 197: return 1; default: return -1; @@ -8620,21 +9735,15 @@ var ts; return modificationCount; } function reattachFileDiagnostics(newFile) { - if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { - var diagnostic = _a[_i]; - diagnostic.file = newFile; - } + ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } function add(diagnostic) { var diagnostics; if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); if (!diagnostics) { diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; + fileDiagnostics.set(diagnostic.file.fileName, diagnostics); } } else { @@ -8651,16 +9760,16 @@ var ts; function getDiagnostics(fileName) { sortAndDeduplicate(); if (fileName) { - return fileDiagnostics[fileName] || []; + return fileDiagnostics.get(fileName) || []; } var allDiagnostics = []; function pushDiagnostic(d) { allDiagnostics.push(d); } ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } + fileDiagnostics.forEach(function (diagnostics) { + ts.forEach(diagnostics, pushDiagnostic); + }); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function sortAndDeduplicate() { @@ -8669,14 +9778,14 @@ var ts; } diagnosticsModified = false; nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } + fileDiagnostics.forEach(function (diagnostics, key) { + fileDiagnostics.set(key, ts.sortAndDeduplicateDiagnostics(diagnostics)); + }); } } ts.createDiagnosticCollection = createDiagnosticCollection; var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = ts.createMap({ + var escapedCharsMap = ts.createMapFromTemplate({ "\0": "\\0", "\t": "\\t", "\v": "\\v", @@ -8695,7 +9804,7 @@ var ts; } ts.escapeString = escapeString; function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); @@ -8839,129 +9948,62 @@ var ts; ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); + var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); }; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); - var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = getAllEmittableSourceFiles(); - return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); + var moduleEmitEnabled_1 = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; + return ts.filter(host.getSourceFiles(), function (sourceFile) { + return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); + }); } else { - var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; - return filterSourceFilesInDirectory(sourceFiles, function (file) { return host.isSourceFileFromExternalLibrary(file); }); - } - function getAllEmittableSourceFiles() { - return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); + var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); }); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; - function filterSourceFilesInDirectory(sourceFiles, isSourceFileFromExternalLibrary) { - return ts.filter(sourceFiles, function (file) { return shouldEmitInDirectory(file, isSourceFileFromExternalLibrary); }); + function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) { + return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !isDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); } - ts.filterSourceFilesInDirectory = filterSourceFilesInDirectory; - function isNonDeclarationFile(sourceFile) { - return !isDeclarationFile(sourceFile); - } - function shouldEmitInDirectory(sourceFile, isSourceFileFromExternalLibrary) { - return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); - } - function isBundleEmitNonExternalModule(sourceFile) { - return isNonDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); - } - function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { + ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { - onBundledEmit(sourceFiles); - } - else { - for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { - var sourceFile = sourceFiles_2[_i]; - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } - } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); - } - function onBundledEmit(sourceFiles) { if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, true); + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); + } + } + else { + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, sourceFile, emitOnlyDtsFiles); } } } - ts.forEachTransformedEmitFile = forEachTransformedEmitFile; + ts.forEachEmittedFile = forEachEmittedFile; function getSourceMapFilePath(jsFilePath, options) { return options.sourceMap ? jsFilePath + ".map" : undefined; } - function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - onBundledEmit(host); - } - else { - var sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; - if (shouldEmitInDirectory(sourceFile, function (file) { return host.isSourceFileFromExternalLibrary(file); })) { - onSingleFileEmit(host, sourceFile); + function getOutputExtension(sourceFile, options) { + if (options.jsx === 1) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + return ".jsx"; } } - } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: declarationFilePath - }; - action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); - } - function onBundledEmit(host) { - var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (!ts.isExternalModule(sourceFile) || - !!ts.getEmitModuleKind(options)); }); - if (bundledSources.length) { - var jsFilePath = options.outFile || options.out; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined - }; - action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); + else if (sourceFile.languageVariant === 1) { + return ".jsx"; } } + return ".js"; } - ts.forEachExpectedEmitFile = forEachExpectedEmitFile; function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); var commonSourceDirectory = host.getCommonSourceDirectory(); @@ -8986,7 +10028,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 150 && nodeIsPresent(member.body)) { + if (member.kind === 151 && nodeIsPresent(member.body)) { return member; } }); @@ -9027,10 +10069,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 151) { + if (accessor.kind === 152) { getAccessor = accessor; } - else if (accessor.kind === 152) { + else if (accessor.kind === 153) { setAccessor = accessor; } else { @@ -9039,7 +10081,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 151 || member.kind === 152) + if ((member.kind === 152 || member.kind === 153) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -9050,10 +10092,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 151 && !getAccessor) { + if (member.kind === 152 && !getAccessor) { getAccessor = member; } - if (member.kind === 152 && !setAccessor) { + if (member.kind === 153 && !setAccessor) { setAccessor = member; } } @@ -9271,7 +10313,7 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 199 && + if (node.kind === 200 && node.parent.token === 84 && isClassLike(node.parent.parent)) { return node.parent.parent; @@ -9289,8 +10331,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 176 - || kind === 175; + return kind === 177 + || kind === 176; } return false; } @@ -9316,29 +10358,33 @@ var ts; ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { return node.kind === 70 || - node.kind === 177 && isEntityNameExpression(node.expression); + node.kind === 178 && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 141 && node.parent.right === node) || - (node.parent.kind === 177 && node.parent.name === node); + return (node.parent.kind === 142 && node.parent.right === node) || + (node.parent.kind === 178 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 176) { + if (kind === 177) { return expression.properties.length === 0; } - if (kind === 175) { + if (kind === 176) { return expression.elements.length === 0; } return false; } ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; + return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function isExportDefaultSymbol(symbol) { + return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512); + } + ts.isExportDefaultSymbol = isExportDefaultSymbol; function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); } @@ -9430,39 +10476,39 @@ var ts; || kind === 94) { return true; } - else if (kind === 177) { + else if (kind === 178) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 178) { + else if (kind === 179) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 190 - || kind === 191) { + else if (kind === 191 + || kind === 192) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 192) { + else if (kind === 193) { return node.operatorToken.kind !== 39 && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 193) { + else if (kind === 194) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 188 - || kind === 187 - || kind === 186) { + else if (kind === 189 + || kind === 188 + || kind === 187) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 175) { + else if (kind === 176) { return node.elements.length === 0; } - else if (kind === 176) { + else if (kind === 177) { return node.properties.length === 0; } - else if (kind === 179) { + else if (kind === 180) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9477,16 +10523,19 @@ var ts; } return false; } - var syntaxKindCache = ts.createMap(); + var syntaxKindCache = []; function formatSyntaxKind(kind) { var syntaxKindEnum = ts.SyntaxKind; if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; + var cached = syntaxKindCache[kind]; + if (cached !== undefined) { + return cached; } - for (var name_8 in syntaxKindEnum) { - if (syntaxKindEnum[name_8] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_8 + ")"; + for (var name in syntaxKindEnum) { + if (syntaxKindEnum[name] === kind) { + var result = kind + " (" + name + ")"; + syntaxKindCache[kind] = result; + return result; } } } @@ -9495,6 +10544,14 @@ var ts; } } ts.formatSyntaxKind = formatSyntaxKind; + function getRangePos(range) { + return range ? range.pos : -1; + } + ts.getRangePos = getRangePos; + function getRangeEnd(range) { + return range ? range.end : -1; + } + ts.getRangeEnd = getRangeEnd; function movePos(pos, value) { return ts.positionIsSynthesized(pos) ? -1 : pos + value; } @@ -9569,11 +10626,11 @@ var ts; } ts.getStartPositionOfRange = getStartPositionOfRange; function isDeclarationNameOfEnumOrNamespace(node) { - var parseNode = getParseTreeNode(node); + var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 230: case 231: + case 232: return parseNode === parseNode.parent.name; } } @@ -9591,7 +10648,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 && declaration !== node) { + if (declaration.kind === 228 && declaration !== node) { return true; } } @@ -9643,7 +10700,7 @@ var ts; } ts.isIdentifier = isIdentifier; function isVoidExpression(node) { - return node.kind === 188; + return node.kind === 189; } ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { @@ -9655,16 +10712,16 @@ var ts; } ts.isModifier = isModifier; function isQualifiedName(node) { - return node.kind === 141; + return node.kind === 142; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 142; + return node.kind === 143; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 141 + return kind === 142 || kind === 70; } ts.isEntityName = isEntityName; @@ -9673,7 +10730,7 @@ var ts; return kind === 70 || kind === 9 || kind === 8 - || kind === 142; + || kind === 143; } ts.isPropertyName = isPropertyName; function isModuleName(node) { @@ -9685,101 +10742,101 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 70 - || kind === 172 - || kind === 173; + || kind === 173 + || kind === 174; } ts.isBindingName = isBindingName; function isTypeParameter(node) { - return node.kind === 143; + return node.kind === 144; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 144; + return node.kind === 145; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 145; + return node.kind === 146; } ts.isDecorator = isDecorator; function isMethodDeclaration(node) { - return node.kind === 149; + return node.kind === 150; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 150 - || kind === 147 - || kind === 149 - || kind === 151 + return kind === 151 + || kind === 148 + || kind === 150 || kind === 152 - || kind === 155 - || kind === 204; + || kind === 153 + || kind === 156 + || kind === 205; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 258 - || kind === 259 - || kind === 260 - || kind === 149 - || kind === 151 + return kind === 260 + || kind === 261 + || kind === 262 + || kind === 150 || kind === 152 - || kind === 245; + || kind === 153 + || kind === 246; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 156 && kind <= 171) + return (kind >= 157 && kind <= 172) || kind === 118 || kind === 132 || kind === 121 - || kind === 134 || kind === 135 + || kind === 136 || kind === 104 || kind === 129 - || kind === 199; + || kind === 200; } function isTypeNode(node) { return isTypeNodeKind(node.kind); } ts.isTypeNode = isTypeNode; function isArrayBindingPattern(node) { - return node.kind === 173; + return node.kind === 174; } ts.isArrayBindingPattern = isArrayBindingPattern; function isObjectBindingPattern(node) { - return node.kind === 172; + return node.kind === 173; } ts.isObjectBindingPattern = isObjectBindingPattern; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 173 - || kind === 172; + return kind === 174 + || kind === 173; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 175 - || kind === 176; + return kind === 176 + || kind === 177; } ts.isAssignmentPattern = isAssignmentPattern; function isBindingElement(node) { - return node.kind === 174; + return node.kind === 175; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 174 - || kind === 198; + return kind === 175 + || kind === 199; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 224: - case 144: - case 174: + case 225: + case 145: + case 175: return true; } return false; @@ -9792,8 +10849,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 172: - case 176: + case 173: + case 177: return true; } return false; @@ -9801,94 +10858,94 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 173: - case 175: + case 174: + case 176: return true; } return false; } ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isArrayLiteralExpression(node) { - return node.kind === 175; + return node.kind === 176; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 176; + return node.kind === 177; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 177; + return node.kind === 178; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 178; + return node.kind === 179; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 192; + return node.kind === 193; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 193; + return node.kind === 194; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 179; + return node.kind === 180; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 194 + return kind === 195 || kind === 12; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadExpression(node) { - return node.kind === 196; + return node.kind === 197; } ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 199; + return node.kind === 200; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 177 - || kind === 178 - || kind === 180 + return kind === 178 || kind === 179 - || kind === 247 - || kind === 248 || kind === 181 - || kind === 175 - || kind === 183 + || kind === 180 + || kind === 248 + || kind === 249 + || kind === 182 || kind === 176 - || kind === 197 || kind === 184 + || kind === 177 + || kind === 198 + || kind === 185 || kind === 70 || kind === 11 || kind === 8 || kind === 9 || kind === 12 - || kind === 194 + || kind === 195 || kind === 85 || kind === 94 || kind === 98 || kind === 100 || kind === 96 - || kind === 201 - || kind === 202; + || kind === 202 + || kind === 203; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 190 - || kind === 191 - || kind === 186 + return kind === 191 + || kind === 192 || kind === 187 || kind === 188 || kind === 189 - || kind === 182 + || kind === 190 + || kind === 183 || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -9896,13 +10953,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 193 - || kind === 195 - || kind === 185 - || kind === 192 + return kind === 194 || kind === 196 - || kind === 200 - || kind === 198 + || kind === 186 + || kind === 193 + || kind === 197 + || kind === 201 + || kind === 199 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -9911,16 +10968,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 182 - || kind === 200; + return kind === 183 + || kind === 201; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 295; + return node.kind === 298; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 294; + return node.kind === 297; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -9929,15 +10986,15 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 198; + return node.kind === 199; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 203; + return node.kind === 204; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 205; + return node.kind === 206; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -9955,121 +11012,135 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 224; + return node.kind === 225; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 225; + return node.kind === 226; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 233; + return node.kind === 234; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 232 - || kind === 231; + return kind === 233 + || kind === 232 + || kind === 70; } ts.isModuleBody = isModuleBody; + function isNamespaceBody(node) { + var kind = node.kind; + return kind === 233 + || kind === 232; + } + ts.isNamespaceBody = isNamespaceBody; + function isJSDocNamespaceBody(node) { + var kind = node.kind; + return kind === 70 + || kind === 232; + } + ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isImportEqualsDeclaration(node) { - return node.kind === 235; + return node.kind === 236; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 237; + return node.kind === 238; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 239 - || kind === 238; + return kind === 240 + || kind === 239; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 240; + return node.kind === 241; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 243; + return node.kind === 244; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 244; + return node.kind === 245; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 231 || node.kind === 230; + return node.kind === 232 || node.kind === 231; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 185 - || kind === 174 - || kind === 227 - || kind === 197 - || kind === 150 - || kind === 230 - || kind === 261 - || kind === 244 - || kind === 226 - || kind === 184 - || kind === 151 - || kind === 237 - || kind === 235 - || kind === 240 + return kind === 186 + || kind === 175 || kind === 228 - || kind === 149 - || kind === 148 + || kind === 198 + || kind === 151 || kind === 231 - || kind === 234 - || kind === 238 - || kind === 144 - || kind === 258 - || kind === 147 - || kind === 146 - || kind === 152 - || kind === 259 - || kind === 229 - || kind === 143 - || kind === 224 - || kind === 286; - } - function isDeclarationStatementKind(kind) { - return kind === 226 + || kind === 263 || kind === 245 || kind === 227 + || kind === 185 + || kind === 152 + || kind === 238 + || kind === 236 + || kind === 241 + || kind === 229 + || kind === 252 + || kind === 150 + || kind === 149 + || kind === 232 + || kind === 235 + || kind === 239 + || kind === 145 + || kind === 260 + || kind === 148 + || kind === 147 + || kind === 153 + || kind === 261 + || kind === 230 + || kind === 144 + || kind === 225 + || kind === 289; + } + function isDeclarationStatementKind(kind) { + return kind === 227 + || kind === 246 || kind === 228 || kind === 229 || kind === 230 || kind === 231 + || kind === 232 + || kind === 237 || kind === 236 - || kind === 235 + || kind === 243 || kind === 242 - || kind === 241 - || kind === 234; + || kind === 235; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 216 - || kind === 215 - || kind === 223 - || kind === 210 - || kind === 208 - || kind === 207 - || kind === 213 - || kind === 214 - || kind === 212 - || kind === 209 - || kind === 220 - || kind === 217 - || kind === 219 - || kind === 221 - || kind === 222 - || kind === 206 + return kind === 217 + || kind === 216 + || kind === 224 || kind === 211 + || kind === 209 + || kind === 208 + || kind === 214 + || kind === 215 + || kind === 213 + || kind === 210 + || kind === 221 || kind === 218 - || kind === 294 + || kind === 220 + || kind === 222 + || kind === 223 + || kind === 207 + || kind === 212 + || kind === 219 || kind === 297 - || kind === 296; + || kind === 300 + || kind === 299; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10087,87 +11158,96 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 205; + || kind === 206; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 246 - || kind === 141 + return kind === 247 + || kind === 142 || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 249; + return node.kind === 250; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 250; + return node.kind === 251; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; return kind === 98 || kind === 70 - || kind === 177; + || kind === 178; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 247 - || kind === 253 - || kind === 248 + return kind === 248 + || kind === 255 + || kind === 249 || kind === 10; } ts.isJsxChild = isJsxChild; + function isJsxAttributes(node) { + var kind = node.kind; + return kind === 253; + } + ts.isJsxAttributes = isJsxAttributes; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 251 - || kind === 252; + return kind === 252 + || kind === 254; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 252; + return node.kind === 254; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 251; + return node.kind === 252; } ts.isJsxAttribute = isJsxAttribute; + function isJsxOpeningLikeElement(node) { + return node.kind === 250 || node.kind === 249; + } + ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 253; + || kind === 255; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 254 - || kind === 255; + return kind === 256 + || kind === 257; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 256; + return node.kind === 258; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 257; + return node.kind === 259; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 258; + return node.kind === 260; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 259; + return node.kind === 261; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 261; + return node.kind === 263; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 262; + return node.kind === 264; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10306,9 +11386,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 143) { + if (d && d.kind === 144) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 228) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 229) { return current; } } @@ -10316,11 +11396,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 150 && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92) && node.parent.kind === 151 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 174 || ts.isBindingPattern(node))) { + while (node && (node.kind === 175 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10328,14 +11408,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 224) { + if (node.kind === 225) { node = node.parent; } - if (node && node.kind === 225) { + if (node && node.kind === 226) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 206) { + if (node && node.kind === 207) { flags |= ts.getModifierFlags(node); } return flags; @@ -10344,14 +11424,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 224) { + if (node.kind === 225) { node = node.parent; } - if (node && node.kind === 225) { + if (node && node.kind === 226) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 206) { + if (node && node.kind === 207) { flags |= node.flags; } return flags; @@ -10404,24 +11484,46 @@ var ts; } } ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage; + function getOriginalNode(node, nodeTest) { + if (node) { + while (node.original !== undefined) { + node = node.original; + } + } + return !nodeTest || nodeTest(node) ? node : undefined; + } + ts.getOriginalNode = getOriginalNode; + function isParseTreeNode(node) { + return (node.flags & 8) === 0; + } + ts.isParseTreeNode = isParseTreeNode; + function getParseTreeNode(node, nodeTest) { + if (isParseTreeNode(node)) { + return node; + } + node = getOriginalNode(node); + if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { + return node; + } + return undefined; + } + ts.getParseTreeNode = getParseTreeNode; + function unescapeIdentifier(identifier) { + return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; + } + ts.unescapeIdentifier = unescapeIdentifier; })(ts || (ts = {})); var ts; (function (ts) { - var NodeConstructor; - var SourceFileConstructor; - function createNode(kind, location, flags) { - var ConstructorForKind = kind === 262 - ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) - : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); - var node = location - ? new ConstructorForKind(kind, location.pos, location.end) - : new ConstructorForKind(kind, -1, -1); - node.flags = flags | 8; + function createSynthesizedNode(kind) { + var node = ts.createNode(kind, -1, -1); + node.flags |= 8; return node; } function updateNode(updated, original) { if (updated !== original) { setOriginalNode(updated, original); + setTextRange(updated, original); if (original.startsOnNewLine) { updated.startsOnNewLine = true; } @@ -10430,7 +11532,7 @@ var ts; return updated; } ts.updateNode = updateNode; - function createNodeArray(elements, location, hasTrailingComma) { + function createNodeArray(elements, hasTrailingComma) { if (elements) { if (ts.isNodeArray(elements)) { return elements; @@ -10440,32 +11542,15 @@ var ts; elements = []; } var array = elements; - if (location) { - array.pos = location.pos; - array.end = location.end; - } - else { - array.pos = -1; - array.end = -1; - } - if (hasTrailingComma) { - array.hasTrailingComma = true; - } + array.pos = -1; + array.end = -1; + array.hasTrailingComma = hasTrailingComma; return array; } ts.createNodeArray = createNodeArray; - function createSynthesizedNode(kind, startsOnNewLine) { - var node = createNode(kind, undefined); - node.startsOnNewLine = startsOnNewLine; - return node; - } - ts.createSynthesizedNode = createSynthesizedNode; - function createSynthesizedNodeArray(elements) { - return createNodeArray(elements, undefined); - } - ts.createSynthesizedNodeArray = createSynthesizedNodeArray; function getSynthesizedClone(node) { - var clone = createNode(node.kind, undefined, node.flags); + var clone = createSynthesizedNode(node.kind); + clone.flags |= node.flags; setOriginalNode(clone, node); for (var key in node) { if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { @@ -10476,50 +11561,47 @@ var ts; return clone; } ts.getSynthesizedClone = getSynthesizedClone; - function getMutableClone(node) { - var clone = getSynthesizedClone(node); - clone.pos = node.pos; - clone.end = node.end; - clone.parent = node.parent; - return clone; - } - ts.getMutableClone = getMutableClone; - function createLiteral(value, location) { + function createLiteral(value) { if (typeof value === "number") { - var node = createNode(8, location, undefined); - node.text = value.toString(); - return node; + return createNumericLiteral(value + ""); } - else if (typeof value === "boolean") { - return createNode(value ? 100 : 85, location, undefined); + if (typeof value === "boolean") { + return value ? createTrue() : createFalse(); } - else if (typeof value === "string") { - var node = createNode(9, location, undefined); - node.text = value; - return node; - } - else if (value) { - var node = createNode(9, location, undefined); - node.textSourceNode = value; - node.text = value.text; - return node; + if (typeof value === "string") { + return createStringLiteral(value); } + return createLiteralFromNode(value); } ts.createLiteral = createLiteral; - var nextAutoGenerateId = 0; - function createIdentifier(text, location) { - var node = createNode(70, location); + function createNumericLiteral(value) { + var node = createSynthesizedNode(8); + node.text = value; + return node; + } + ts.createNumericLiteral = createNumericLiteral; + function createStringLiteral(text) { + var node = createSynthesizedNode(9); + node.text = text; + return node; + } + function createLiteralFromNode(sourceNode) { + var node = createStringLiteral(sourceNode.text); + node.textSourceNode = sourceNode; + return node; + } + function createIdentifier(text) { + var node = createSynthesizedNode(70); node.text = ts.escapeIdentifier(text); - node.originalKeywordKind = ts.stringToToken(text); + node.originalKeywordKind = text ? ts.stringToToken(text) : 0; node.autoGenerateKind = 0; node.autoGenerateId = 0; return node; } ts.createIdentifier = createIdentifier; - function createTempVariable(recordTempVariable, location) { - var name = createNode(70, location); - name.text = ""; - name.originalKeywordKind = 0; + var nextAutoGenerateId = 0; + function createTempVariable(recordTempVariable) { + var name = createIdentifier(""); name.autoGenerateKind = 1; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; @@ -10529,93 +11611,121 @@ var ts; return name; } ts.createTempVariable = createTempVariable; - function createLoopVariable(location) { - var name = createNode(70, location); - name.text = ""; - name.originalKeywordKind = 0; + function createLoopVariable() { + var name = createIdentifier(""); name.autoGenerateKind = 2; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createLoopVariable = createLoopVariable; - function createUniqueName(text, location) { - var name = createNode(70, location); - name.text = text; - name.originalKeywordKind = 0; + function createUniqueName(text) { + var name = createIdentifier(text); name.autoGenerateKind = 3; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createUniqueName = createUniqueName; - function getGeneratedNameForNode(node, location) { - var name = createNode(70, location); - name.original = node; - name.text = ""; - name.originalKeywordKind = 0; + function getGeneratedNameForNode(node) { + var name = createIdentifier(""); name.autoGenerateKind = 4; name.autoGenerateId = nextAutoGenerateId; + name.original = node; nextAutoGenerateId++; return name; } ts.getGeneratedNameForNode = getGeneratedNameForNode; function createToken(token) { - return createNode(token); + return createSynthesizedNode(token); } ts.createToken = createToken; function createSuper() { - var node = createNode(96); - return node; + return createSynthesizedNode(96); } ts.createSuper = createSuper; - function createThis(location) { - var node = createNode(98, location); - return node; + function createThis() { + return createSynthesizedNode(98); } ts.createThis = createThis; function createNull() { - var node = createNode(94); - return node; + return createSynthesizedNode(94); } ts.createNull = createNull; - function createComputedPropertyName(expression, location) { - var node = createNode(142, location); + function createTrue() { + return createSynthesizedNode(100); + } + ts.createTrue = createTrue; + function createFalse() { + return createSynthesizedNode(85); + } + ts.createFalse = createFalse; + function createQualifiedName(left, right) { + var node = createSynthesizedNode(142); + node.left = left; + node.right = asName(right); + return node; + } + ts.createQualifiedName = createQualifiedName; + function updateQualifiedName(node, left, right) { + return node.left !== left + || node.right !== right + ? updateNode(createQualifiedName(left, right), node) + : node; + } + ts.updateQualifiedName = updateQualifiedName; + function createComputedPropertyName(expression) { + var node = createSynthesizedNode(143); node.expression = expression; return node; } ts.createComputedPropertyName = createComputedPropertyName; function updateComputedPropertyName(node, expression) { - if (node.expression !== expression) { - return updateNode(createComputedPropertyName(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createComputedPropertyName(expression), node) + : node; } ts.updateComputedPropertyName = updateComputedPropertyName; - function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(144, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { + var node = createSynthesizedNode(145); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.questionToken = questionToken; node.type = type; - node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createParameter = createParameter; function updateParameter(node, decorators, modifiers, dotDotDotToken, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + : node; } ts.updateParameter = updateParameter; - function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(147, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createDecorator(expression) { + var node = createSynthesizedNode(146); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createDecorator = createDecorator; + function updateDecorator(node, expression) { + return node.expression !== expression + ? updateNode(createDecorator(expression), node) + : node; + } + ts.updateDecorator = updateDecorator; + function createProperty(decorators, modifiers, name, questionToken, type, initializer) { + var node = createSynthesizedNode(148); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.questionToken = questionToken; node.type = type; node.initializer = initializer; @@ -10623,19 +11733,22 @@ var ts; } ts.createProperty = createProperty; function updateProperty(node, decorators, modifiers, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer), node) + : node; } ts.updateProperty = updateProperty; - function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(149, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(150); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -10643,16 +11756,21 @@ var ts; } ts.createMethod = createMethod; function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateMethod = updateMethod; - function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(150, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createConstructor(decorators, modifiers, parameters, body) { + var node = createSynthesizedNode(151); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = undefined; @@ -10661,17 +11779,19 @@ var ts; } ts.createConstructor = createConstructor; function updateConstructor(node, decorators, modifiers, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.parameters !== parameters || node.body !== body) { - return updateNode(createConstructor(decorators, modifiers, parameters, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.parameters !== parameters + || node.body !== body + ? updateNode(createConstructor(decorators, modifiers, parameters, body), node) + : node; } ts.updateConstructor = updateConstructor; - function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(151, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createGetAccessor(decorators, modifiers, name, parameters, type, body) { + var node = createSynthesizedNode(152); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = type; @@ -10680,17 +11800,21 @@ var ts; } ts.createGetAccessor = createGetAccessor; function updateGetAccessor(node, decorators, modifiers, name, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body), node) + : node; } ts.updateGetAccessor = updateGetAccessor; - function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(152, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createSetAccessor(decorators, modifiers, name, parameters, body) { + var node = createSynthesizedNode(153); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.body = body; @@ -10698,57 +11822,60 @@ var ts; } ts.createSetAccessor = createSetAccessor; function updateSetAccessor(node, decorators, modifiers, name, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.body !== body) { - return updateNode(createSetAccessor(decorators, modifiers, name, parameters, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.body !== body + ? updateNode(createSetAccessor(decorators, modifiers, name, parameters, body), node) + : node; } ts.updateSetAccessor = updateSetAccessor; - function createObjectBindingPattern(elements, location) { - var node = createNode(172, location); + function createObjectBindingPattern(elements) { + var node = createSynthesizedNode(173); node.elements = createNodeArray(elements); return node; } ts.createObjectBindingPattern = createObjectBindingPattern; function updateObjectBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createObjectBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createObjectBindingPattern(elements), node) + : node; } ts.updateObjectBindingPattern = updateObjectBindingPattern; - function createArrayBindingPattern(elements, location) { - var node = createNode(173, location); + function createArrayBindingPattern(elements) { + var node = createSynthesizedNode(174); node.elements = createNodeArray(elements); return node; } ts.createArrayBindingPattern = createArrayBindingPattern; function updateArrayBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayBindingPattern(elements), node) + : node; } ts.updateArrayBindingPattern = updateArrayBindingPattern; - function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(174, location); - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createBindingElement(propertyName, dotDotDotToken, name, initializer) { + var node = createSynthesizedNode(175); + node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.initializer = initializer; return node; } ts.createBindingElement = createBindingElement; function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) { - if (node.propertyName !== propertyName || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer) { - return updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer, node), node); - } - return node; + return node.propertyName !== propertyName + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.initializer !== initializer + ? updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer), node) + : node; } ts.updateBindingElement = updateBindingElement; - function createArrayLiteral(elements, location, multiLine) { - var node = createNode(175, location); - node.elements = parenthesizeListElements(createNodeArray(elements)); + function createArrayLiteral(elements, multiLine) { + var node = createSynthesizedNode(176); + node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; } @@ -10756,14 +11883,13 @@ var ts; } ts.createArrayLiteral = createArrayLiteral; function updateArrayLiteral(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayLiteral(elements, node, node.multiLine), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayLiteral(elements, node.multiLine), node) + : node; } ts.updateArrayLiteral = updateArrayLiteral; - function createObjectLiteral(properties, location, multiLine) { - var node = createNode(176, location); + function createObjectLiteral(properties, multiLine) { + var node = createSynthesizedNode(177); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10772,108 +11898,118 @@ var ts; } ts.createObjectLiteral = createObjectLiteral; function updateObjectLiteral(node, properties) { - if (node.properties !== properties) { - return updateNode(createObjectLiteral(properties, node, node.multiLine), node); - } - return node; + return node.properties !== properties + ? updateNode(createObjectLiteral(properties, node.multiLine), node) + : node; } ts.updateObjectLiteral = updateObjectLiteral; - function createPropertyAccess(expression, name, location, flags) { - var node = createNode(177, location, flags); - node.expression = parenthesizeForAccess(expression); - (node.emitNode || (node.emitNode = {})).flags |= 65536; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAccess(expression, name) { + var node = createSynthesizedNode(178); + node.expression = ts.parenthesizeForAccess(expression); + node.name = asName(name); + setEmitFlags(node, 65536); return node; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { - if (node.expression !== expression || node.name !== name) { - var propertyAccess = createPropertyAccess(expression, name, node, node.flags); - (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); - return updateNode(propertyAccess, node); - } - return node; + return node.expression !== expression + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccess(expression, name), getEmitFlags(node)), node) + : node; } ts.updatePropertyAccess = updatePropertyAccess; - function createElementAccess(expression, index, location) { - var node = createNode(178, location); - node.expression = parenthesizeForAccess(expression); - node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; + function createElementAccess(expression, index) { + var node = createSynthesizedNode(179); + node.expression = ts.parenthesizeForAccess(expression); + node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { - if (node.expression !== expression || node.argumentExpression !== argumentExpression) { - return updateNode(createElementAccess(expression, argumentExpression, node), node); - } - return node; + return node.expression !== expression + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccess(expression, argumentExpression), node) + : node; } ts.updateElementAccess = updateElementAccess; - function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(179, location, flags); - node.expression = parenthesizeForAccess(expression); - if (typeArguments) { - node.typeArguments = createNodeArray(typeArguments); - } - node.arguments = parenthesizeListElements(createNodeArray(argumentsArray)); + function createCall(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(180); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); return node; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { - if (expression !== node.expression || typeArguments !== node.typeArguments || argumentsArray !== node.arguments) { - return updateNode(createCall(expression, typeArguments, argumentsArray, node, node.flags), node); - } - return node; + return expression !== node.expression + || typeArguments !== node.typeArguments + || argumentsArray !== node.arguments + ? updateNode(createCall(expression, typeArguments, argumentsArray), node) + : node; } ts.updateCall = updateCall; - function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(180, location, flags); - node.expression = parenthesizeForNew(expression); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; + function createNew(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(181); + node.expression = ts.parenthesizeForNew(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; return node; } ts.createNew = createNew; function updateNew(node, expression, typeArguments, argumentsArray) { - if (node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray) { - return updateNode(createNew(expression, typeArguments, argumentsArray, node, node.flags), node); - } - return node; + return node.expression !== expression + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createNew(expression, typeArguments, argumentsArray), node) + : node; } ts.updateNew = updateNew; - function createTaggedTemplate(tag, template, location) { - var node = createNode(181, location); - node.tag = parenthesizeForAccess(tag); + function createTaggedTemplate(tag, template) { + var node = createSynthesizedNode(182); + node.tag = ts.parenthesizeForAccess(tag); node.template = template; return node; } ts.createTaggedTemplate = createTaggedTemplate; function updateTaggedTemplate(node, tag, template) { - if (node.tag !== tag || node.template !== template) { - return updateNode(createTaggedTemplate(tag, template, node), node); - } - return node; + return node.tag !== tag + || node.template !== template + ? updateNode(createTaggedTemplate(tag, template), node) + : node; } ts.updateTaggedTemplate = updateTaggedTemplate; - function createParen(expression, location) { - var node = createNode(183, location); + function createTypeAssertion(type, expression) { + var node = createSynthesizedNode(183); + node.type = type; + node.expression = ts.parenthesizePrefixOperand(expression); + return node; + } + ts.createTypeAssertion = createTypeAssertion; + function updateTypeAssertion(node, type, expression) { + return node.type !== type + || node.expression !== expression + ? updateNode(createTypeAssertion(type, expression), node) + : node; + } + ts.updateTypeAssertion = updateTypeAssertion; + function createParen(expression) { + var node = createSynthesizedNode(184); node.expression = expression; return node; } ts.createParen = createParen; function updateParen(node, expression) { - if (node.expression !== expression) { - return updateNode(createParen(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createParen(expression), node) + : node; } ts.updateParen = updateParen; - function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(184, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(185); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -10881,322 +12017,340 @@ var ts; } ts.createFunctionExpression = createFunctionExpression; function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.name !== name + || node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionExpression = updateFunctionExpression; - function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(185, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { + var node = createSynthesizedNode(186); + node.modifiers = asNodeArray(modifiers); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35); - node.body = parenthesizeConciseBody(body); + node.body = ts.parenthesizeConciseBody(body); return node; } ts.createArrowFunction = createArrowFunction; function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { - if (node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body, node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + : node; } ts.updateArrowFunction = updateArrowFunction; - function createDelete(expression, location) { - var node = createNode(186, location); - node.expression = parenthesizePrefixOperand(expression); + function createDelete(expression) { + var node = createSynthesizedNode(187); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createDelete = createDelete; function updateDelete(node, expression) { - if (node.expression !== expression) { - return updateNode(createDelete(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createDelete(expression), node) + : node; } ts.updateDelete = updateDelete; - function createTypeOf(expression, location) { - var node = createNode(187, location); - node.expression = parenthesizePrefixOperand(expression); + function createTypeOf(expression) { + var node = createSynthesizedNode(188); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createTypeOf = createTypeOf; function updateTypeOf(node, expression) { - if (node.expression !== expression) { - return updateNode(createTypeOf(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createTypeOf(expression), node) + : node; } ts.updateTypeOf = updateTypeOf; - function createVoid(expression, location) { - var node = createNode(188, location); - node.expression = parenthesizePrefixOperand(expression); + function createVoid(expression) { + var node = createSynthesizedNode(189); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createVoid = createVoid; function updateVoid(node, expression) { - if (node.expression !== expression) { - return updateNode(createVoid(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createVoid(expression), node) + : node; } ts.updateVoid = updateVoid; - function createAwait(expression, location) { - var node = createNode(189, location); - node.expression = parenthesizePrefixOperand(expression); + function createAwait(expression) { + var node = createSynthesizedNode(190); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createAwait = createAwait; function updateAwait(node, expression) { - if (node.expression !== expression) { - return updateNode(createAwait(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createAwait(expression), node) + : node; } ts.updateAwait = updateAwait; - function createPrefix(operator, operand, location) { - var node = createNode(190, location); + function createPrefix(operator, operand) { + var node = createSynthesizedNode(191); node.operator = operator; - node.operand = parenthesizePrefixOperand(operand); + node.operand = ts.parenthesizePrefixOperand(operand); return node; } ts.createPrefix = createPrefix; function updatePrefix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPrefix(node.operator, operand, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPrefix(node.operator, operand), node) + : node; } ts.updatePrefix = updatePrefix; - function createPostfix(operand, operator, location) { - var node = createNode(191, location); - node.operand = parenthesizePostfixOperand(operand); + function createPostfix(operand, operator) { + var node = createSynthesizedNode(192); + node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; } ts.createPostfix = createPostfix; function updatePostfix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPostfix(operand, node.operator, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPostfix(operand, node.operator), node) + : node; } ts.updatePostfix = updatePostfix; - function createBinary(left, operator, right, location) { - var operatorToken = typeof operator === "number" ? createToken(operator) : operator; + function createBinary(left, operator, right) { + var node = createSynthesizedNode(193); + var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; - var node = createNode(192, location); - node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); + node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; - node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); + node.right = ts.parenthesizeBinaryOperand(operatorKind, right, false, node.left); return node; } ts.createBinary = createBinary; function updateBinary(node, left, right) { - if (node.left !== left || node.right !== right) { - return updateNode(createBinary(left, node.operatorToken, right, node), node); - } - return node; + return node.left !== left + || node.right !== right + ? updateNode(createBinary(left, node.operatorToken, right), node) + : node; } ts.updateBinary = updateBinary; - function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonTokenOrLocation, whenFalse, location) { - var node = createNode(193, whenFalse ? location : colonTokenOrLocation); - node.condition = parenthesizeForConditionalHead(condition); - if (whenFalse) { - node.questionToken = questionTokenOrWhenTrue; - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - node.colonToken = colonTokenOrLocation; - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenFalse); - } - else { - node.questionToken = createToken(54); - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(questionTokenOrWhenTrue); - node.colonToken = createToken(55); - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - } + function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { + var node = createSynthesizedNode(194); + node.condition = ts.parenthesizeForConditionalHead(condition); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(54); + node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); + node.colonToken = whenFalse ? colonToken : createToken(55); + node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } ts.createConditional = createConditional; function updateConditional(node, condition, whenTrue, whenFalse) { - if (node.condition !== condition || node.whenTrue !== whenTrue || node.whenFalse !== whenFalse) { - return updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse, node), node); - } - return node; + return node.condition !== condition + || node.whenTrue !== whenTrue + || node.whenFalse !== whenFalse + ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + : node; } ts.updateConditional = updateConditional; - function createTemplateExpression(head, templateSpans, location) { - var node = createNode(194, location); + function createTemplateExpression(head, templateSpans) { + var node = createSynthesizedNode(195); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; } ts.createTemplateExpression = createTemplateExpression; function updateTemplateExpression(node, head, templateSpans) { - if (node.head !== head || node.templateSpans !== templateSpans) { - return updateNode(createTemplateExpression(head, templateSpans, node), node); - } - return node; + return node.head !== head + || node.templateSpans !== templateSpans + ? updateNode(createTemplateExpression(head, templateSpans), node) + : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createYield(asteriskToken, expression, location) { - var node = createNode(195, location); - node.asteriskToken = asteriskToken; - node.expression = expression; + function createYield(asteriskTokenOrExpression, expression) { + var node = createSynthesizedNode(196); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 38 ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 38 ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; function updateYield(node, expression) { - if (node.expression !== expression) { - return updateNode(createYield(node.asteriskToken, expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createYield(node.asteriskToken, expression), node) + : node; } ts.updateYield = updateYield; - function createSpread(expression, location) { - var node = createNode(196, location); - node.expression = parenthesizeExpressionForList(expression); + function createSpread(expression) { + var node = createSynthesizedNode(197); + node.expression = ts.parenthesizeExpressionForList(expression); return node; } ts.createSpread = createSpread; function updateSpread(node, expression) { - if (node.expression !== expression) { - return updateNode(createSpread(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createSpread(expression), node) + : node; } ts.updateSpread = updateSpread; - function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(197, location); + function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(198); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassExpression = createClassExpression; function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) { - if (node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassExpression = updateClassExpression; - function createOmittedExpression(location) { - var node = createNode(198, location); - return node; + function createOmittedExpression() { + return createSynthesizedNode(199); } ts.createOmittedExpression = createOmittedExpression; - function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(199, location); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.expression = parenthesizeForAccess(expression); + function createExpressionWithTypeArguments(typeArguments, expression) { + var node = createSynthesizedNode(200); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); return node; } ts.createExpressionWithTypeArguments = createExpressionWithTypeArguments; function updateExpressionWithTypeArguments(node, typeArguments, expression) { - if (node.typeArguments !== typeArguments || node.expression !== expression) { - return updateNode(createExpressionWithTypeArguments(typeArguments, expression, node), node); - } - return node; + return node.typeArguments !== typeArguments + || node.expression !== expression + ? updateNode(createExpressionWithTypeArguments(typeArguments, expression), node) + : node; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; - function createTemplateSpan(expression, literal, location) { - var node = createNode(203, location); + function createAsExpression(expression, type) { + var node = createSynthesizedNode(201); + node.expression = expression; + node.type = type; + return node; + } + ts.createAsExpression = createAsExpression; + function updateAsExpression(node, expression, type) { + return node.expression !== expression + || node.type !== type + ? updateNode(createAsExpression(expression, type), node) + : node; + } + ts.updateAsExpression = updateAsExpression; + function createNonNullExpression(expression) { + var node = createSynthesizedNode(202); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createNonNullExpression = createNonNullExpression; + function updateNonNullExpression(node, expression) { + return node.expression !== expression + ? updateNode(createNonNullExpression(expression), node) + : node; + } + ts.updateNonNullExpression = updateNonNullExpression; + function createTemplateSpan(expression, literal) { + var node = createSynthesizedNode(204); node.expression = expression; node.literal = literal; return node; } ts.createTemplateSpan = createTemplateSpan; function updateTemplateSpan(node, expression, literal) { - if (node.expression !== expression || node.literal !== literal) { - return updateNode(createTemplateSpan(expression, literal, node), node); - } - return node; + return node.expression !== expression + || node.literal !== literal + ? updateNode(createTemplateSpan(expression, literal), node) + : node; } ts.updateTemplateSpan = updateTemplateSpan; - function createBlock(statements, location, multiLine, flags) { - var block = createNode(205, location, flags); + function createBlock(statements, multiLine) { + var block = createSynthesizedNode(206); block.statements = createNodeArray(statements); - if (multiLine) { - block.multiLine = true; - } + if (multiLine) + block.multiLine = multiLine; return block; } ts.createBlock = createBlock; function updateBlock(node, statements) { - if (statements !== node.statements) { - return updateNode(createBlock(statements, node, node.multiLine, node.flags), node); - } - return node; + return statements !== node.statements + ? updateNode(createBlock(statements, node.multiLine), node) + : node; } ts.updateBlock = updateBlock; - function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(206, location, flags); + function createVariableStatement(modifiers, declarationList) { + var node = createSynthesizedNode(207); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; return node; } ts.createVariableStatement = createVariableStatement; function updateVariableStatement(node, modifiers, declarationList) { - if (node.modifiers !== modifiers || node.declarationList !== declarationList) { - return updateNode(createVariableStatement(modifiers, declarationList, node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.declarationList !== declarationList + ? updateNode(createVariableStatement(modifiers, declarationList), node) + : node; } ts.updateVariableStatement = updateVariableStatement; - function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(225, location, flags); + function createVariableDeclarationList(declarations, flags) { + var node = createSynthesizedNode(226); + node.flags |= flags; node.declarations = createNodeArray(declarations); return node; } ts.createVariableDeclarationList = createVariableDeclarationList; function updateVariableDeclarationList(node, declarations) { - if (node.declarations !== declarations) { - return updateNode(createVariableDeclarationList(declarations, node, node.flags), node); - } - return node; + return node.declarations !== declarations + ? updateNode(createVariableDeclarationList(declarations, node.flags), node) + : node; } ts.updateVariableDeclarationList = updateVariableDeclarationList; - function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(224, location, flags); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createVariableDeclaration(name, type, initializer) { + var node = createSynthesizedNode(225); + node.name = asName(name); node.type = type; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createVariableDeclaration = createVariableDeclaration; function updateVariableDeclaration(node, name, type, initializer) { - if (node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createVariableDeclaration(name, type, initializer, node, node.flags), node); - } - return node; + return node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createVariableDeclaration(name, type, initializer), node) + : node; } ts.updateVariableDeclaration = updateVariableDeclaration; - function createEmptyStatement(location) { - return createNode(207, location); + function createEmptyStatement() { + return createSynthesizedNode(208); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression, location, flags) { - var node = createNode(208, location, flags); - node.expression = parenthesizeExpressionForExpressionStatement(expression); + function createStatement(expression) { + var node = createSynthesizedNode(209); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } ts.createStatement = createStatement; function updateStatement(node, expression) { - if (node.expression !== expression) { - return updateNode(createStatement(expression, node, node.flags), node); - } - return node; + return node.expression !== expression + ? updateNode(createStatement(expression), node) + : node; } ts.updateStatement = updateStatement; - function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(209, location); + function createIf(expression, thenStatement, elseStatement) { + var node = createSynthesizedNode(210); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11204,42 +12358,43 @@ var ts; } ts.createIf = createIf; function updateIf(node, expression, thenStatement, elseStatement) { - if (node.expression !== expression || node.thenStatement !== thenStatement || node.elseStatement !== elseStatement) { - return updateNode(createIf(expression, thenStatement, elseStatement, node), node); - } - return node; + return node.expression !== expression + || node.thenStatement !== thenStatement + || node.elseStatement !== elseStatement + ? updateNode(createIf(expression, thenStatement, elseStatement), node) + : node; } ts.updateIf = updateIf; - function createDo(statement, expression, location) { - var node = createNode(210, location); + function createDo(statement, expression) { + var node = createSynthesizedNode(211); node.statement = statement; node.expression = expression; return node; } ts.createDo = createDo; function updateDo(node, statement, expression) { - if (node.statement !== statement || node.expression !== expression) { - return updateNode(createDo(statement, expression, node), node); - } - return node; + return node.statement !== statement + || node.expression !== expression + ? updateNode(createDo(statement, expression), node) + : node; } ts.updateDo = updateDo; - function createWhile(expression, statement, location) { - var node = createNode(211, location); + function createWhile(expression, statement) { + var node = createSynthesizedNode(212); node.expression = expression; node.statement = statement; return node; } ts.createWhile = createWhile; function updateWhile(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWhile(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWhile(expression, statement), node) + : node; } ts.updateWhile = updateWhile; - function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(212, location, undefined); + function createFor(initializer, condition, incrementor, statement) { + var node = createSynthesizedNode(213); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11248,14 +12403,16 @@ var ts; } ts.createFor = createFor; function updateFor(node, initializer, condition, incrementor, statement) { - if (node.initializer !== initializer || node.condition !== condition || node.incrementor !== incrementor || node.statement !== statement) { - return updateNode(createFor(initializer, condition, incrementor, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.condition !== condition + || node.incrementor !== incrementor + || node.statement !== statement + ? updateNode(createFor(initializer, condition, incrementor, statement), node) + : node; } ts.updateFor = updateFor; - function createForIn(initializer, expression, statement, location) { - var node = createNode(213, location); + function createForIn(initializer, expression, statement) { + var node = createSynthesizedNode(214); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11263,14 +12420,15 @@ var ts; } ts.createForIn = createForIn; function updateForIn(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForIn(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForIn(initializer, expression, statement), node) + : node; } ts.updateForIn = updateForIn; - function createForOf(initializer, expression, statement, location) { - var node = createNode(214, location); + function createForOf(initializer, expression, statement) { + var node = createSynthesizedNode(215); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11278,112 +12436,105 @@ var ts; } ts.createForOf = createForOf; function updateForOf(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForOf(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForOf(initializer, expression, statement), node) + : node; } ts.updateForOf = updateForOf; - function createContinue(label, location) { - var node = createNode(215, location); - if (label) { - node.label = label; - } + function createContinue(label) { + var node = createSynthesizedNode(216); + node.label = asName(label); return node; } ts.createContinue = createContinue; function updateContinue(node, label) { - if (node.label !== label) { - return updateNode(createContinue(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createContinue(label), node) + : node; } ts.updateContinue = updateContinue; - function createBreak(label, location) { - var node = createNode(216, location); - if (label) { - node.label = label; - } + function createBreak(label) { + var node = createSynthesizedNode(217); + node.label = asName(label); return node; } ts.createBreak = createBreak; function updateBreak(node, label) { - if (node.label !== label) { - return updateNode(createBreak(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createBreak(label), node) + : node; } ts.updateBreak = updateBreak; - function createReturn(expression, location) { - var node = createNode(217, location); + function createReturn(expression) { + var node = createSynthesizedNode(218); node.expression = expression; return node; } ts.createReturn = createReturn; function updateReturn(node, expression) { - if (node.expression !== expression) { - return updateNode(createReturn(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createReturn(expression), node) + : node; } ts.updateReturn = updateReturn; - function createWith(expression, statement, location) { - var node = createNode(218, location); + function createWith(expression, statement) { + var node = createSynthesizedNode(219); node.expression = expression; node.statement = statement; return node; } ts.createWith = createWith; function updateWith(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWith(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWith(expression, statement), node) + : node; } ts.updateWith = updateWith; - function createSwitch(expression, caseBlock, location) { - var node = createNode(219, location); - node.expression = parenthesizeExpressionForList(expression); + function createSwitch(expression, caseBlock) { + var node = createSynthesizedNode(220); + node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; } ts.createSwitch = createSwitch; function updateSwitch(node, expression, caseBlock) { - if (node.expression !== expression || node.caseBlock !== caseBlock) { - return updateNode(createSwitch(expression, caseBlock, node), node); - } - return node; + return node.expression !== expression + || node.caseBlock !== caseBlock + ? updateNode(createSwitch(expression, caseBlock), node) + : node; } ts.updateSwitch = updateSwitch; - function createLabel(label, statement, location) { - var node = createNode(220, location); - node.label = typeof label === "string" ? createIdentifier(label) : label; + function createLabel(label, statement) { + var node = createSynthesizedNode(221); + node.label = asName(label); node.statement = statement; return node; } ts.createLabel = createLabel; function updateLabel(node, label, statement) { - if (node.label !== label || node.statement !== statement) { - return updateNode(createLabel(label, statement, node), node); - } - return node; + return node.label !== label + || node.statement !== statement + ? updateNode(createLabel(label, statement), node) + : node; } ts.updateLabel = updateLabel; - function createThrow(expression, location) { - var node = createNode(221, location); + function createThrow(expression) { + var node = createSynthesizedNode(222); node.expression = expression; return node; } ts.createThrow = createThrow; function updateThrow(node, expression) { - if (node.expression !== expression) { - return updateNode(createThrow(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createThrow(expression), node) + : node; } ts.updateThrow = updateThrow; - function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(222, location); + function createTry(tryBlock, catchClause, finallyBlock) { + var node = createSynthesizedNode(223); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11391,32 +12542,20 @@ var ts; } ts.createTry = createTry; function updateTry(node, tryBlock, catchClause, finallyBlock) { - if (node.tryBlock !== tryBlock || node.catchClause !== catchClause || node.finallyBlock !== finallyBlock) { - return updateNode(createTry(tryBlock, catchClause, finallyBlock, node), node); - } - return node; + return node.tryBlock !== tryBlock + || node.catchClause !== catchClause + || node.finallyBlock !== finallyBlock + ? updateNode(createTry(tryBlock, catchClause, finallyBlock), node) + : node; } ts.updateTry = updateTry; - function createCaseBlock(clauses, location) { - var node = createNode(233, location); - node.clauses = createNodeArray(clauses); - return node; - } - ts.createCaseBlock = createCaseBlock; - function updateCaseBlock(node, clauses) { - if (node.clauses !== clauses) { - return updateNode(createCaseBlock(clauses, node), node); - } - return node; - } - ts.updateCaseBlock = updateCaseBlock; - function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(226, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(227); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -11424,161 +12563,261 @@ var ts; } ts.createFunctionDeclaration = createFunctionDeclaration; function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionDeclaration = updateFunctionDeclaration; - function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(227, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(228); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassDeclaration = createClassDeclaration; function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassDeclaration = updateClassDeclaration; - function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(236, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createEnumDeclaration(decorators, modifiers, name, members) { + var node = createSynthesizedNode(231); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.members = createNodeArray(members); + return node; + } + ts.createEnumDeclaration = createEnumDeclaration; + function updateEnumDeclaration(node, decorators, modifiers, name, members) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.members !== members + ? updateNode(createEnumDeclaration(decorators, modifiers, name, members), node) + : node; + } + ts.updateEnumDeclaration = updateEnumDeclaration; + function createModuleDeclaration(decorators, modifiers, name, body, flags) { + var node = createSynthesizedNode(232); + node.flags |= flags; + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = name; + node.body = body; + return node; + } + ts.createModuleDeclaration = createModuleDeclaration; + function updateModuleDeclaration(node, decorators, modifiers, name, body) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.body !== body + ? updateNode(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node) + : node; + } + ts.updateModuleDeclaration = updateModuleDeclaration; + function createModuleBlock(statements) { + var node = createSynthesizedNode(234); + node.statements = createNodeArray(statements); + return node; + } + ts.createModuleBlock = createModuleBlock; + function updateModuleBlock(node, statements) { + return node.statements !== statements + ? updateNode(createModuleBlock(statements), node) + : node; + } + ts.updateModuleBlock = updateModuleBlock; + function createCaseBlock(clauses) { + var node = createSynthesizedNode(234); + node.clauses = createNodeArray(clauses); + return node; + } + ts.createCaseBlock = createCaseBlock; + function updateCaseBlock(node, clauses) { + return node.clauses !== clauses + ? updateNode(createCaseBlock(clauses), node) + : node; + } + ts.updateCaseBlock = updateCaseBlock; + function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { + var node = createSynthesizedNode(236); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.moduleReference = moduleReference; + return node; + } + ts.createImportEqualsDeclaration = createImportEqualsDeclaration; + function updateImportEqualsDeclaration(node, decorators, modifiers, name, moduleReference) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.moduleReference !== moduleReference + ? updateNode(createImportEqualsDeclaration(decorators, modifiers, name, moduleReference), node) + : node; + } + ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; + function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { + var node = createSynthesizedNode(237); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createImportDeclaration = createImportDeclaration; function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node) + : node; } ts.updateImportDeclaration = updateImportDeclaration; - function createImportClause(name, namedBindings, location) { - var node = createNode(237, location); + function createImportClause(name, namedBindings) { + var node = createSynthesizedNode(238); node.name = name; node.namedBindings = namedBindings; return node; } ts.createImportClause = createImportClause; function updateImportClause(node, name, namedBindings) { - if (node.name !== name || node.namedBindings !== namedBindings) { - return updateNode(createImportClause(name, namedBindings, node), node); - } - return node; + return node.name !== name + || node.namedBindings !== namedBindings + ? updateNode(createImportClause(name, namedBindings), node) + : node; } ts.updateImportClause = updateImportClause; - function createNamespaceImport(name, location) { - var node = createNode(238, location); + function createNamespaceImport(name) { + var node = createSynthesizedNode(239); node.name = name; return node; } ts.createNamespaceImport = createNamespaceImport; function updateNamespaceImport(node, name) { - if (node.name !== name) { - return updateNode(createNamespaceImport(name, node), node); - } - return node; + return node.name !== name + ? updateNode(createNamespaceImport(name), node) + : node; } ts.updateNamespaceImport = updateNamespaceImport; - function createNamedImports(elements, location) { - var node = createNode(239, location); + function createNamedImports(elements) { + var node = createSynthesizedNode(240); node.elements = createNodeArray(elements); return node; } ts.createNamedImports = createNamedImports; function updateNamedImports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedImports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedImports(elements), node) + : node; } ts.updateNamedImports = updateNamedImports; - function createImportSpecifier(propertyName, name, location) { - var node = createNode(240, location); + function createImportSpecifier(propertyName, name) { + var node = createSynthesizedNode(241); node.propertyName = propertyName; node.name = name; return node; } ts.createImportSpecifier = createImportSpecifier; function updateImportSpecifier(node, propertyName, name) { - if (node.propertyName !== propertyName || node.name !== name) { - return updateNode(createImportSpecifier(propertyName, name, node), node); - } - return node; + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createImportSpecifier(propertyName, name), node) + : node; } ts.updateImportSpecifier = updateImportSpecifier; - function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(241, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportAssignment(decorators, modifiers, isExportEquals, expression) { + var node = createSynthesizedNode(242); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = expression; return node; } ts.createExportAssignment = createExportAssignment; function updateExportAssignment(node, decorators, modifiers, expression) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.expression !== expression) { - return updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.expression !== expression + ? updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node) + : node; } ts.updateExportAssignment = updateExportAssignment; - function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(242, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { + var node = createSynthesizedNode(243); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createExportDeclaration = createExportDeclaration; function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.exportClause !== exportClause + || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier), node) + : node; } ts.updateExportDeclaration = updateExportDeclaration; - function createNamedExports(elements, location) { - var node = createNode(243, location); + function createNamedExports(elements) { + var node = createSynthesizedNode(244); node.elements = createNodeArray(elements); return node; } ts.createNamedExports = createNamedExports; function updateNamedExports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedExports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedExports(elements), node) + : node; } ts.updateNamedExports = updateNamedExports; - function createExportSpecifier(name, propertyName, location) { - var node = createNode(244, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createExportSpecifier(name, propertyName) { + var node = createSynthesizedNode(245); + node.name = asName(name); + node.propertyName = asName(propertyName); return node; } ts.createExportSpecifier = createExportSpecifier; function updateExportSpecifier(node, name, propertyName) { - if (node.name !== name || node.propertyName !== propertyName) { - return updateNode(createExportSpecifier(name, propertyName, node), node); - } - return node; + return node.name !== name || node.propertyName !== propertyName + ? updateNode(createExportSpecifier(name, propertyName), node) + : node; } ts.updateExportSpecifier = updateExportSpecifier; - function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(247, location); + function createExternalModuleReference(expression) { + var node = createSynthesizedNode(247); + node.expression = expression; + return node; + } + ts.createExternalModuleReference = createExternalModuleReference; + function updateExternalModuleReference(node, expression) { + return node.expression !== expression + ? updateNode(createExternalModuleReference(expression), node) + : node; + } + ts.updateExternalModuleReference = updateExternalModuleReference; + function createJsxElement(openingElement, children, closingElement) { + var node = createSynthesizedNode(248); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11586,96 +12825,107 @@ var ts; } ts.createJsxElement = createJsxElement; function updateJsxElement(node, openingElement, children, closingElement) { - if (node.openingElement !== openingElement || node.children !== children || node.closingElement !== closingElement) { - return updateNode(createJsxElement(openingElement, children, closingElement, node), node); - } - return node; + return node.openingElement !== openingElement + || node.children !== children + || node.closingElement !== closingElement + ? updateNode(createJsxElement(openingElement, children, closingElement), node) + : node; } ts.updateJsxElement = updateJsxElement; - function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(248, location); + function createJsxSelfClosingElement(tagName, attributes) { + var node = createSynthesizedNode(249); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxSelfClosingElement = createJsxSelfClosingElement; function updateJsxSelfClosingElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxSelfClosingElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxSelfClosingElement(tagName, attributes), node) + : node; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; - function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(249, location); + function createJsxOpeningElement(tagName, attributes) { + var node = createSynthesizedNode(250); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxOpeningElement = createJsxOpeningElement; function updateJsxOpeningElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxOpeningElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxOpeningElement(tagName, attributes), node) + : node; } ts.updateJsxOpeningElement = updateJsxOpeningElement; - function createJsxClosingElement(tagName, location) { - var node = createNode(250, location); + function createJsxClosingElement(tagName) { + var node = createSynthesizedNode(251); node.tagName = tagName; return node; } ts.createJsxClosingElement = createJsxClosingElement; function updateJsxClosingElement(node, tagName) { - if (node.tagName !== tagName) { - return updateNode(createJsxClosingElement(tagName, node), node); - } - return node; + return node.tagName !== tagName + ? updateNode(createJsxClosingElement(tagName), node) + : node; } ts.updateJsxClosingElement = updateJsxClosingElement; - function createJsxAttribute(name, initializer, location) { - var node = createNode(251, location); + function createJsxAttributes(properties) { + var jsxAttributes = createSynthesizedNode(253); + jsxAttributes.properties = createNodeArray(properties); + return jsxAttributes; + } + ts.createJsxAttributes = createJsxAttributes; + function updateJsxAttributes(jsxAttributes, properties) { + if (jsxAttributes.properties !== properties) { + return updateNode(createJsxAttributes(properties), jsxAttributes); + } + return jsxAttributes; + } + ts.updateJsxAttributes = updateJsxAttributes; + function createJsxAttribute(name, initializer) { + var node = createSynthesizedNode(252); node.name = name; node.initializer = initializer; return node; } ts.createJsxAttribute = createJsxAttribute; function updateJsxAttribute(node, name, initializer) { - if (node.name !== name || node.initializer !== initializer) { - return updateNode(createJsxAttribute(name, initializer, node), node); - } - return node; + return node.name !== name + || node.initializer !== initializer + ? updateNode(createJsxAttribute(name, initializer), node) + : node; } ts.updateJsxAttribute = updateJsxAttribute; - function createJsxSpreadAttribute(expression, location) { - var node = createNode(252, location); + function createJsxSpreadAttribute(expression) { + var node = createSynthesizedNode(254); node.expression = expression; return node; } ts.createJsxSpreadAttribute = createJsxSpreadAttribute; function updateJsxSpreadAttribute(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxSpreadAttribute(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxSpreadAttribute(expression), node) + : node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, dotDotDotToken, location) { - var node = createNode(253, location); + function createJsxExpression(expression, dotDotDotToken) { + var node = createSynthesizedNode(255); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxExpression(expression, node.dotDotDotToken), node) + : node; } ts.updateJsxExpression = updateJsxExpression; - function createHeritageClause(token, types, location) { - var node = createNode(256, location); + function createHeritageClause(token, types) { + var node = createSynthesizedNode(258); node.token = token; node.types = createNodeArray(types); return node; @@ -11683,40 +12933,40 @@ var ts; ts.createHeritageClause = createHeritageClause; function updateHeritageClause(node, types) { if (node.types !== types) { - return updateNode(createHeritageClause(node.token, types, node), node); + return updateNode(createHeritageClause(node.token, types), node); } return node; } ts.updateHeritageClause = updateHeritageClause; - function createCaseClause(expression, statements, location) { - var node = createNode(254, location); - node.expression = parenthesizeExpressionForList(expression); + function createCaseClause(expression, statements) { + var node = createSynthesizedNode(256); + node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; } ts.createCaseClause = createCaseClause; function updateCaseClause(node, expression, statements) { if (node.expression !== expression || node.statements !== statements) { - return updateNode(createCaseClause(expression, statements, node), node); + return updateNode(createCaseClause(expression, statements), node); } return node; } ts.updateCaseClause = updateCaseClause; - function createDefaultClause(statements, location) { - var node = createNode(255, location); + function createDefaultClause(statements) { + var node = createSynthesizedNode(257); node.statements = createNodeArray(statements); return node; } ts.createDefaultClause = createDefaultClause; function updateDefaultClause(node, statements) { if (node.statements !== statements) { - return updateNode(createDefaultClause(statements, node), node); + return updateNode(createDefaultClause(statements), node); } return node; } ts.updateDefaultClause = updateDefaultClause; - function createCatchClause(variableDeclaration, block, location) { - var node = createNode(257, location); + function createCatchClause(variableDeclaration, block) { + var node = createSynthesizedNode(259); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11724,56 +12974,71 @@ var ts; ts.createCatchClause = createCatchClause; function updateCatchClause(node, variableDeclaration, block) { if (node.variableDeclaration !== variableDeclaration || node.block !== block) { - return updateNode(createCatchClause(variableDeclaration, block, node), node); + return updateNode(createCatchClause(variableDeclaration, block), node); } return node; } ts.updateCatchClause = updateCatchClause; - function createPropertyAssignment(name, initializer, location) { - var node = createNode(258, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAssignment(name, initializer) { + var node = createSynthesizedNode(260); + node.name = asName(name); node.questionToken = undefined; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createPropertyAssignment = createPropertyAssignment; function updatePropertyAssignment(node, name, initializer) { if (node.name !== name || node.initializer !== initializer) { - return updateNode(createPropertyAssignment(name, initializer, node), node); + return updateNode(createPropertyAssignment(name, initializer), node); } return node; } ts.updatePropertyAssignment = updatePropertyAssignment; - function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(259, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; + function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { + var node = createSynthesizedNode(261); + node.name = asName(name); + node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; - function createSpreadAssignment(expression, location) { - var node = createNode(260, location); - node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; + function createSpreadAssignment(expression) { + var node = createSynthesizedNode(262); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; return node; } ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { - return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); + return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); } return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function updateSpreadAssignment(node, expression) { if (node.expression !== expression) { - return updateNode(createSpreadAssignment(expression, node), node); + return updateNode(createSpreadAssignment(expression), node); } return node; } ts.updateSpreadAssignment = updateSpreadAssignment; + function createEnumMember(name, initializer) { + var node = createSynthesizedNode(263); + node.name = asName(name); + node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); + return node; + } + ts.createEnumMember = createEnumMember; + function updateEnumMember(node, name, initializer) { + return node.name !== name + || node.initializer !== initializer + ? updateNode(createEnumMember(name, initializer), node) + : node; + } + ts.updateEnumMember = updateEnumMember; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(262, node, node.flags); + var updated = createSynthesizedNode(264); + updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -11832,50 +13097,73 @@ var ts; return node; } ts.updateSourceFileNode = updateSourceFileNode; + function getMutableClone(node) { + var clone = getSynthesizedClone(node); + clone.pos = node.pos; + clone.end = node.end; + clone.parent = node.parent; + return clone; + } + ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createNode(294, original); + var node = createSynthesizedNode(297); node.original = original; + setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createNode(297); + var node = createSynthesizedNode(300); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createNode(296); + var node = createSynthesizedNode(299); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; - function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(295, location || original); + function createPartiallyEmittedExpression(expression, original) { + var node = createSynthesizedNode(298); node.expression = expression; node.original = original; + setTextRange(node, original); return node; } ts.createPartiallyEmittedExpression = createPartiallyEmittedExpression; function updatePartiallyEmittedExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createPartiallyEmittedExpression(expression, node.original, node), node); + return updateNode(createPartiallyEmittedExpression(expression, node.original), node); } return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; + function createBundle(sourceFiles) { + var node = ts.createNode(265); + node.sourceFiles = sourceFiles; + return node; + } + ts.createBundle = createBundle; + function updateBundle(node, sourceFiles) { + if (node.sourceFiles !== sourceFiles) { + return createBundle(sourceFiles); + } + return node; + } + ts.updateBundle = updateBundle; function createComma(left, right) { return createBinary(left, 25, right); } ts.createComma = createComma; - function createLessThan(left, right, location) { - return createBinary(left, 26, right, location); + function createLessThan(left, right) { + return createBinary(left, 26, right); } ts.createLessThan = createLessThan; - function createAssignment(left, right, location) { - return createBinary(left, 57, right, location); + function createAssignment(left, right) { + return createBinary(left, 57, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { @@ -11894,8 +13182,8 @@ var ts; return createBinary(left, 37, right); } ts.createSubtract = createSubtract; - function createPostfixIncrement(operand, location) { - return createPostfix(operand, 42, location); + function createPostfixIncrement(operand) { + return createPostfix(operand, 42); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { @@ -11914,97 +13202,6 @@ var ts; return createVoid(createLiteral(0)); } ts.createVoidZero = createVoidZero; - function createTypeCheck(value, tag) { - return tag === "undefined" - ? createStrictEquality(value, createVoidZero()) - : createStrictEquality(createTypeOf(value), createLiteral(tag)); - } - ts.createTypeCheck = createTypeCheck; - function createMemberAccessForPropertyName(target, memberName, location) { - if (ts.isComputedPropertyName(memberName)) { - return createElementAccess(target, memberName.expression, location); - } - else { - var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - (expression.emitNode || (expression.emitNode = {})).flags |= 64; - return expression; - } - } - ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; - function createFunctionCall(func, thisArg, argumentsList, location) { - return createCall(createPropertyAccess(func, "call"), undefined, [ - thisArg - ].concat(argumentsList), location); - } - ts.createFunctionCall = createFunctionCall; - function createFunctionApply(func, thisArg, argumentsExpression, location) { - return createCall(createPropertyAccess(func, "apply"), undefined, [ - thisArg, - argumentsExpression - ], location); - } - ts.createFunctionApply = createFunctionApply; - function createArraySlice(array, start) { - var argumentsList = []; - if (start !== undefined) { - argumentsList.push(typeof start === "number" ? createLiteral(start) : start); - } - return createCall(createPropertyAccess(array, "slice"), undefined, argumentsList); - } - ts.createArraySlice = createArraySlice; - function createArrayConcat(array, values) { - return createCall(createPropertyAccess(array, "concat"), undefined, values); - } - ts.createArrayConcat = createArrayConcat; - function createMathPow(left, right, location) { - return createCall(createPropertyAccess(createIdentifier("Math"), "pow"), undefined, [left, right], location); - } - ts.createMathPow = createMathPow; - function createReactNamespace(reactNamespace, parent) { - var react = createIdentifier(reactNamespace || "React"); - react.flags &= ~8; - react.parent = ts.getParseTreeNode(parent); - return react; - } - function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { - if (ts.isQualifiedName(jsxFactory)) { - var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); - var right = createSynthesizedNode(70); - right.text = jsxFactory.right.text; - return createPropertyAccess(left, right); - } - else { - return createReactNamespace(jsxFactory.text, parent); - } - } - function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { - return jsxFactoryEntity ? - createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : - createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); - } - function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { - var argumentsList = [tagName]; - if (props) { - argumentsList.push(props); - } - if (children && children.length > 0) { - if (!props) { - argumentsList.push(createNull()); - } - if (children.length > 1) { - for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { - var child = children_1[_i]; - child.startsOnNewLine = true; - argumentsList.push(child); - } - } - else { - argumentsList.push(children[0]); - } - } - return createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList, location); - } - ts.createExpressionForJsxElement = createExpressionForJsxElement; function createExportDefault(expression) { return createExportAssignment(undefined, undefined, false, expression); } @@ -12013,586 +13210,17 @@ var ts; return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(exportName)])); } ts.createExternalModuleExport = createExternalModuleExport; - function createLetStatement(name, initializer, location) { - return createVariableStatement(undefined, createLetDeclarationList([createVariableDeclaration(name, undefined, initializer)]), location); + function asName(name) { + return typeof name === "string" ? createIdentifier(name) : name; } - ts.createLetStatement = createLetStatement; - function createLetDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 1); + function asExpression(value) { + return typeof value === "string" || typeof value === "number" ? createLiteral(value) : value; } - ts.createLetDeclarationList = createLetDeclarationList; - function createConstDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 2); + function asNodeArray(array) { + return array ? createNodeArray(array) : undefined; } - ts.createConstDeclarationList = createConstDeclarationList; - function getHelperName(name) { - return setEmitFlags(createIdentifier(name), 4096 | 2); - } - ts.getHelperName = getHelperName; - function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { - if (!outermostLabeledStatement) { - return node; - } - var updated = updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 220 - ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) - : node); - if (afterRestoreLabelCallback) { - afterRestoreLabelCallback(outermostLabeledStatement); - } - return updated; - } - ts.restoreEnclosingLabel = restoreEnclosingLabel; - function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { - var target = skipParentheses(node); - switch (target.kind) { - case 70: - return cacheIdentifiers; - case 98: - case 8: - case 9: - return false; - case 175: - var elements = target.elements; - if (elements.length === 0) { - return false; - } - return true; - case 176: - return target.properties.length > 0; - default: - return true; - } - } - function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { - var callee = skipOuterExpressions(expression, 7); - var thisArg; - var target; - if (ts.isSuperProperty(callee)) { - thisArg = createThis(); - target = callee; - } - else if (callee.kind === 96) { - thisArg = createThis(); - target = languageVersion < 2 ? createIdentifier("_super", callee) : callee; - } - else { - switch (callee.kind) { - case 177: { - if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { - thisArg = createTempVariable(recordTempVariable); - target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); - } - else { - thisArg = callee.expression; - target = callee; - } - break; - } - case 178: { - if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { - thisArg = createTempVariable(recordTempVariable); - target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); - } - else { - thisArg = callee.expression; - target = callee; - } - break; - } - default: { - thisArg = createVoidZero(); - target = parenthesizeForAccess(expression); - break; - } - } - } - return { target: target, thisArg: thisArg }; - } - ts.createCallBinding = createCallBinding; - function inlineExpressions(expressions) { - return ts.reduceLeft(expressions, createComma); - } - ts.inlineExpressions = inlineExpressions; - function createExpressionFromEntityName(node) { - if (ts.isQualifiedName(node)) { - var left = createExpressionFromEntityName(node.left); - var right = getMutableClone(node.right); - return createPropertyAccess(left, right, node); - } - else { - return getMutableClone(node); - } - } - ts.createExpressionFromEntityName = createExpressionFromEntityName; - function createExpressionForPropertyName(memberName) { - if (ts.isIdentifier(memberName)) { - return createLiteral(memberName, undefined); - } - else if (ts.isComputedPropertyName(memberName)) { - return getMutableClone(memberName.expression); - } - else { - return getMutableClone(memberName); - } - } - ts.createExpressionForPropertyName = createExpressionForPropertyName; - function createExpressionForObjectLiteralElementLike(node, property, receiver) { - switch (property.kind) { - case 151: - case 152: - return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 258: - return createExpressionForPropertyAssignment(property, receiver); - case 259: - return createExpressionForShorthandPropertyAssignment(property, receiver); - case 149: - return createExpressionForMethodDeclaration(property, receiver); - } - } - ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike; - function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { - var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; - if (property === firstAccessor) { - var properties_1 = []; - if (getAccessor) { - var getterFunction = createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); - setOriginalNode(getterFunction, getAccessor); - var getter = createPropertyAssignment("get", getterFunction); - properties_1.push(getter); - } - if (setAccessor) { - var setterFunction = createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); - setOriginalNode(setterFunction, setAccessor); - var setter = createPropertyAssignment("set", setterFunction); - properties_1.push(setter); - } - properties_1.push(createPropertyAssignment("enumerable", createLiteral(true))); - properties_1.push(createPropertyAssignment("configurable", createLiteral(true))); - var expression = createCall(createPropertyAccess(createIdentifier("Object"), "defineProperty"), undefined, [ - receiver, - createExpressionForPropertyName(property.name), - createObjectLiteral(properties_1, undefined, multiLine) - ], firstAccessor); - return ts.aggregateTransformFlags(expression); - } - return undefined; - } - function createExpressionForPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer, property), property)); - } - function createExpressionForShorthandPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), getSynthesizedClone(property.name), property), property)); - } - function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); - } - function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384); - } - ts.getLocalName = getLocalName; - function isLocalName(node) { - return (getEmitFlags(node) & 16384) !== 0; - } - ts.isLocalName = isLocalName; - function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 8192); - } - ts.getExportName = getExportName; - function isExportName(node) { - return (getEmitFlags(node) & 8192) !== 0; - } - ts.isExportName = isExportName; - function getDeclarationName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps); - } - ts.getDeclarationName = getDeclarationName; - function getName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { - var name_9 = getMutableClone(node.name); - emitFlags |= getEmitFlags(node.name); - if (!allowSourceMaps) - emitFlags |= 48; - if (!allowComments) - emitFlags |= 1536; - if (emitFlags) - setEmitFlags(name_9, emitFlags); - return name_9; - } - return getGeneratedNameForNode(node); - } - function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && ts.hasModifier(node, 1)) { - return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); - } - return getExportName(node, allowComments, allowSourceMaps); - } - ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; - function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { - var qualifiedName = createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : getSynthesizedClone(name), name); - var emitFlags; - if (!allowSourceMaps) - emitFlags |= 48; - if (!allowComments) - emitFlags |= 1536; - if (emitFlags) - setEmitFlags(qualifiedName, emitFlags); - return qualifiedName; - } - ts.getNamespaceMemberName = getNamespaceMemberName; - function convertToFunctionBody(node, multiLine) { - return ts.isBlock(node) ? node : createBlock([createReturn(node, node)], node, multiLine); - } - ts.convertToFunctionBody = convertToFunctionBody; - function isUseStrictPrologue(node) { - return node.expression.text === "use strict"; - } - function addPrologueDirectives(target, source, ensureUseStrict, visitor) { - ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); - var foundUseStrict = false; - var statementOffset = 0; - var numStatements = source.length; - while (statementOffset < numStatements) { - var statement = source[statementOffset]; - if (ts.isPrologueDirective(statement)) { - if (isUseStrictPrologue(statement)) { - foundUseStrict = true; - } - target.push(statement); - } - else { - break; - } - statementOffset++; - } - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - } - while (statementOffset < numStatements) { - var statement = source[statementOffset]; - if (getEmitFlags(statement) & 524288) { - target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); - } - else { - break; - } - statementOffset++; - } - return statementOffset; - } - ts.addPrologueDirectives = addPrologueDirectives; - function startsWithUseStrict(statements) { - var firstStatement = ts.firstOrUndefined(statements); - return firstStatement !== undefined - && ts.isPrologueDirective(firstStatement) - && isUseStrictPrologue(firstStatement); - } - ts.startsWithUseStrict = startsWithUseStrict; - function ensureUseStrict(statements) { - var foundUseStrict = false; - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; - if (ts.isPrologueDirective(statement)) { - if (isUseStrictPrologue(statement)) { - foundUseStrict = true; - break; - } - } - else { - break; - } - } - if (!foundUseStrict) { - return createNodeArray([ - startOnNewLine(createStatement(createLiteral("use strict"))) - ].concat(statements), statements); - } - return statements; - } - ts.ensureUseStrict = ensureUseStrict; - function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 183) { - return operand; - } - return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) - ? createParen(operand) - : operand; - } - ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; - function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(192, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(192, binaryOperator); - var emittedOperand = skipPartiallyEmittedExpressions(operand); - var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); - switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1: - if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 - && operand.kind === 195) { - return false; - } - return true; - case 1: - return false; - case 0: - if (isLeftSideOfBinary) { - return binaryOperatorAssociativity === 1; - } - else { - if (ts.isBinaryExpression(emittedOperand) - && emittedOperand.operatorToken.kind === binaryOperator) { - if (operatorHasAssociativeProperty(binaryOperator)) { - return false; - } - if (binaryOperator === 36) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; - if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { - return false; - } - } - } - var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0; - } - } - } - function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 38 - || binaryOperator === 48 - || binaryOperator === 47 - || binaryOperator === 49; - } - function getLiteralKindOfBinaryPlusOperand(node) { - node = skipPartiallyEmittedExpressions(node); - if (ts.isLiteralKind(node.kind)) { - return node.kind; - } - if (node.kind === 192 && node.operatorToken.kind === 36) { - if (node.cachedLiteralKind !== undefined) { - return node.cachedLiteralKind; - } - var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0; - node.cachedLiteralKind = literalKind; - return literalKind; - } - return 0; - } - function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(193, 54); - var emittedCondition = skipPartiallyEmittedExpressions(condition); - var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { - return createParen(condition); - } - return condition; - } - ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; - function parenthesizeSubexpressionOfConditionalExpression(e) { - return e.kind === 192 && e.operatorToken.kind === 25 - ? createParen(e) - : e; - } - function parenthesizeForNew(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - switch (emittedExpression.kind) { - case 179: - return createParen(expression); - case 180: - return emittedExpression.arguments - ? expression - : createParen(expression); - } - return parenthesizeForAccess(expression); - } - ts.parenthesizeForNew = parenthesizeForNew; - function parenthesizeForAccess(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 180 || emittedExpression.arguments) - && emittedExpression.kind !== 8) { - return expression; - } - return createParen(expression, expression); - } - ts.parenthesizeForAccess = parenthesizeForAccess; - function parenthesizePostfixOperand(operand) { - return ts.isLeftHandSideExpression(operand) - ? operand - : createParen(operand, operand); - } - ts.parenthesizePostfixOperand = parenthesizePostfixOperand; - function parenthesizePrefixOperand(operand) { - return ts.isUnaryExpression(operand) - ? operand - : createParen(operand, operand); - } - ts.parenthesizePrefixOperand = parenthesizePrefixOperand; - function parenthesizeListElements(elements) { - var result; - for (var i = 0; i < elements.length; i++) { - var element = parenthesizeExpressionForList(elements[i]); - if (result !== undefined || element !== elements[i]) { - if (result === undefined) { - result = elements.slice(0, i); - } - result.push(element); - } - } - if (result !== undefined) { - return createNodeArray(result, elements, elements.hasTrailingComma); - } - return elements; - } - function parenthesizeExpressionForList(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(192, 25); - return expressionPrecedence > commaPrecedence - ? expression - : createParen(expression, expression); - } - ts.parenthesizeExpressionForList = parenthesizeExpressionForList; - function parenthesizeExpressionForExpressionStatement(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - if (ts.isCallExpression(emittedExpression)) { - var callee = emittedExpression.expression; - var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 184 || kind === 185) { - var mutableCall = getMutableClone(emittedExpression); - mutableCall.expression = createParen(callee, callee); - return recreatePartiallyEmittedExpressions(expression, mutableCall); - } - } - else { - var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 176 || leftmostExpressionKind === 184) { - return createParen(expression, expression); - } - } - return expression; - } - ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; - function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { - if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { - var clone_1 = getMutableClone(originalOuterExpression); - clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); - return clone_1; - } - return newInnerExpression; - } - function getLeftmostExpression(node) { - while (true) { - switch (node.kind) { - case 191: - node = node.operand; - continue; - case 192: - node = node.left; - continue; - case 193: - node = node.condition; - continue; - case 179: - case 178: - case 177: - node = node.expression; - continue; - case 295: - node = node.expression; - continue; - } - return node; - } - } - function parenthesizeConciseBody(body) { - var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 176) { - return createParen(body, body); - } - return body; - } - ts.parenthesizeConciseBody = parenthesizeConciseBody; - function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 7; } - var previousNode; - do { - previousNode = node; - if (kinds & 1) { - node = skipParentheses(node); - } - if (kinds & 2) { - node = skipAssertions(node); - } - if (kinds & 4) { - node = skipPartiallyEmittedExpressions(node); - } - } while (previousNode !== node); - return node; - } - ts.skipOuterExpressions = skipOuterExpressions; - function skipParentheses(node) { - while (node.kind === 183) { - node = node.expression; - } - return node; - } - ts.skipParentheses = skipParentheses; - function skipAssertions(node) { - while (ts.isAssertionExpression(node)) { - node = node.expression; - } - return node; - } - ts.skipAssertions = skipAssertions; - function skipPartiallyEmittedExpressions(node) { - while (node.kind === 295) { - node = node.expression; - } - return node; - } - ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; - function startOnNewLine(node) { - node.startsOnNewLine = true; - return node; - } - ts.startOnNewLine = startOnNewLine; - function setOriginalNode(node, original) { - node.original = original; - if (original) { - var emitNode = original.emitNode; - if (emitNode) - node.emitNode = mergeEmitNode(emitNode, node.emitNode); - } - return node; - } - ts.setOriginalNode = setOriginalNode; - function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; - if (!destEmitNode) - destEmitNode = {}; - if (flags) - destEmitNode.flags = flags; - if (commentRange) - destEmitNode.commentRange = commentRange; - if (sourceMapRange) - destEmitNode.sourceMapRange = sourceMapRange; - if (tokenSourceMapRanges) - destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); - if (constantValue !== undefined) - destEmitNode.constantValue = constantValue; - if (helpers) - destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); - return destEmitNode; - } - function mergeTokenSourceMapRanges(sourceRanges, destRanges) { - if (!destRanges) - destRanges = ts.createMap(); - ts.copyProperties(sourceRanges, destRanges); - return destRanges; + function asToken(value) { + return typeof value === "number" ? createToken(value) : value; } function disposeEmitNodes(sourceFile) { sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); @@ -12609,7 +13237,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 262) { + if (node.kind === 264) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12620,6 +13248,14 @@ var ts; return node.emitNode; } ts.getOrCreateEmitNode = getOrCreateEmitNode; + function setTextRange(range, location) { + if (location) { + range.pos = location.pos; + range.end = location.end; + } + return range; + } + ts.setTextRange = setTextRange; function getEmitFlags(node) { var emitNode = node.emitNode; return emitNode && emitNode.flags; @@ -12648,7 +13284,7 @@ var ts; ts.getTokenSourceMapRange = getTokenSourceMapRange; function setTokenSourceMapRange(node, token, range) { var emitNode = getOrCreateEmitNode(node); - var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); + var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []); tokenSourceMapRanges[token] = range; return node; } @@ -12674,32 +13310,6 @@ var ts; return node; } ts.setConstantValue = setConstantValue; - function getExternalHelpersModuleName(node) { - var parseNode = ts.getOriginalNode(node, ts.isSourceFile); - var emitNode = parseNode && parseNode.emitNode; - return emitNode && emitNode.externalHelpersModuleName; - } - ts.getExternalHelpersModuleName = getExternalHelpersModuleName; - function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions) { - if (compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { - var externalHelpersModuleName = getExternalHelpersModuleName(node); - if (externalHelpersModuleName) { - return externalHelpersModuleName; - } - var helpers = getEmitHelpers(node); - if (helpers) { - for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { - var helper = helpers_1[_i]; - if (!helper.scoped) { - var parseNode = ts.getOriginalNode(node, ts.isSourceFile); - var emitNode = getOrCreateEmitNode(parseNode); - return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = createUniqueName(ts.externalHelpersModuleNameText)); - } - } - } - } - } - ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; function addEmitHelper(node, helper) { var emitNode = getOrCreateEmitNode(node); emitNode.helpers = ts.append(emitNode.helpers, helper); @@ -12709,8 +13319,8 @@ var ts; function addEmitHelpers(node, helpers) { if (ts.some(helpers)) { var emitNode = getOrCreateEmitNode(node); - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { + var helper = helpers_1[_i]; if (!ts.contains(emitNode.helpers, helper)) { emitNode.helpers = ts.append(emitNode.helpers, helper); } @@ -12771,40 +13381,725 @@ var ts; return ts.compareValues(x.priority, y.priority); } ts.compareEmitHelpers = compareEmitHelpers; - function setTextRange(node, location) { - if (location) { - node.pos = location.pos; - node.end = location.end; + function setOriginalNode(node, original) { + node.original = original; + if (original) { + var emitNode = original.emitNode; + if (emitNode) + node.emitNode = mergeEmitNode(emitNode, node.emitNode); } return node; } - ts.setTextRange = setTextRange; - function setNodeFlags(node, flags) { - node.flags = flags; + ts.setOriginalNode = setOriginalNode; + function mergeEmitNode(sourceEmitNode, destEmitNode) { + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; + if (!destEmitNode) + destEmitNode = {}; + if (flags) + destEmitNode.flags = flags; + if (commentRange) + destEmitNode.commentRange = commentRange; + if (sourceMapRange) + destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + if (constantValue !== undefined) + destEmitNode.constantValue = constantValue; + if (helpers) + destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); + return destEmitNode; + } + function mergeTokenSourceMapRanges(sourceRanges, destRanges) { + if (!destRanges) + destRanges = []; + for (var key in sourceRanges) { + destRanges[key] = sourceRanges[key]; + } + return destRanges; + } +})(ts || (ts = {})); +(function (ts) { + function createTypeCheck(value, tag) { + return tag === "undefined" + ? ts.createStrictEquality(value, ts.createVoidZero()) + : ts.createStrictEquality(ts.createTypeOf(value), ts.createLiteral(tag)); + } + ts.createTypeCheck = createTypeCheck; + function createMemberAccessForPropertyName(target, memberName, location) { + if (ts.isComputedPropertyName(memberName)) { + return ts.setTextRange(ts.createElementAccess(target, memberName.expression), location); + } + else { + var expression = ts.setTextRange(ts.isIdentifier(memberName) + ? ts.createPropertyAccess(target, memberName) + : ts.createElementAccess(target, memberName), memberName); + ts.getOrCreateEmitNode(expression).flags |= 64; + return expression; + } + } + ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; + function createFunctionCall(func, thisArg, argumentsList, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), undefined, [ + thisArg + ].concat(argumentsList)), location); + } + ts.createFunctionCall = createFunctionCall; + function createFunctionApply(func, thisArg, argumentsExpression, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "apply"), undefined, [ + thisArg, + argumentsExpression + ]), location); + } + ts.createFunctionApply = createFunctionApply; + function createArraySlice(array, start) { + var argumentsList = []; + if (start !== undefined) { + argumentsList.push(typeof start === "number" ? ts.createLiteral(start) : start); + } + return ts.createCall(ts.createPropertyAccess(array, "slice"), undefined, argumentsList); + } + ts.createArraySlice = createArraySlice; + function createArrayConcat(array, values) { + return ts.createCall(ts.createPropertyAccess(array, "concat"), undefined, values); + } + ts.createArrayConcat = createArrayConcat; + function createMathPow(left, right, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Math"), "pow"), undefined, [left, right]), location); + } + ts.createMathPow = createMathPow; + function createReactNamespace(reactNamespace, parent) { + var react = ts.createIdentifier(reactNamespace || "React"); + react.flags &= ~8; + react.parent = ts.getParseTreeNode(parent); + return react; + } + function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { + if (ts.isQualifiedName(jsxFactory)) { + var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); + var right = ts.createIdentifier(jsxFactory.right.text); + right.text = jsxFactory.right.text; + return ts.createPropertyAccess(left, right); + } + else { + return createReactNamespace(jsxFactory.text, parent); + } + } + function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { + return jsxFactoryEntity ? + createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : + ts.createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); + } + function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { + var argumentsList = [tagName]; + if (props) { + argumentsList.push(props); + } + if (children && children.length > 0) { + if (!props) { + argumentsList.push(ts.createNull()); + } + if (children.length > 1) { + for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { + var child = children_1[_i]; + child.startsOnNewLine = true; + argumentsList.push(child); + } + } + else { + argumentsList.push(children[0]); + } + } + return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location); + } + ts.createExpressionForJsxElement = createExpressionForJsxElement; + function getHelperName(name) { + return ts.setEmitFlags(ts.createIdentifier(name), 4096 | 2); + } + ts.getHelperName = getHelperName; + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 221 + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; + function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { + var target = skipParentheses(node); + switch (target.kind) { + case 70: + return cacheIdentifiers; + case 98: + case 8: + case 9: + return false; + case 176: + var elements = target.elements; + if (elements.length === 0) { + return false; + } + return true; + case 177: + return target.properties.length > 0; + default: + return true; + } + } + function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { + var callee = skipOuterExpressions(expression, 7); + var thisArg; + var target; + if (ts.isSuperProperty(callee)) { + thisArg = ts.createThis(); + target = callee; + } + else if (callee.kind === 96) { + thisArg = ts.createThis(); + target = languageVersion < 2 + ? ts.setTextRange(ts.createIdentifier("_super"), callee) + : callee; + } + else { + switch (callee.kind) { + case 178: { + if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); + ts.setTextRange(target, callee); + } + else { + thisArg = callee.expression; + target = callee; + } + break; + } + case 179: { + if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); + ts.setTextRange(target, callee); + } + else { + thisArg = callee.expression; + target = callee; + } + break; + } + default: { + thisArg = ts.createVoidZero(); + target = parenthesizeForAccess(expression); + break; + } + } + } + return { target: target, thisArg: thisArg }; + } + ts.createCallBinding = createCallBinding; + function inlineExpressions(expressions) { + return ts.reduceLeft(expressions, ts.createComma); + } + ts.inlineExpressions = inlineExpressions; + function createExpressionFromEntityName(node) { + if (ts.isQualifiedName(node)) { + var left = createExpressionFromEntityName(node.left); + var right = ts.getMutableClone(node.right); + return ts.setTextRange(ts.createPropertyAccess(left, right), node); + } + else { + return ts.getMutableClone(node); + } + } + ts.createExpressionFromEntityName = createExpressionFromEntityName; + function createExpressionForPropertyName(memberName) { + if (ts.isIdentifier(memberName)) { + return ts.createLiteral(memberName); + } + else if (ts.isComputedPropertyName(memberName)) { + return ts.getMutableClone(memberName.expression); + } + else { + return ts.getMutableClone(memberName); + } + } + ts.createExpressionForPropertyName = createExpressionForPropertyName; + function createExpressionForObjectLiteralElementLike(node, property, receiver) { + switch (property.kind) { + case 152: + case 153: + return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); + case 260: + return createExpressionForPropertyAssignment(property, receiver); + case 261: + return createExpressionForShorthandPropertyAssignment(property, receiver); + case 150: + return createExpressionForMethodDeclaration(property, receiver); + } + } + ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike; + function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { + var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + if (property === firstAccessor) { + var properties_1 = []; + if (getAccessor) { + var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body); + ts.setTextRange(getterFunction, getAccessor); + ts.setOriginalNode(getterFunction, getAccessor); + var getter = ts.createPropertyAssignment("get", getterFunction); + properties_1.push(getter); + } + if (setAccessor) { + var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body); + ts.setTextRange(setterFunction, setAccessor); + ts.setOriginalNode(setterFunction, setAccessor); + var setter = ts.createPropertyAssignment("set", setterFunction); + properties_1.push(setter); + } + properties_1.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_1.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + receiver, + createExpressionForPropertyName(property.name), + ts.createObjectLiteral(properties_1, multiLine) + ]), firstAccessor); + return ts.aggregateTransformFlags(expression); + } + return undefined; + } + function createExpressionForPropertyAssignment(property, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer), property), property)); + } + function createExpressionForShorthandPropertyAssignment(property, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), ts.getSynthesizedClone(property.name)), property), property)); + } + function createExpressionForMethodDeclaration(method, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body), method), method)), method), method)); + } + function getLocalName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 16384); + } + ts.getLocalName = getLocalName; + function isLocalName(node) { + return (ts.getEmitFlags(node) & 16384) !== 0; + } + ts.isLocalName = isLocalName; + function getExportName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 8192); + } + ts.getExportName = getExportName; + function isExportName(node) { + return (ts.getEmitFlags(node) & 8192) !== 0; + } + ts.isExportName = isExportName; + function getDeclarationName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps); + } + ts.getDeclarationName = getDeclarationName; + function getName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { + var name = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); + if (!allowSourceMaps) + emitFlags |= 48; + if (!allowComments) + emitFlags |= 1536; + if (emitFlags) + ts.setEmitFlags(name, emitFlags); + return name; + } + return ts.getGeneratedNameForNode(node); + } + function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { + if (ns && ts.hasModifier(node, 1)) { + return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); + } + return getExportName(node, allowComments, allowSourceMaps); + } + ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; + function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { + var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name)); + ts.setTextRange(qualifiedName, name); + var emitFlags; + if (!allowSourceMaps) + emitFlags |= 48; + if (!allowComments) + emitFlags |= 1536; + if (emitFlags) + ts.setEmitFlags(qualifiedName, emitFlags); + return qualifiedName; + } + ts.getNamespaceMemberName = getNamespaceMemberName; + function convertToFunctionBody(node, multiLine) { + return ts.isBlock(node) ? node : ts.setTextRange(ts.createBlock([ts.setTextRange(ts.createReturn(node), node)], multiLine), node); + } + ts.convertToFunctionBody = convertToFunctionBody; + function isUseStrictPrologue(node) { + return node.expression.text === "use strict"; + } + function addPrologueDirectives(target, source, ensureUseStrict, visitor) { + ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); + var foundUseStrict = false; + var statementOffset = 0; + var numStatements = source.length; + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + } + target.push(statement); + } + else { + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (ts.getEmitFlags(statement) & 524288) { + target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); + } + else { + break; + } + statementOffset++; + } + return statementOffset; + } + ts.addPrologueDirectives = addPrologueDirectives; + function startsWithUseStrict(statements) { + var firstStatement = ts.firstOrUndefined(statements); + return firstStatement !== undefined + && ts.isPrologueDirective(firstStatement) + && isUseStrictPrologue(firstStatement); + } + ts.startsWithUseStrict = startsWithUseStrict; + function ensureUseStrict(statements) { + var foundUseStrict = false; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + break; + } + } + else { + break; + } + } + if (!foundUseStrict) { + return ts.setTextRange(ts.createNodeArray([ + startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) + ].concat(statements)), statements); + } + return statements; + } + ts.ensureUseStrict = ensureUseStrict; + function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { + var skipped = skipPartiallyEmittedExpressions(operand); + if (skipped.kind === 184) { + return operand; + } + return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) + ? ts.createParen(operand) + : operand; + } + ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; + function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { + var binaryOperatorPrecedence = ts.getOperatorPrecedence(193, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(193, binaryOperator); + var emittedOperand = skipPartiallyEmittedExpressions(operand); + var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); + switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { + case -1: + if (!isLeftSideOfBinary + && binaryOperatorAssociativity === 1 + && operand.kind === 196) { + return false; + } + return true; + case 1: + return false; + case 0: + if (isLeftSideOfBinary) { + return binaryOperatorAssociativity === 1; + } + else { + if (ts.isBinaryExpression(emittedOperand) + && emittedOperand.operatorToken.kind === binaryOperator) { + if (operatorHasAssociativeProperty(binaryOperator)) { + return false; + } + if (binaryOperator === 36) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; + if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { + return false; + } + } + } + var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); + return operandAssociativity === 0; + } + } + } + function operatorHasAssociativeProperty(binaryOperator) { + return binaryOperator === 38 + || binaryOperator === 48 + || binaryOperator === 47 + || binaryOperator === 49; + } + function getLiteralKindOfBinaryPlusOperand(node) { + node = skipPartiallyEmittedExpressions(node); + if (ts.isLiteralKind(node.kind)) { + return node.kind; + } + if (node.kind === 193 && node.operatorToken.kind === 36) { + if (node.cachedLiteralKind !== undefined) { + return node.cachedLiteralKind; + } + var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); + var literalKind = ts.isLiteralKind(leftKind) + && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) + ? leftKind + : 0; + node.cachedLiteralKind = literalKind; + return literalKind; + } + return 0; + } + function parenthesizeForConditionalHead(condition) { + var conditionalPrecedence = ts.getOperatorPrecedence(194, 54); + var emittedCondition = skipPartiallyEmittedExpressions(condition); + var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { + return ts.createParen(condition); + } + return condition; + } + ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; + function parenthesizeSubexpressionOfConditionalExpression(e) { + return e.kind === 193 && e.operatorToken.kind === 25 + ? ts.createParen(e) + : e; + } + ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression; + function parenthesizeForNew(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + switch (emittedExpression.kind) { + case 180: + return ts.createParen(expression); + case 181: + return emittedExpression.arguments + ? expression + : ts.createParen(expression); + } + return parenthesizeForAccess(expression); + } + ts.parenthesizeForNew = parenthesizeForNew; + function parenthesizeForAccess(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + if (ts.isLeftHandSideExpression(emittedExpression) + && (emittedExpression.kind !== 181 || emittedExpression.arguments) + && emittedExpression.kind !== 8) { + return expression; + } + return ts.setTextRange(ts.createParen(expression), expression); + } + ts.parenthesizeForAccess = parenthesizeForAccess; + function parenthesizePostfixOperand(operand) { + return ts.isLeftHandSideExpression(operand) + ? operand + : ts.setTextRange(ts.createParen(operand), operand); + } + ts.parenthesizePostfixOperand = parenthesizePostfixOperand; + function parenthesizePrefixOperand(operand) { + return ts.isUnaryExpression(operand) + ? operand + : ts.setTextRange(ts.createParen(operand), operand); + } + ts.parenthesizePrefixOperand = parenthesizePrefixOperand; + function parenthesizeListElements(elements) { + var result; + for (var i = 0; i < elements.length; i++) { + var element = parenthesizeExpressionForList(elements[i]); + if (result !== undefined || element !== elements[i]) { + if (result === undefined) { + result = elements.slice(0, i); + } + result.push(element); + } + } + if (result !== undefined) { + return ts.setTextRange(ts.createNodeArray(result, elements.hasTrailingComma), elements); + } + return elements; + } + ts.parenthesizeListElements = parenthesizeListElements; + function parenthesizeExpressionForList(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); + var commaPrecedence = ts.getOperatorPrecedence(193, 25); + return expressionPrecedence > commaPrecedence + ? expression + : ts.setTextRange(ts.createParen(expression), expression); + } + ts.parenthesizeExpressionForList = parenthesizeExpressionForList; + function parenthesizeExpressionForExpressionStatement(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + if (ts.isCallExpression(emittedExpression)) { + var callee = emittedExpression.expression; + var kind = skipPartiallyEmittedExpressions(callee).kind; + if (kind === 185 || kind === 186) { + var mutableCall = ts.getMutableClone(emittedExpression); + mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); + return recreatePartiallyEmittedExpressions(expression, mutableCall); + } + } + else { + var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; + if (leftmostExpressionKind === 177 || leftmostExpressionKind === 185) { + return ts.setTextRange(ts.createParen(expression), expression); + } + } + return expression; + } + ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; + function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { + if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { + var clone_1 = ts.getMutableClone(originalOuterExpression); + clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); + return clone_1; + } + return newInnerExpression; + } + function getLeftmostExpression(node) { + while (true) { + switch (node.kind) { + case 192: + node = node.operand; + continue; + case 193: + node = node.left; + continue; + case 194: + node = node.condition; + continue; + case 180: + case 179: + case 178: + node = node.expression; + continue; + case 298: + node = node.expression; + continue; + } + return node; + } + } + function parenthesizeConciseBody(body) { + var emittedBody = skipPartiallyEmittedExpressions(body); + if (emittedBody.kind === 177) { + return ts.setTextRange(ts.createParen(body), body); + } + return body; + } + ts.parenthesizeConciseBody = parenthesizeConciseBody; + var OuterExpressionKinds; + (function (OuterExpressionKinds) { + OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; + OuterExpressionKinds[OuterExpressionKinds["Assertions"] = 2] = "Assertions"; + OuterExpressionKinds[OuterExpressionKinds["PartiallyEmittedExpressions"] = 4] = "PartiallyEmittedExpressions"; + OuterExpressionKinds[OuterExpressionKinds["All"] = 7] = "All"; + })(OuterExpressionKinds = ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); + function skipOuterExpressions(node, kinds) { + if (kinds === void 0) { kinds = 7; } + var previousNode; + do { + previousNode = node; + if (kinds & 1) { + node = skipParentheses(node); + } + if (kinds & 2) { + node = skipAssertions(node); + } + if (kinds & 4) { + node = skipPartiallyEmittedExpressions(node); + } + } while (previousNode !== node); return node; } - ts.setNodeFlags = setNodeFlags; - function setMultiLine(node, multiLine) { - node.multiLine = multiLine; + ts.skipOuterExpressions = skipOuterExpressions; + function skipParentheses(node) { + while (node.kind === 184) { + node = node.expression; + } return node; } - ts.setMultiLine = setMultiLine; - function setHasTrailingComma(nodes, hasTrailingComma) { - nodes.hasTrailingComma = hasTrailingComma; - return nodes; + ts.skipParentheses = skipParentheses; + function skipAssertions(node) { + while (ts.isAssertionExpression(node)) { + node = node.expression; + } + return node; } - ts.setHasTrailingComma = setHasTrailingComma; + ts.skipAssertions = skipAssertions; + function skipPartiallyEmittedExpressions(node) { + while (node.kind === 298) { + node = node.expression; + } + return node; + } + ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; + function startOnNewLine(node) { + node.startsOnNewLine = true; + return node; + } + ts.startOnNewLine = startOnNewLine; + function getExternalHelpersModuleName(node) { + var parseNode = ts.getOriginalNode(node, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return emitNode && emitNode.externalHelpersModuleName; + } + ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions) { + if (compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { + var externalHelpersModuleName = getExternalHelpersModuleName(node); + if (externalHelpersModuleName) { + return externalHelpersModuleName; + } + var helpers = ts.getEmitHelpers(node); + if (helpers) { + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var parseNode = ts.getOriginalNode(node, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = ts.createUniqueName(ts.externalHelpersModuleNameText)); + } + } + } + } + } + ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_10 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_10) ? name_10 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 236 && node.importClause) { - return getGeneratedNameForNode(node); + if (node.kind === 237 && node.importClause) { + return ts.getGeneratedNameForNode(node); } - if (node.kind === 242 && node.moduleSpecifier) { - return getGeneratedNameForNode(node); + if (node.kind === 243 && node.moduleSpecifier) { + return ts.getGeneratedNameForNode(node); } return undefined; } @@ -12814,26 +14109,24 @@ var ts; if (moduleName.kind === 9) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) - || getSynthesizedClone(moduleName); + || ts.getSynthesizedClone(moduleName); } return undefined; } ts.getExternalModuleNameLiteral = getExternalModuleNameLiteral; function tryRenameExternalModule(moduleName, sourceFile) { - if (sourceFile.renamedDependencies && ts.hasProperty(sourceFile.renamedDependencies, moduleName.text)) { - return createLiteral(sourceFile.renamedDependencies[moduleName.text]); - } - return undefined; + var rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text); + return rename && ts.createLiteral(rename); } function tryGetModuleNameFromFile(file, host, options) { if (!file) { return undefined; } if (file.moduleName) { - return createLiteral(file.moduleName); + return ts.createLiteral(file.moduleName); } if (!ts.isDeclarationFile(file) && (options.out || options.outFile)) { - return createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); + return ts.createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); } return undefined; } @@ -12867,11 +14160,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 258: - return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 259: - return bindingElement.name; case 260: + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); + case 261: + return bindingElement.name; + case 262: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -12887,11 +14180,11 @@ var ts; ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 144: - case 174: + case 145: + case 175: return bindingElement.dotDotDotToken; - case 196: - case 260: + case 197: + case 262: return bindingElement; } return undefined; @@ -12899,7 +14192,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 174: + case 175: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -12907,7 +14200,7 @@ var ts; : propertyName; } break; - case 258: + case 260: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -12915,7 +14208,7 @@ var ts; : propertyName; } break; - case 260: + case 262: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -12929,11 +14222,11 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 172: case 173: - case 175: - return name.elements; + case 174: case 176: + return name.elements; + case 177: return name.properties; } } @@ -12942,10 +14235,12 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpread(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpread(element.name), element), element); } var expression = convertToAssignmentElementTarget(element.name); - return element.initializer ? setOriginalNode(createAssignment(expression, element.initializer, element), element) : expression; + return element.initializer + ? ts.setOriginalNode(ts.setTextRange(ts.createAssignment(expression, element.initializer), element), element) + : expression; } ts.Debug.assertNode(element, ts.isExpression); return element; @@ -12955,14 +14250,14 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpreadAssignment(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpreadAssignment(element.name), element), element); } if (element.propertyName) { var expression = convertToAssignmentElementTarget(element.name); - return setOriginalNode(createPropertyAssignment(element.propertyName, element.initializer ? createAssignment(expression, element.initializer) : expression, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createPropertyAssignment(element.propertyName, element.initializer ? ts.createAssignment(expression, element.initializer) : expression), element), element); } ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createShorthandPropertyAssignment(element.name, element.initializer, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createShorthandPropertyAssignment(element.name, element.initializer), element), element); } ts.Debug.assertNode(element, ts.isObjectLiteralElementLike); return element; @@ -12970,18 +14265,18 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 173: - case 175: - return convertToArrayAssignmentPattern(node); - case 172: + case 174: case 176: + return convertToArrayAssignmentPattern(node); + case 173: + case 177: return convertToObjectAssignmentPattern(node); } } ts.convertToAssignmentPattern = convertToAssignmentPattern; function convertToObjectAssignmentPattern(node) { if (ts.isObjectBindingPattern(node)) { - return setOriginalNode(createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isObjectLiteralExpression); return node; @@ -12989,7 +14284,7 @@ var ts; ts.convertToObjectAssignmentPattern = convertToObjectAssignmentPattern; function convertToArrayAssignmentPattern(node) { if (ts.isArrayBindingPattern(node)) { - return setOriginalNode(createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isArrayLiteralExpression); return node; @@ -13005,30 +14300,30 @@ var ts; ts.convertToAssignmentElementTarget = convertToAssignmentElementTarget; function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) { var externalImports = []; - var exportSpecifiers = ts.createMap(); - var exportedBindings = ts.createMap(); + var exportSpecifiers = ts.createMultiMap(); + var exportedBindings = []; var uniqueExports = ts.createMap(); var exportedNames; var hasExportDefault = false; var exportEquals = undefined; var hasExportStarsToExportValues = false; var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions); - var externalHelpersImportDeclaration = externalHelpersModuleName && createImportDeclaration(undefined, undefined, createImportClause(undefined, createNamespaceImport(externalHelpersModuleName)), createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); if (externalHelpersImportDeclaration) { externalImports.push(externalHelpersImportDeclaration); } for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 236: + case 237: externalImports.push(node); break; - case 235: - if (node.moduleReference.kind === 246) { + case 236: + if (node.moduleReference.kind === 247) { externalImports.push(node); } break; - case 242: + case 243: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -13041,26 +14336,26 @@ var ts; else { for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - if (!uniqueExports[specifier.name.text]) { - var name_11 = specifier.propertyName || specifier.name; - ts.multiMapAdd(exportSpecifiers, name_11.text, specifier); - var decl = resolver.getReferencedImportDeclaration(name_11) - || resolver.getReferencedValueDeclaration(name_11); + if (!uniqueExports.get(specifier.name.text)) { + var name = specifier.propertyName || specifier.name; + exportSpecifiers.add(name.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); if (decl) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); } - uniqueExports[specifier.name.text] = true; + uniqueExports.set(specifier.name.text, true); exportedNames = ts.append(exportedNames, specifier.name); } } } break; - case 241: + case 242: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 206: + case 207: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13068,38 +14363,38 @@ var ts; } } break; - case 226: - if (ts.hasModifier(node, 1)) { - if (ts.hasModifier(node, 512)) { - if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); - hasExportDefault = true; - } - } - else { - var name_12 = node.name; - if (!uniqueExports[name_12.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_12); - uniqueExports[name_12.text] = true; - exportedNames = ts.append(exportedNames, name_12); - } - } - } - break; case 227: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { - var name_13 = node.name; - if (!uniqueExports[name_13.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_13); - uniqueExports[name_13.text] = true; - exportedNames = ts.append(exportedNames, name_13); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); + } + } + } + break; + case 228: + if (ts.hasModifier(node, 1)) { + if (ts.hasModifier(node, 512)) { + if (!hasExportDefault) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + hasExportDefault = true; + } + } + else { + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } @@ -13119,13 +14414,23 @@ var ts; } } else if (!ts.isGeneratedIdentifier(decl.name)) { - if (!uniqueExports[decl.name.text]) { - uniqueExports[decl.name.text] = true; + if (!uniqueExports.get(decl.name.text)) { + uniqueExports.set(decl.name.text, true); exportedNames = ts.append(exportedNames, decl.name); } } return exportedNames; } + function multiMapSparseArrayAdd(map, key, value) { + var values = map[key]; + if (values) { + values.push(value); + } + else { + map[key] = values = [value]; + } + return values; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -13134,13 +14439,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 262) { + if (kind === 264) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 141) { + else if (kind < 142) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -13176,28 +14481,29 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 141: + case 142: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 143: + case 144: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || + visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 259: + case 261: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 260: + case 262: return visitNode(cbNode, node.expression); - case 144: + case 145: + case 148: case 147: - case 146: - case 258: - case 224: - case 174: + case 260: + case 225: + case 175: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -13206,24 +14512,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 158: case 159: - case 153: + case 160: case 154: case 155: + case 156: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 184: - case 226: + case 153: case 185: + case 227: + case 186: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -13234,174 +14540,167 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 157: + case 158: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 156: + case 157: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 160: - return visitNode(cbNode, node.exprName); case 161: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 162: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 163: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 164: + return visitNodes(cbNodes, node.elementTypes); case 165: - return visitNodes(cbNodes, node.types); case 166: - case 168: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); + case 167: case 169: + return visitNode(cbNode, node.type); + case 170: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 170: + case 171: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 171: - return visitNode(cbNode, node.literal); case 172: + return visitNode(cbNode, node.literal); case 173: - return visitNodes(cbNodes, node.elements); - case 175: + case 174: return visitNodes(cbNodes, node.elements); case 176: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 177: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.name); + return visitNodes(cbNodes, node.properties); case 178: return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); + visitNode(cbNode, node.name); case 179: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); case 180: + case 181: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 181: + case 182: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 182: + case 183: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 183: - return visitNode(cbNode, node.expression); - case 186: + case 184: return visitNode(cbNode, node.expression); case 187: return visitNode(cbNode, node.expression); case 188: return visitNode(cbNode, node.expression); - case 190: - return visitNode(cbNode, node.operand); - case 195: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 189: return visitNode(cbNode, node.expression); case 191: return visitNode(cbNode, node.operand); + case 196: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 190: + return visitNode(cbNode, node.expression); case 192: + return visitNode(cbNode, node.operand); + case 193: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 200: + case 201: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 201: - return visitNode(cbNode, node.expression); case 202: + return visitNode(cbNode, node.expression); + case 203: return visitNode(cbNode, node.name); - case 193: + case 194: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 196: + case 197: return visitNode(cbNode, node.expression); - case 205: - case 232: + case 206: + case 233: return visitNodes(cbNodes, node.statements); - case 262: + case 264: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 206: + case 207: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 225: + case 226: return visitNodes(cbNodes, node.declarations); - case 208: - return visitNode(cbNode, node.expression); case 209: + return visitNode(cbNode, node.expression); + case 210: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 210: + case 211: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 211: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 212: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 213: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 214: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 215: - case 216: - return visitNode(cbNode, node.label); - case 217: - return visitNode(cbNode, node.expression); - case 218: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 216: + case 217: + return visitNode(cbNode, node.label); + case 218: + return visitNode(cbNode, node.expression); case 219: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 220: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 233: + case 234: return visitNodes(cbNodes, node.clauses); - case 254: + case 256: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 255: + case 257: return visitNodes(cbNodes, node.statements); - case 220: + case 221: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 221: - return visitNode(cbNode, node.expression); case 222: + return visitNode(cbNode, node.expression); + case 223: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 257: + case 259: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 145: + case 146: return visitNode(cbNode, node.expression); - case 227: - case 197: - 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 228: + case 198: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13413,144 +14712,153 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 230: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 261: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 231: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 263: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 232: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 235: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 236: + case 237: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 237: + case 238: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 234: - return visitNode(cbNode, node.name); - case 238: + case 235: return visitNode(cbNode, node.name); case 239: - case 243: + return visitNode(cbNode, node.name); + case 240: + case 244: return visitNodes(cbNodes, node.elements); - case 242: + case 243: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 240: - case 244: + case 241: + case 245: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 241: + case 242: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 194: + case 195: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 203: + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 142: + case 143: return visitNode(cbNode, node.expression); - case 256: + case 258: return visitNodes(cbNodes, node.types); - case 199: + case 200: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 246: - return visitNode(cbNode, node.expression); - case 245: - return visitNodes(cbNodes, node.decorators); case 247: + return visitNode(cbNode, node.expression); + case 246: + return visitNodes(cbNodes, node.decorators); + case 248: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 248: case 249: + case 250: return visitNode(cbNode, node.tagName) || - visitNodes(cbNodes, node.attributes); - case 251: + visitNode(cbNode, node.attributes); + case 253: + return visitNodes(cbNodes, node.properties); + case 252: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 252: + case 254: return visitNode(cbNode, node.expression); - case 253: + case 255: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 250: + case 251: return visitNode(cbNode, node.tagName); - case 263: - return visitNode(cbNode, node.type); - case 267: - return visitNodes(cbNodes, node.types); - case 268: - return visitNodes(cbNodes, node.types); case 266: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.type); case 270: - return visitNode(cbNode, node.type); - case 269: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); case 271: - return visitNode(cbNode, node.literal); + return visitNodes(cbNodes, node.types); + case 269: + return visitNode(cbNode, node.elementType); case 273: + return visitNode(cbNode, node.type); + case 272: + return visitNode(cbNode, node.type); + case 274: + return visitNode(cbNode, node.literal); + case 276: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 274: - return visitNode(cbNode, node.type); - case 275: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 276: - return visitNode(cbNode, node.type); case 277: return visitNode(cbNode, node.type); case 278: - return visitNode(cbNode, node.type); - case 272: - return visitNode(cbNode, node.name) || + return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); case 279: - return visitNodes(cbNodes, node.tags); + return visitNode(cbNode, node.type); + case 280: + return visitNode(cbNode, node.type); + case 281: + return visitNode(cbNode, node.type); + case 275: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.type); case 282: + return visitNodes(cbNodes, node.tags); + case 285: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 283: + case 286: + return visitNode(cbNode, node.typeExpression); + case 287: return visitNode(cbNode, node.typeExpression); case 284: return visitNode(cbNode, node.typeExpression); - case 281: - return visitNode(cbNode, node.typeExpression); - case 285: + case 288: return visitNodes(cbNodes, node.typeParameters); - case 286: + case 289: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 288: + case 291: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 287: + case 290: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 295: + case 298: return visitNode(cbNode, node.expression); - case 289: + case 292: return visitNode(cbNode, node.literal); } } @@ -13714,7 +15022,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(262, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(264, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -13941,7 +15249,7 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 141 ? new NodeConstructor(kind, pos, pos) : + return kind >= 142 ? new NodeConstructor(kind, pos, pos) : kind === 70 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } @@ -13978,7 +15286,11 @@ var ts; } function internIdentifier(text) { text = ts.escapeIdentifier(text); - return identifiers[text] || (identifiers[text] = text); + var identifier = identifiers.get(text); + if (identifier === undefined) { + identifiers.set(text, identifier = text); + } + return identifier; } function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; @@ -14023,7 +15335,7 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(142); + var node = createNode(143); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); @@ -14328,14 +15640,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 150: - case 155: case 151: + case 156: case 152: - case 147: - case 204: + case 153: + case 148: + case 205: return true; - case 149: + case 150: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 70 && methodDeclaration.name.originalKeywordKind === 122; @@ -14347,8 +15659,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 254: - case 255: + case 256: + case 257: return true; } } @@ -14357,65 +15669,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 226: + case 227: + case 207: case 206: - case 205: + case 210: case 209: - case 208: - case 221: + case 222: + case 218: + case 220: case 217: - case 219: case 216: + case 214: case 215: case 213: - case 214: case 212: - case 211: - case 218: - case 207: - case 222: - case 220: - case 210: + case 219: + case 208: case 223: + case 221: + case 211: + case 224: + case 237: case 236: - case 235: + case 243: case 242: - case 241: - case 231: - case 227: + case 232: case 228: - case 230: case 229: + case 231: + case 230: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 261; + return node.kind === 263; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 154: - case 148: case 155: - case 146: - case 153: + case 149: + case 156: + case 147: + case 154: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 224) { + if (node.kind !== 225) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 144) { + if (node.kind !== 145) { return false; } var parameter = node; @@ -14511,7 +15823,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(22)) { - var node = createNode(141, entity.pos); + var node = createNode(142, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -14528,7 +15840,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(194); + var template = createNode(195); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -14540,7 +15852,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(203); + var span = createNode(204); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -14588,7 +15900,7 @@ var ts; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(157, typeName.pos); + var node = createNode(158, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token() === 26) { node.typeArguments = parseBracketedList(19, parseType, 26, 28); @@ -14597,24 +15909,24 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(156, lhs.pos); + var node = createNode(157, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(167); + var node = createNode(168); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(160); + var node = createNode(161); parseExpected(102); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(143); + var node = createNode(144); node.name = parseIdentifier(); if (parseOptional(84)) { if (isStartOfType() || !isStartOfExpression()) { @@ -14624,6 +15936,9 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } + if (parseOptional(57)) { + node.default = parseType(); + } return finishNode(node); } function parseTypeParameters() { @@ -14641,7 +15956,7 @@ var ts; return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; } function parseParameter() { - var node = createNode(144); + var node = createNode(145); if (token() === 98) { node.name = createIdentifier(true, undefined); node.type = parseParameterType(); @@ -14701,7 +16016,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 154) { + if (kind === 155) { parseExpected(93); } fillSignature(55, false, false, false, node); @@ -14741,7 +16056,7 @@ var ts; return token() === 55 || token() === 25 || token() === 21; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(155, fullStart); + var node = createNode(156, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.parameters = parseBracketedList(16, parseParameter, 20, 21); @@ -14753,7 +16068,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(54); if (token() === 18 || token() === 26) { - var method = createNode(148, fullStart); + var method = createNode(149, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; @@ -14762,7 +16077,7 @@ var ts; return addJSDocComment(finishNode(method)); } else { - var property = createNode(146, fullStart); + var property = createNode(147, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; @@ -14802,10 +16117,10 @@ var ts; } function parseTypeMember() { if (token() === 18 || token() === 26) { - return parseSignatureMember(153); + return parseSignatureMember(154); } if (token() === 93 && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(154); + return parseSignatureMember(155); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -14819,7 +16134,7 @@ var ts; return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(161); + var node = createNode(162); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -14842,14 +16157,14 @@ var ts; return token() === 20 && nextTokenIsIdentifier() && nextToken() === 91; } function parseMappedTypeParameter() { - var node = createNode(143); + var node = createNode(144); node.name = parseIdentifier(); parseExpected(91); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(170); + var node = createNode(171); parseExpected(16); node.readonlyToken = parseOptionalToken(130); parseExpected(20); @@ -14862,12 +16177,12 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(163); + var node = createNode(164); node.elementTypes = parseBracketedList(20, parseType, 20, 21); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(166); + var node = createNode(167); parseExpected(18); node.type = parseType(); parseExpected(19); @@ -14875,7 +16190,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 159) { + if (kind === 160) { parseExpected(93); } fillSignature(35, false, false, false, node); @@ -14886,7 +16201,7 @@ var ts; return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(171); + var node = createNode(172); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -14897,12 +16212,13 @@ var ts; function parseNonArrayType() { switch (token()) { case 118: - case 134: + case 135: case 132: case 121: - case 135: - case 137: + case 136: + case 138: case 129: + case 133: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: @@ -14939,12 +16255,12 @@ var ts; function isStartOfType() { switch (token()) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: case 104: - case 137: + case 138: case 94: case 98: case 102: @@ -14959,6 +16275,7 @@ var ts; case 8: case 100: case 85: + case 133: return true; case 37: return lookAhead(nextTokenIsNumericLiteral); @@ -14976,14 +16293,14 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { if (isStartOfType()) { - var node = createNode(169, type.pos); + var node = createNode(170, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(21); type = finishNode(node); } else { - var node = createNode(162, type.pos); + var node = createNode(163, type.pos); node.elementType = type; parseExpected(21); type = finishNode(node); @@ -14992,7 +16309,7 @@ var ts; return type; } function parseTypeOperator(operator) { - var node = createNode(168); + var node = createNode(169); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); @@ -15021,10 +16338,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(165, parseTypeOperatorOrHigher, 47); + return parseUnionOrIntersectionType(166, parseTypeOperatorOrHigher, 47); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(164, parseIntersectionTypeOrHigher, 48); + return parseUnionOrIntersectionType(165, parseIntersectionTypeOrHigher, 48); } function isStartOfFunctionType() { if (token() === 26) { @@ -15070,7 +16387,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(156, typePredicateVariable.pos); + var node = createNode(157, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -15091,10 +16408,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(158); + return parseFunctionOrConstructorType(159); } if (token() === 93) { - return parseFunctionOrConstructorType(159); + return parseFunctionOrConstructorType(160); } return parseUnionTypeOrHigher(); } @@ -15213,7 +16530,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(195); + var node = createNode(196); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 38 || isStartOfExpression())) { @@ -15229,13 +16546,13 @@ var ts; ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(185, asyncModifier.pos); + node = createNode(186, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(185, identifier.pos); + node = createNode(186, identifier.pos); } - var parameter = createNode(144, identifier.pos); + var parameter = createNode(145, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); @@ -15369,7 +16686,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(185); + var node = createNode(186); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); fillSignature(55, false, isAsync, !allowAmbiguity, node); @@ -15401,7 +16718,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(193, leftOperand.pos); + var node = createNode(194, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -15414,7 +16731,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 || t === 140; + return t === 91 || t === 141; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -15492,43 +16809,43 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(192, left.pos); + var node = createNode(193, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(200, left.pos); + var node = createNode(201, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(190); + var node = createNode(191); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(186); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(187); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(188); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(189); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { if (token() === 120) { if (inAwaitContext()) { @@ -15539,7 +16856,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(189); + var node = createNode(190); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15555,7 +16872,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 182) { + if (simpleUnaryExpression.kind === 183) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -15608,7 +16925,7 @@ var ts; } function parseIncrementExpression() { if (token() === 42 || token() === 43) { - var node = createNode(190); + var node = createNode(191); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -15620,7 +16937,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(191, expression.pos); + var node = createNode(192, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -15643,7 +16960,7 @@ var ts; if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(177, expression.pos); + var node = createNode(178, expression.pos); node.expression = expression; parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -15665,8 +16982,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 249) { - var node = createNode(247, opening.pos); + if (opening.kind === 250) { + var node = createNode(248, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -15676,14 +16993,14 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 248); + ts.Debug.assert(opening.kind === 249); result = opening; } if (inExpressionContext && token() === 26) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(192, result.pos); + var badNode = createNode(193, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -15729,14 +17046,19 @@ var ts; parsingContext = saveParsingContext; return result; } + function parseJsxAttributes() { + var jsxAttributes = createNode(253); + jsxAttributes.properties = parseList(13, parseJsxAttribute); + return finishNode(jsxAttributes); + } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); parseExpected(26); var tagName = parseJsxElementName(); - var attributes = parseList(13, parseJsxAttribute); + var attributes = parseJsxAttributes(); var node; if (token() === 28) { - node = createNode(249, fullStart); + node = createNode(250, fullStart); scanJsxText(); } else { @@ -15748,7 +17070,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(248, fullStart); + node = createNode(249, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -15759,7 +17081,7 @@ var ts; var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22)) { - var propertyAccess = createNode(177, expression.pos); + var propertyAccess = createNode(178, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -15767,7 +17089,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(253); + var node = createNode(255); parseExpected(16); if (token() !== 17) { node.dotDotDotToken = parseOptionalToken(23); @@ -15787,7 +17109,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(251); + var node = createNode(252); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -15802,7 +17124,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(252); + var node = createNode(254); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -15810,7 +17132,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(250); + var node = createNode(251); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -15823,7 +17145,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(182); + var node = createNode(183); parseExpected(26); node.type = parseType(); parseExpected(28); @@ -15834,7 +17156,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(177, expression.pos); + var propertyAccess = createNode(178, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -15842,13 +17164,13 @@ var ts; } if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(201, expression.pos); + var nonNullExpression = createNode(202, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(20)) { - var indexedAccess = createNode(178, expression.pos); + var indexedAccess = createNode(179, expression.pos); indexedAccess.expression = expression; if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -15862,7 +17184,7 @@ var ts; continue; } if (token() === 12 || token() === 13) { - var tagExpression = createNode(181, expression.pos); + var tagExpression = createNode(182, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 ? parseLiteralNode() @@ -15881,7 +17203,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(179, expression.pos); + var callExpr = createNode(180, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -15889,7 +17211,7 @@ var ts; continue; } else if (token() === 18) { - var callExpr = createNode(179, expression.pos); + var callExpr = createNode(180, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -15984,28 +17306,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(183); + var node = createNode(184); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(196); + var node = createNode(197); parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 ? parseSpreadElement() : - token() === 25 ? createNode(198) : + token() === 25 ? createNode(199) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(175); + var node = createNode(176); parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16016,18 +17338,18 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(124)) { - return parseAccessorDeclaration(151, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(133)) { return parseAccessorDeclaration(152, fullStart, decorators, modifiers); } + else if (parseContextualModifier(134)) { + return parseAccessorDeclaration(153, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23); if (dotDotDotToken) { - var spreadElement = createNode(260, fullStart); + var spreadElement = createNode(262, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -16046,7 +17368,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(259, fullStart); + var shorthandDeclaration = createNode(261, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -16057,7 +17379,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(258, fullStart); + var propertyAssignment = createNode(260, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -16067,7 +17389,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(176); + var node = createNode(177); parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16081,7 +17403,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(184); + var node = createNode(185); node.modifiers = parseModifiers(); parseExpected(88); node.asteriskToken = parseOptionalToken(38); @@ -16106,12 +17428,12 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(93); if (parseOptional(22)) { - var node_1 = createNode(202, fullStart); + var node_1 = createNode(203, fullStart); node_1.keywordToken = 93; node_1.name = parseIdentifierName(); return finishNode(node_1); } - var node = createNode(180, fullStart); + var node = createNode(181, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18) { @@ -16120,7 +17442,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(205); + var node = createNode(206); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16151,12 +17473,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(207); + var node = createNode(208); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(209); + var node = createNode(210); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16166,7 +17488,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(210); + var node = createNode(211); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -16177,7 +17499,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(211); + var node = createNode(212); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16200,21 +17522,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(213, pos); + var forInStatement = createNode(214, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(140)) { - var forOfStatement = createNode(214, pos); + else if (parseOptional(141)) { + var forOfStatement = createNode(215, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(212, pos); + var forStatement = createNode(213, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -16232,7 +17554,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 216 ? 71 : 76); + parseExpected(kind === 217 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16240,7 +17562,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(217); + var node = createNode(218); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -16249,7 +17571,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(218); + var node = createNode(219); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16258,7 +17580,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(254); + var node = createNode(256); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -16266,7 +17588,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(255); + var node = createNode(257); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -16276,12 +17598,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(219); + var node = createNode(220); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(233, scanner.getStartPos()); + var caseBlock = createNode(234, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -16289,14 +17611,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(221); + var node = createNode(222); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(222); + var node = createNode(223); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -16307,7 +17629,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(257); + var result = createNode(259); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -16317,7 +17639,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(223); + var node = createNode(224); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -16326,13 +17648,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(220, fullStart); + var labeledStatement = createNode(221, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(208, fullStart); + var expressionStatement = createNode(209, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16361,7 +17683,7 @@ var ts; case 82: return true; case 108: - case 136: + case 137: return nextTokenIsIdentifierOnSameLine(); case 127: case 128: @@ -16378,7 +17700,7 @@ var ts; return false; } continue; - case 139: + case 140: nextToken(); return token() === 16 || token() === 70 || token() === 83; case 90: @@ -16438,8 +17760,8 @@ var ts; case 108: case 127: case 128: - case 136: - case 139: + case 137: + case 140: return true; case 113: case 111: @@ -16484,9 +17806,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(215); - case 71: return parseBreakOrContinueStatement(216); + case 71: + return parseBreakOrContinueStatement(217); case 95: return parseReturnStatement(); case 106: @@ -16505,7 +17827,7 @@ var ts; return parseDeclaration(); case 119: case 108: - case 136: + case 137: case 127: case 128: case 123: @@ -16519,7 +17841,7 @@ var ts; case 116: case 114: case 130: - case 139: + case 140: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -16542,11 +17864,11 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 108: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 136: + case 137: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 82: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 139: + case 140: case 127: case 128: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -16565,7 +17887,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(245, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(246, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -16586,16 +17908,16 @@ var ts; } function parseArrayBindingElement() { if (token() === 25) { - return createNode(198); + return createNode(199); } - var node = createNode(174); + var node = createNode(175); node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(174); + var node = createNode(175); node.dotDotDotToken = parseOptionalToken(23); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -16611,14 +17933,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(172); + var node = createNode(173); parseExpected(16); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(173); + var node = createNode(174); parseExpected(20); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(21); @@ -16637,7 +17959,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(224); + var node = createNode(225); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -16646,7 +17968,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(225); + var node = createNode(226); switch (token()) { case 103: break; @@ -16660,7 +17982,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token() === 140 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 141 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -16675,7 +17997,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(206, fullStart); + var node = createNode(207, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -16683,7 +18005,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -16696,7 +18018,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(150, pos); + var node = createNode(151, pos); node.decorators = decorators; node.modifiers = modifiers; parseExpected(122); @@ -16705,7 +18027,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(149, fullStart); + var method = createNode(150, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -16718,7 +18040,7 @@ var ts; return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(147, fullStart); + var property = createNode(148, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -16788,7 +18110,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 133 || idToken === 124) { + if (!ts.isKeyword(idToken) || idToken === 134 || idToken === 124) { return true; } switch (token()) { @@ -16811,7 +18133,7 @@ var ts; if (!parseOptional(56)) { break; } - var decorator = createNode(145, decoratorStart); + var decorator = createNode(146, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -16868,7 +18190,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(204); + var result = createNode(205); nextToken(); return finishNode(result); } @@ -16893,16 +18215,16 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_14 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_14, undefined); + var name = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 197); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 198); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 227); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 228); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -16937,7 +18259,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 || token() === 107) { - var node = createNode(256); + var node = createNode(258); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -16946,7 +18268,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(199); + var node = createNode(200); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26) { node.typeArguments = parseBracketedList(19, parseType, 26, 28); @@ -16960,7 +18282,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228, fullStart); + var node = createNode(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -16971,10 +18293,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(136); + parseExpected(137); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57); @@ -16983,13 +18305,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(261, scanner.getStartPos()); + var node = createNode(263, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -17004,7 +18326,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(232, scanner.getStartPos()); + var node = createNode(233, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -17015,7 +18337,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(231, fullStart); + var node = createNode(232, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -17027,10 +18349,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(231, fullStart); + var node = createNode(232, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 139) { + if (token() === 140) { node.name = parseIdentifier(); node.flags |= 512; } @@ -17047,7 +18369,7 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 139) { + if (token() === 140) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } else if (parseOptional(128)) { @@ -17072,7 +18394,7 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(234, fullStart); + var exportDeclaration = createNode(235, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); @@ -17087,8 +18409,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 && token() !== 138) { - var importEqualsDeclaration = createNode(235, fullStart); + if (token() !== 25 && token() !== 139) { + var importEqualsDeclaration = createNode(236, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -17098,27 +18420,27 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(236, fullStart); + var importDeclaration = createNode(237, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || token() === 38 || token() === 16) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(138); + parseExpected(139); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(237, fullStart); + var importClause = createNode(238, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(239); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(240); } return finishNode(importClause); } @@ -17128,7 +18450,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(246); + var node = createNode(247); parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); @@ -17146,7 +18468,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(238); + var namespaceImport = createNode(239); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -17154,14 +18476,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 239 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 240 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(244); + return parseImportOrExportSpecifier(245); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(240); + return parseImportOrExportSpecifier(241); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17180,23 +18502,23 @@ var ts; else { node.name = identifierName; } - if (kind === 240 && checkIdentifierIsKeyword) { + if (kind === 241 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(242, fullStart); + var node = createNode(243, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38)) { - parseExpected(138); + parseExpected(139); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(243); - if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(138); + node.exportClause = parseNamedImportsOrExports(244); + if (token() === 139 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(139); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -17204,7 +18526,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(241, fullStart); + var node = createNode(242, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -17283,14 +18605,51 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 235 && node.moduleReference.kind === 246 - || node.kind === 236 - || node.kind === 241 + || node.kind === 236 && node.moduleReference.kind === 247 + || node.kind === 237 || node.kind === 242 + || node.kind === 243 ? node : undefined; }); } + var ParsingContext; + (function (ParsingContext) { + ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; + ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; + ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; + ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; + ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; + ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; + ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; + ParsingContext[ParsingContext["RestProperties"] = 17] = "RestProperties"; + ParsingContext[ParsingContext["TypeParameters"] = 18] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 19] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 20] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 21] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 22] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 23] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 24] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 25] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 26] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 27] = "Count"; + })(ParsingContext || (ParsingContext = {})); + var Tristate; + (function (Tristate) { + Tristate[Tristate["False"] = 0] = "False"; + Tristate[Tristate["True"] = 1] = "True"; + Tristate[Tristate["Unknown"] = 2] = "Unknown"; + })(Tristate || (Tristate = {})); var JSDocParser; (function (JSDocParser) { function isJSDocType() { @@ -17322,7 +18681,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(263, scanner.getTokenPos()); + var result = createNode(266, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -17333,12 +18692,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(267, type.pos); + var unionType = createNode(270, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(274, type.pos); + var optionalType = createNode(277, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -17349,20 +18708,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(266, type.pos); + var arrayType = createNode(269, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(269, type.pos); + var nullableType = createNode(272, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(270, type.pos); + var nonNullableType = createNode(273, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -17396,14 +18755,15 @@ var ts; case 98: return parseJSDocThisType(); case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: case 104: case 94: - case 137: + case 138: case 129: + case 133: return parseTokenNode(); case 9: case 8: @@ -17414,27 +18774,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(278); + var result = createNode(281); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(277); + var result = createNode(280); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(276); + var result = createNode(279); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(275); + var result = createNode(278); nextToken(); parseExpected(18); result.parameters = parseDelimitedList(23, parseJSDocParameter); @@ -17447,7 +18807,7 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(144); + var parameter = createNode(145); parameter.type = parseJSDocType(); if (parseOptional(57)) { parameter.questionToken = createNode(57); @@ -17455,7 +18815,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(273); + var result = createNode(276); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -17489,24 +18849,24 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(141, left.pos); + var result = createNode(142, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(271); + var result = createNode(274); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(270); + var result = createNode(273); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(268); + var result = createNode(271); nextToken(); result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); @@ -17520,7 +18880,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(267); + var result = createNode(270); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -17536,12 +18896,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(264); + var result = createNode(267); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(289); + var result = createNode(292); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -17554,11 +18914,11 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(265, pos); + var result = createNode(268, pos); return finishNode(result); } else { - var result = createNode(269, pos); + var result = createNode(272, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -17586,6 +18946,12 @@ var ts; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; + var JSDocState; + (function (JSDocState) { + JSDocState[JSDocState["BeginningOfLine"] = 0] = "BeginningOfLine"; + JSDocState[JSDocState["SawAsterisk"] = 1] = "SawAsterisk"; + JSDocState[JSDocState["SavingComments"] = 2] = "SavingComments"; + })(JSDocState || (JSDocState = {})); function parseJSDocCommentWorker(start, length) { var content = sourceText; start = start || 0; @@ -17702,7 +19068,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(279, start); + var result = createNode(282, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -17812,7 +19178,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(280, atToken.pos); + var result = createNode(283, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -17867,7 +19233,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(282, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -17878,20 +19244,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283; })) { + if (ts.forEach(tags, function (t) { return t.kind === 286; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283, atToken.pos); + var result = createNode(286, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284; })) { + if (ts.forEach(tags, function (t) { return t.kind === 287; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(284, atToken.pos); + var result = createNode(287, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -17906,7 +19272,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(287, atToken.pos); + var result = createNode(290, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -17915,7 +19281,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(281, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -17924,25 +19290,28 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(286, atToken.pos); + var typedefTag = createNode(289, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); if (typedefTag.fullName) { var rightNode = typedefTag.fullName; - while (rightNode.kind !== 70) { + while (true) { + if (rightNode.kind === 70 || !rightNode.body) { + typedefTag.name = rightNode.kind === 70 ? rightNode : rightNode.name; + break; + } rightNode = rightNode.body; } - typedefTag.name = rightNode; } typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 273) { + if (typeExpression.type.kind === 276) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { - var name_15 = jsDocTypeReference.name; - if (name_15.text === "Object") { + var name = jsDocTypeReference.name; + if (name.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -17956,7 +19325,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(288, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(291, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -17997,7 +19366,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(231, pos); + var jsDocNamespaceNode = createNode(232, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -18041,19 +19410,19 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 285; })) { + if (ts.forEach(tags, function (t) { return t.kind === 288; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); while (true) { - var name_16 = parseJSDocIdentifierName(); + var name = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_16) { + if (!name) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(143, name_16.pos); - typeParameter.name = name_16; + var typeParameter = createNode(144, name.pos); + typeParameter.name = name; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25) { @@ -18064,7 +19433,7 @@ var ts; break; } } - var result = createNode(285, atToken.pos); + var result = createNode(288, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -18378,21 +19747,31 @@ var ts; } } } + var InvalidPosition; + (function (InvalidPosition) { + InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; + })(InvalidPosition || (InvalidPosition = {})); })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); var ts; (function (ts) { + var ModuleInstanceState; + (function (ModuleInstanceState) { + ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; + ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; + ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; + })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); function getModuleInstanceState(node) { - if (node.kind === 228 || node.kind === 229) { + if (node.kind === 229 || node.kind === 230) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 236 || node.kind === 235) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 237 || node.kind === 236) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 232) { + else if (node.kind === 233) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -18408,7 +19787,7 @@ var ts; }); return state_1; } - else if (node.kind === 231) { + else if (node.kind === 232) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -18420,6 +19799,18 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; + var ContainerFlags; + (function (ContainerFlags) { + ContainerFlags[ContainerFlags["None"] = 0] = "None"; + ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; + ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; + ContainerFlags[ContainerFlags["IsControlFlowContainer"] = 4] = "IsControlFlowContainer"; + ContainerFlags[ContainerFlags["IsFunctionLike"] = 8] = "IsFunctionLike"; + ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; + ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; + ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; + ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; + })(ContainerFlags || (ContainerFlags = {})); var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -18517,7 +19908,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 231)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 232)) { symbol.valueDeclaration = node; } } @@ -18527,7 +19918,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 142) { + if (node.name.kind === 143) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression)) { return nameExpression.text; @@ -18538,21 +19929,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 150: + case 151: return "__constructor"; - case 158: - case 153: - return "__call"; case 159: case 154: - return "__new"; + return "__call"; + case 160: case 155: + return "__new"; + case 156: return "__index"; - case 242: + case 243: return "__export"; - case 241: + case 242: return node.isExportEquals ? "export=" : "default"; - case 192: + case 193: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -18564,20 +19955,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 226: case 227: + case 228: return ts.hasModifier(node, 512) ? "default" : undefined; - case 275: + case 278: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 144: - ts.Debug.assert(node.parent.kind === 275); + case 145: + ts.Debug.assert(node.parent.kind === 278); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 286: + case 289: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 206) { + if (parentNode && parentNode.kind === 207) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -18600,13 +19991,16 @@ var ts; symbol = createSymbol(0, "__missing"); } else { - symbol = symbolTable[name] || (symbolTable[name] = createSymbol(0, name)); + symbol = symbolTable.get(name); + if (!symbol) { + symbolTable.set(name, symbol = createSymbol(0, name)); + } if (name && (includes & 788448)) { - classifiableNames[name] = name; + classifiableNames.set(name, name); } if (symbol.flags & excludes) { if (symbol.isReplaceableByMethod) { - symbol = symbolTable[name] = createSymbol(0, name); + symbolTable.set(name, symbol = createSymbol(0, name)); } else { if (node.name) { @@ -18621,7 +20015,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 241 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 242 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -18641,7 +20035,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 244 || (node.kind === 235 && hasExportModifier)) { + if (node.kind === 245 || (node.kind === 236 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -18649,7 +20043,7 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 286 && + var isJSDocTypedefInJSDocNamespace = node.kind === 289 && node.name && node.name.kind === 70 && node.name.isInJSDocNamespace; @@ -18710,7 +20104,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 262) { + if (node.kind === 264) { node.flags |= emitFlags; } if (isIIFE) { @@ -18786,64 +20180,64 @@ var ts; return; } switch (node.kind) { - case 211: + case 212: bindWhileStatement(node); break; - case 210: + case 211: bindDoStatement(node); break; - case 212: + case 213: bindForStatement(node); break; - case 213: case 214: + case 215: bindForInOrForOfStatement(node); break; - case 209: + case 210: bindIfStatement(node); break; - case 217: - case 221: + case 218: + case 222: bindReturnOrThrow(node); break; + case 217: case 216: - case 215: bindBreakOrContinueStatement(node); break; - case 222: + case 223: bindTryStatement(node); break; - case 219: + case 220: bindSwitchStatement(node); break; - case 233: + case 234: bindCaseBlock(node); break; - case 254: + case 256: bindCaseClause(node); break; - case 220: + case 221: bindLabeledStatement(node); break; - case 190: + case 191: bindPrefixUnaryExpressionFlow(node); break; - case 191: + case 192: bindPostfixUnaryExpressionFlow(node); break; - case 192: + case 193: bindBinaryExpressionFlow(node); break; - case 186: + case 187: bindDeleteExpressionFlow(node); break; - case 193: + case 194: bindConditionalExpressionFlow(node); break; - case 224: + case 225: bindVariableDeclarationFlow(node); break; - case 179: + case 180: bindCallExpressionFlow(node); break; default: @@ -18855,15 +20249,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 177: + case 178: return isNarrowableReference(expr); - case 179: + case 180: return hasNarrowableArgument(expr); - case 183: + case 184: return isNarrowingExpression(expr.expression); - case 192: + case 193: return isNarrowingBinaryExpression(expr); - case 190: + case 191: return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; @@ -18871,7 +20265,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 || expr.kind === 98 || - expr.kind === 177 && isNarrowableReference(expr.expression); + expr.kind === 178 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -18882,14 +20276,14 @@ var ts; } } } - if (expr.expression.kind === 177 && + if (expr.expression.kind === 178 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 187 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 188 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -18910,9 +20304,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 183: + case 184: return isNarrowableOperand(expr.expression); - case 192: + case 193: switch (expr.operatorToken.kind) { case 57: return isNarrowableOperand(expr.left); @@ -19006,33 +20400,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 209: - case 211: case 210: - return parent.expression === node; case 212: - case 193: + case 211: + return parent.expression === node; + case 213: + case 194: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 183) { + if (node.kind === 184) { node = node.expression; } - else if (node.kind === 190 && node.operator === 50) { + else if (node.kind === 191 && node.operator === 50) { node = node.operand; } else { - return node.kind === 192 && (node.operatorToken.kind === 52 || + return node.kind === 193 && (node.operatorToken.kind === 52 || node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 183 || - node.parent.kind === 190 && + while (node.parent.kind === 184 || + node.parent.kind === 191 && node.parent.operator === 50) { node = node.parent; } @@ -19074,7 +20468,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 220 + var enclosingLabeledStatement = node.parent.kind === 221 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -19109,7 +20503,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 225) { + if (node.initializer.kind !== 226) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -19131,7 +20525,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 217) { + if (node.kind === 218) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -19151,7 +20545,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 216 ? breakTarget : continueTarget; + var flowLabel = node.kind === 217 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -19184,7 +20578,8 @@ var ts; flowAfterCatch = currentFlow; } if (node.finallyBlock) { - addAntecedent(preFinallyLabel, preTryFlow); + var preFinallyFlow = { flags: 2048, antecedent: preTryFlow, lock: {} }; + addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); if (!(currentFlow.flags & 1)) { @@ -19194,6 +20589,11 @@ var ts; : unreachableFlow; } } + if (!(currentFlow.flags & 1)) { + var afterFinallyFlow = { flags: 4096, antecedent: currentFlow }; + preFinallyFlow.lock = afterFinallyFlow; + currentFlow = afterFinallyFlow; + } } else { currentFlow = finishFlowLabel(preFinallyLabel); @@ -19208,7 +20608,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 255; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 257; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -19273,13 +20673,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 210) { + if (!node.statement || node.statement.kind !== 211) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 192 && node.operatorToken.kind === 57) { + if (node.kind === 193 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -19290,10 +20690,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 175) { + else if (node.kind === 176) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 196) { + if (e.kind === 197) { bindAssignmentTargetFlow(e.expression); } else { @@ -19301,16 +20701,16 @@ var ts; } } } - else if (node.kind === 176) { + else if (node.kind === 177) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 258) { + if (p.kind === 260) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 259) { + else if (p.kind === 261) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 260) { + else if (p.kind === 262) { bindAssignmentTargetFlow(p.expression); } } @@ -19366,7 +20766,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 57 && node.left.kind === 178) { + if (operator === 57 && node.left.kind === 179) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -19377,7 +20777,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 177) { + if (node.expression.kind === 178) { bindAssignmentTargetFlow(node.expression); } } @@ -19410,16 +20810,16 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 213 || node.parent.parent.kind === 214) { + if (node.initializer || node.parent.parent.kind === 214 || node.parent.parent.kind === 215) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 183) { + while (expr.kind === 184) { expr = expr.expression; } - if (expr.kind === 184 || expr.kind === 185) { + if (expr.kind === 185 || expr.kind === 186) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -19427,7 +20827,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 177) { + if (node.expression.kind === 178) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -19436,52 +20836,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 197: - case 227: - case 230: - case 176: - case 161: - case 288: - case 271: - return 1; + case 198: case 228: - return 1 | 64; - case 275: case 231: + case 177: + case 162: + case 291: + case 274: + case 253: + return 1; case 229: - case 170: + return 1 | 64; + case 278: + case 232: + case 230: + case 171: return 1 | 32; - case 262: + case 264: return 1 | 4 | 32; - case 149: + case 150: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 150: - case 226: - case 148: case 151: + case 227: + case 149: case 152: case 153: case 154: case 155: - case 158: + case 156: case 159: + case 160: return 1 | 4 | 32 | 8; - case 184: case 185: + case 186: return 1 | 4 | 32 | 8 | 16; - case 232: + case 233: return 4; - case 147: + case 148: return node.initializer ? 4 : 0; - case 257: - case 212: + case 259: case 213: case 214: - case 233: + case 215: + case 234: return 2; - case 205: + case 206: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -19497,37 +20898,38 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 231: + case 232: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 262: + case 264: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 197: - case 227: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 230: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 161: - case 176: + case 198: case 228: - case 271: - case 288: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 231: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 162: + case 177: + case 229: + case 274: + case 291: + case 253: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 158: case 159: - case 153: + case 160: case 154: case 155: - case 149: - case 148: + case 156: case 150: + case 149: case 151: case 152: - case 226: - case 184: + case 153: + case 227: case 185: - case 275: - case 229: - case 170: + case 186: + case 278: + case 230: + case 171: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -19542,11 +20944,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 262 ? node : node.body; - if (body && (body.kind === 262 || body.kind === 232)) { + var body = node.kind === 264 ? node : node.body; + if (body && (body.kind === 264 || body.kind === 233)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 242 || stat.kind === 241) { + if (stat.kind === 243 || stat.kind === 242) { return true; } } @@ -19568,7 +20970,7 @@ var ts; errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isExternalModuleAugmentation(node)) { - declareSymbolAndAddToSymbolTable(node, 1024, 0); + declareModuleSymbol(node); } else { var pattern = void 0; @@ -19588,12 +20990,8 @@ var ts; } } else { - var state = getModuleInstanceState(node); - if (state === 0) { - declareSymbolAndAddToSymbolTable(node, 1024, 0); - } - else { - declareSymbolAndAddToSymbolTable(node, 512, 106639); + var state = declareModuleSymbol(node); + if (state !== 0) { if (node.symbol.flags & (16 | 32 | 256)) { node.symbol.constEnumOnlyModule = false; } @@ -19609,29 +21007,40 @@ var ts; } } } + function declareModuleSymbol(node) { + var state = getModuleInstanceState(node); + var instantiated = state !== 0; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 : 1024, instantiated ? 106639 : 0); + return state; + } function bindFunctionOrConstructorType(node) { var symbol = createSymbol(131072, getDeclarationName(node)); addDeclarationToSymbol(symbol, node, 131072); var typeLiteralSymbol = createSymbol(2048, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048); typeLiteralSymbol.members = ts.createMap(); - typeLiteralSymbol.members[symbol.name] = symbol; + typeLiteralSymbol.members.set(symbol.name, symbol); } function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); if (inStrictMode) { var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 260 || prop.name.kind !== 70) { + if (prop.kind === 262 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 258 || prop.kind === 259 || prop.kind === 149 + var currentKind = prop.kind === 260 || prop.kind === 261 || prop.kind === 150 ? 1 : 2; - var existingKind = seen[identifier.text]; + var existingKind = seen.get(identifier.text); if (!existingKind) { - seen[identifier.text] = currentKind; + seen.set(identifier.text, currentKind); continue; } if (currentKind === 1 && existingKind === 1) { @@ -19642,16 +21051,22 @@ var ts; } return bindAnonymousDeclaration(node, 4096, "__object"); } + function bindJsxAttributes(node) { + return bindAnonymousDeclaration(node, 4096, "__jsxAttributes"); + } + function bindJsxAttribute(node, symbolFlags, symbolExcludes) { + return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 231: + case 232: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 262: + case 264: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -19741,8 +21156,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 262 && - blockScopeContainer.kind !== 231 && + if (blockScopeContainer.kind !== 264 && + blockScopeContainer.kind !== 232 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -19785,7 +21200,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 140) { + if (node.kind > 141) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -19825,23 +21240,23 @@ var ts; case 70: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 286) { + while (parentNode && parentNode.kind !== 289) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 259)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 261)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 177: + case 178: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 192: + case 193: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -19864,48 +21279,48 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 257: + case 259: return checkStrictModeCatchClause(node); - case 186: + case 187: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 191: + case 192: return checkStrictModePostfixUnaryExpression(node); - case 190: + case 191: return checkStrictModePrefixUnaryExpression(node); - case 218: + case 219: return checkStrictModeWithStatement(node); - case 167: + case 168: seenThisKeyword = true; return; - case 156: + case 157: return checkTypePredicate(node); - case 143: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 144: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 145: return bindParameter(node); - case 224: - case 174: + case 225: + case 175: return bindVariableDeclarationOrBindingElement(node); + case 148: case 147: - case 146: - case 272: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 287: + case 275: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 67108864 : 0), 0); + case 290: return bindJSDocProperty(node); - case 258: - case 259: - return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 261: - return bindPropertyOrMethodOrAccessor(node, 8, 900095); case 260: - case 252: + case 261: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 263: + return bindPropertyOrMethodOrAccessor(node, 8, 900095); + case 262: + case 254: var root = container; var hasRest = false; while (root.parent) { - if (root.kind === 176 && - root.parent.kind === 192 && + if (root.kind === 177 && + root.parent.kind === 193 && root.parent.operatorToken.kind === 57 && root.parent.left === root) { hasRest = true; @@ -19914,78 +21329,82 @@ var ts; root = root.parent; } return; - case 153: case 154: case 155: + case 156: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 149: - case 148: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 226: - return bindFunctionDeclaration(node); case 150: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 149: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 67108864 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); + case 227: + return bindFunctionDeclaration(node); case 151: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 152: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 153: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 158: case 159: - case 275: + case 160: + case 278: return bindFunctionOrConstructorType(node); - case 161: - case 170: - case 288: - case 271: + case 162: + case 171: + case 291: + case 274: return bindAnonymousDeclaration(node, 2048, "__type"); - case 176: + case 177: return bindObjectLiteralExpression(node); - case 184: case 185: + case 186: return bindFunctionExpression(node); - case 179: + case 180: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 197: - case 227: + case 198: + case 228: inStrictMode = true; return bindClassLikeDeclaration(node); - case 228: + case 229: return bindBlockScopedDeclaration(node, 64, 792968); - case 286: + case 289: if (!node.fullName || node.fullName.kind === 70) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 229: - return bindBlockScopedDeclaration(node, 524288, 793064); case 230: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 231: + return bindEnumDeclaration(node); + case 232: return bindModuleDeclaration(node); - case 235: - case 238: - case 240: - case 244: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 234: - return bindNamespaceExportDeclaration(node); - case 237: - return bindImportClause(node); - case 242: - return bindExportDeclaration(node); + case 253: + return bindJsxAttributes(node); + case 252: + return bindJsxAttribute(node, 4, 0); + case 236: + case 239: case 241: + case 245: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 235: + return bindNamespaceExportDeclaration(node); + case 238: + return bindImportClause(node); + case 243: + return bindExportDeclaration(node); + case 242: return bindExportAssignment(node); - case 262: + case 264: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 205: + case 206: if (!ts.isFunctionLike(node.parent)) { return; } - case 232: + case 233: return updateStrictModeStatementList(node.statements); } } @@ -19994,7 +21413,7 @@ var ts; if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 167) { + if (parameterName && parameterName.kind === 168) { seenThisKeyword = true; } bind(type); @@ -20013,7 +21432,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 241 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 242 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -20023,17 +21442,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 262) { + if (node.parent.kind !== 264) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_5 = node.parent; - if (!ts.isExternalModule(parent_5)) { + var parent_1 = node.parent; + if (!ts.isExternalModule(parent_1)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_5.isDeclarationFile) { + if (!parent_1.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -20043,10 +21462,10 @@ var ts; } function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { - bindAnonymousDeclaration(node, 1073741824, getDeclarationName(node)); + bindAnonymousDeclaration(node, 33554432, getDeclarationName(node)); } else if (!node.exportClause) { - declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); + declareSymbol(container.symbol.exports, container.symbol, node, 33554432, 0); } } function bindImportClause(node) { @@ -20072,11 +21491,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 226 || container.kind === 184) { + if (container.kind === 227 || container.kind === 185) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } - else if (container.kind === 150) { + else if (container.kind === 151) { var saveContainer = container; container = container.parent; var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); @@ -20093,7 +21512,7 @@ var ts; leftSideOfAssignment.parent = node; constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - var funcSymbol = container.locals[constructorFunction.text]; + var funcSymbol = container.locals.get(constructorFunction.text); if (!funcSymbol || !(funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { return; } @@ -20108,25 +21527,26 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 227) { + if (node.kind === 228) { bindBlockScopedDeclaration(node, 32, 899519); } else { var bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, 32, bindingName); if (node.name) { - classifiableNames[node.name.text] = node.name.text; + classifiableNames.set(node.name.text, node.name.text); } } var symbol = node.symbol; - var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); - if (symbol.exports[prototypeSymbol.name]) { + var prototypeSymbol = createSymbol(4 | 16777216, "prototype"); + var symbolExport = symbol.exports.get(prototypeSymbol.name); + if (symbolExport) { if (node.name) { node.name.parent = node; } - file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbolExport.declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; + symbol.exports.set(prototypeSymbol.name, prototypeSymbol); prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { @@ -20162,7 +21582,7 @@ var ts; } if (ts.isParameterPropertyDeclaration(node)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 536870912 : 0), 0); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 67108864 : 0), 0); } } function bindFunctionDeclaration(node) { @@ -20218,15 +21638,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 207) || - node.kind === 227 || - (node.kind === 231 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 230 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 208) || + node.kind === 228 || + (node.kind === 232 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 231 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 206 || + (node.kind !== 207 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -20240,56 +21660,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 179: - return computeCallExpression(node, subtreeFlags); case 180: + return computeCallExpression(node, subtreeFlags); + case 181: return computeNewExpression(node, subtreeFlags); - case 231: + case 232: return computeModuleDeclaration(node, subtreeFlags); - case 183: - return computeParenthesizedExpression(node, subtreeFlags); - case 192: - return computeBinaryExpression(node, subtreeFlags); - case 208: - return computeExpressionStatement(node, subtreeFlags); - case 144: - return computeParameter(node, subtreeFlags); - case 185: - return computeArrowFunction(node, subtreeFlags); case 184: + return computeParenthesizedExpression(node, subtreeFlags); + case 193: + return computeBinaryExpression(node, subtreeFlags); + case 209: + return computeExpressionStatement(node, subtreeFlags); + case 145: + return computeParameter(node, subtreeFlags); + case 186: + return computeArrowFunction(node, subtreeFlags); + case 185: return computeFunctionExpression(node, subtreeFlags); - case 226: - return computeFunctionDeclaration(node, subtreeFlags); - case 224: - return computeVariableDeclaration(node, subtreeFlags); - case 225: - return computeVariableDeclarationList(node, subtreeFlags); - case 206: - return computeVariableStatement(node, subtreeFlags); - case 220: - return computeLabeledStatement(node, subtreeFlags); case 227: + return computeFunctionDeclaration(node, subtreeFlags); + case 225: + return computeVariableDeclaration(node, subtreeFlags); + case 226: + return computeVariableDeclarationList(node, subtreeFlags); + case 207: + return computeVariableStatement(node, subtreeFlags); + case 221: + return computeLabeledStatement(node, subtreeFlags); + case 228: return computeClassDeclaration(node, subtreeFlags); - case 197: + case 198: return computeClassExpression(node, subtreeFlags); - case 256: + case 258: return computeHeritageClause(node, subtreeFlags); - case 257: + case 259: return computeCatchClause(node, subtreeFlags); - case 199: + case 200: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 150: - return computeConstructor(node, subtreeFlags); - case 147: - return computePropertyDeclaration(node, subtreeFlags); - case 149: - return computeMethod(node, subtreeFlags); case 151: + return computeConstructor(node, subtreeFlags); + case 148: + return computePropertyDeclaration(node, subtreeFlags); + case 150: + return computeMethod(node, subtreeFlags); case 152: + case 153: return computeAccessor(node, subtreeFlags); - case 235: + case 236: return computeImportEquals(node, subtreeFlags); - case 177: + case 178: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -20314,8 +21734,8 @@ var ts; switch (kind) { case 96: return true; - case 177: case 178: + case 179: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96; @@ -20337,10 +21757,10 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 && leftKind === 176) { + if (operatorTokenKind === 57 && leftKind === 177) { transformFlags |= 8 | 192 | 3072; } - else if (operatorTokenKind === 57 && leftKind === 175) { + else if (operatorTokenKind === 57 && leftKind === 176) { transformFlags |= 192 | 3072; } else if (operatorTokenKind === 39 @@ -20379,8 +21799,8 @@ var ts; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 200 - || expressionKind === 182) { + if (expressionKind === 201 + || expressionKind === 183) { transformFlags |= 3; } if (expressionTransformFlags & 1024) { @@ -20666,7 +22086,7 @@ var ts; var excludeFlags = 536872257; switch (kind) { case 119: - case 189: + case 190: transformFlags |= 16; break; case 113: @@ -20675,51 +22095,52 @@ var ts; case 116: case 123: case 75: - case 230: - case 261: - case 182: - case 200: + case 231: + case 263: + case 183: case 201: + case 202: case 130: transformFlags |= 3; break; - case 247: case 248: case 249: - case 10: case 250: + case 10: case 251: case 252: case 253: + case 254: + case 255: transformFlags |= 4; break; - case 214: + case 215: transformFlags |= 8; case 12: case 13: case 14: case 15: - case 194: - case 181: - case 259: + case 195: + case 182: + case 261: case 114: - case 202: + case 203: transformFlags |= 192; break; - case 195: + case 196: transformFlags |= 192 | 16777216; break; case 118: case 132: case 129: - case 134: - case 121: + case 133: case 135: + case 121: + case 136: case 104: - case 143: - case 146: - case 148: - case 153: + case 144: + case 147: + case 149: case 154: case 155: case 156: @@ -20733,26 +22154,27 @@ var ts; case 164: case 165: case 166: - case 228: - case 229: case 167: + case 229: + case 230: case 168: case 169: case 170: case 171: + case 172: transformFlags = 3; excludeFlags = -3; break; - case 142: + case 143: transformFlags |= 2097152; if (subtreeFlags & 16384) { transformFlags |= 65536; } break; - case 196: + case 197: transformFlags |= 192 | 524288; break; - case 260: + case 262: transformFlags |= 8 | 1048576; break; case 96: @@ -20761,27 +22183,27 @@ var ts; case 98: transformFlags |= 16384; break; - case 172: + case 173: transformFlags |= 192 | 8388608; if (subtreeFlags & 524288) { transformFlags |= 8 | 1048576; } excludeFlags = 537396545; break; - case 173: + case 174: transformFlags |= 192 | 8388608; excludeFlags = 537396545; break; - case 174: + case 175: transformFlags |= 192; if (node.dotDotDotToken) { transformFlags |= 524288; } break; - case 145: + case 146: transformFlags |= 3 | 4096; break; - case 176: + case 177: excludeFlags = 540087617; if (subtreeFlags & 2097152) { transformFlags |= 192; @@ -20793,29 +22215,29 @@ var ts; transformFlags |= 8; } break; - case 175: - case 180: + case 176: + case 181: excludeFlags = 537396545; if (subtreeFlags & 524288) { transformFlags |= 192; } break; - case 210: case 211: case 212: case 213: + case 214: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 262: + case 264: if (subtreeFlags & 32768) { transformFlags |= 192; } break; - case 217: - case 215: + case 218: case 216: + case 217: transformFlags |= 33554432; break; } @@ -20823,56 +22245,57 @@ var ts; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 156 && kind <= 171) { + if (kind >= 157 && kind <= 172) { return -3; } switch (kind) { - case 179: case 180: - case 175: + case 181: + case 176: return 537396545; - case 231: + case 232: return 574674241; - case 144: + case 145: return 536872257; - case 185: + case 186: return 601249089; - case 184: - case 226: - return 601281857; - case 225: - return 546309441; + case 185: case 227: - case 197: + return 601281857; + case 226: + return 546309441; + case 228: + case 198: return 539358529; - case 150: - return 601015617; - case 149: case 151: + return 601015617; + case 150: case 152: + case 153: return 601015617; case 118: case 132: case 129: - case 134: - case 121: case 135: + case 133: + case 121: + case 136: case 104: - case 143: - case 146: - case 148: - case 153: + case 144: + case 147: + case 149: case 154: case 155: - case 228: + case 156: case 229: + case 230: return -3; - case 176: + case 177: return 540087617; - case 257: + case 259: return 537920833; - case 172: case 173: + case 174: return 537396545; default: return 536872257; @@ -20921,9 +22344,9 @@ var ts; var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; var strictNullChecks = compilerOptions.strictNullChecks; var emitResolver = createResolver(); - var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); + var undefinedSymbol = createSymbol(4, "undefined"); undefinedSymbol.declarations = []; - var argumentsSymbol = createSymbol(4 | 67108864, "arguments"); + var argumentsSymbol = createSymbol(4, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, @@ -20944,6 +22367,7 @@ var ts; getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, getTypeFromTypeNode: getTypeFromTypeNode, + getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -20968,8 +22392,9 @@ var ts; getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getAmbientModules: getAmbientModules, - getJsxElementAttributesType: getJsxElementAttributesType, + getAllAttributesTypeFromJsxOpeningLikeElement: getAllAttributesTypeFromJsxOpeningLikeElement, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, isOptionalParameter: isOptionalParameter, tryGetMemberInModuleExports: tryGetMemberInModuleExports, @@ -20985,8 +22410,8 @@ var ts; var numericLiteralTypes = ts.createMap(); var indexedAccessTypes = ts.createMap(); var evolvingArrayTypes = []; - var unknownSymbol = createSymbol(4 | 67108864, "unknown"); - var resolvingSymbol = createSymbol(67108864, "__resolving__"); + var unknownSymbol = createSymbol(4, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__"); var anyType = createIntrinsicType(1, "any"); var autoType = createIntrinsicType(1, "any"); var unknownType = createIntrinsicType(1, "unknown"); @@ -21003,8 +22428,9 @@ var ts; var voidType = createIntrinsicType(1024, "void"); var neverType = createIntrinsicType(8192, "never"); var silentNeverType = createIntrinsicType(8192, "never"); + var nonPrimitiveType = createIntrinsicType(16777216, "object"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var emptyTypeLiteralSymbol = createSymbol(2048 | 67108864, "__type"); + var emptyTypeLiteralSymbol = createSymbol(2048, "__type"); emptyTypeLiteralSymbol.members = ts.createMap(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -21012,6 +22438,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); anyFunctionType.flags |= 8388608; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); @@ -21073,7 +22500,67 @@ var ts; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - var typeofEQFacts = ts.createMap({ + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; + TypeFacts[TypeFacts["Discriminatable"] = 4194304] = "Discriminatable"; + TypeFacts[TypeFacts["All"] = 8388607] = "All"; + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; + TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; + TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; + TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 6166480] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 8378320] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 6164448] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 8376288] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; + })(TypeFacts || (TypeFacts = {})); + var typeofEQFacts = ts.createMapFromTemplate({ "string": 1, "number": 2, "boolean": 4, @@ -21082,7 +22569,7 @@ var ts; "object": 16, "function": 32 }); - var typeofNEFacts = ts.createMap({ + var typeofNEFacts = ts.createMapFromTemplate({ "string": 128, "number": 256, "boolean": 512, @@ -21091,13 +22578,14 @@ var ts; "object": 2048, "function": 4096 }); - var typeofTypesByName = ts.createMap({ + var typeofTypesByName = ts.createMapFromTemplate({ "string": stringType, "number": numberType, "boolean": booleanType, "symbol": esSymbolType, "undefined": undefinedType }); + var typeofType = createTypeofType(); var jsxElementType; var _jsxNamespace; var _jsxFactoryEntity; @@ -21117,8 +22605,15 @@ var ts; var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); - builtinGlobals[undefinedSymbol.name] = undefinedSymbol; + builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); return checker; function getJsxNamespace() { @@ -21148,7 +22643,9 @@ var ts; } function createSymbol(flags, name) { symbolCount++; - return new Symbol(flags, name); + var symbol = (new Symbol(flags | 134217728, name)); + symbol.checkFlags = 0; + return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; @@ -21194,7 +22691,7 @@ var ts; mergedSymbols[source.mergeId] = target; } function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 33554432, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) @@ -21216,7 +22713,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 231 && source.valueDeclaration.kind !== 231))) { + (target.valueDeclaration.kind === 232 && source.valueDeclaration.kind !== 232))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -21232,6 +22729,9 @@ var ts; } recordMergedSymbol(target, source); } + else if (target.flags & 1024) { + error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + } else { var message_2 = target.flags & 2 || source.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -21244,18 +22744,19 @@ var ts; } } function mergeSymbolTable(target, source) { - for (var id in source) { - var targetSymbol = target[id]; + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); if (!targetSymbol) { - target[id] = source[id]; + target.set(id, sourceSymbol); } else { - if (!(targetSymbol.flags & 33554432)) { - target[id] = targetSymbol = cloneSymbol(targetSymbol); + if (!(targetSymbol.flags & 134217728)) { + targetSymbol = cloneSymbol(targetSymbol); + target.set(id, targetSymbol); } - mergeSymbol(targetSymbol, source[id]); + mergeSymbol(targetSymbol, sourceSymbol); } - } + }); } function mergeModuleAugmentation(moduleName) { var moduleAugmentation = moduleName.parent; @@ -21276,7 +22777,7 @@ var ts; } mainModule = resolveExternalModuleSymbol(mainModule); if (mainModule.flags & 1920) { - mainModule = mainModule.flags & 33554432 ? mainModule : cloneSymbol(mainModule); + mainModule = mainModule.flags & 134217728 ? mainModule : cloneSymbol(mainModule); mergeSymbol(mainModule, moduleAugmentation.symbol); } else { @@ -21285,20 +22786,21 @@ var ts; } } function addToSymbolTable(target, source, message) { - for (var id in source) { - if (target[id]) { - ts.forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); + if (targetSymbol) { + ts.forEach(targetSymbol.declarations, addDeclarationDiagnostic(id, message)); } else { - target[id] = source[id]; + target.set(id, sourceSymbol); } - } + }); function addDeclarationDiagnostic(id, message) { return function (declaration) { return diagnostics.add(ts.createDiagnosticForNode(declaration, message, id)); }; } } function getSymbolLinks(symbol) { - if (symbol.flags & 67108864) + if (symbol.flags & 134217728) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = {}); @@ -21310,14 +22812,17 @@ var ts; function getObjectFlags(type) { return type.flags & 32768 ? type.objectFlags : 0; } + function getCheckFlags(symbol) { + return symbol.flags & 134217728 ? symbol.checkFlags : 0; + } function isGlobalSourceFile(node) { - return node.kind === 262 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 264 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { - var symbol = symbols[name]; + var symbol = symbols.get(name); if (symbol) { - ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } @@ -21348,49 +22853,50 @@ var ts; (!compilerOptions.outFile && !compilerOptions.out)) { return true; } - if (isUsedInFunctionOrNonStaticProperty(usage)) { + if (isUsedInFunctionOrInstanceProperty(usage)) { return true; } var sourceFiles = host.getSourceFiles(); return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - if (declaration.kind === 174) { - var errorBindingElement = ts.getAncestor(usage, 174); + if (declaration.kind === 175) { + var errorBindingElement = ts.getAncestor(usage, 175); if (errorBindingElement) { return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || declaration.pos < errorBindingElement.pos; } - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 224), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 225), usage); } - else if (declaration.kind === 224) { + else if (declaration.kind === 225) { return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return isUsedInFunctionOrNonStaticProperty(usage, container); + var isInstanceProperty = declaration.kind === 148 && !(ts.getModifierFlags(declaration) & 32); + return isUsedInFunctionOrInstanceProperty(usage, isInstanceProperty, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 206: - case 212: - case 214: + case 207: + case 213: + case 215: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 213: case 214: + case 215: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } } return false; } - function isUsedInFunctionOrNonStaticProperty(usage, container) { + function isUsedInFunctionOrInstanceProperty(usage, isDeclarationInstanceProperty, container) { var current = usage; while (current) { if (current === container) { @@ -21399,12 +22905,12 @@ var ts; if (ts.isFunctionLike(current)) { return true; } - var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 147 && + var initializerOfInstanceProperty = current.parent && + current.parent.kind === 148 && (ts.getModifierFlags(current.parent) & 32) === 0 && current.parent.initializer === current; - if (initializerOfNonStaticProperty) { - return true; + if (initializerOfInstanceProperty) { + return !isDeclarationInstanceProperty; } current = current.parent; } @@ -21432,18 +22938,18 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793064 && lastLocation.kind !== 279) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 282) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 144 || - lastLocation.kind === 143 + lastLocation.kind === 145 || + lastLocation.kind === 144 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 144 || + lastLocation.kind === 145 || (lastLocation === location.type && - result.valueDeclaration.kind === 144); + result.valueDeclaration.kind === 145); } } if (useResult) { @@ -21455,23 +22961,24 @@ var ts; } } switch (location.kind) { - case 262: + case 264: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 231: + case 232: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 262 || ts.isAmbientModule(location)) { - if (result = moduleExports["default"]) { + if (location.kind === 264 || ts.isAmbientModule(location)) { + if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } - if (moduleExports[name] && - moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 244)) { + var moduleExport = moduleExports.get(name); + if (moduleExport && + moduleExport.flags === 8388608 && + ts.getDeclarationOfKind(moduleExport, 245)) { break; } } @@ -21479,13 +22986,13 @@ var ts; break loop; } break; - case 230: + case 231: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 148: case 147: - case 146: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -21495,17 +23002,21 @@ var ts; } } break; - case 227: - case 197: case 228: + case 198: + case 229: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { + if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { + result = undefined; + break; + } if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; } break loop; } - if (location.kind === 197 && meaning & 32) { + if (location.kind === 198 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -21513,28 +23024,28 @@ var ts; } } break; - case 142: + case 143: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 228) { + if (ts.isClassLike(grandparent) || grandparent.kind === 229) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 226: - case 185: + case 153: + case 227: + case 186: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 184: + case 185: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -21547,8 +23058,8 @@ var ts; } } break; - case 145: - if (location.parent && location.parent.kind === 144) { + case 146: + if (location.parent && location.parent.kind === 145) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -21591,13 +23102,22 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 234) { + if (decls && decls.length === 1 && decls[0].kind === 235) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } } return result; } + function isTypeParameterSymbolDeclaredInContainer(symbol, container) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 144 && decl.parent === container) { + return true; + } + } + return false; + } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { if ((errorLocation.kind === 70 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; @@ -21638,9 +23158,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70: - case 177: + case 178: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 199: + case 200: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -21688,10 +23208,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 235) { + if (node.kind === 236) { return node; } - while (node && node.kind !== 236) { + while (node && node.kind !== 237) { node = node.parent; } return node; @@ -21701,7 +23221,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 246) { + if (node.moduleReference.kind === 247) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -21709,11 +23229,16 @@ var ts; function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { - var exportDefaultSymbol = ts.isShorthandAmbientModuleSymbol(moduleSymbol) ? - moduleSymbol : - moduleSymbol.exports["export="] ? - getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") : - resolveSymbol(moduleSymbol.exports["default"]); + var exportDefaultSymbol = void 0; + if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { + exportDefaultSymbol = moduleSymbol; + } + else { + var exportValue = moduleSymbol.exports.get("export="); + exportDefaultSymbol = exportValue + ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") + : resolveSymbol(moduleSymbol.exports.get("default")); + } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } @@ -21744,7 +23269,7 @@ var ts; } function getExportOfModule(symbol, name) { if (symbol.flags & 1536) { - var exportedSymbol = getExportsOfSymbol(symbol)[name]; + var exportedSymbol = getExportsOfSymbol(symbol).get(name); if (exportedSymbol) { return resolveSymbol(exportedSymbol); } @@ -21762,28 +23287,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_17 = specifier.propertyName || specifier.name; - if (name_17.text) { + var name = specifier.propertyName || specifier.name; + if (name.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_17.text); + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) { + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_17.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_17.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_17.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_17, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_17)); + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name)); } return symbol; } @@ -21805,19 +23330,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 235: + case 236: return getTargetOfImportEqualsDeclaration(node); - case 237: - return getTargetOfImportClause(node); case 238: + return getTargetOfImportClause(node); + case 239: return getTargetOfNamespaceImport(node); - case 240: - return getTargetOfImportSpecifier(node); - case 244: - return getTargetOfExportSpecifier(node); case 241: + return getTargetOfImportSpecifier(node); + case 245: + return getTargetOfExportSpecifier(node); + case 242: return getTargetOfExportAssignment(node); - case 234: + case 235: return getTargetOfNamespaceExportDeclaration(node); } } @@ -21861,10 +23386,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 241) { + if (node.kind === 242) { checkExpressionCached(node.expression); } - else if (node.kind === 244) { + else if (node.kind === 245) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -21876,11 +23401,11 @@ var ts; if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 70 || entityName.parent.kind === 141) { + if (entityName.kind === 70 || entityName.parent.kind === 142) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 235); + ts.Debug.assert(entityName.parent.kind === 236); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -21899,9 +23424,9 @@ var ts; return undefined; } } - else if (name.kind === 141 || name.kind === 177) { - var left = name.kind === 141 ? name.left : name.expression; - var right = name.kind === 141 ? name.right : name.name; + else if (name.kind === 142 || name.kind === 178) { + var left = name.kind === 142 ? name.left : name.expression; + var right = name.kind === 142 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -21920,7 +23445,7 @@ var ts; else { ts.Debug.fail("Unknown entity name kind."); } - ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); } function resolveExternalModuleName(location, moduleReferenceExpression) { @@ -21991,7 +23516,7 @@ var ts; return undefined; } function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="))) || moduleSymbol; } function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { var symbol = resolveExternalModuleSymbol(moduleSymbol); @@ -22002,15 +23527,23 @@ var ts; return symbol; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="] !== undefined; + return moduleSymbol.exports.get("export=") !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); } + function getExportsAndPropertiesOfModule(moduleSymbol) { + var exports = getExportsOfModuleAsArray(moduleSymbol); + var exportEquals = resolveExternalModuleSymbol(moduleSymbol); + if (exportEquals !== moduleSymbol) { + ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + } + return exports; + } function tryGetMemberInModuleExports(memberName, moduleSymbol) { var symbolTable = getExportsOfModule(moduleSymbol); if (symbolTable) { - return symbolTable[memberName]; + return symbolTable.get(memberName); } } function getExportsOfSymbol(symbol) { @@ -22021,24 +23554,28 @@ var ts; return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol)); } function extendExportSymbols(target, source, lookupTable, exportNode) { - for (var id in source) { - if (id !== "default" && !target[id]) { - target[id] = source[id]; + source && source.forEach(function (sourceSymbol, id) { + if (id === "default") + return; + var targetSymbol = target.get(id); + if (!targetSymbol) { + target.set(id, sourceSymbol); if (lookupTable && exportNode) { - lookupTable[id] = { + lookupTable.set(id, { specifierText: ts.getTextOfNode(exportNode.moduleSpecifier) - }; + }); } } - else if (lookupTable && exportNode && id !== "default" && target[id] && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { - if (!lookupTable[id].exportsWithDuplicate) { - lookupTable[id].exportsWithDuplicate = [exportNode]; + else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) { + var collisionTracker = lookupTable.get(id); + if (!collisionTracker.exportsWithDuplicate) { + collisionTracker.exportsWithDuplicate = [exportNode]; } else { - lookupTable[id].exportsWithDuplicate.push(exportNode); + collisionTracker.exportsWithDuplicate.push(exportNode); } } - } + }); } function getExportsForModule(moduleSymbol) { var visitedSymbols = []; @@ -22050,26 +23587,26 @@ var ts; } visitedSymbols.push(symbol); var symbols = ts.cloneMap(symbol.exports); - var exportStars = symbol.exports["__export"]; + var exportStars = symbol.exports.get("__export"); if (exportStars) { var nestedSymbols = ts.createMap(); - var lookupTable = ts.createMap(); + var lookupTable_1 = ts.createMap(); for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { var node = _a[_i]; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable, node); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); } - for (var id in lookupTable) { - var exportsWithDuplicate = lookupTable[id].exportsWithDuplicate; - if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols[id]) { - continue; + lookupTable_1.forEach(function (_a, id) { + var exportsWithDuplicate = _a.exportsWithDuplicate; + if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) { + return; } - for (var _b = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _b < exportsWithDuplicate_1.length; _b++) { - var node = exportsWithDuplicate_1[_b]; - diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable[id].specifierText, id)); + for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) { + var node = exportsWithDuplicate_1[_i]; + diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable_1.get(id).specifierText, id)); } - } + }); extendExportSymbols(symbols, nestedSymbols); } return symbols; @@ -22091,22 +23628,13 @@ var ts; : symbol; } function symbolIsValue(symbol) { - if (symbol.flags & 16777216) { - return symbolIsValue(getSymbolLinks(symbol).target); - } - if (symbol.flags & 107455) { - return true; - } - if (symbol.flags & 8388608) { - return (resolveAlias(symbol).flags & 107455) !== 0; - } - return false; + return !!(symbol.flags & 107455 || symbol.flags & 8388608 && resolveAlias(symbol).flags & 107455); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 150 && ts.nodeIsPresent(member.body)) { + if (member.kind === 151 && ts.nodeIsPresent(member.body)) { return member; } } @@ -22134,6 +23662,9 @@ var ts; type.symbol = symbol; return type; } + function createTypeofType() { + return getUnionType(ts.convertToArray(typeofEQFacts.keys(), function (s) { return getLiteralTypeForText(32, s); })); + } function isReservedMemberName(name) { return name.charCodeAt(0) === 95 && name.charCodeAt(1) === 95 && @@ -22142,16 +23673,15 @@ var ts; } function getNamedMembers(members) { var result; - for (var id in members) { + members.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { if (!result) result = []; - var symbol = members[id]; if (symbolIsValue(symbol)) { result.push(symbol); } } - } + }); return result || emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -22170,19 +23700,19 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { - if (location_1.locals && !isGlobalSourceFile(location_1)) { - if (result = callback(location_1.locals)) { + for (var location = enclosingDeclaration; location; location = location.parent) { + if (location.locals && !isGlobalSourceFile(location)) { + if (result = callback(location.locals)) { return result; } } - switch (location_1.kind) { - case 262: - if (!ts.isExternalOrCommonJsModule(location_1)) { + switch (location.kind) { + case 264: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 231: - if (result = callback(getSymbolOfNode(location_1).exports)) { + case 232: + if (result = callback(getSymbolOfNode(location).exports)) { return result; } break; @@ -22219,13 +23749,13 @@ var ts; } } function trySymbolTable(symbols) { - if (isAccessible(symbols[symbol.name])) { + if (isAccessible(symbols.get(symbol.name))) { return [symbol]; } - return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { + return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -22250,14 +23780,14 @@ var ts; function needsQualification(symbol, enclosingDeclaration, meaning) { var qualify = false; forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { - var symbolFromSymbolTable = symbolTable[symbol.name]; + var symbolFromSymbolTable = symbolTable.get(symbol.name); if (!symbolFromSymbolTable) { return false; } if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -22271,10 +23801,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 147: - case 149: - case 151: + case 148: + case 150: case 152: + case 153: continue; default: return false; @@ -22330,7 +23860,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 262 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 264 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -22364,11 +23894,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 160 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 161 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 141 || entityName.kind === 177 || - entityName.parent.kind === 235) { + else if (entityName.kind === 142 || entityName.kind === 178 || + entityName.parent.kind === 236) { meaning = 1920; } else { @@ -22460,10 +23990,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 166) { + while (node.kind === 167) { node = node.parent; } - if (node.kind === 229) { + if (node.kind === 230) { return getSymbolOfNode(node); } } @@ -22471,29 +24001,29 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 232 && + node.parent.kind === 233 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { return type.flags & 32 ? "\"" + ts.escapeString(type.text) + "\"" : type.text; } - function getSymbolDisplayBuilder() { - function getNameOfSymbol(symbol) { - if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - if (declaration.name) { - return ts.declarationNameToString(declaration.name); - } - switch (declaration.kind) { - case 197: - return "(Anonymous class)"; - case 184: - case 185: - return "(Anonymous function)"; - } + function getNameOfSymbol(symbol) { + if (symbol.declarations && symbol.declarations.length) { + var declaration = symbol.declarations[0]; + if (declaration.name) { + return ts.declarationNameToString(declaration.name); + } + switch (declaration.kind) { + case 198: + return "(Anonymous class)"; + case 185: + case 186: + return "(Anonymous function)"; } - return symbol.name; } + return symbol.name; + } + function getSymbolDisplayBuilder() { function appendSymbolNameOnly(symbol, writer) { writer.writeSymbol(getNameOfSymbol(symbol), symbol); } @@ -22521,7 +24051,7 @@ var ts; function appendParentTypeArgumentsAndSymbolName(symbol) { if (parentSymbol) { if (flags & 1) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); } else { @@ -22540,9 +24070,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_6) { - walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), false); + var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + walkSymbol(parent, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -22572,7 +24102,7 @@ var ts; return writeType(type, globalFlags); function writeType(type, flags) { var nextFlags = flags & ~512; - if (type.flags & 16015) { + if (type.flags & 16793231) { writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) ? "any" : type.intrinsicName); @@ -22597,7 +24127,7 @@ var ts; else if (!(flags & 512) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { var typeArguments = type.aliasTypeArguments; - writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); + writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, ts.length(typeArguments), nextFlags); } else if (type.flags & 196608) { writeUnionOrIntersectionType(type, nextFlags); @@ -22675,12 +24205,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); + writeSymbolTypeReference(parent, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -22706,7 +24236,8 @@ var ts; function writeAnonymousType(type, flags) { var symbol = type.symbol; if (symbol) { - if (symbol.flags & (32 | 384 | 512)) { + if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (384 | 512)) { writeTypeOfSymbol(type, flags); } else if (shouldWriteTypeOfFunctionSymbol()) { @@ -22739,7 +24270,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 262 || declaration.parent.kind === 232; + return declaration.parent.kind === 264 || declaration.parent.kind === 233; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -22758,7 +24289,7 @@ var ts; writeSpace(writer); } buildSymbolDisplay(prop, writer); - if (prop.flags & 536870912) { + if (prop.flags & 67108864) { writePunctuation(writer, 54); } } @@ -22901,6 +24432,13 @@ var ts; writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } + var defaultType = getDefaultFromTypeParameter(tp); + if (defaultType) { + writeSpace(writer); + writePunctuation(writer, 57); + writeSpace(writer); + buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack); + } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; @@ -22918,15 +24456,19 @@ var ts; } writePunctuation(writer, 55); writeSpace(writer); - buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); + var type = getTypeOfSymbol(p); + if (isRequiredInitializedParameter(parameterNode)) { + type = includeFalsyTypes(type, 2048); + } + buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 172) { + if (bindingPattern.kind === 173) { writePunctuation(writer, 16); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); writePunctuation(writer, 17); } - else if (bindingPattern.kind === 173) { + else if (bindingPattern.kind === 174) { writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -22940,7 +24482,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 174); + ts.Debug.assert(bindingElement.kind === 175); if (bindingElement.propertyName) { writer.writeProperty(ts.getTextOfNode(bindingElement.propertyName)); writePunctuation(writer, 55); @@ -23062,7 +24604,7 @@ var ts; writeKeyword(writer, 132); break; case 0: - writeKeyword(writer, 134); + writeKeyword(writer, 135); break; } writePunctuation(writer, 21); @@ -23098,64 +24640,64 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 174: + case 175: return isDeclarationVisible(node.parent.parent); - case 224: + case 225: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 231: - case 227: + case 232: case 228: case 229: - case 226: case 230: - case 235: + case 227: + case 231: + case 236: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_8 = getDeclarationContainer(node); + var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 235 && parent_8.kind !== 262 && ts.isInAmbientContext(parent_8))) { - return isGlobalSourceFile(parent_8); + !(node.kind !== 236 && parent.kind !== 264 && ts.isInAmbientContext(parent))) { + return isGlobalSourceFile(parent); } - return isDeclarationVisible(parent_8); - case 147: - case 146: - case 151: - case 152: - case 149: + return isDeclarationVisible(parent); case 148: + case 147: + case 152: + case 153: + case 150: + case 149: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 150: - case 154: - case 153: + case 151: case 155: - case 144: - case 232: - case 158: + case 154: + case 156: + case 145: + case 233: case 159: - case 161: - case 157: + case 160: case 162: + case 158: case 163: case 164: case 165: case 166: + case 167: return isDeclarationVisible(node.parent); - case 237: case 238: - case 240: - return false; - case 143: - case 262: - case 234: - return true; + case 239: case 241: return false; + case 144: + case 264: + case 235: + return true; + case 242: + return false; default: return false; } @@ -23163,10 +24705,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 241) { + if (node.parent && node.parent.kind === 242) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 244) { + else if (node.parent.kind === 245) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -23244,12 +24786,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 224: case 225: + case 226: + case 241: case 240: case 239: case 238: - case 237: node = node.parent; break; default: @@ -23273,7 +24815,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } function isComputedNonLiteralName(name) { - return name.kind === 142 && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 143 && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 6144); }); @@ -23286,17 +24828,16 @@ var ts; var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name_18 = properties_2[_i]; - names[ts.getTextOfPropertyName(name_18)] = true; + var name = properties_2[_i]; + names.set(ts.getTextOfPropertyName(name), true); } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - var inNamesToRemove = prop.name in names; + var inNamesToRemove = names.has(prop.name); var isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16); - var isMethod = prop.flags & 8192; var isSetOnlyAccessor = prop.flags & 65536 && !(prop.flags & 32768); - if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { - members[prop.name] = prop; + if (!inNamesToRemove && !isPrivate && !isClassMethod(prop) && !isSetOnlyAccessor) { + members.set(prop.name, prop); } } var stringIndexInfo = getIndexInfoOfType(source, 0); @@ -23316,7 +24857,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 172) { + if (pattern.kind === 173) { if (declaration.dotDotDotToken) { if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -23332,19 +24873,19 @@ var ts; type = getRestType(parentType, literalMembers, declaration.symbol); } else { - var name_19 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_19)) { + var name = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name)) { return anyType; } if (declaration.initializer) { getContextualType(declaration.initializer); } - var text = ts.getTextOfPropertyName(name_19); + var text = ts.getTextOfPropertyName(name); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_19, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_19)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); return unknownType; } } @@ -23377,7 +24918,7 @@ var ts; getUnionType([type, checkExpressionCached(declaration.initializer)], true) : type; } - function getTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); if (jsdocType) { return getTypeFromTypeNode(jsdocType); @@ -23390,33 +24931,42 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 175 && expr.elements.length === 0; + return expr.kind === 176 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } + function removeOptionalityFromAnnotation(annotatedType, declaration) { + var annotationIncludesUndefined = strictNullChecks && + declaration.kind === 145 && + declaration.initializer && + getFalsyFlags(annotatedType) & 2048 && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048); + return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; + } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { if (declaration.flags & 65536) { - var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); + var type = getTypeForDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } } - if (declaration.parent.parent.kind === 213) { + if (declaration.parent.parent.kind === 214) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 | 262144) ? indexType : stringType; } - if (declaration.parent.parent.kind === 214) { + if (declaration.parent.parent.kind === 215) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } if (declaration.type) { - return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); + var declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + return addOptionality(declaredType, declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && - declaration.kind === 224 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 225 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -23425,10 +24975,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 144) { + if (declaration.kind === 145) { var func = declaration.parent; - if (func.kind === 152 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 151); + if (func.kind === 153 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 152); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -23454,7 +25004,10 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 259) { + if (ts.isJsxAttribute(declaration)) { + return trueType; + } + if (declaration.kind === 261) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -23462,6 +25015,21 @@ var ts; } return undefined; } + function getTypeForJSSpecialPropertyDeclaration(declaration) { + var expression = declaration.kind === 193 ? declaration : + declaration.kind === 178 ? ts.getAncestor(declaration, 193) : + undefined; + if (!expression) { + return unknownType; + } + if (expression.flags & 65536) { + var type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + return getWidenedType(type); + } + } + return getWidenedLiteralType(checkExpressionCached(expression.right)); + } function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { return checkDeclarationInitializer(element); @@ -23489,11 +25057,11 @@ var ts; return; } var text = ts.getTextOfPropertyName(name); - var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); + var flags = 4 | (e.initializer ? 67108864 : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; - members[symbol.name] = symbol; + members.set(symbol.name, symbol); }); var result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { @@ -23519,7 +25087,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 172 + return pattern.kind === 173 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -23529,7 +25097,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 258) { + if (declaration.kind === 260) { return type; } return getWidenedType(type); @@ -23544,41 +25112,32 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 144 ? root.parent : root; + var memberDeclaration = root.kind === 145 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.flags & 134217728) { + if (symbol.flags & 16777216) { return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 241) { + if (declaration.kind === 242) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 && declaration.kind === 287 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 290 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = void 0; - if (declaration.kind === 192 || - declaration.kind === 177 && declaration.parent.kind === 192) { - if (declaration.flags & 65536) { - var jsdocType = ts.getJSDocType(declaration.parent); - if (jsdocType) { - return links.type = getTypeFromTypeNode(jsdocType); - } - } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 192 ? - checkExpressionCached(decl.right) : - checkExpressionCached(decl.parent.right); }); - type = getUnionType(declaredTypes, true); + if (declaration.kind === 193 || + declaration.kind === 178 && declaration.parent.kind === 193) { + type = getWidenedType(getUnionType(ts.map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), true)); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -23592,7 +25151,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 151) { + if (accessor.kind === 152) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -23612,10 +25171,10 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 151); - var setter = ts.getDeclarationOfKind(symbol, 152); + var getter = ts.getDeclarationOfKind(symbol, 152); + var setter = ts.getDeclarationOfKind(symbol, 153); if (getter && getter.flags & 65536) { - var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); + var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; } @@ -23654,7 +25213,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 151); + var getter_1 = ts.getDeclarationOfKind(symbol, 152); 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)); } } @@ -23662,6 +25221,10 @@ var ts; } return links.type; } + function getBaseTypeVariableOfClass(symbol) { + var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); + return baseConstructorType.flags & 540672 ? baseConstructorType : undefined; + } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { @@ -23670,8 +25233,13 @@ var ts; } else { var type = createObjectType(16, symbol); - links.type = strictNullChecks && symbol.flags & 536870912 ? - includeFalsyTypes(type, 2048) : type; + if (symbol.flags & 32) { + var baseTypeVariable = getBaseTypeVariableOfClass(symbol); + links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; + } + else { + links.type = strictNullChecks && symbol.flags & 67108864 ? includeFalsyTypes(type, 2048) : type; + } } } return links.type; @@ -23718,7 +25286,7 @@ var ts; return anyType; } function getTypeOfSymbol(symbol) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { return getTypeOfInstantiatedSymbol(symbol); } if (symbol.flags & (3 | 4)) { @@ -23744,13 +25312,18 @@ var ts; function hasBaseType(type, checkBase) { return check(type); function check(type) { - var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); + if (getObjectFlags(type) & (3 | 4)) { + var target = getTargetType(type); + return target === checkBase || ts.forEach(getBaseTypes(target), check); + } + else if (type.flags & 131072) { + return ts.forEach(type.types, check); + } } } function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { - var declaration = declarations_2[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -23767,9 +25340,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 227 || node.kind === 197 || - node.kind === 226 || node.kind === 184 || - node.kind === 149 || node.kind === 185) { + if (node.kind === 228 || node.kind === 198 || + node.kind === 227 || node.kind === 185 || + node.kind === 150 || node.kind === 186) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -23778,15 +25351,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 228); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 229); 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 === 228 || node.kind === 227 || - node.kind === 197 || node.kind === 229) { + if (node.kind === 229 || node.kind === 228 || + node.kind === 198 || node.kind === 230) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -23798,15 +25371,30 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } + function isMixinConstructorType(type) { + var signatures = getSignaturesOfType(type, 1); + if (signatures.length === 1) { + var s = signatures[0]; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + } + return false; + } function isConstructorType(type) { - return type.flags & 32768 && getSignaturesOfType(type, 1).length > 0; + if (isValidBaseType(type) && getSignaturesOfType(type, 1).length > 0) { + return true; + } + if (type.flags & 540672) { + var constraint = getBaseConstraintOfType(type); + return isValidBaseType(constraint) && isMixinConstructorType(constraint); + } + return false; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); } function getConstructorsForTypeArguments(type, typeArgumentNodes) { - var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; - return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + var typeArgCount = ts.length(typeArgumentNodes); + return ts.filter(getSignaturesOfType(type, 1), function (sig) { return typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); @@ -23826,7 +25414,7 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 32768) { + if (baseConstructorType.flags & (32768 | 131072)) { resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { @@ -23862,8 +25450,8 @@ var ts; } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - var baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & 32768)) { + var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); + if (!(baseConstructorType.flags & (32768 | 131072))) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -23891,7 +25479,7 @@ var ts; if (baseType === unknownType) { return; } - if (!(getObjectFlags(getTargetType(baseType)) & 3)) { + if (!isValidBaseType(baseType)) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -23915,16 +25503,20 @@ var ts; } return true; } + function isValidBaseType(type) { + return type.flags & (32768 | 16777216) && !isGenericMappedType(type) || + type.flags & 131072 && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); + } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 228 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 229 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { - if (getObjectFlags(getTargetType(baseType)) & 3) { + if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -23948,7 +25540,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 228) { + if (declaration.kind === 229) { if (declaration.flags & 64) { return false; } @@ -23981,7 +25573,7 @@ var ts; type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384); @@ -23998,7 +25590,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 286); + var declaration = ts.getDeclarationOfKind(symbol, 289); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -24009,7 +25601,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 229); + declaration = ts.getDeclarationOfKind(symbol, 230); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -24017,7 +25609,7 @@ var ts; if (typeParameters) { links.typeParameters = typeParameters; links.instantiations = ts.createMap(); - links.instantiations[getTypeListId(typeParameters)] = type; + links.instantiations.set(getTypeListId(typeParameters), type); } } else { @@ -24034,14 +25626,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 190 && expr.operator === 37 && + expr.kind === 191 && expr.operator === 37 && expr.operand.kind === 8 || - expr.kind === 70 && !!symbol.exports[expr.text]; + expr.kind === 70 && !!symbol.exports.get(expr.text); } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 230) { + if (declaration.kind === 231) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -24066,10 +25658,10 @@ var ts; enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { var memberTypeList = []; - var memberTypes = ts.createMap(); + var memberTypes = []; for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 230) { + if (declaration.kind === 231) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -24086,7 +25678,7 @@ var ts; if (memberTypeList.length > 1) { enumType.flags |= 65536; enumType.types = memberTypeList; - unionTypes[getTypeListId(memberTypeList)] = enumType; + unionTypes.set(getTypeListId(memberTypeList), enumType); } } } @@ -24107,9 +25699,6 @@ var ts; if (!links.declaredType) { var type = createType(16384); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 143).constraint) { - type.constraint = noConstraintType; - } links.declaredType = type; } return links.declaredType; @@ -24122,7 +25711,6 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 16777216) === 0); if (symbol.flags & (32 | 64)) { return getDeclaredTypeOfClassOrInterface(symbol); } @@ -24157,19 +25745,20 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: + case 133: case 104: - case 137: + case 138: case 94: case 129: - case 171: + case 172: return true; - case 162: + case 163: return isIndependentType(node.elementType); - case 157: + case 158: return isIndependentTypeReference(node); } return false; @@ -24178,7 +25767,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 150 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 151 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -24194,12 +25783,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 147: - case 146: - return isIndependentVariableLikeDeclaration(declaration); - case 149: case 148: + case 147: + return isIndependentVariableLikeDeclaration(declaration); case 150: + case 149: + case 151: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -24210,7 +25799,7 @@ var ts; var result = ts.createMap(); for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { var symbol = symbols_1[_i]; - result[symbol.name] = symbol; + result.set(symbol.name, symbol); } return result; } @@ -24218,15 +25807,15 @@ var ts; var result = ts.createMap(); for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { var symbol = symbols_2[_i]; - result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); + result.set(symbol.name, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } function addInheritedMembers(symbols, baseSymbols) { for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { var s = baseSymbols_1[_i]; - if (!symbols[s.name]) { - symbols[s.name] = s; + if (!symbols.has(s.name)) { + symbols.set(s.name, s); } } } @@ -24234,8 +25823,8 @@ var ts; if (!type.declaredProperties) { var symbol = type.symbol; type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members.get("__call")); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members.get("__new")); type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0); type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1); } @@ -24243,7 +25832,14 @@ var ts; } function getTypeWithThisArgument(type, thisArgument) { if (getObjectFlags(type) & 4) { - return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + var target = type.target; + var typeArguments = type.typeArguments; + if (ts.length(target.typeParameters) === ts.length(typeArguments)) { + return createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); + } + } + else if (type.flags & 131072) { + return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument); })); } return type; } @@ -24279,7 +25875,7 @@ var ts; for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) { var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0); @@ -24322,13 +25918,14 @@ var ts; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); - var typeArgCount = typeArguments ? typeArguments.length : 0; + var typeArgCount = ts.length(typeArguments); var result = []; for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { var baseSig = baseSignatures_1[_i]; - var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; - if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); + var typeParamCount = ts.length(baseSig.typeParameters); + if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -24382,7 +25979,7 @@ var ts; s = cloneSignature(signature); if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return getTypeOfSymbol(sig.thisParameter) || anyType; }), true); - s.thisParameter = createTransientSymbol(signature.thisParameter, thisType); + s.thisParameter = createSymbolWithType(signature.thisParameter, thisType); } s.resolvedReturnType = undefined; s.unionSignatures = unionSignatures; @@ -24424,17 +26021,44 @@ var ts; function unionSpreadIndexInfos(info1, info2) { return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); } + function includeMixinType(type, types, index) { + var mixedTypes = []; + for (var i = 0; i < types.length; i++) { + if (i === index) { + mixedTypes.push(type); + } + else if (isMixinConstructorType(types[i])) { + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1)[0])); + } + } + return getIntersectionType(mixedTypes); + } function resolveIntersectionTypeMembers(type) { var callSignatures = emptyArray; var constructSignatures = emptyArray; - var stringIndexInfo = undefined; - var numberIndexInfo = undefined; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + var stringIndexInfo; + var numberIndexInfo; + var types = type.types; + var mixinCount = ts.countWhere(types, isMixinConstructorType); + var _loop_3 = function (i) { + var t = type.types[i]; + if (mixinCount === 0 || mixinCount === types.length && i === 0 || !isMixinConstructorType(t)) { + var signatures = getSignaturesOfType(t, 1); + if (signatures.length && mixinCount > 0) { + signatures = ts.map(signatures, function (s) { + var clone = cloneSignature(s); + clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, i); + return clone; + }); + } + constructSignatures = ts.concatenate(constructSignatures, signatures); + } callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1)); stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1)); + }; + for (var i = 0; i < types.length; i++) { + _loop_3(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } @@ -24450,8 +26074,8 @@ var ts; } else if (symbol.flags & 2048) { var members = symbol.members; - var callSignatures = getSignaturesOfSymbol(members["__call"]); - var constructSignatures = getSignaturesOfSymbol(members["__new"]); + var callSignatures = getSignaturesOfSymbol(members.get("__call")); + var constructSignatures = getSignaturesOfSymbol(members.get("__new")); var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0); var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -24464,14 +26088,14 @@ var ts; } if (symbol.flags & 32) { var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 32768) { + if (baseConstructorType.flags & (32768 | 131072 | 540672)) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); + addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } } var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; @@ -24491,8 +26115,11 @@ var ts; var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); var templateReadonly = !!type.declaration.readonlyToken; var templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === 168) { - forEachType(getLiteralTypeFromPropertyNames(modifiersType), addMemberForKeyType); + if (type.declaration.typeParameter.constraint.kind === 169) { + for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { + var propertySymbol = _a[_i]; + addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); + } if (getIndexInfoOfType(modifiersType, 0)) { addMemberForKeyType(stringType); } @@ -24503,18 +26130,21 @@ var ts; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t) { - var iterationMapper = createUnaryTypeMapper(typeParameter, t); + function addMemberForKeyType(t, propertySymbol) { + var iterationMapper = createTypeMapper([typeParameter], [t]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; var propType = instantiateType(templateType, templateMapper); if (t.flags & 32) { var propName = t.text; var modifiersProp = getPropertyOfType(modifiersType, propName); - var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 536870912); - var prop = createSymbol(4 | 67108864 | (isOptional ? 536870912 : 0), propName); + var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 67108864); + var prop = createSymbol(4 | (isOptional ? 67108864 : 0), propName); + prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 4 : 0; prop.type = propType; - prop.isReadonly = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp); - members[propName] = prop; + if (propertySymbol) { + prop.mappedTypeOrigin = propertySymbol; + } + members.set(propName, prop); } else if (t.flags & 2) { stringIndexInfo = createIndexInfo(propType, templateReadonly); @@ -24538,7 +26168,7 @@ var ts; function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { var constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === 168) { + if (constraintDeclaration.kind === 169) { type.modifiersType = instantiateType(getTypeFromTypeNode(constraintDeclaration.type), type.mapper || identityMapper); } else { @@ -24550,9 +26180,6 @@ var ts; } return type.modifiersType; } - function getErasedTemplateTypeFromMappedType(type) { - return instantiateType(getTemplateTypeFromMappedType(type), createUnaryTypeMapper(getTypeParameterFromMappedType(type), anyType)); - } function isGenericMappedType(type) { if (getObjectFlags(type) & 32) { var constraintType = getConstraintTypeFromMappedType(type); @@ -24594,35 +26221,33 @@ var ts; function getPropertyOfObjectType(type, name) { if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } } } 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]; - getUnionOrIntersectionProperty(type, prop.name); - } - if (type.flags & 65536) { - break; - } - } - var props = type.resolvedProperties; - if (props) { - var result = []; - for (var key in props) { - var prop = props[key]; - if (!(prop.flags & 268435456 && prop.isPartial)) { - result.push(prop); + if (!type.resolvedProperties) { + var members = ts.createMap(); + 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]; + if (!members.has(prop.name)) { + var combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.name); + if (combinedProp) { + members.set(prop.name, combinedProp); + } + } + } + if (type.flags & 65536) { + break; } } - return result; + type.resolvedProperties = getNamedMembers(members); } - return emptyArray; + return type.resolvedProperties; } function getPropertiesOfType(type) { type = getApparentType(type); @@ -24630,36 +26255,110 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } - function getApparentTypeOfTypeVariable(type) { - if (!type.resolvedApparentType) { - var constraintType = getConstraintOfTypeVariable(type); - while (constraintType && constraintType.flags & 16384) { - constraintType = getConstraintOfTypeVariable(constraintType); - } - type.resolvedApparentType = getTypeWithThisArgument(constraintType || emptyObjectType, type); + function getConstraintOfType(type) { + return type.flags & 16384 ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + } + function getConstraintOfTypeParameter(typeParameter) { + return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; + } + function getBaseConstraintOfType(type) { + var constraint = getResolvedBaseConstraint(type); + return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + } + function hasNonCircularBaseConstraint(type) { + return getResolvedBaseConstraint(type) !== circularConstraintType; + } + function getResolvedBaseConstraint(type) { + var typeStack; + var circular; + if (!type.resolvedBaseConstraint) { + typeStack = []; + var constraint = getBaseConstraint(type); + type.resolvedBaseConstraint = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type); } - return type.resolvedApparentType; + return type.resolvedBaseConstraint; + function getBaseConstraint(t) { + if (ts.contains(typeStack, t)) { + circular = true; + return undefined; + } + typeStack.push(t); + var result = computeBaseConstraint(t); + typeStack.pop(); + return result; + } + function computeBaseConstraint(t) { + if (t.flags & 16384) { + var constraint = getConstraintFromTypeParameter(t); + return t.isThisType ? constraint : + constraint ? getBaseConstraint(constraint) : undefined; + } + if (t.flags & 196608) { + var types = t.types; + var baseTypes = []; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var type_1 = types_2[_i]; + var baseType = getBaseConstraint(type_1); + if (baseType) { + baseTypes.push(baseType); + } + } + return t.flags & 65536 && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 131072 && baseTypes.length ? getIntersectionType(baseTypes) : + undefined; + } + if (t.flags & 262144) { + return stringType; + } + if (t.flags & 524288) { + var baseObjectType = getBaseConstraint(t.objectType); + var baseIndexType = getBaseConstraint(t.indexType); + var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; + return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + } + return t; + } + } + function getApparentTypeOfIntersectionType(type) { + return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type)); + } + function getDefaultFromTypeParameter(typeParameter) { + if (!typeParameter.default) { + if (typeParameter.target) { + var targetDefault = getDefaultFromTypeParameter(typeParameter.target); + typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType; + } + else { + var defaultDeclaration = typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameter(decl) && decl.default; }); + typeParameter.default = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType; + } + } + return typeParameter.default === noConstraintType ? undefined : typeParameter.default; } function getApparentType(type) { - var t = type.flags & 540672 ? getApparentTypeOfTypeVariable(type) : type; - return t.flags & 262178 ? globalStringType : - t.flags & 340 ? globalNumberType : - t.flags & 136 ? globalBooleanType : - t.flags & 512 ? getGlobalESSymbolType() : - t; + var t = type.flags & 540672 ? getBaseConstraintOfType(type) || emptyObjectType : type; + return t.flags & 131072 ? getApparentTypeOfIntersectionType(t) : + t.flags & 262178 ? globalStringType : + t.flags & 340 ? globalNumberType : + t.flags & 136 ? globalBooleanType : + t.flags & 512 ? getGlobalESSymbolType() : + t.flags & 16777216 ? emptyObjectType : + t; } function createUnionOrIntersectionProperty(containingType, name) { - var types = containingType.types; var props; - var commonFlags = (containingType.flags & 131072) ? 536870912 : 0; - var isReadonly = false; - var isPartial = false; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var current = types_2[_i]; + var types = containingType.types; + var isUnion = containingType.flags & 65536; + var excludeModifiers = isUnion ? 24 : 0; + var commonFlags = isUnion ? 0 : 67108864; + var checkFlags = 2; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var current = types_3[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16))) { + var modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0; + if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; if (!props) { props = [prop]; @@ -24667,25 +26366,26 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } - if (isReadonlySymbol(prop)) { - isReadonly = true; - } + checkFlags |= (isReadonlySymbol(prop) ? 4 : 0) | + (!(modifiers & 24) ? 32 : 0) | + (modifiers & 16 ? 64 : 0) | + (modifiers & 8 ? 128 : 0) | + (modifiers & 32 ? 256 : 0); } - else if (containingType.flags & 65536) { - isPartial = true; + else if (isUnion) { + checkFlags |= 8; } } } if (!props) { return undefined; } - if (props.length === 1 && !isPartial) { + if (props.length === 1 && !(checkFlags & 8)) { return props[0]; } var propTypes = []; var declarations = []; var commonType = undefined; - var hasNonUniformType = false; for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; if (prop.declarations) { @@ -24696,39 +26396,37 @@ var ts; commonType = type; } else if (type !== commonType) { - hasNonUniformType = true; + checkFlags |= 16; } propTypes.push(type); } - var result = createSymbol(4 | 67108864 | 268435456 | commonFlags, name); + var result = createSymbol(4 | commonFlags, name); + result.checkFlags = checkFlags; result.containingType = containingType; - result.hasNonUniformType = hasNonUniformType; - result.isPartial = isPartial; result.declarations = declarations; - result.isReadonly = isReadonly; - result.type = containingType.flags & 65536 ? getUnionType(propTypes) : getIntersectionType(propTypes); + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } function getUnionOrIntersectionProperty(type, name) { - var properties = type.resolvedProperties || (type.resolvedProperties = ts.createMap()); - var property = properties[name]; + var properties = type.propertyCache || (type.propertyCache = ts.createMap()); + var property = properties.get(name); if (!property) { property = createUnionOrIntersectionProperty(type, name); if (property) { - properties[name] = property; + properties.set(name, property); } } return property; } function getPropertyOfUnionOrIntersectionType(type, name) { var property = getUnionOrIntersectionProperty(type, name); - return property && !(property.flags & 268435456 && property.isPartial) ? property : undefined; + return property && !(getCheckFlags(property) & 8) ? property : undefined; } function getPropertyOfType(type, name) { type = getApparentType(type); if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } @@ -24807,16 +26505,16 @@ var ts; } function symbolsToArray(symbols) { var result = []; - for (var id in symbols) { + symbols.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { - result.push(symbols[id]); + result.push(symbol); } - } + }); return result; } function isJSDocOptionalParameter(node) { if (node.flags & 65536) { - if (node.type && node.type.kind === 274) { + if (node.type && node.type.kind === 277) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -24827,7 +26525,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 274; + return paramTag.typeExpression.type.kind === 277; } } } @@ -24851,6 +26549,12 @@ var ts; ts.Debug.assert(parameterIndex >= 0); return parameterIndex >= signature.minArgumentCount; } + var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); + if (iife) { + return !node.type && + !node.dotDotDotToken && + ts.indexOf(node.parent.parameters, node) >= iife.arguments.length; + } return false; } function createTypePredicateFromTypePredicateNode(node) { @@ -24870,15 +26574,48 @@ var ts; }; } } + function getMinTypeArgumentCount(typeParameters) { + var minTypeArgumentCount = 0; + if (typeParameters) { + for (var i = 0; i < typeParameters.length; i++) { + if (!getDefaultFromTypeParameter(typeParameters[i])) { + minTypeArgumentCount = i + 1; + } + } + } + return minTypeArgumentCount; + } + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount) { + var numTypeParameters = ts.length(typeParameters); + if (numTypeParameters) { + var numTypeArguments = ts.length(typeArguments); + if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + if (!typeArguments) { + typeArguments = []; + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + typeArguments[i] = emptyObjectType; + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + var mapper = createTypeMapper(typeParameters, typeArguments); + var defaultType = getDefaultFromTypeParameter(typeParameters[i]); + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + } + } + } + return typeArguments; + } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; var hasLiteralTypes = false; - var minArgumentCount = -1; + var minArgumentCount = 0; var thisParameter = undefined; var hasThisParameter = void 0; + var iife = ts.getImmediatelyInvokedFunctionExpression(declaration); var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); + var isUntypedSignatureInJSFile = !iife && !isJSConstructSignature && ts.isInJavaScriptFile(declaration) && !ts.hasJSDocParameterTags(declaration); for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; @@ -24893,41 +26630,34 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 171) { + if (param.type && param.type.kind === 172) { hasLiteralTypes = true; } - if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { - if (minArgumentCount < 0) { - minArgumentCount = i - (hasThisParameter ? 1 : 0); - } - } - else { - minArgumentCount = -1; + var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken || + iife && parameters.length > iife.arguments.length && !param.type || + isJSDocOptionalParameter(param) || + isUntypedSignatureInJSFile; + if (!isOptionalParameter_1) { + minArgumentCount = parameters.length; } } - if ((declaration.kind === 151 || declaration.kind === 152) && + if ((declaration.kind === 152 || declaration.kind === 153) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 151 ? 152 : 151; + var otherKind = declaration.kind === 152 ? 153 : 152; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); - } - if (isJSConstructSignature) { - minArgumentCount--; - } - var classType = declaration.kind === 150 ? + var classType = declaration.kind === 151 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 156 ? + var typePredicate = declaration.type && declaration.type.kind === 157 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -24950,8 +26680,8 @@ var ts; return type; } } - if (declaration.kind === 151 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 152); + if (declaration.kind === 152 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 153); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -24965,20 +26695,20 @@ var ts; for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 158: case 159: - case 226: - case 149: - case 148: + case 160: + case 227: case 150: - case 153: + case 149: + case 151: case 154: case 155: - case 151: + case 156: case 152: - case 184: + case 153: case 185: - case 275: + case 186: + case 278: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -25046,9 +26776,14 @@ var ts; return anyType; } function getSignatureInstantiation(signature, typeArguments) { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); - return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + var instantiation = instantiations.get(id); + if (!instantiation) { + instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments)); + } + return instantiation; } function createSignatureInstantiation(signature, typeArguments) { return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); @@ -25063,7 +26798,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 150 || signature.declaration.kind === 154; + var isConstructor = signature.declaration.kind === 151 || signature.declaration.kind === 155; var type = createObjectType(16); type.members = emptySymbols; type.properties = emptyArray; @@ -25074,10 +26809,10 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members["__index"]; + return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 132 : 134; + var syntaxKind = kind === 1 ? 132 : 135; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -25104,21 +26839,9 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 143).constraint; + return ts.getDeclarationOfKind(type.symbol, 144).constraint; } - function hasConstraintReferenceTo(type, target) { - var checked; - while (type && type.flags & 16384 && !(type.isThisType) && !ts.contains(checked, type)) { - if (type === target) { - return true; - } - (checked || (checked = [])).push(type); - var constraintDeclaration = getConstraintDeclaration(type); - type = constraintDeclaration && getTypeFromTypeNode(constraintDeclaration); - } - return false; - } - function getConstraintOfTypeParameter(typeParameter) { + function getConstraintFromTypeParameter(typeParameter) { if (!typeParameter.constraint) { if (typeParameter.target) { var targetConstraint = getConstraintOfTypeParameter(typeParameter.target); @@ -25126,23 +26849,13 @@ var ts; } else { var constraintDeclaration = getConstraintDeclaration(typeParameter); - var constraint = getTypeFromTypeNode(constraintDeclaration); - if (hasConstraintReferenceTo(constraint, typeParameter)) { - error(constraintDeclaration, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); - constraint = unknownType; - } - typeParameter.constraint = constraint; + typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : noConstraintType; } } return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } - function getConstraintOfTypeVariable(type) { - return type.flags & 16384 ? getConstraintOfTypeParameter(type) : - type.flags & 524288 ? type.constraint : - undefined; - } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 143).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 144).parent); } function getTypeListId(types) { var result = ""; @@ -25169,8 +26882,8 @@ var ts; } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var type = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -25179,9 +26892,10 @@ var ts; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); - var type = target.instantiations[id]; + var type = target.instantiations.get(id); if (!type) { - type = target.instantiations[id] = createObjectType(4, target.symbol); + type = createObjectType(4, target.symbol); + target.instantiations.set(id, type); type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0; type.target = target; type.typeArguments = typeArguments; @@ -25197,17 +26911,22 @@ var ts; return type; } function getTypeReferenceArity(type) { - return type.target.typeParameters ? type.target.typeParameters.length : 0; + return ts.length(type.target.typeParameters); } function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), typeParameters.length); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, undefined, 1), minTypeArgumentCount, typeParameters.length); return unknownType; } - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + return createTypeReference(type, typeArguments); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -25220,14 +26939,22 @@ var ts; var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + var instantiation = links.instantiations.get(id); + if (!instantiation) { + links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + } + return instantiation; } function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return unknownType; } var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); @@ -25248,11 +26975,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 157: + case 158: return node.typeName; - case 273: + case 276: return node.name; - case 199: + case 200: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -25276,7 +27003,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 273) { + if (symbol.flags & 107455 && node.kind === 276) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -25286,13 +27013,13 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 273) { + if (node.kind === 276) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { - var typeNameOrExpression = node.kind === 157 + var typeNameOrExpression = node.kind === 158 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -25318,12 +27045,12 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var declaration = declarations_4[_i]; switch (declaration.kind) { - case 227: case 228: - case 230: + case 229: + case 231: return declaration; } } @@ -25336,7 +27063,7 @@ var ts; error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return arity ? emptyGenericType : emptyObjectType; } - if ((type.typeParameters ? type.typeParameters.length : 0) !== arity) { + if (ts.length(type.typeParameters) !== arity) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); return arity ? emptyGenericType : emptyObjectType; } @@ -25391,7 +27118,7 @@ var ts; for (var i = 0; i < arity; i++) { var typeParameter = createType(16384); typeParameters.push(typeParameter); - var property = createSymbol(4 | 67108864, "" + i); + var property = createSymbol(4, "" + i); property.type = typeParameter; properties.push(property); } @@ -25400,7 +27127,7 @@ var ts; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384); @@ -25482,14 +27209,14 @@ var ts; } } function addTypesToUnion(typeSet, types) { - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var t = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var t = types_6[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -25497,8 +27224,8 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } @@ -25577,10 +27304,11 @@ var ts; return types[0]; } var id = getTypeListId(types); - var type = unionTypes[id]; + var type = unionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(types, 6144); - type = unionTypes[id] = createType(65536 | propagatedFlags); + type = createType(65536 | propagatedFlags); + unionTypes.set(id, type); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -25605,12 +27333,15 @@ var ts; if (type.flags & 65536 && typeSet.unionIndex === undefined) { typeSet.unionIndex = typeSet.length; } - typeSet.push(type); + if (!(type.flags & 32768 && type.objectFlags & 16 && + type.symbol && type.symbol.flags & (16 | 8192) && containsIdenticalType(typeSet, type))) { + typeSet.push(type); + } } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; addTypeToIntersection(typeSet, type); } } @@ -25632,10 +27363,11 @@ var ts; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex, t)); }), false, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); - var type = intersectionTypes[id]; + var type = intersectionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, 6144); - type = intersectionTypes[id] = createType(131072 | propagatedFlags); + type = createType(131072 | propagatedFlags); + intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -25685,21 +27417,10 @@ var ts; var type = createType(524288); type.objectType = objectType; type.indexType = indexType; - if (type.objectType.flags & 229376) { - type.constraint = getIndexTypeOfType(type.objectType, 0); - } - else if (type.objectType.flags & 540672) { - var apparentType = getApparentTypeOfTypeVariable(type.objectType); - if (apparentType !== emptyObjectType) { - type.constraint = isTypeOfKind(type.indexType, 262178) ? - getIndexedAccessType(apparentType, type.indexType) : - getIndexTypeOfType(apparentType, 0); - } - } return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 178 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; var propName = indexType.flags & (32 | 64 | 256) ? indexType.text : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? @@ -25747,7 +27468,7 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 178 ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 179 ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (32 | 64)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); } @@ -25761,33 +27482,31 @@ var ts; return unknownType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 178 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; } - var mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); + var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } function getIndexedAccessType(objectType, indexType, accessNode) { if (maybeTypeOfKind(indexType, 540672 | 262144) || - maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 178) || + maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 179) || isGenericMappedType(objectType)) { if (objectType.flags & 1) { return objectType; } - if (accessNode) { - if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { - error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); - return unknownType; - } - } if (isGenericMappedType(objectType)) { return getIndexedAccessForMappedType(objectType, indexType, accessNode); } var id = objectType.id + "," + indexType.id; - return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType)); + var type = indexedAccessTypes.get(id); + if (!type) { + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType)); + } + return type; } var apparentObjectType = getApparentType(objectType); if (indexType.flags & 65536 && !(indexType.flags & 8190)) { @@ -25827,7 +27546,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - if (ts.isEmpty(node.symbol.members) && !aliasSymbol) { + if (node.symbol.members.size === 0 && !aliasSymbol) { links.resolvedType = emptyTypeLiteralType; } else { @@ -25840,13 +27559,13 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 229 ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 230 ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } - function getSpreadType(left, right, isFromObjectLiteral) { + function getSpreadType(left, right) { if (left.flags & 1 || right.flags & 1) { return anyType; } @@ -25859,10 +27578,13 @@ var ts; return left; } if (left.flags & 65536) { - return mapType(left, function (t) { return getSpreadType(t, right, isFromObjectLiteral); }); + return mapType(left, function (t) { return getSpreadType(t, right); }); } if (right.flags & 65536) { - return mapType(right, function (t) { return getSpreadType(left, t, isFromObjectLiteral); }); + return mapType(right, function (t) { return getSpreadType(left, t); }); + } + if (right.flags & 16777216) { + return emptyObjectType; } var members = ts.createMap(); var skippedPrivateMembers = ts.createMap(); @@ -25878,42 +27600,45 @@ var ts; } for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; - var isOwnProperty = !(rightProp.flags & 8192) || isFromObjectLiteral; var isSetterWithoutGetter = rightProp.flags & 65536 && !(rightProp.flags & 32768); if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 | 16)) { - skippedPrivateMembers[rightProp.name] = true; + skippedPrivateMembers.set(rightProp.name, true); } - else if (isOwnProperty && !isSetterWithoutGetter) { - members[rightProp.name] = rightProp; + else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { + members.set(rightProp.name, rightProp); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { var leftProp = _c[_b]; if (leftProp.flags & 65536 && !(leftProp.flags & 32768) - || leftProp.name in skippedPrivateMembers) { + || skippedPrivateMembers.has(leftProp.name) + || isClassMethod(leftProp)) { continue; } - if (leftProp.name in members) { - var rightProp = members[leftProp.name]; + if (members.has(leftProp.name)) { + var rightProp = members.get(leftProp.name); var rightType = getTypeOfSymbol(rightProp); - if (maybeTypeOfKind(rightType, 2048) || rightProp.flags & 536870912) { + if (maybeTypeOfKind(rightType, 2048) || rightProp.flags & 67108864) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 | 67108864 | (leftProp.flags & 536870912); + var flags = 4 | (leftProp.flags & 67108864); var result = createSymbol(flags, leftProp.name); + result.checkFlags = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp) ? 4 : 0; result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; - result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); - members[leftProp.name] = result; + members.set(leftProp.name, result); } } else { - members[leftProp.name] = leftProp; + members.set(leftProp.name, leftProp); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function isClassMethod(prop) { + return prop.flags & 8192 && ts.find(prop.declarations, function (decl) { return ts.isClassLike(decl.parent); }); + } function createLiteralType(flags, text) { var type = createType(flags); type.text = text; @@ -25935,7 +27660,11 @@ var ts; } function getLiteralTypeForText(flags, text) { var map = flags & 32 ? stringLiteralTypes : numericLiteralTypes; - return map[text] || (map[text] = createLiteralType(flags, text)); + var type = map.get(text); + if (!type) { + map.set(text, type = createLiteralType(flags, text)); + } + return type; } function getTypeFromLiteralTypeNode(node) { var links = getNodeLinks(node); @@ -25963,9 +27692,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 228)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 229)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 150 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 151 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -25982,85 +27711,87 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118: - case 264: - case 265: + case 267: + case 268: return anyType; - case 134: + case 135: return stringType; case 132: return numberType; case 121: return booleanType; - case 135: + case 136: return esSymbolType; case 104: return voidType; - case 137: + case 138: return undefinedType; case 94: return nullType; case 129: return neverType; - case 290: + case 133: + return nonPrimitiveType; + case 293: return nullType; - case 291: + case 294: return undefinedType; - case 292: + case 295: return neverType; - case 167: + case 168: case 98: return getTypeFromThisTypeNode(node); - case 171: + case 172: return getTypeFromLiteralTypeNode(node); - case 289: + case 292: return getTypeFromLiteralTypeNode(node.literal); - case 157: - case 273: - return getTypeFromTypeReference(node); - case 156: - return booleanType; - case 199: - return getTypeFromTypeReference(node); - case 160: - return getTypeFromTypeQueryNode(node); - case 162: - case 266: - return getTypeFromArrayTypeNode(node); - case 163: - return getTypeFromTupleTypeNode(node); - case 164: - case 267: - return getTypeFromUnionTypeNode(node); - case 165: - return getTypeFromIntersectionTypeNode(node); - case 166: - case 269: - case 270: - case 277: - case 278: - case 274: - return getTypeFromTypeNode(node.type); - case 271: - return getTypeFromTypeNode(node.literal); case 158: - case 159: + case 276: + return getTypeFromTypeReference(node); + case 157: + return booleanType; + case 200: + return getTypeFromTypeReference(node); case 161: - case 288: - case 275: + return getTypeFromTypeQueryNode(node); + case 163: + case 269: + return getTypeFromArrayTypeNode(node); + case 164: + return getTypeFromTupleTypeNode(node); + case 165: + case 270: + return getTypeFromUnionTypeNode(node); + case 166: + return getTypeFromIntersectionTypeNode(node); + case 167: + case 272: + case 273: + case 280: + case 281: + case 277: + return getTypeFromTypeNode(node.type); + case 274: + return getTypeFromTypeNode(node.literal); + case 159: + case 160: + case 162: + case 291: + case 278: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 168: - return getTypeFromTypeOperatorNode(node); case 169: - return getTypeFromIndexedAccessTypeNode(node); + return getTypeFromTypeOperatorNode(node); case 170: + return getTypeFromIndexedAccessTypeNode(node); + case 171: return getTypeFromMappedTypeNode(node); case 70: - case 141: + case 142: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 268: + case 271: return getTypeFromJSDocTupleType(node); - case 276: + case 279: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -26087,13 +27818,13 @@ var ts; var instantiations = mapper.instantiations || (mapper.instantiations = []); return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); } - function createUnaryTypeMapper(source, target) { + function makeUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } - function createBinaryTypeMapper(source1, target1, source2, target2) { + function makeBinaryTypeMapper(source1, target1, source2, target2) { return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; } - function createArrayTypeMapper(sources, targets) { + function makeArrayTypeMapper(sources, targets) { return function (t) { for (var i = 0; i < sources.length; i++) { if (t === sources[i]) { @@ -26104,16 +27835,20 @@ var ts; }; } function createTypeMapper(sources, targets) { - var count = sources.length; - var mapper = count == 1 ? createUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : - count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - createArrayTypeMapper(sources, targets); + var mapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : + makeArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; return mapper; } function createTypeEraser(sources) { return createTypeMapper(sources, undefined); } + function createBackreferenceMapper(typeParameters, index) { + var mapper = function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; + mapper.mappedTypes = typeParameters; + return mapper; + } function getInferenceMapper(context) { if (!context.mapper) { var mapper = function (t) { @@ -26137,7 +27872,12 @@ var ts; } function combineTypeMappers(mapper1, mapper2) { var mapper = function (t) { return instantiateType(mapper1(t), mapper2); }; - mapper.mappedTypes = mapper1.mappedTypes; + mapper.mappedTypes = ts.concatenate(mapper1.mappedTypes, mapper2.mappedTypes); + return mapper; + } + function createReplacementMapper(source, target, baseMapper) { + var mapper = function (t) { return t === source ? target : baseMapper(t); }; + mapper.mappedTypes = baseMapper.mappedTypes; return mapper; } function cloneTypeParameter(typeParameter) { @@ -26182,12 +27922,13 @@ var ts; return result; } function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { var links = getSymbolLinks(symbol); symbol = links.target; mapper = combineTypeMappers(links.mapper, mapper); } - var result = createSymbol(16777216 | 67108864 | symbol.flags, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); + result.checkFlags = 1; result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -26214,10 +27955,7 @@ var ts; if (typeVariable_1 !== mappedTypeVariable) { return mapType(mappedTypeVariable, function (t) { if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); + return instantiateMappedObjectType(type, createReplacementMapper(typeVariable_1, t, mapper)); } return t; }); @@ -26245,23 +27983,23 @@ var ts; var node = symbol.declarations[0]; while (node) { switch (node.kind) { - case 158: case 159: - case 226: - case 149: - case 148: + case 160: + case 227: case 150: - case 153: + case 149: + case 151: case 154: case 155: - case 151: + case 156: case 152: - case 184: + case 153: case 185: - case 227: - case 197: + case 186: case 228: + case 198: case 229: + case 230: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -26271,14 +28009,19 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 228) { + if (ts.isClassLike(node) || node.kind === 229) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 275: + case 171: + if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { + return true; + } + break; + case 278: var func = node; for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { var p = _c[_b]; @@ -26287,8 +28030,8 @@ var ts; } } break; - case 231: - case 262: + case 232: + case 264: return false; } node = node.parent; @@ -26298,7 +28041,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 262 || parentKind === 232; + return parentKind === 264 || parentKind === 233; } return false; } @@ -26350,28 +28093,34 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 184: case 185: + case 186: return isContextSensitiveFunctionLikeDeclaration(node); - case 176: + case 177: return ts.forEach(node.properties, isContextSensitive); - case 175: + case 176: return ts.forEach(node.elements, isContextSensitive); - case 193: + case 194: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 192: + case 193: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 258: + case 260: return isContextSensitive(node.initializer); + case 150: case 149: - case 148: return isContextSensitiveFunctionLikeDeclaration(node); - case 183: + case 184: return isContextSensitive(node.expression); + case 253: + return ts.forEach(node.properties, isContextSensitive); + case 252: + return node.initializer && isContextSensitive(node.initializer); + case 255: + return node.expression && isContextSensitive(node.expression); } return false; } @@ -26382,7 +28131,7 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !p.type; })) { return true; } - if (node.kind === 185) { + if (node.kind === 186) { return false; } var parameter = ts.firstOrUndefined(node.parameters); @@ -26400,9 +28149,12 @@ var ts; result.properties = resolved.properties; result.callSignatures = emptyArray; result.constructSignatures = emptyArray; - type = result; + return result; } } + else if (type.flags & 131072) { + return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); + } return type; } function isTypeIdenticalTo(source, target) { @@ -26569,13 +28321,15 @@ var ts; return true; } var id = source.id + "," + target.id; - if (enumRelation[id] !== undefined) { - return enumRelation[id]; + var relation = enumRelation.get(id); + if (relation !== undefined) { + return relation; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & 256) || !(target.symbol.flags & 256) || (source.flags & 65536) !== (target.flags & 65536)) { - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } var targetEnumType = getTypeOfSymbol(target.symbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(source.symbol)); _i < _a.length; _i++) { @@ -26586,11 +28340,13 @@ var ts; if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, property.name, typeToString(target, undefined, 128)); } - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } } } - return enumRelation[id] = true; + enumRelation.set(id, true); + return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { if (target.flags & 8192) @@ -26611,6 +28367,8 @@ var ts; return true; if (source.flags & 4096 && (!strictNullChecks || target.flags & 4096)) return true; + if (source.flags & 32768 && target.flags & 16777216) + return true; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & 1) return true; @@ -26642,12 +28400,12 @@ var ts; } if (source.flags & 32768 && target.flags & 32768) { var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { return related === 1; } } - if (source.flags & 507904 || target.flags & 507904) { + if (source.flags & 1032192 || target.flags & 1032192) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -26786,14 +28544,6 @@ var ts; } } } - else { - var constraint = getConstraintOfTypeParameter(target); - if (constraint && constraint.flags & 262144) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - return result; - } - } - } } else if (target.flags & 262144) { if (source.flags & 262144) { @@ -26801,12 +28551,10 @@ var ts; return result; } } - if (target.type.flags & 540672) { - var constraint = getConstraintOfTypeVariable(target.type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } + var constraint = getConstraintOfType(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; } } } @@ -26816,8 +28564,9 @@ var ts; return result; } } - if (target.constraint) { - if (result = isRelatedTo(source, target.constraint, reportErrors)) { + var constraint = getBaseConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -26834,20 +28583,23 @@ var ts; } else { var constraint = getConstraintOfTypeParameter(source); - if (!constraint || constraint.flags & 1) { - constraint = emptyObjectType; - } - constraint = getTypeWithThisArgument(constraint, source); - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; + if (constraint || !(target.flags & 16777216)) { + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + constraint = getTypeWithThisArgument(constraint, source); + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } } else if (source.flags & 524288) { - if (source.constraint) { - if (result = isRelatedTo(source.constraint, target, reportErrors)) { + var constraint = getBaseConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -26899,42 +28651,55 @@ var ts; } return 0; } - function isKnownProperty(type, name) { + function isKnownProperty(type, name, isComparingJsxAttributes) { if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || - resolved.stringIndexInfo || - (resolved.numberIndexInfo && isNumericLiteralName(name)) || - getPropertyOfType(type, name)) { + if ((relation === assignableRelation || relation === comparableRelation) && + (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) { + return true; + } + else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) { + return true; + } + else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) { return true; } } else if (type.flags & 196608) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (isKnownProperty(t, name)) { + if (isKnownProperty(t, name, isComparingJsxAttributes)) { return true; } } } return false; } - function isEmptyObjectType(t) { + function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && !t.stringIndexInfo && !t.numberIndexInfo; } + function isEmptyObjectType(type) { + return type.flags & 32768 && isEmptyResolvedType(resolveStructuredTypeMembers(type)); + } function hasExcessProperties(source, target, reportErrors) { if (maybeTypeOfKind(target, 32768) && !(getObjectFlags(target) & 512)) { + var isComparingJsxAttributes = !!(source.flags & 33554432); for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; - if (!isKnownProperty(target, prop.name)) { + if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { if (reportErrors) { ts.Debug.assert(!!errorNode); - errorNode = prop.valueDeclaration; - reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + if (ts.isJsxAttributes(errorNode)) { + reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); + } + else { + errorNode = prop.valueDeclaration; + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } } return true; } @@ -26960,20 +28725,42 @@ var ts; if (target.flags & 65536 && containsType(targetTypes, source)) { return -1; } - var len = targetTypes.length; - for (var i = 0; i < len; i++) { - var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var type = targetTypes_1[_i]; + var related = isRelatedTo(source, type, false); if (related) { return related; } } + if (reportErrors) { + var discriminantType = findMatchingDiscriminantType(source, target); + isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], true); + } return 0; } + function findMatchingDiscriminantType(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProperty = sourceProperties_1[_i]; + if (isDiscriminantProperty(target, sourceProperty.name)) { + var sourceType = getTypeOfSymbol(sourceProperty); + for (var _a = 0, _b = target.types; _a < _b.length; _a++) { + var type = _b[_a]; + var targetType = getTypeOfPropertyOfType(type, sourceProperty.name); + if (targetType && isRelatedTo(sourceType, targetType)) { + return type; + } + } + } + } + } + } function typeRelatedToEachType(source, target, reportErrors) { var result = -1; var targetTypes = target.types; - for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { - var targetType = targetTypes_1[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var targetType = targetTypes_2[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0; @@ -27031,10 +28818,10 @@ var ts; return 0; } var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2) { - relation[id] = 3; + relation.set(id, 3); } else { return related === 1 ? -1 : 0; @@ -27042,7 +28829,7 @@ var ts; } if (depth > 0) { for (var i = 0; i < depth; i++) { - if (maybeStack[i][id]) { + if (maybeStack[i].get(id)) { return 1; } } @@ -27060,7 +28847,7 @@ var ts; sourceStack[depth] = source; targetStack[depth] = target; maybeStack[depth] = ts.createMap(); - maybeStack[depth][id] = 1; + maybeStack[depth].set(id, 1); depth++; var saveExpandingFlags = expandingFlags; if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) @@ -27094,38 +28881,38 @@ var ts; if (result) { var maybeCache = maybeStack[depth]; var destinationCache = (result === -1 || depth === 0) ? relation : maybeStack[depth - 1]; - ts.copyProperties(maybeCache, destinationCache); + ts.copyEntries(maybeCache, destinationCache); } else { - relation[id] = reportErrors ? 3 : 2; + relation.set(id, reportErrors ? 3 : 2); } return result; } function mappedTypeRelatedTo(source, target, reportErrors) { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { - var result_2; - if (relation === identityRelation) { - var readonlyMatches = !source.declaration.readonlyToken === !target.declaration.readonlyToken; - var optionalMatches = !source.declaration.questionToken === !target.declaration.questionToken; - if (readonlyMatches && optionalMatches) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getErasedTemplateTypeFromMappedType(source), getErasedTemplateTypeFromMappedType(target), reportErrors); - } - } - } - else { - if (relation === comparableRelation || !source.declaration.questionToken || target.declaration.questionToken) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors); - } + var sourceReadonly = !!source.declaration.readonlyToken; + var sourceOptional = !!source.declaration.questionToken; + var targetReadonly = !!target.declaration.readonlyToken; + var targetOptional = !!target.declaration.questionToken; + var modifiersRelated = relation === identityRelation ? + sourceReadonly === targetReadonly && sourceOptional === targetOptional : + relation === comparableRelation || !sourceOptional || targetOptional; + if (modifiersRelated) { + var result_2; + if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { + var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); + return result_2 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } + else if (target.declaration.questionToken && isEmptyObjectType(source)) { + return -1; + } } else if (relation !== identityRelation) { var resolved = resolveStructuredTypeMembers(target); - if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1) { + if (isEmptyResolvedType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1) { return -1; } } @@ -27143,17 +28930,23 @@ var ts; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { - if (!(targetProp.flags & 536870912) || requireOptionalProperties) { + if (!(targetProp.flags & 67108864) || requireOptionalProperties) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); } return 0; } } - else if (!(targetProp.flags & 134217728)) { + else if (!(targetProp.flags & 16777216)) { var sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 || targetPropFlags & 8) { + if (getCheckFlags(sourceProp) & 128) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); + } + return 0; + } if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { if (sourcePropFlags & 8 && targetPropFlags & 8) { @@ -27167,12 +28960,9 @@ var ts; } } else if (targetPropFlags & 16) { - var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(getParentOfSymbol(sourceProp)) : undefined; - var targetClass = getDeclaredTypeOfSymbol(getParentOfSymbol(targetProp)); - if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { + if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); + reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } return 0; } @@ -27191,7 +28981,7 @@ var ts; return 0; } result &= related; - if (relation !== comparableRelation && sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { + if (relation !== comparableRelation && sourceProp.flags & 67108864 && !(targetProp.flags & 67108864)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -27212,8 +29002,8 @@ var ts; return 0; } var result = -1; - for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { - var sourceProp = sourceProperties_1[_i]; + for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { + var sourceProp = sourceProperties_2[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0; @@ -27374,6 +29164,37 @@ var ts; return false; } } + function forEachProperty(prop, callback) { + if (getCheckFlags(prop) & 2) { + for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var p = getPropertyOfType(t, prop.name); + var result = p && forEachProperty(p, callback); + if (result) { + return result; + } + } + return undefined; + } + return callback(prop); + } + function getDeclaringClass(prop) { + return prop.parent && prop.parent.flags & 32 ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + } + function isPropertyInClassDerivedFrom(prop, baseClass) { + return forEachProperty(prop, function (sp) { + var sourceClass = getDeclaringClass(sp); + return sourceClass ? hasBaseType(sourceClass, baseClass) : false; + }); + } + function isValidOverrideOf(sourceProp, targetProp) { + return !forEachProperty(targetProp, function (tp) { return getDeclarationModifierFlagsFromSymbol(tp) & 16 ? + !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); + } + function isClassDerivedFromDeclaringClasses(checkClass, prop) { + return forEachProperty(prop, function (p) { return getDeclarationModifierFlagsFromSymbol(p) & 16 ? + !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; + } function isAbstractConstructorType(type) { if (getObjectFlags(type) & 16) { var symbol = type.symbol; @@ -27419,7 +29240,7 @@ var ts; } } else { - if ((sourceProp.flags & 536870912) !== (targetProp.flags & 536870912)) { + if ((sourceProp.flags & 67108864) !== (targetProp.flags & 67108864)) { return 0; } } @@ -27449,7 +29270,7 @@ var ts; if (!(isMatchingSignature(source, target, partialMatch))) { return 0; } - if ((source.typeParameters ? source.typeParameters.length : 0) !== (target.typeParameters ? target.typeParameters.length : 0)) { + if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { return 0; } source = getErasedSignature(source); @@ -27487,8 +29308,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -27496,8 +29317,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -27588,8 +29409,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getFalsyFlags(t); } return result; @@ -27618,7 +29439,7 @@ var ts; types.push(undefinedType); if (flags & 4096) types.push(nullType); - return getUnionType(types, true); + return getUnionType(types); } function removeDefinitelyFalsyTypes(type) { return getFalsyFlags(type) & 7392 ? @@ -27633,8 +29454,8 @@ var ts; getSignaturesOfType(type, 0).length === 0 && getSignaturesOfType(type, 1).length === 0; } - function createTransientSymbol(source, type) { - var symbol = createSymbol(source.flags | 67108864, source.name); + function createSymbolWithType(source, type) { + var symbol = createSymbol(source.flags, source.name); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -27650,7 +29471,7 @@ var ts; var property = _a[_i]; var original = getTypeOfSymbol(property); var updated = f(original); - members[property.name] = updated === original ? property : createTransientSymbol(property, updated); + members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); } ; return members; @@ -27736,25 +29557,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 148: case 147: - case 146: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 144: + case 145: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 174: + case 175: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 226: + case 227: + case 150: case 149: - case 148: - case 151: case 152: - case 184: + case 153: case 185: + case 186: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -27839,7 +29660,7 @@ var ts; var typeInferencesArray = [typeInferences]; var templateType = getTemplateTypeFromMappedType(target); var readonlyMask = target.declaration.readonlyToken ? false : true; - var optionalMask = target.declaration.questionToken ? 0 : 536870912; + var optionalMask = target.declaration.questionToken ? 0 : 67108864; var members = createSymbolTable(properties); for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var prop = properties_4[_i]; @@ -27847,11 +29668,11 @@ var ts; if (!inferredPropType) { return undefined; } - var inferredProp = createSymbol(4 | 67108864 | prop.flags & optionalMask, prop.name); + var inferredProp = createSymbol(4 | prop.flags & optionalMask, prop.name); + inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 4 : 0; inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; - inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); - members[prop.name] = inferredProp; + members.set(prop.name, inferredProp); } if (indexInfo) { var inferredIndexType = inferTargetType(indexInfo.type); @@ -27961,8 +29782,8 @@ var ts; var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; - for (var _d = 0, targetTypes_2 = targetTypes; _d < targetTypes_2.length; _d++) { - var t = targetTypes_2[_d]; + for (var _d = 0, targetTypes_3 = targetTypes; _d < targetTypes_3.length; _d++) { + var t = targetTypes_3[_d]; if (t.flags & 540672 && ts.contains(typeVariables, t)) { typeVariable = t; typeVariableCount++; @@ -27994,10 +29815,10 @@ var ts; return; } var key = source.id + "," + target.id; - if (visited[key]) { + if (visited.get(key)) { return; } - visited[key] = true; + visited.set(key, true); if (depth === 0) { sourceStack = []; targetStack = []; @@ -28089,8 +29910,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -28131,7 +29952,13 @@ var ts; inferenceSucceeded = !!unionOrSuperType; } else { - inferredType = emptyObjectType; + var defaultType = getDefaultFromTypeParameter(context.signature.typeParameters[index]); + if (defaultType) { + inferredType = instantiateType(defaultType, combineTypeMappers(createBackreferenceMapper(context.signature.typeParameters, index), getInferenceMapper(context))); + } + else { + inferredType = emptyObjectType; + } inferenceSucceeded = true; } context.inferredTypes[index] = inferredType; @@ -28166,10 +29993,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 160: + case 161: return true; case 70: - case 141: + case 142: node = node.parent; continue; default: @@ -28186,7 +30013,7 @@ var ts; if (node.kind === 98) { return "0"; } - if (node.kind === 177) { + if (node.kind === 178) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -28197,7 +30024,7 @@ var ts; case 70: case 98: return node; - case 177: + case 178: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -28206,19 +30033,19 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 224 || target.kind === 174) && + (target.kind === 225 || target.kind === 175) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; - case 177: - return target.kind === 177 && + case 178: + return target.kind === 178 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 177) { + while (source.kind === 178) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -28227,7 +30054,7 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 177 && + return target.kind === 178 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -28235,7 +30062,7 @@ var ts; if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 177) { + if (expr.kind === 178) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -28244,9 +30071,9 @@ var ts; function isDiscriminantProperty(type, name) { if (type && type.flags & 65536) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && prop.flags & 268435456) { + if (prop && getCheckFlags(prop) & 2) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.hasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.checkFlags & 16 && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -28265,7 +30092,7 @@ var ts; } } } - if (callExpression.expression.kind === 177 && + if (callExpression.expression.kind === 178 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -28304,8 +30131,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -28313,7 +30140,7 @@ var ts; function isFunctionObjectType(type) { var resolved = resolveStructuredTypeMembers(type); return !!(resolved.callSignatures.length || resolved.constructSignatures.length || - resolved.members["bind"] && isTypeSubtypeOf(type, globalFunctionType)); + resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type) { var flags = type.flags; @@ -28356,6 +30183,9 @@ var ts; if (flags & 512) { return strictNullChecks ? 1981320 : 4193160; } + if (flags & 16777216) { + return strictNullChecks ? 6166480 : 8378320; + } if (flags & 16384) { var constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); @@ -28391,10 +30221,16 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 || node.parent.kind === 258 ? + var isDestructuringDefaultAssignment = node.parent.kind === 176 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 260 && isDestructuringAssignmentTarget(node.parent.parent); + return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } + function isDestructuringAssignmentTarget(parent) { + return parent.parent.kind === 193 && parent.parent.left === parent || + parent.parent.kind === 215 && parent.parent.initializer === parent; + } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); } @@ -28410,21 +30246,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 213: - return stringType; case 214: + return stringType; + case 215: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 192: + case 193: return getAssignedTypeOfBinaryExpression(parent); - case 186: + case 187: return undefinedType; - case 175: + case 176: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 196: + case 197: return getAssignedTypeOfSpreadExpression(parent); - case 258: + case 260: return getAssignedTypeOfPropertyAssignment(parent); - case 259: + case 261: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -28432,7 +30268,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 172 ? + var type = pattern.kind === 173 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -28447,35 +30283,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 213) { + if (node.parent.parent.kind === 214) { return stringType; } - if (node.parent.parent.kind === 214) { + if (node.parent.parent.kind === 215) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 224 ? + return node.kind === 225 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 224 || node.kind === 174 ? + return node.kind === 225 || node.kind === 175 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 224 && node.initializer && + return node.kind === 225 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 174 && node.parent.kind === 192 && + node.kind !== 175 && node.parent.kind === 193 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 183: + case 184: return getReferenceCandidate(node.expression); - case 192: + case 193: switch (node.operatorToken.kind) { case 57: return getReferenceCandidate(node.left); @@ -28487,13 +30323,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 183 || - parent.kind === 192 && parent.operatorToken.kind === 57 && parent.left === node || - parent.kind === 192 && parent.operatorToken.kind === 25 && parent.right === node ? + return parent.kind === 184 || + parent.kind === 193 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 193 && parent.operatorToken.kind === 25 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 254) { + if (clause.kind === 256) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -28595,8 +30431,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -28614,11 +30450,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 177 && (parent.name.text === "length" || - parent.parent.kind === 179 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 178 && + var isLengthPushOrUnshift = parent.kind === 178 && (parent.name.text === "length" || + parent.parent.kind === 180 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 179 && parent.expression === root && - parent.parent.kind === 192 && + parent.parent.kind === 193 && parent.parent.operatorToken.kind === 57 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -28647,7 +30483,7 @@ var ts; } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 17810431)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -28657,7 +30493,7 @@ var ts; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; var resultType = getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 201 && getTypeWithFacts(resultType, 524288).flags & 8192) { + if (reference.parent.kind === 202 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; @@ -28671,7 +30507,16 @@ var ts; } } var type = void 0; - if (flow.flags & 16) { + if (flow.flags & 4096) { + flow.locked = true; + type = getTypeAtFlowNode(flow.antecedent); + flow.locked = false; + } + else if (flow.flags & 2048) { + flow = flow.antecedent; + continue; + } + else if (flow.flags & 16) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; @@ -28702,7 +30547,7 @@ var ts; } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 177) { + if (container && container !== flowContainer && reference.kind !== 178) { flow = container.flowNode; continue; } @@ -28745,7 +30590,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 179 ? + var expr = node.kind === 180 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -28753,7 +30598,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 179) { + if (node.kind === 180) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -28805,6 +30650,9 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; + if (antecedent.flags & 2048 && antecedent.lock.locked) { + continue; + } var flowType = getTypeAtFlowNode(antecedent); var type = getTypeFromFlowType(flowType); if (type === declaredType && declaredType === initialType) { @@ -28828,8 +30676,9 @@ var ts; if (!key) { key = getFlowCacheKey(reference); } - if (cache[key]) { - return cache[key]; + var cached = cache.get(key); + if (cached) { + return cached; } for (var i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { @@ -28851,8 +30700,9 @@ var ts; firstAntecedentType = flowType; } var type = getTypeFromFlowType(flowType); - if (cache[key]) { - return cache[key]; + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; } if (!ts.contains(antecedentTypes, type)) { antecedentTypes.push(type); @@ -28868,10 +30718,11 @@ var ts; if (isIncomplete(firstAntecedentType)) { return createFlowType(result, true); } - return cache[key] = result; + cache.set(key, result); + return result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 177 && + return expr.kind === 178 && declaredType.flags & 65536 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -28905,10 +30756,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 187 && right_1.kind === 9) { + if (left_1.kind === 188 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 187 && left_1.kind === 9) { + if (right_1.kind === 188 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -28954,7 +30805,7 @@ var ts; assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); } - if (type.flags & 33281) { + if (type.flags & 16810497) { return type; } if (assumeTrue) { @@ -28979,14 +30830,14 @@ var ts; assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 65536)) { - var targetType = typeofTypesByName[literal.text]; + var targetType = typeofTypesByName.get(literal.text); if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; } } var facts = assumeTrue ? - typeofEQFacts[literal.text] || 64 : - typeofNEFacts[literal.text] || 8192; + typeofEQFacts.get(literal.text) || 64 : + typeofNEFacts.get(literal.text) || 8192; return getTypeWithFacts(type, facts); } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { @@ -29086,7 +30937,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 178 || invokedExpression.kind === 177) { + if (invokedExpression.kind === 179 || invokedExpression.kind === 178) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -29103,15 +30954,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 177: + case 178: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 179: + case 180: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 183: + case 184: return narrowType(type, expr.expression, assumeTrue); - case 192: + case 193: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 190: + case 191: if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } @@ -29138,9 +30989,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 232 || - node.kind === 262 || - node.kind === 147) { + node.kind === 233 || + node.kind === 264 || + node.kind === 148) { return node; } } @@ -29171,7 +31022,7 @@ var ts; if (node.kind === 70) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 144) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 145) { symbol.isAssigned = true; } } @@ -29191,7 +31042,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 185) { + if (container.kind === 186) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { @@ -29209,7 +31060,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; - if (declaration_1.kind === 227 + if (declaration_1.kind === 228 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -29221,11 +31072,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 197) { + else if (declaration_1.kind === 198) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 147 && ts.hasModifier(container, 32)) { + if (container.kind === 148 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -29255,12 +31106,12 @@ var ts; if (!(localOrExportSymbol.flags & 3) || assignmentKind === 1 || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 144; + var isParameter = ts.getRootDeclaration(declaration).kind === 145; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && (flowContainer.kind === 184 || - flowContainer.kind === 185 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 185 || + flowContainer.kind === 186 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -29296,7 +31147,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 257) { + symbol.valueDeclaration.parent.kind === 259) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -29314,8 +31165,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 212 && - ts.getAncestor(symbol.valueDeclaration, 225).parent === container && + if (container.kind === 213 && + ts.getAncestor(symbol.valueDeclaration, 226).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -29327,14 +31178,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 183) { + while (current.parent.kind === 184) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 190 || current.parent.kind === 191)) { + else if ((current.parent.kind === 191 || current.parent.kind === 192)) { var expr = current.parent; isAssigned = expr.operator === 42 || expr.operator === 43; } @@ -29353,7 +31204,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 147 || container.kind === 150) { + if (container.kind === 148 || container.kind === 151) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -29397,32 +31248,32 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 150) { + if (container.kind === 151) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 185) { + if (container.kind === 186) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 231: + case 232: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 230: + case 231: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 150: + case 151: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 148: case 147: - case 146: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 142: + case 143: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -29431,7 +31282,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 184 && + if (container.kind === 185 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -29466,27 +31317,27 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 275) { + if (jsdocType && jsdocType.kind === 278) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 278) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 281) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 144) { + if (n.kind === 145) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 179 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 180 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 185) { + while (container && container.kind === 186) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -29495,16 +31346,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 142) { + while (current && current !== container && current.kind !== 143) { current = current.parent; } - if (current && current.kind === 142) { + if (current && current.kind === 143) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 176)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 177)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -29512,7 +31363,7 @@ var ts; } return unknownType; } - if (!isCallExpression && container.kind === 150) { + if (!isCallExpression && container.kind === 151) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if ((ts.getModifierFlags(container) & 32) || isCallExpression) { @@ -29522,7 +31373,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 149 && ts.getModifierFlags(container) & 256) { + if (container.kind === 150 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -29533,7 +31384,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 176) { + if (container.parent.kind === 177) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -29551,7 +31402,7 @@ var ts; } return unknownType; } - if (container.kind === 150 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 151 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -29563,24 +31414,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 150; + return container.kind === 151; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 176) { + if (ts.isClassLike(container.parent) || container.parent.kind === 177) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 149 || - container.kind === 148 || - container.kind === 151 || - container.kind === 152; + return container.kind === 150 || + container.kind === 149 || + container.kind === 152 || + container.kind === 153; } else { - return container.kind === 149 || - container.kind === 148 || - container.kind === 151 || + return container.kind === 150 || + container.kind === 149 || container.kind === 152 || + container.kind === 153 || + container.kind === 148 || container.kind === 147 || - container.kind === 146 || - container.kind === 150; + container.kind === 151; } } } @@ -29588,7 +31439,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 185) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 186) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -29603,23 +31454,23 @@ var ts; var func = parameter.parent; if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { var iife = ts.getImmediatelyInvokedFunctionExpression(func); - if (iife) { + if (iife && iife.arguments) { var indexOfParameter = ts.indexOf(func.parameters, parameter); - if (iife.arguments && indexOfParameter < iife.arguments.length) { - if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return createArrayType(getUnionType(restTypes)); + if (parameter.dotDotDotToken) { + var restTypes = []; + for (var i = indexOfParameter; i < iife.arguments.length; i++) { + restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); } - var links = getNodeLinks(iife); - var cached = links.resolvedSignature; - links.resolvedSignature = anySignature; - var type = getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])); - links.resolvedSignature = cached; - return type; + return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; } + var links = getNodeLinks(iife); + var cached = links.resolvedSignature; + links.resolvedSignature = anySignature; + var type = indexOfParameter < iife.arguments.length ? + getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + parameter.initializer ? undefined : undefinedWideningType; + links.resolvedSignature = cached; + return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -29644,7 +31495,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 144) { + if (declaration.kind === 145) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -29655,11 +31506,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_20 = declaration.propertyName || declaration.name; + var name = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_20)) { - var text = ts.getTextOfPropertyName(name_20); + !ts.isBindingPattern(name)) { + var text = ts.getTextOfPropertyName(name); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -29696,7 +31547,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 144 && node.parent.initializer === node) { + if (node.parent.kind === 145 && node.parent.initializer === node) { return true; } node = node.parent; @@ -29705,8 +31556,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 150 || - functionDecl.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 152))) { + functionDecl.kind === 151 || + functionDecl.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 153))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -29725,7 +31576,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 181) { + if (template.parent.kind === 182) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -29762,8 +31613,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -29830,19 +31681,16 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxAttribute(attribute) { - var kind = attribute.kind; - var jsxElement = attribute.parent; - var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 251) { - if (!attrsType || isTypeAny(attrsType)) { + var attributesType = getContextualType(attribute.parent); + if (ts.isJsxAttribute(attribute)) { + if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attrsType, attribute.name.text); + return getTypeOfPropertyOfType(attributesType, attribute.name.text); } - else if (attribute.kind === 252) { - return attrsType; + else { + return attributesType; } - ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); } function getApparentTypeOfContextualType(node) { var type = getContextualType(node); @@ -29857,42 +31705,45 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 224: - case 144: + case 225: + case 145: + case 148: case 147: - case 146: - case 174: - return getContextualTypeForInitializerExpression(node); - case 185: - case 217: - return getContextualTypeForReturnExpression(node); - case 195: - return getContextualTypeForYieldOperand(parent); - case 179: - case 180: - return getContextualTypeForArgument(parent, node); - case 182: - case 200: - return getTypeFromTypeNode(parent.type); - case 192: - return getContextualTypeForBinaryOperand(node); - case 258: - case 259: - return getContextualTypeForObjectLiteralElement(parent); case 175: - return getContextualTypeForElementExpression(node); - case 193: - return getContextualTypeForConditionalOperand(node); - case 203: - ts.Debug.assert(parent.parent.kind === 194); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 186: + case 218: + return getContextualTypeForReturnExpression(node); + case 196: + return getContextualTypeForYieldOperand(parent); + case 180: + case 181: + return getContextualTypeForArgument(parent, node); case 183: + case 201: + return getTypeFromTypeNode(parent.type); + case 193: + return getContextualTypeForBinaryOperand(node); + case 260: + case 261: + return getContextualTypeForObjectLiteralElement(parent); + case 176: + return getContextualTypeForElementExpression(node); + case 194: + return getContextualTypeForConditionalOperand(node); + case 204: + ts.Debug.assert(parent.parent.kind === 195); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 184: return getContextualType(parent); - case 253: + case 255: return getContextualType(parent); - case 251: case 252: + case 254: return getContextualTypeForJsxAttribute(parent); + case 250: + case 249: + return getAttributesTypeFromJsxOpeningLikeElement(parent); } return undefined; } @@ -29920,7 +31771,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 184 || node.kind === 185; + return node.kind === 185 || node.kind === 186; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -29933,7 +31784,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -29943,8 +31794,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var current = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -29974,8 +31825,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 174 && !!node.initializer) || - (node.kind === 192 && node.operatorToken.kind === 57); + return (node.kind === 175 && !!node.initializer) || + (node.kind === 193 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -29984,7 +31835,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 196) { + if (inDestructuringPattern && e.kind === 197) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -29996,7 +31847,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 196; + hasSpreadElement = hasSpreadElement || e.kind === 197; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -30007,7 +31858,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 173 || pattern.kind === 175)) { + if (pattern && (pattern.kind === 174 || pattern.kind === 176)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -30015,7 +31866,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 198) { + if (patternElement.kind !== 199) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -30032,7 +31883,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 142 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 143 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -30078,7 +31929,7 @@ var ts; var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 172 || contextualType.pattern.kind === 176); + (contextualType.pattern.kind === 173 || contextualType.pattern.kind === 177); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -30087,27 +31938,27 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 258 || - memberDecl.kind === 259 || + if (memberDecl.kind === 260 || + memberDecl.kind === 261 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 258) { + if (memberDecl.kind === 260) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 149) { + else if (memberDecl.kind === 150) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 259); + ts.Debug.assert(memberDecl.kind === 261); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; - var prop = createSymbol(4 | 67108864 | member.flags, member.name); + var prop = createSymbol(4 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 258 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 259 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 260 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 261 && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 536870912; + prop.flags |= 67108864; } if (ts.hasDynamicName(memberDecl)) { patternWithComputedProperties = true; @@ -30116,7 +31967,7 @@ var ts; else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & 512)) { var impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { - prop.flags |= impliedProp.flags & 536870912; + prop.flags |= impliedProp.flags & 67108864; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -30131,12 +31982,12 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 260) { - if (languageVersion < 5) { + else if (memberDecl.kind === 262) { + if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), true); + spread = getSpreadType(spread, createObjectLiteralType()); propertiesArray = []; propertiesTable = ts.createMap(); hasComputedStringProperty = false; @@ -30148,12 +31999,12 @@ var ts; error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } - spread = getSpreadType(spread, type, false); + spread = getSpreadType(spread, type); offset = i + 1; continue; } else { - ts.Debug.assert(memberDecl.kind === 151 || memberDecl.kind === 152); + ts.Debug.assert(memberDecl.kind === 152 || memberDecl.kind === 153); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -30165,25 +32016,25 @@ var ts; } } else { - propertiesTable[member.name] = member; + propertiesTable.set(member.name, member); } propertiesArray.push(member); } if (contextualTypeHasPattern) { for (var _i = 0, _a = getPropertiesOfType(contextualType); _i < _a.length; _i++) { var prop = _a[_i]; - if (!propertiesTable[prop.name]) { - if (!(prop.flags & 536870912)) { + if (!propertiesTable.get(prop.name)) { + if (!(prop.flags & 67108864)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } - propertiesTable[prop.name] = prop; + propertiesTable.set(prop.name, prop); propertiesArray.push(prop); } } } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), true); + spread = getSpreadType(spread, createObjectLiteralType()); } if (spread.flags & 32768) { spread.flags |= propagatedFlags; @@ -30212,7 +32063,7 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (1 | 4096 | 2048) || + return !!(type.flags & (1 | 4096 | 2048 | 16777216) || type.flags & 32768 && !isGenericMappedType(type) || type.flags & 196608 && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } @@ -30231,13 +32082,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 253: + case 255: checkJsxExpression(child); break; - case 247: + case 248: checkJsxElement(child); break; - case 248: + case 249: checkJsxSelfClosingElement(child); break; } @@ -30248,71 +32099,88 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 177 || tagName.kind === 98) { + if (tagName.kind === 178 || tagName.kind === 98) { 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 (isUnhyphenatedJsxName(node.name.text)) { - var attributeType = getTypeOfPropertyOfType(elementAttributesType, ts.getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0); - if (attributeType) { - correspondingPropType = attributeType; + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, contextualMapper) { + var attributes = openingLikeElement.attributes; + var attributesTable = ts.createMap(); + var spread = emptyObjectType; + var attributesArray = []; + for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { + var attributeDecl = _a[_i]; + var member = attributeDecl.symbol; + if (ts.isJsxAttribute(attributeDecl)) { + var exprType = attributeDecl.initializer ? + checkExpression(attributeDecl.initializer, contextualMapper) : + trueType; + var attributeSymbol = createSymbol(4 | 134217728 | member.flags, member.name); + attributeSymbol.declarations = member.declarations; + attributeSymbol.parent = member.parent; + if (member.valueDeclaration) { + attributeSymbol.valueDeclaration = member.valueDeclaration; } - else { - if (!correspondingPropType) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; - } + attributeSymbol.type = exprType; + attributeSymbol.target = member; + attributesTable.set(attributeSymbol.name, attributeSymbol); + attributesArray.push(attributeSymbol); + } + else { + ts.Debug.assert(attributeDecl.kind === 254); + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); } + var exprType = checkExpression(attributeDecl.expression); + if (!(exprType.flags & (32768 | 1))) { + error(attributeDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + return anyType; + } + if (isTypeAny(exprType)) { + return anyType; + } + spread = getSpreadType(spread, exprType); } } - var exprType; - if (node.initializer) { - exprType = checkExpression(node.initializer); + if (spread !== emptyObjectType) { + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); + } + attributesArray = getPropertiesOfType(spread); } - else { - exprType = booleanType; + attributesTable = ts.createMap(); + if (attributesArray) { + ts.forEach(attributesArray, function (attr) { + if (!filter || filter(attr)) { + attributesTable.set(attr.name, attr); + } + }); } - if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, node); + return createJsxAttributesType(attributes.symbol, attributesTable); + function createJsxAttributesType(symbol, attributesTable) { + var result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, undefined, undefined); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; + result.flags |= 33554432 | 4194304 | freshObjectLiteralFlag; + result.objectFlags |= 128; + return result; } - nameTable[node.name.text] = true; - return exprType; } - function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { - if (compilerOptions.jsx === 2) { - checkExternalEmitHelpers(node, 2); - } - var type = checkExpression(node.expression); - var props = getPropertiesOfType(type); - for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { - var prop = props_2[_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 checkJsxAttributes(node, contextualMapper) { + return createJsxAttributesTypeFromAttributesProperty(node.parent, undefined, contextualMapper); } function getJsxType(name) { - if (jsxTypes[name] === undefined) { - return jsxTypes[name] = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType; + var jsxType = jsxTypes.get(name); + if (jsxType === undefined) { + jsxTypes.set(name, jsxType = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType); } - return jsxTypes[name]; + return jsxType; } function getIntrinsicTagSymbol(node) { var links = getNodeLinks(node); @@ -30377,23 +32245,84 @@ var ts; return undefined; } } - function getResolvedJsxType(node, elemType, elemClassType) { - if (!elemType) { - elemType = checkExpression(node.tagName); + function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, undefined); + if (callSignature !== unknownSignature) { + var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); + var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + paramType = intersectTypes(intrinsicAttributes, paramType); + } + return paramType; + } + } + } } - if (elemType.flags & 65536) { - var types = elemType.types; - return getUnionType(ts.map(types, function (type) { - return getResolvedJsxType(node, type, elemClassType); + return undefined; + } + function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + var candidatesOutArray = []; + getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); + var result = void 0; + var allMatchingAttributesType = void 0; + for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { + var candidate = candidatesOutArray_1[_i]; + var callReturnType = getReturnTypeOfSignature(candidate); + var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var shouldBeCandidate = true; + for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { + var attribute = _b[_a]; + if (ts.isJsxAttribute(attribute) && + isUnhyphenatedJsxName(attribute.name.text) && + !getPropertyOfType(paramType, attribute.name.text)) { + shouldBeCandidate = false; + break; + } + } + if (shouldBeCandidate) { + result = intersectTypes(result, paramType); + } + allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); + } + } + if (!result) { + result = allMatchingAttributesType; + } + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + result = intersectTypes(intrinsicAttributes, result); + } + return result; + } + } + return undefined; + } + function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { + if (!elementType) { + elementType = checkExpression(openingLikeElement.tagName); + } + if (elementType.flags & 65536) { + var types = elementType.types; + return getUnionType(types.map(function (type) { + return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); }), true); } - if (elemType.flags & 2) { + if (elementType.flags & 2) { return anyType; } - else if (elemType.flags & 32) { + else if (elementType.flags & 32) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { - var stringLiteralTypeName = elemType.text; + var stringLiteralTypeName = elementType.text; var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); if (intrinsicProp) { return getTypeOfSymbol(intrinsicProp); @@ -30402,28 +32331,19 @@ var ts; if (indexSignatureType) { return indexSignatureType; } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + error(openingLikeElement, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); } return anyType; } - var elemInstanceType = getJsxElementInstanceType(node, elemType); - if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { - if (jsxElementType) { - var callSignatures = elemType && getSignaturesOfType(elemType, 0); - var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); - if (intrinsicAttributes !== unknownType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } + var elemInstanceType = getJsxElementInstanceType(openingLikeElement, elementType); + var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? + tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : + defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); + if (statelessAttributesType) { + return statelessAttributesType; } - if (elemClassType) { - checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + if (elementClassType) { + checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } if (isTypeAny(elemInstanceType)) { return elemInstanceType; @@ -30444,7 +32364,7 @@ var ts; return attributesType; } else if (attributesType.flags & 65536) { - error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); + error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); return anyType; } else { @@ -30469,30 +32389,49 @@ var ts; } } } - function getJsxElementAttributesType(node) { + function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) { + ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName)); var links = getNodeLinks(node); - if (!links.resolvedJsxType) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1) { - return links.resolvedJsxType = getTypeOfSymbol(symbol); - } - else if (links.jsxFlags & 2) { - return links.resolvedJsxType = getIndexInfoOfSymbol(symbol, 0).type; - } - else { - return links.resolvedJsxType = unknownType; - } + if (!links.resolvedJsxElementAttributesType) { + var symbol = getIntrinsicTagSymbol(node); + if (links.jsxFlags & 1) { + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + } + else if (links.jsxFlags & 2) { + return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, 0).type; } else { - var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxType = getResolvedJsxType(node, undefined, elemClassType); + return links.resolvedJsxElementAttributesType = unknownType; } } - return links.resolvedJsxType; + return links.resolvedJsxElementAttributesType; + } + function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { + var links = getNodeLinks(node); + if (!links.resolvedJsxElementAttributesType) { + var elemClassType = getJsxGlobalElementClassType(); + return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); + } + return links.resolvedJsxElementAttributesType; + } + function getAllAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, true); + } + } + function getAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, false); + } } function getJsxAttributePropertySymbol(attrib) { - var attributesType = getJsxElementAttributesType(attrib.parent); + var attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent); var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } @@ -30528,34 +32467,25 @@ var ts; markAliasSymbolAsReferenced(reactSym); } } - var targetAttributesType = getJsxElementAttributesType(node); - var nameTable = ts.createMap(); - var sawSpreadedAny = false; - for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 251) { - checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); - } - else { - ts.Debug.assert(node.attributes[i].kind === 252); - var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if (isTypeAny(spreadType)) { - sawSpreadedAny = true; - } - } + checkJsxAttributesAssignableToTagNameAttributes(node); + } + function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement) { + var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? + getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : + getCustomJsxElementAttributesType(openingLikeElement, false); + var sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, function (attribute) { + return isUnhyphenatedJsxName(attribute.name) || !!(getPropertyOfType(targetAttributesType, attribute.name)); + }); + if (targetAttributesType === emptyObjectType && (isTypeAny(sourceAttributesType) || sourceAttributesType.properties.length > 0)) { + error(openingLikeElement, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); } - if (targetAttributesType && !sawSpreadedAny) { - var targetProperties = getPropertiesOfType(targetAttributesType); - for (var i = 0; i < targetProperties.length; i++) { - if (!(targetProperties[i].flags & 536870912) && - !nameTable[targetProperties[i].name]) { - error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); - } - } + else { + checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); } } - function checkJsxExpression(node) { + function checkJsxExpression(node, contextualMapper) { if (node.expression) { - var type = checkExpression(node.expression); + var type = checkExpression(node.expression, contextualMapper); if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); } @@ -30566,27 +32496,48 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 147; + return s.valueDeclaration ? s.valueDeclaration.kind : 148; } function getDeclarationModifierFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; + if (s.valueDeclaration) { + var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + return s.parent && s.parent.flags & 32 ? flags : flags & ~28; + } + if (getCheckFlags(s) & 2) { + var checkFlags = s.checkFlags; + var accessModifier = checkFlags & 128 ? 8 : + checkFlags & 32 ? 4 : + 16; + var staticModifier = checkFlags & 256 ? 32 : 0; + return accessModifier | staticModifier; + } + if (s.flags & 16777216) { + return 4 | 32; + } + return 0; } function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; } - function checkClassPropertyAccess(node, left, type, prop) { + function checkPropertyAccessibility(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 || node.kind === 224 ? + var errorNode = node.kind === 178 || node.kind === 225 ? node.name : node.right; + if (getCheckFlags(prop) & 128) { + error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); + return false; + } if (left.kind === 96) { - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 149) { - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - return false; + if (languageVersion < 2) { + var propKind = getDeclarationKindFromSymbol(prop); + if (propKind !== 150 && propKind !== 149) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } } if (flags & 128) { - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } } @@ -30596,7 +32547,7 @@ var ts; if (flags & 8) { var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } return true; @@ -30606,10 +32557,10 @@ var ts; } var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return hasBaseType(enclosingClass, declaringClass) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; }); if (!enclosingClass) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); return false; } if (flags & 32) { @@ -30625,16 +32576,17 @@ var ts; return true; } function checkNonNullExpression(node) { - var type = checkExpression(node); - if (strictNullChecks) { - var kind = getFalsyFlags(type) & 6144; - if (kind) { - error(node, kind & 2048 ? kind & 4096 ? - ts.Diagnostics.Object_is_possibly_null_or_undefined : - ts.Diagnostics.Object_is_possibly_undefined : - ts.Diagnostics.Object_is_possibly_null); - } - return getNonNullableType(type); + return checkNonNullType(checkExpression(node), node); + } + function checkNonNullType(type, errorNode) { + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 6144; + if (kind) { + error(errorNode, kind & 2048 ? kind & 4096 ? + ts.Diagnostics.Object_is_possibly_null_or_undefined : + ts.Diagnostics.Object_is_possibly_undefined : + ts.Diagnostics.Object_is_possibly_null); + var t = getNonNullableType(type); + return t.flags & (6144 | 8192) ? unknownType : t; } return type; } @@ -30663,7 +32615,7 @@ var ts; noUnusedIdentifiers && (prop.flags & 106500) && prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8)) { - if (prop.flags & 16777216) { + if (getCheckFlags(prop) & 1) { getSymbolLinks(prop).target.isReferenced = true; } else { @@ -30671,6 +32623,15 @@ var ts; } } } + function isInPropertyInitializer(node) { + while (node) { + if (node.parent && node.parent.kind === 148 && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { var type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -30682,16 +32643,23 @@ var ts; } var prop = getPropertyOfType(apparentType, right.text); if (!prop) { + var stringIndexType = getIndexTypeOfType(apparentType, 0); + if (stringIndexType) { + return stringIndexType; + } if (right.text && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & 16384 && type.isThisType ? apparentType : type); } return unknownType; } + if (prop.valueDeclaration && + isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; - if (prop.parent && prop.parent.flags & 32) { - checkClassPropertyAccess(node, left, apparentType, prop); - } + checkPropertyAccessibility(node, left, apparentType, prop); var propType = getTypeOfSymbol(prop); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { @@ -30700,7 +32668,7 @@ var ts; return unknownType; } } - if (node.kind !== 177 || assignmentKind === 1 || + if (node.kind !== 178 || assignmentKind === 1 || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 65536)) { return propType; @@ -30709,21 +32677,21 @@ var ts; return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 177 + var left = node.kind === 178 ? 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) { - return checkClassPropertyAccess(node, left, type, prop); + if (prop) { + return checkPropertyAccessibility(node, left, type, prop); } } return true; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 225) { + if (initializer.kind === 226) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -30745,7 +32713,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 213 && + if (node.kind === 214 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -30763,7 +32731,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 180 && node.parent.expression === node) { + if (node.parent.kind === 181 && 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); @@ -30783,7 +32751,7 @@ var ts; error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } - return getIndexedAccessType(objectType, indexType, node); + return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === unknownType) { @@ -30816,10 +32784,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 181) { + if (node.kind === 182) { checkExpression(node.template); } - else if (node.kind !== 145) { + else if (node.kind !== 146) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -30841,19 +32809,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_9 = signature.declaration && signature.declaration.parent; + var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_9 === lastParent) { + if (lastParent && parent === lastParent) { index++; } else { - lastParent = parent_9; + lastParent = parent; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_9; + lastParent = parent; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -30870,7 +32838,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 196) { + if (arg && arg.kind === 197) { return i; } } @@ -30883,11 +32851,14 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 181) { + if (ts.isJsxOpeningLikeElement(node)) { + return true; + } + if (node.kind === 182) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 194) { + if (tagExpression.template.kind === 195) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -30899,7 +32870,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 145) { + else if (node.kind === 146) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -30907,7 +32878,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 180); + ts.Debug.assert(callExpression.kind === 181); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -30915,8 +32886,10 @@ var ts; typeArguments = callExpression.typeArguments; spreadArgIndex = getSpreadArgumentIndex(args); } + var numTypeParameters = ts.length(signature.typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters); var hasRightNumberOfTypeArgs = !typeArguments || - (signature.typeParameters && typeArguments.length === signature.typeParameters.length); + (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters); if (!hasRightNumberOfTypeArgs) { return false; } @@ -30966,7 +32939,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 !== 198) { + if (arg === undefined || arg.kind !== 199) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -30991,7 +32964,7 @@ var ts; var typeParameters = signature.typeParameters; var typeArgumentsAreAssignable = true; var mapper; - for (var i = 0; i < typeParameters.length; i++) { + for (var i = 0; i < typeArgumentNodes.length; i++) { if (typeArgumentsAreAssignable) { var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { @@ -31011,9 +32984,29 @@ var ts; } return typeArgumentsAreAssignable; } + function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { + var callIsIncomplete = node.attributes.end === node.end; + if (callIsIncomplete) { + return true; + } + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + var paramType = getTypeAtPosition(signature, 0); + var attributesType = checkExpressionWithContextualType(node.attributes, paramType, undefined); + var argProperties = getPropertiesOfType(attributesType); + for (var _i = 0, argProperties_1 = argProperties; _i < argProperties_1.length; _i++) { + var arg = argProperties_1[_i]; + if (!getPropertyOfType(paramType, arg.name) && isUnhyphenatedJsxName(arg.name)) { + return false; + } + } + return checkTypeRelatedTo(attributesType, paramType, relation, undefined, headMessage); + } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { + if (ts.isJsxOpeningLikeElement(node)) { + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 180) { + if (thisType && thisType !== voidType && node.kind !== 181) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -31026,7 +33019,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 !== 198) { + if (arg === undefined || arg.kind !== 199) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -31041,51 +33034,54 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 179) { + if (node.kind === 180) { var callee = node.expression; - if (callee.kind === 177) { + if (callee.kind === 178) { return callee.expression; } - else if (callee.kind === 178) { + else if (callee.kind === 179) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 181) { + if (node.kind === 182) { var template = node.template; args = [undefined]; - if (template.kind === 194) { + if (template.kind === 195) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 145) { + else if (node.kind === 146) { return undefined; } + else if (ts.isJsxOpeningLikeElement(node)) { + args = node.attributes.properties.length > 0 ? [node.attributes] : emptyArray; + } else { args = node.arguments || emptyArray; } return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 145) { + if (node.kind === 146) { switch (node.parent.kind) { - case 227: - case 197: + case 228: + case 198: return 1; - case 147: + case 148: return 2; - case 149: - case 151: + case 150: case 152: + case 153: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 144: + case 145: return 3; } } @@ -31094,48 +33090,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 227) { + if (node.kind === 228) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 144) { + if (node.kind === 145) { node = node.parent; - if (node.kind === 150) { + if (node.kind === 151) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 152 || + node.kind === 153) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 227) { + if (node.kind === 228) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 144) { + if (node.kind === 145) { node = node.parent; - if (node.kind === 150) { + if (node.kind === 151) { return anyType; } } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 152 || + node.kind === 153) { var element = node; switch (element.name.kind) { case 70: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 142: + case 143: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -31152,20 +33148,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 227) { + if (node.kind === 228) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 144) { + if (node.kind === 145) { return numberType; } - if (node.kind === 147) { + if (node.kind === 148) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 150 || + node.kind === 152 || + node.kind === 153) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -31186,26 +33182,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex) { - if (node.kind === 145) { + if (node.kind === 146) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 181) { + else if (argIndex === 0 && node.kind === 182) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 145 || - (argIndex === 0 && node.kind === 181)) { + if (node.kind === 146 || + (argIndex === 0 && node.kind === 182)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 145) { + if (node.kind === 146) { return node.expression; } - else if (argIndex === 0 && node.kind === 181) { + else if (argIndex === 0 && node.kind === 182) { return node.template; } else { @@ -31213,10 +33209,11 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 181; - var isDecorator = node.kind === 145; + var isTaggedTemplate = node.kind === 182; + var isDecorator = node.kind === 146; + var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; - if (!isTaggedTemplate && !isDecorator) { + if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) { typeArguments = node.typeArguments; if (node.expression.kind !== 96) { ts.forEach(typeArguments, checkSourceElement); @@ -31244,7 +33241,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 179 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 180 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -31258,6 +33255,9 @@ var ts; return result; } if (candidateForArgumentError) { + if (isJsxOpeningOrSelfClosingElement) { + return candidateForArgumentError; + } checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); } else if (candidateForTypeArgumentError) { @@ -31273,7 +33273,7 @@ var ts; if (headMessage) { diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); } - reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); + reportNoCommonSupertypeError(inferenceCandidates, node.tagName || node.expression || node.tag, diagnosticChainHead); } } else { @@ -31316,13 +33316,13 @@ var ts; if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNode); + typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); - typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; } if (!typeArgumentsAreValid) { break; @@ -31513,16 +33513,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 227: - case 197: + case 228: + case 198: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 144: + case 145: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 147: + case 148: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 149: - case 151: + case 150: case 152: + case 153: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -31547,16 +33547,42 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray, headMessage); } + function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray) { + ts.Debug.assert(!(elementType.flags & 65536)); + var callSignature = resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray); + return callSignature; + } + function resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray) { + if (elementType.flags & 65536) { + var types = elementType.types; + var result = void 0; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); + } + return result; + } + var callSignatures = elementType && getSignaturesOfType(elementType, 0); + if (callSignatures && callSignatures.length > 0) { + var callSignature = void 0; + callSignature = resolveCall(openingLikeElement, callSignatures, candidatesOutArray); + return callSignature; + } + return undefined; + } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 179: - return resolveCallExpression(node, candidatesOutArray); case 180: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 181: + return resolveNewExpression(node, candidatesOutArray); + case 182: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 145: + case 146: return resolveDecorator(node, candidatesOutArray); + case 250: + case 249: + return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); } @@ -31587,12 +33613,12 @@ var ts; if (node.expression.kind === 96) { return voidType; } - if (node.kind === 180) { + if (node.kind === 181) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 150 && - declaration.kind !== 154 && - declaration.kind !== 159 && + declaration.kind !== 151 && + declaration.kind !== 155 && + declaration.kind !== 160 && !ts.isJSDocConstructSignature(declaration)) { var funcSymbol = node.expression.kind === 70 ? getResolvedSymbol(node.expression) : @@ -31623,9 +33649,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 226 + ? 227 : resolvedRequire.flags & 3 - ? 224 + ? 225 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -31659,7 +33685,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return unknownType; } - else if (container.kind === 150) { + else if (container.kind === 151) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -31697,7 +33723,7 @@ var ts; var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { if (!parameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); } assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } @@ -31735,8 +33761,8 @@ var ts; if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 172 || - parameter.valueDeclaration.name.kind === 173)) { + (parameter.valueDeclaration.name.kind === 173 || + parameter.valueDeclaration.name.kind === 174)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -31766,6 +33792,9 @@ var ts; error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } + else if (!getGlobalPromiseConstructorSymbol()) { + error(func, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } return promiseType; } function getReturnTypeFromBody(func, contextualMapper) { @@ -31775,7 +33804,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 205) { + if (func.body.kind !== 206) { 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); @@ -31854,7 +33883,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 219 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 220 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -31883,7 +33912,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 184 || func.kind === 185)) { + func.kind === 185 || func.kind === 186)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -31900,7 +33929,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 205 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 206 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -31927,9 +33956,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 184) { + if (!hasGrammarError && node.kind === 185) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -31963,7 +33992,7 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 149) { + if (produceDiagnostics && node.kind !== 150) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithCapturedNewTargetVariable(node, node.name); @@ -31971,7 +34000,7 @@ var ts; return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -31981,7 +34010,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 205) { + if (node.body.kind === 206) { checkSourceElement(node.body); } else { @@ -32007,19 +34036,19 @@ var ts; return true; } function isReadonlySymbol(symbol) { - return symbol.isReadonly || - symbol.flags & 4 && (getDeclarationModifierFlagsFromSymbol(symbol) & 64) !== 0 || - symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 || + return !!(getCheckFlags(symbol) & 4 || + symbol.flags & 4 && getDeclarationModifierFlagsFromSymbol(symbol) & 64 || + symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 || symbol.flags & 98304 && !(symbol.flags & 65536) || - (symbol.flags & 8) !== 0; + symbol.flags & 8); } function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 177 || expr.kind === 178) && + (expr.kind === 178 || expr.kind === 179) && expr.expression.kind === 98) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 150)) + if (!(func && func.kind === 151)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -32028,13 +34057,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 177 || expr.kind === 178) { + if (expr.kind === 178 || expr.kind === 179) { var node = ts.skipParentheses(expr.expression); if (node.kind === 70) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 238; + return declaration && declaration.kind === 239; } } } @@ -32042,7 +34071,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage) { var node = ts.skipParentheses(expr); - if (node.kind !== 70 && node.kind !== 177 && node.kind !== 178) { + if (node.kind !== 70 && node.kind !== 178 && node.kind !== 179) { error(expr, invalidReferenceMessage); return false; } @@ -32051,7 +34080,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 177 && expr.kind !== 178) { + if (expr.kind !== 178 && expr.kind !== 179) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -32064,7 +34093,7 @@ var ts; } function checkTypeOfExpression(node) { checkExpression(node.expression); - return stringType; + return typeofType; } function checkVoidExpression(node) { checkExpression(node.expression); @@ -32094,6 +34123,7 @@ var ts; case 36: case 37: case 51: + checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 512)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } @@ -32105,7 +34135,7 @@ var ts; booleanType; case 42: case 43: - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); } @@ -32118,7 +34148,7 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); } @@ -32130,8 +34160,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -32145,8 +34175,8 @@ var ts; } if (type.flags & 65536) { var types = type.types; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var t = types_19[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -32155,8 +34185,8 @@ var ts; } if (type.flags & 131072) { var types = type.types; - for (var _a = 0, types_18 = types; _a < types_18.length; _a++) { - var t = types_18[_a]; + for (var _a = 0, types_20 = types; _a < types_20.length; _a++) { + var t = types_20[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -32177,7 +34207,10 @@ var ts; if (isTypeOfKind(leftType, 8190)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } - if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { + if (!(isTypeAny(rightType) || + getSignaturesOfType(rightType, 0).length || + getSignaturesOfType(rightType, 1).length || + isTypeSubtypeOf(rightType, globalFunctionType))) { error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; @@ -32186,6 +34219,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 | 512))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } @@ -32203,22 +34238,22 @@ var ts; return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 258 || property.kind === 259) { - var name_21 = property.name; - if (name_21.kind === 142) { - checkComputedPropertyName(name_21); + if (property.kind === 260 || property.kind === 261) { + var name = property.name; + if (name.kind === 143) { + checkComputedPropertyName(name); } - if (isComputedNonLiteralName(name_21)) { + if (isComputedNonLiteralName(name)) { return undefined; } - var text = ts.getTextOfPropertyName(name_21); + var text = ts.getTextOfPropertyName(name); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 259) { + if (property.kind === 261) { return checkDestructuringAssignment(property, type); } else { @@ -32226,10 +34261,10 @@ var ts; } } else { - error(name_21, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_21)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 260) { + else if (property.kind === 262) { if (languageVersion < 5) { checkExternalEmitHelpers(property, 4); } @@ -32257,8 +34292,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 198) { - if (element.kind !== 196) { + if (element.kind !== 199) { + if (element.kind !== 197) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -32284,7 +34319,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 192 && restExpression.operatorToken.kind === 57) { + if (restExpression.kind === 193 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -32297,7 +34332,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 259) { + if (exprOrAssignment.kind === 261) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -32311,21 +34346,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 192 && target.operatorToken.kind === 57) { + if (target.kind === 193 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 176) { + if (target.kind === 177) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 175) { + if (target.kind === 176) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 260 ? + var error = target.parent.kind === 262 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -32339,35 +34374,35 @@ var ts; case 70: case 9: case 11: - case 181: - case 194: + case 182: + case 195: case 12: case 8: case 100: case 85: case 94: - case 137: - case 184: - case 197: + case 138: case 185: - case 175: + case 198: + case 186: case 176: - case 187: - case 201: + case 177: + case 188: + case 202: + case 249: case 248: - case 247: return true; - case 193: + case 194: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 192: + case 193: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 190: case 191: + case 192: switch (node.operator) { case 50: case 36: @@ -32376,9 +34411,9 @@ var ts; return true; } return false; - case 188: - case 182: - case 200: + case 189: + case 183: + case 201: default: return false; } @@ -32398,7 +34433,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 57 && (left.kind === 176 || left.kind === 175)) { + if (operator === 57 && (left.kind === 177 || left.kind === 176)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -32429,12 +34464,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (leftType.flags & 6144) - leftType = rightType; - if (rightType.flags & 6144) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); var suggestedOperator = void 0; if ((leftType.flags & 136) && (rightType.flags & 136) && @@ -32454,12 +34485,10 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (leftType.flags & 6144) - leftType = rightType; - if (rightType.flags & 6144) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + if (!isTypeOfKind(leftType, 1 | 262178) && !isTypeOfKind(rightType, 1 | 262178)) { + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); + } var resultType = void 0; if (isTypeOfKind(leftType, 340) && isTypeOfKind(rightType, 340)) { resultType = numberType; @@ -32488,8 +34517,8 @@ var ts; case 29: case 30: if (checkForDisallowedESSymbolOperand(operator)) { - leftType = getBaseTypeOfLiteralType(leftType); - rightType = getBaseTypeOfLiteralType(rightType); + leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); + rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } @@ -32658,7 +34687,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 182 || node.kind === 200; + return node.kind === 183 || node.kind === 201; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -32669,11 +34698,11 @@ var ts; function isLiteralContextualType(contextualType) { if (contextualType) { if (contextualType.flags & 540672) { - var apparentType = getApparentTypeOfTypeVariable(contextualType); - if (apparentType.flags & (2 | 4 | 8 | 16)) { + var constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; + if (constraint.flags & (2 | 4 | 8 | 16)) { return true; } - contextualType = apparentType; + contextualType = constraint; } return maybeTypeOfKind(contextualType, (480 | 262144)); } @@ -32684,14 +34713,14 @@ var ts; return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -32713,7 +34742,7 @@ var ts; return type; } function getTypeOfExpression(node) { - if (node.kind === 179 && node.expression.kind !== 96) { + if (node.kind === 180 && node.expression.kind !== 96) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -32724,7 +34753,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 141) { + if (node.kind === 142) { type = checkQualifiedName(node); } else { @@ -32732,9 +34761,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 177 && node.parent.expression === node) || - (node.parent.kind === 178 && node.parent.expression === node) || - ((node.kind === 70 || node.kind === 141) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 178 && node.parent.expression === node) || + (node.parent.kind === 179 && node.parent.expression === node) || + ((node.kind === 70 || node.kind === 142) && 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); } @@ -32756,68 +34785,70 @@ var ts; case 100: case 85: return checkLiteralExpression(node); - case 194: + case 195: return checkTemplateExpression(node); case 12: return stringType; case 11: return globalRegExpType; - case 175: - return checkArrayLiteral(node, contextualMapper); case 176: - return checkObjectLiteral(node, contextualMapper); + return checkArrayLiteral(node, contextualMapper); case 177: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, contextualMapper); case 178: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 179: + return checkIndexedAccess(node); case 180: - return checkCallExpression(node); case 181: - return checkTaggedTemplateExpression(node); - case 183: - return checkExpression(node.expression, contextualMapper); - case 197: - return checkClassExpression(node); - case 184: - case 185: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 187: - return checkTypeOfExpression(node); + return checkCallExpression(node); case 182: - case 200: - return checkAssertion(node); - case 201: - return checkNonNullAssertion(node); - case 202: - return checkMetaProperty(node); - case 186: - return checkDeleteExpression(node); - case 188: - return checkVoidExpression(node); - case 189: - return checkAwaitExpression(node); - case 190: - return checkPrefixUnaryExpression(node); - case 191: - return checkPostfixUnaryExpression(node); - case 192: - return checkBinaryExpression(node, contextualMapper); - case 193: - return checkConditionalExpression(node, contextualMapper); - case 196: - return checkSpreadExpression(node, contextualMapper); + return checkTaggedTemplateExpression(node); + case 184: + return checkExpression(node.expression, contextualMapper); case 198: + return checkClassExpression(node); + case 185: + case 186: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 188: + return checkTypeOfExpression(node); + case 183: + case 201: + return checkAssertion(node); + case 202: + return checkNonNullAssertion(node); + case 203: + return checkMetaProperty(node); + case 187: + return checkDeleteExpression(node); + case 189: + return checkVoidExpression(node); + case 190: + return checkAwaitExpression(node); + case 191: + return checkPrefixUnaryExpression(node); + case 192: + return checkPostfixUnaryExpression(node); + case 193: + return checkBinaryExpression(node, contextualMapper); + case 194: + return checkConditionalExpression(node, contextualMapper); + case 197: + return checkSpreadExpression(node, contextualMapper); + case 199: return undefinedWideningType; - case 195: + case 196: return checkYieldExpression(node); - case 253: - return checkJsxExpression(node); - case 247: - return checkJsxElement(node); + case 255: + return checkJsxExpression(node, contextualMapper); case 248: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 249: + return checkJsxSelfClosingElement(node); + case 253: + return checkJsxAttributes(node, contextualMapper); + case 250: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -32827,7 +34858,16 @@ var ts; grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } checkSourceElement(node.constraint); - getConstraintOfTypeParameter(getDeclaredTypeOfTypeParameter(getSymbolOfNode(node))); + checkSourceElement(node.default); + var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); + if (!hasNonCircularBaseConstraint(typeParameter)) { + error(node.constraint, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); + } + var constraintType = getConstraintOfTypeParameter(typeParameter); + var defaultType = getDefaultFromTypeParameter(typeParameter); + if (constraintType && defaultType) { + checkTypeAssignableTo(defaultType, getTypeWithThisArgument(constraintType, defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } @@ -32838,7 +34878,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 150 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 151 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -32849,7 +34889,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 150 || func.kind === 154 || func.kind === 159) { + if (func.kind === 151 || func.kind === 155 || func.kind === 160) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -32861,9 +34901,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 149 || - node.kind === 226 || - node.kind === 184; + return node.kind === 150 || + node.kind === 227 || + node.kind === 185; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -32904,9 +34944,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_22 = _a[_i].name; - if (ts.isBindingPattern(name_22) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, parameterName, typePredicate.parameterName)) { + var name = _a[_i].name; + if (ts.isBindingPattern(name) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -32919,16 +34959,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 186: + case 154: + case 227: case 185: - case 153: - case 226: - case 184: - case 158: + case 159: + case 150: case 149: - case 148: - var parent_10 = node.parent; - if (node === parent_10.type) { - return parent_10; + var parent = node.parent; + if (node === parent.type) { + return parent; } } } @@ -32938,27 +34978,27 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_23 = element.name; - if (name_23.kind === 70 && - name_23.text === predicateVariableName) { + var name = element.name; + if (name.kind === 70 && + name.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_23.kind === 173 || - name_23.kind === 172) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_23, predicateVariableNode, predicateVariableName)) { + else if (name.kind === 174 || + name.kind === 173) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } } } } function checkSignatureDeclaration(node) { - if (node.kind === 155) { + if (node.kind === 156) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 || node.kind === 226 || node.kind === 159 || - node.kind === 153 || node.kind === 150 || - node.kind === 154) { + else if (node.kind === 159 || node.kind === 227 || node.kind === 160 || + node.kind === 154 || node.kind === 151 || + node.kind === 155) { checkGrammarFunctionLikeDeclaration(node); } if (ts.isAsyncFunctionLike(node) && languageVersion < 4) { @@ -32976,10 +35016,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 154: + case 155: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 153: + case 154: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -33006,11 +35046,18 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { + var Declaration; + (function (Declaration) { + Declaration[Declaration["Getter"] = 1] = "Getter"; + Declaration[Declaration["Setter"] = 2] = "Setter"; + Declaration[Declaration["Method"] = 4] = "Method"; + Declaration[Declaration["Property"] = 3] = "Property"; + })(Declaration || (Declaration = {})); var instanceNames = ts.createMap(); var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150) { + if (member.kind === 151) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -33019,36 +35066,65 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114; }); + var isStatic = ts.getModifierFlags(member) & 32; var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 151: + case 152: addName(names, member.name, memberName, 1); break; - case 152: + case 153: addName(names, member.name, memberName, 2); break; - case 147: + case 148: addName(names, member.name, memberName, 3); break; + case 150: + addName(names, member.name, memberName, 4); + break; } } } } function addName(names, location, name, meaning) { - var prev = names[name]; + var prev = names.get(name); if (prev) { - if (prev & meaning) { + if (prev & 4) { + if (meaning !== 4) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + } + else if (prev & meaning) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { - names[name] = prev | meaning; + names.set(name, prev | meaning); } } else { - names[name] = meaning; + names.set(name, meaning); + } + } + } + function checkClassForStaticPropertyNameConflicts(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + var memberNameNode = member.name; + var isStatic = ts.getModifierFlags(member) & 32; + if (isStatic && memberNameNode) { + var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode); + switch (memberName) { + case "name": + case "length": + case "caller": + case "arguments": + case "prototype": + var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; + var className = getNameOfSymbol(getSymbolOfNode(node)); + error(memberNameNode, message, memberName, className); + break; + } } } } @@ -33056,7 +35132,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 146) { + if (member.kind == 147) { var memberName = void 0; switch (member.name.kind) { case 9: @@ -33067,18 +35143,18 @@ var ts; default: continue; } - if (names[memberName]) { + if (names.get(memberName)) { error(member.symbol.valueDeclaration.name, ts.Diagnostics.Duplicate_identifier_0, memberName); error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName); } else { - names[memberName] = true; + names.set(memberName, true); } } } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 228) { + if (node.kind === 229) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -33093,7 +35169,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 134: + case 135: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -33160,12 +35236,12 @@ var ts; if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 && n.kind !== 226) { + else if (n.kind !== 185 && n.kind !== 227) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 147 && + return n.kind === 148 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -33185,7 +35261,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -33208,18 +35284,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 151) { + if (node.kind === 152) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 151 ? 152 : 151; + var otherKind = node.kind === 152 ? 153 : 152; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -33233,11 +35309,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 151) { + if (node.kind === 152) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 176) { + if (node.parent.kind !== 177) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -33260,6 +35336,7 @@ var ts; checkDecorators(node); } function checkTypeArgumentConstraints(typeParameters, typeArgumentNodes) { + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); var typeArguments; var mapper; var result = true; @@ -33267,7 +35344,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -33318,25 +35395,42 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessIndexType(type, accessNode) { + if (!(type.flags & 524288)) { + return type; + } + var objectType = type.objectType; + var indexType = type.indexType; + if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + return type; + } + if (maybeTypeOfKind(objectType, 540672) && isTypeOfKind(indexType, 340)) { + var constraint = getBaseConstraintOfType(objectType); + if (constraint && getIndexInfoOfType(constraint, 1)) { + return type; + } + } + error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); + return type; + } function checkIndexedAccessType(node) { - getTypeFromIndexedAccessTypeNode(node); + checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node) { checkSourceElement(node.typeParameter); checkSourceElement(node.type); var type = getTypeFromMappedTypeNode(node); var constraintType = getConstraintTypeFromMappedType(type); - var keyType = constraintType.flags & 540672 ? getApparentTypeOfTypeVariable(constraintType) : constraintType; - checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint); + checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 228 && - n.parent.kind !== 227 && - n.parent.kind !== 197 && + if (n.parent.kind !== 229 && + n.parent.kind !== 228 && + n.parent.kind !== 198 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -33413,7 +35507,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) { - var reportError = (node.kind === 149 || node.kind === 148) && + var reportError = (node.kind === 150 || node.kind === 149) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -33442,15 +35536,15 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var current = declarations_5[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 228 || node.parent.kind === 161 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 229 || node.parent.kind === 162 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 226 || node.kind === 149 || node.kind === 148 || node.kind === 150) { + if (node.kind === 227 || node.kind === 150 || node.kind === 149 || node.kind === 151) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -33561,16 +35655,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 228: + case 229: return 2097152; - case 231: + case 232: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 227: - case 230: + case 228: + case 231: return 2097152 | 1048576; - case 235: + case 236: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -33688,7 +35782,12 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455, true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; if (promiseConstructorType === unknownType) { - error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + if (promiseConstructorName.kind === 70 && promiseConstructorName.text === "Promise" && getTargetType(returnType) === tryGetGlobalPromiseType()) { + error(node.type, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } + else { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + } return unknownType; } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); @@ -33718,22 +35817,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 227: + case 228: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 144: + case 145: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 147: + case 148: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 149: - case 151: + case 150: case 152: + case 153: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -33767,13 +35866,13 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8); - if (node.kind === 144) { + if (node.kind === 145) { checkExternalEmitHelpers(firstDecorator, 32); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 227: + case 228: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -33782,19 +35881,19 @@ var ts; } } break; - case 149: - case 151: + case 150: case 152: + case 153: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markTypeNodeAsReferenced(node.type); break; - case 147: + case 148: markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); break; - case 144: + case 145: markTypeNodeAsReferenced(node.type); break; } @@ -33815,7 +35914,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 142) { + if (node.name && node.name.kind === 143) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -33857,43 +35956,43 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 262: - case 231: + case 264: + case 232: checkUnusedModuleMembers(node); break; - case 227: - case 197: + case 228: + case 198: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 228: + case 229: checkUnusedTypeParameters(node); break; - case 205: - case 233: - case 212: + case 206: + case 234: case 213: case 214: + case 215: checkUnusedLocalsAndParameters(node); break; - case 150: - case 184: - case 226: - case 185: - case 149: case 151: + case 185: + case 227: + case 186: + case 150: case 152: + case 153: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 148: - case 153: + case 149: case 154: case 155: - case 158: + case 156: case 159: + case 160: checkUnusedTypeParameters(node); break; } @@ -33902,11 +36001,10 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 228 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_2 = function (key) { - var local = node.locals[key]; + if (node.parent.kind !== 229 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + node.locals.forEach(function (local) { if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 145) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -33919,10 +36017,7 @@ var ts; ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d.name || d, local.name); }); } } - }; - for (var key in node.locals) { - _loop_2(key); - } + }); } } function isRemovedPropertyFromObjectSpread(node) { @@ -33935,9 +36030,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 224 && - (declaration.parent.parent.kind === 213 || - declaration.parent.parent.kind === 214)) { + if (declaration.kind === 225 && + (declaration.parent.parent.kind === 214 || + declaration.parent.parent.kind === 215)) { return; } } @@ -33956,12 +36051,12 @@ var ts; if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149 || member.kind === 147) { + if (member.kind === 150 || member.kind === 148) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 150) { + else if (member.kind === 151) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -33992,8 +36087,7 @@ var ts; } function checkUnusedModuleMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { - for (var key in node.locals) { - var local = node.locals[key]; + node.locals.forEach(function (local) { if (!local.isReferenced && !local.exportSymbol) { for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; @@ -34002,11 +36096,11 @@ var ts; } } } - } + }); } } function checkBlock(node) { - if (node.kind === 205) { + if (node.kind === 206) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -34028,19 +36122,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 147 || - node.kind === 146 || + if (node.kind === 148 || + node.kind === 147 || + node.kind === 150 || node.kind === 149 || - node.kind === 148 || - node.kind === 151 || - node.kind === 152) { + node.kind === 152 || + node.kind === 153) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 144 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 145 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -34112,11 +36206,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 262 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 264 && ts.isExternalOrCommonJsModule(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)); } } @@ -34124,11 +36218,11 @@ var ts; if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 262 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 264 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -34136,7 +36230,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 224 && !node.initializer) { + if (node.kind === 225 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -34146,25 +36240,25 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 225); - var container = varDeclList.parent.kind === 206 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 226); + var container = varDeclList.parent.kind === 207 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 205 && ts.isFunctionLike(container.parent) || + (container.kind === 206 && ts.isFunctionLike(container.parent) || + container.kind === 233 || container.kind === 232 || - container.kind === 231 || - container.kind === 262); + container.kind === 264); if (!namesShareScope) { - var name_24 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_24, name_24); + var name = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 144) { + if (ts.getRootDeclaration(node).kind !== 145) { return; } var func = ts.getContainingFunction(node); @@ -34173,7 +36267,7 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 177) { + if (n.kind === 178) { return visit(n.expression); } else if (n.kind === 70) { @@ -34187,8 +36281,8 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144 || - symbol.valueDeclaration.kind === 174) { + if (symbol.valueDeclaration.kind === 145 || + symbol.valueDeclaration.kind === 175) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -34197,7 +36291,7 @@ var ts; if (ts.isFunctionLike(current.parent)) { return; } - if (current.parent.kind === 147 && + if (current.parent.kind === 148 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)) { return; @@ -34219,37 +36313,37 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 174) { - if (node.parent.kind === 172 && languageVersion < 5 && !ts.isInAmbientContext(node)) { + if (node.kind === 175) { + if (node.parent.kind === 173 && languageVersion < 5 && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4); } - if (node.propertyName && node.propertyName.kind === 142) { + if (node.propertyName && node.propertyName.kind === 143) { checkComputedPropertyName(node.propertyName); } - var parent_11 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_11); - var name_25 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_25)); + var parent = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent); + var name = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); markPropertyAsReferenced(property); - if (parent_11.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); + if (parent.initializer && property) { + checkPropertyAccessibility(parent, parent.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 144 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 145 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 213) { + if (node.initializer && node.parent.parent.kind !== 214) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -34258,7 +36352,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 213) { + if (node.initializer && node.parent.parent.kind !== 214) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -34276,9 +36370,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 147 && node.kind !== 146) { + if (node.kind !== 148 && node.kind !== 147) { checkExportsOnMergedDeclarations(node); - if (node.kind === 224 || node.kind === 174) { + if (node.kind === 225 || node.kind === 175) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -34289,8 +36383,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 && right.kind === 224) || - (left.kind === 224 && right.kind === 144)) { + if ((left.kind === 145 && right.kind === 225) || + (left.kind === 225 && right.kind === 145)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -34317,7 +36411,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 176) { + if (node.modifiers && node.parent.kind === 177) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -34336,7 +36430,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 207) { + if (node.thenStatement.kind === 208) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -34353,12 +36447,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 225) { + if (node.initializer && node.initializer.kind === 226) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 225) { + if (node.initializer.kind === 226) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -34376,13 +36470,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 225) { + if (node.initializer.kind === 226) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 175 || varExpr.kind === 176) { + if (varExpr.kind === 176 || varExpr.kind === 177) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -34401,7 +36495,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 225) { + if (node.initializer.kind === 226) { 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); @@ -34411,7 +36505,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 175 || varExpr.kind === 176) { + if (varExpr.kind === 176 || varExpr.kind === 177) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -34587,7 +36681,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 152))); + return !!(node.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 153))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -34609,30 +36703,30 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 152) { + if (func.kind === 153) { if (node.expression) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); + error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 150) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { - error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + else if (func.kind === 151) { + if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node.expression || node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); if (promisedType) { - checkTypeAssignableTo(awaitedType, promisedType, node.expression || node); + checkTypeAssignableTo(awaitedType, promisedType, node); } } else { - checkTypeAssignableTo(exprType, returnType, node.expression || node); + checkTypeAssignableTo(exprType, returnType, node); } } } - else if (func.kind !== 150 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 151 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -34658,7 +36752,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 255 && !hasDuplicateDefaultClause) { + if (clause.kind === 257 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -34670,7 +36764,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 254) { + if (produceDiagnostics && clause.kind === 256) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var caseIsLiteral = isLiteralType(caseType); @@ -34696,7 +36790,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 220 && current.label.text === node.label.text) { + if (current.kind === 221 && 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; @@ -34729,14 +36823,14 @@ var ts; grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - var blockLocals = catchClause.block.locals; - if (blockLocals) { - for (var caughtName in catchClause.locals) { - var blockLocal = blockLocals[caughtName]; + var blockLocals_1 = catchClause.block.locals; + if (blockLocals_1) { + ts.forEachKey(catchClause.locals, function (caughtName) { + var blockLocal = blockLocals_1.get(caughtName); if (blockLocal && (blockLocal.flags & 2) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } - } + }); } } } @@ -34784,12 +36878,13 @@ var ts; if (!indexType) { return; } - if (indexKind === 1 && !isNumericName(prop.valueDeclaration.name)) { + var propDeclaration = prop.valueDeclaration; + if (indexKind === 1 && !(propDeclaration ? isNumericName(propDeclaration.name) : isNumericLiteralName(prop.name))) { return; } var errorNode; - if (prop.valueDeclaration.name.kind === 142 || prop.parent === containingType.symbol) { - errorNode = prop.valueDeclaration; + if (propDeclaration && (propDeclaration.name.kind === 143 || prop.parent === containingType.symbol)) { + errorNode = propDeclaration; } else if (indexDeclaration) { errorNode = indexDeclaration; @@ -34814,15 +36909,23 @@ var ts; case "string": case "symbol": case "void": + case "object": error(name, message, name.text); } } function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { + var seenDefault = false; for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { + if (node.default) { + seenDefault = true; + } + else if (seenDefault) { + error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters); + } for (var j = 0; j < i; j++) { if (typeParameterDeclarations[j].symbol === node.symbol) { error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name)); @@ -34832,23 +36935,57 @@ var ts; } } } - function checkTypeParameterListsIdentical(node, symbol) { + function checkTypeParameterListsIdentical(symbol) { if (symbol.declarations.length === 1) { return; } - var firstDecl; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 227 || declaration.kind === 228) { - if (!firstDecl) { - firstDecl = declaration; - } - else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); + var links = getSymbolLinks(symbol); + if (!links.typeParametersChecked) { + links.typeParametersChecked = true; + var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); + if (declarations.length <= 1) { + return; + } + var type = getDeclaredTypeOfSymbol(symbol); + if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { + var name = symbolToString(symbol); + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; + error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } } } + function areTypeParametersIdentical(declarations, typeParameters) { + var maxTypeArgumentCount = ts.length(typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; + var numTypeParameters = ts.length(declaration.typeParameters); + if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { + return false; + } + for (var i = 0; i < numTypeParameters; i++) { + var source = declaration.typeParameters[i]; + var target = typeParameters[i]; + if (source.name.text !== target.symbol.name) { + return false; + } + var sourceConstraint = source.constraint && getTypeFromTypeNode(source.constraint); + var targetConstraint = getConstraintFromTypeParameter(target); + if ((sourceConstraint || targetConstraint) && + (!sourceConstraint || !targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint))) { + return false; + } + var sourceDefault = source.default && getTypeFromTypeNode(source.default); + var targetDefault = getDefaultFromTypeParameter(target); + if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) { + return false; + } + } + } + return true; + } function checkClassExpression(node) { checkClassLikeDeclaration(node); checkNodeDeferred(node); @@ -34882,8 +37019,11 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); + if (!ts.isInAmbientContext(node)) { + checkClassForStaticPropertyNameConflicts(node); + } var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { if (languageVersion < 2 && !ts.isInAmbientContext(node)) { @@ -34892,7 +37032,8 @@ var ts; var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType_1 = baseTypes[0]; - var staticBaseType = getBaseConstructorTypeOfClass(type); + var baseConstructorType = getBaseConstructorTypeOfClass(type); + var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { @@ -34906,14 +37047,17 @@ var ts; } checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType_1.symbol.valueDeclaration && + if (baseConstructorType.flags & 540672 && !isMixinConstructorType(staticType)) { + error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); + } + if (baseType_1.symbol && baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 227) { + baseType_1.symbol.valueDeclaration.kind === 228) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 540672)) { var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType_1; })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); @@ -34933,8 +37077,7 @@ var ts; if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - var declaredType = getObjectFlags(t) & 4 ? t.target : t; - if (getObjectFlags(declaredType) & 3) { + if (isValidBaseType(t)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -34962,17 +37105,22 @@ var ts; } } function getTargetSymbol(s) { - return s.flags & 16777216 ? getSymbolLinks(s).target : s; + return getCheckFlags(s) & 1 ? s.target : s; } function getClassLikeDeclarationOfSymbol(symbol) { return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); } + function getClassOrInterfaceDeclarationsOfSymbol(symbol) { + return ts.filter(symbol.declarations, function (d) { + return d.kind === 228 || d.kind === 229; + }); + } function checkKindsOfPropertyMemberOverrides(type, baseType) { - var baseProperties = getPropertiesOfObjectType(baseType); + var baseProperties = getPropertiesOfType(baseType); for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); - if (base.flags & 134217728) { + if (base.flags & 16777216) { continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); @@ -34982,7 +37130,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 197) { + if (derivedClassDecl.kind === 198) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -35026,32 +37174,7 @@ var ts; } } function isAccessor(kind) { - return kind === 151 || kind === 152; - } - function areTypeParametersIdentical(list1, list2) { - if (!list1 && !list2) { - return true; - } - if (!list1 || !list2 || list1.length !== list2.length) { - return false; - } - for (var i = 0; i < list1.length; i++) { - var tp1 = list1[i]; - var tp2 = list2[i]; - if (tp1.name.text !== tp2.name.text) { - return false; - } - if (!tp1.constraint && !tp2.constraint) { - continue; - } - if (!tp1.constraint || !tp2.constraint) { - return false; - } - if (!isTypeIdenticalTo(getTypeFromTypeNode(tp1.constraint), getTypeFromTypeNode(tp2.constraint))) { - return false; - } - } - return true; + return kind === 152 || kind === 153; } function checkInheritedPropertiesAreIdentical(type, typeNode) { var baseTypes = getBaseTypes(type); @@ -35059,16 +37182,16 @@ var ts; return true; } var seen = ts.createMap(); - ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.name, { prop: p, containingType: type }); }); var ok = true; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; - var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { var prop = properties_7[_a]; - var existing = seen[prop.name]; + var existing = seen.get(prop.name); if (!existing) { - seen[prop.name] = { prop: prop, containingType: base }; + seen.set(prop.name, { prop: prop, containingType: base }); } else { var isInheritedProperty = existing.containingType !== type; @@ -35092,8 +37215,8 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 228); + checkTypeParameterListsIdentical(symbol); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 229); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -35189,7 +37312,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 190: + case 191: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -35200,7 +37323,7 @@ var ts; case 51: return ~value_1; } return undefined; - case 192: + case 193: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -35226,11 +37349,11 @@ var ts; case 8: checkGrammarNumericLiteral(e); return +e.text; - case 183: + case 184: return evalConstant(e.expression); case 70: + case 179: case 178: - case 177: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -35241,7 +37364,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 178) { + if (e.kind === 179) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -35258,7 +37381,7 @@ var ts; if (current.kind === 70) { break; } - else if (current.kind === 177) { + else if (current.kind === 178) { current = current.expression; } else { @@ -35319,7 +37442,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 230) { + if (declaration.kind !== 231) { return false; } var enumDeclaration = declaration; @@ -35340,10 +37463,10 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var declaration = declarations_5[_i]; - if ((declaration.kind === 227 || - (declaration.kind === 226 && ts.nodeIsPresent(declaration.body))) && + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 228 || + (declaration.kind === 227 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -35402,7 +37525,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 227); + var mergedClass = ts.getDeclarationOfKind(symbol, 228); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -35410,7 +37533,7 @@ var ts; } if (isAmbientExternalModule) { if (ts.isExternalModuleAugmentation(node)) { - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 134217728); if (checkBody && node.body) { for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -35445,42 +37568,42 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 206: + case 207: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 241: case 242: + case 243: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 235: case 236: + case 237: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 174: - case 224: - var name_26 = node.name; - if (ts.isBindingPattern(name_26)) { - for (var _b = 0, _c = name_26.elements; _b < _c.length; _b++) { + case 175: + case 225: + var name = node.name; + if (ts.isBindingPattern(name)) { + for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 227: - case 230: - case 226: case 228: case 231: + case 227: case 229: + case 232: + case 230: if (isGlobalAugmentation) { return; } var symbol = getSymbolOfNode(node); if (symbol) { - var reportError = !(symbol.flags & 33554432); + var reportError = !(symbol.flags & 134217728); if (!reportError) { reportError = ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } @@ -35492,12 +37615,12 @@ var ts; switch (node.kind) { case 70: return node; - case 141: + case 142: do { node = node.left; } while (node.kind !== 70); return node; - case 177: + case 178: do { node = node.expression; } while (node.kind !== 70); @@ -35510,9 +37633,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 262 && !inAmbientExternalModule) { - error(moduleName, node.kind === 242 ? + var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 264 && !inAmbientExternalModule) { + error(moduleName, node.kind === 243 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -35533,7 +37656,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 244 ? + var message = node.kind === 245 ? 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)); @@ -35560,7 +37683,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 238) { + if (importClause.namedBindings.kind === 239) { checkImportBinding(importClause.namedBindings); } else { @@ -35611,8 +37734,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 262 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 233 && + !node.moduleSpecifier && ts.isInAmbientContext(node); + if (node.parent.kind !== 264 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -35625,7 +37750,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 262 || node.parent.kind === 232 || node.parent.kind === 231; + var isInAppropriateContext = node.parent.kind === 264 || node.parent.kind === 233 || node.parent.kind === 232; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -35648,8 +37773,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 262 ? node.parent : node.parent.parent; - if (container.kind === 231 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 264 ? node.parent : node.parent.parent; + if (container.kind === 232 && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -35678,18 +37803,13 @@ var ts; } } function hasExportedMembers(moduleSymbol) { - for (var id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; + return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; }); } function checkExternalModuleExports(node) { var moduleSymbol = getSymbolOfNode(node); var links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - var exportEqualsSymbol = moduleSymbol.exports["export="]; + var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; if (!isTopLevelInExternalModuleAugmentation(declaration)) { @@ -35697,31 +37817,31 @@ var ts; } } var exports_1 = getExportsOfModule(moduleSymbol); - for (var id in exports_1) { + exports_1 && exports_1.forEach(function (_a, id) { + var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { - continue; + return; } - var _a = exports_1[id], declarations = _a.declarations, flags = _a.flags; if (flags & (1920 | 64 | 384)) { - continue; + return; } var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); if (flags & 524288 && exportedDeclarationsCount <= 2) { - continue; + return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, id)); } } } - } + }); links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 226 && declaration.kind !== 149) || + return (declaration.kind !== 227 && declaration.kind !== 150) || !!declaration.body; } } @@ -35732,123 +37852,123 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 231: - case 227: + case 232: case 228: - case 226: + case 229: + case 227: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 143: - return checkTypeParameter(node); case 144: + return checkTypeParameter(node); + case 145: return checkParameter(node); + case 148: case 147: - case 146: return checkPropertyDeclaration(node); - case 158: case 159: - case 153: + case 160: case 154: - return checkSignatureDeclaration(node); case 155: return checkSignatureDeclaration(node); - case 149: - case 148: - return checkMethodDeclaration(node); - case 150: - return checkConstructorDeclaration(node); - case 151: - case 152: - return checkAccessorDeclaration(node); - case 157: - return checkTypeReferenceNode(node); case 156: + return checkSignatureDeclaration(node); + case 150: + case 149: + return checkMethodDeclaration(node); + case 151: + return checkConstructorDeclaration(node); + case 152: + case 153: + return checkAccessorDeclaration(node); + case 158: + return checkTypeReferenceNode(node); + case 157: return checkTypePredicate(node); - case 160: - return checkTypeQuery(node); case 161: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 162: - return checkArrayType(node); + return checkTypeLiteral(node); case 163: - return checkTupleType(node); + return checkArrayType(node); case 164: + return checkTupleType(node); case 165: - return checkUnionOrIntersectionType(node); case 166: - case 168: - return checkSourceElement(node.type); + return checkUnionOrIntersectionType(node); + case 167: case 169: - return checkIndexedAccessType(node); + return checkSourceElement(node.type); case 170: + return checkIndexedAccessType(node); + case 171: return checkMappedType(node); - case 226: - return checkFunctionDeclaration(node); - case 205: - case 232: - return checkBlock(node); - case 206: - return checkVariableStatement(node); - case 208: - return checkExpressionStatement(node); - case 209: - return checkIfStatement(node); - case 210: - return checkDoStatement(node); - case 211: - return checkWhileStatement(node); - case 212: - return checkForStatement(node); - case 213: - return checkForInStatement(node); - case 214: - return checkForOfStatement(node); - case 215: - case 216: - return checkBreakOrContinueStatement(node); - case 217: - return checkReturnStatement(node); - case 218: - return checkWithStatement(node); - case 219: - return checkSwitchStatement(node); - case 220: - return checkLabeledStatement(node); - case 221: - return checkThrowStatement(node); - case 222: - return checkTryStatement(node); - case 224: - return checkVariableDeclaration(node); - case 174: - return checkBindingElement(node); case 227: - return checkClassDeclaration(node); - case 228: - return checkInterfaceDeclaration(node); - case 229: - return checkTypeAliasDeclaration(node); - case 230: - return checkEnumDeclaration(node); - case 231: - return checkModuleDeclaration(node); - case 236: - return checkImportDeclaration(node); - case 235: - return checkImportEqualsDeclaration(node); - case 242: - return checkExportDeclaration(node); - case 241: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 206: + case 233: + return checkBlock(node); case 207: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 209: + return checkExpressionStatement(node); + case 210: + return checkIfStatement(node); + case 211: + return checkDoStatement(node); + case 212: + return checkWhileStatement(node); + case 213: + return checkForStatement(node); + case 214: + return checkForInStatement(node); + case 215: + return checkForOfStatement(node); + case 216: + case 217: + return checkBreakOrContinueStatement(node); + case 218: + return checkReturnStatement(node); + case 219: + return checkWithStatement(node); + case 220: + return checkSwitchStatement(node); + case 221: + return checkLabeledStatement(node); + case 222: + return checkThrowStatement(node); case 223: + return checkTryStatement(node); + case 225: + return checkVariableDeclaration(node); + case 175: + return checkBindingElement(node); + case 228: + return checkClassDeclaration(node); + case 229: + return checkInterfaceDeclaration(node); + case 230: + return checkTypeAliasDeclaration(node); + case 231: + return checkEnumDeclaration(node); + case 232: + return checkModuleDeclaration(node); + case 237: + return checkImportDeclaration(node); + case 236: + return checkImportEqualsDeclaration(node); + case 243: + return checkExportDeclaration(node); + case 242: + return checkExportAssignment(node); + case 208: checkGrammarStatementInAmbientContext(node); return; - case 245: + case 224: + checkGrammarStatementInAmbientContext(node); + return; + case 246: return checkMissingDeclaration(node); } } @@ -35861,17 +37981,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 184: case 185: + case 186: + case 150: case 149: - case 148: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 151: case 152: + case 153: checkAccessorDeferred(node); break; - case 197: + case 198: checkClassExpressionDeferred(node); break; } @@ -35959,7 +38079,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 218 && node.parent.statement === node) { + if (node.parent.kind === 219 && node.parent.statement === node) { return true; } node = node.parent; @@ -35981,28 +38101,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 262: + case 264: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 231: + case 232: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 230: + case 231: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 197: + case 198: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 227: case 228: + case 229: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 184: + case 185: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -36020,17 +38140,16 @@ var ts; function copySymbol(symbol, meaning) { if (symbol.flags & meaning) { var id = symbol.name; - if (!symbols[id]) { - symbols[id] = symbol; + if (!symbols.has(id)) { + symbols.set(id, symbol); } } } function copySymbols(source, meaning) { if (meaning) { - for (var id in source) { - var symbol = source[id]; + source.forEach(function (symbol) { copySymbol(symbol, meaning); - } + }); } } } @@ -36041,27 +38160,27 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 143: - case 227: + case 144: case 228: case 229: case 230: + case 231: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 141) { + while (node.parent && node.parent.kind === 142) { node = node.parent; } - return node.parent && (node.parent.kind === 157 || node.parent.kind === 273); + return node.parent && (node.parent.kind === 158 || node.parent.kind === 276); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 177) { + while (node.parent && node.parent.kind === 178) { node = node.parent; } - return node.parent && node.parent.kind === 199; + return node.parent && node.parent.kind === 200; } function forEachEnclosingClass(node, callback) { var result; @@ -36078,13 +38197,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 141) { + while (nodeOnRightSide.parent.kind === 142) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 235) { + if (nodeOnRightSide.parent.kind === 236) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 241) { + if (nodeOnRightSide.parent.kind === 242) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -36096,7 +38215,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 177) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 178) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -36108,11 +38227,11 @@ var ts; default: } } - if (entityName.parent.kind === 241 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 242 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 177 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 235); + if (entityName.kind !== 178 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 236); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -36121,7 +38240,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 199) { + if (entityName.parent.kind === 200) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -36143,14 +38262,14 @@ var ts; } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 177) { + else if (entityName.kind === 178) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 141) { + else if (entityName.kind === 142) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -36159,19 +38278,19 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 273) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 158 || entityName.parent.kind === 276) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 251) { + else if (entityName.parent.kind === 252) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 156) { + if (entityName.parent.kind === 157) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 262) { + if (node.kind === 264) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -36187,8 +38306,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 174 && - node.parent.parent.kind === 172 && + else if (node.parent.kind === 175 && + node.parent.parent.kind === 173 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -36199,8 +38318,8 @@ var ts; } switch (node.kind) { case 70: - case 177: - case 141: + case 178: + case 142: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98: var container = ts.getThisContainer(node, false); @@ -36213,18 +38332,18 @@ var ts; case 96: var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 167: + case 168: return getTypeFromTypeNode(node).symbol; case 122: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 150) { + if (constructorDeclaration && constructorDeclaration.kind === 151) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 236 || node.parent.kind === 242) && + ((node.parent.kind === 237 || node.parent.kind === 243) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -36232,7 +38351,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 178 && node.parent.argumentExpression === node) { + if (node.parent.kind === 179 && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -36246,7 +38365,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 259) { + if (location && location.kind === 261) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -36296,20 +38415,20 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 176 || expr.kind === 175); - if (expr.parent.kind === 214) { + ts.Debug.assert(expr.kind === 177 || expr.kind === 176); + if (expr.parent.kind === 215) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 192) { + if (expr.parent.kind === 193) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 258) { + if (expr.parent.kind === 260) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 175); + ts.Debug.assert(expr.parent.kind === 176); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); @@ -36335,30 +38454,33 @@ var ts; var propsByName = createSymbolTable(getPropertiesOfType(type)); if (getSignaturesOfType(type, 0).length || getSignaturesOfType(type, 1).length) { ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { - if (!propsByName[p.name]) { - propsByName[p.name] = p; + if (!propsByName.has(p.name)) { + propsByName.set(p.name, p); } }); } return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (symbol.flags & 268435456) { + if (getCheckFlags(symbol) & 2) { var symbols_3 = []; - var name_27 = symbol.name; + var name_2 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_27); + var symbol = getPropertyOfType(t, name_2); if (symbol) { symbols_3.push(symbol); } }); return symbols_3; } - else if (symbol.flags & 67108864) { + else if (symbol.flags & 134217728) { if (symbol.leftSpread) { var links = symbol; return [links.leftSpread, links.rightSpread]; } + if (symbol.mappedTypeOrigin) { + return getRootSymbols(symbol.mappedTypeOrigin); + } var target = void 0; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -36374,7 +38496,8 @@ var ts; if (!ts.isGeneratedIdentifier(node)) { node = ts.getParseTreeNode(node, ts.isIdentifier); if (node) { - return getReferencedValueSymbol(node) === argumentsSymbol; + var isPropertyName_1 = node.parent.kind === 178 && node.parent.name === node; + return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } return false; @@ -36390,7 +38513,7 @@ var ts; if (symbolLinks.exportsSomeValue === undefined) { symbolLinks.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & 107455) - : ts.forEachProperty(getExportsOfModule(moduleSymbol), isValue); + : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { @@ -36416,7 +38539,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 262) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 264) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -36454,7 +38577,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 205 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 206 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -36494,16 +38617,16 @@ var ts; return true; } switch (node.kind) { - case 235: - case 237: + case 236: case 238: - case 240: - case 244: + case 239: + case 241: + case 245: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 242: + case 243: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 241: + case 242: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -36513,7 +38636,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 262 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 264 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -36555,6 +38678,12 @@ var ts; } return false; } + function isRequiredInitializedParameter(parameter) { + return strictNullChecks && + !isOptionalParameter(parameter) && + parameter.initializer && + !(ts.getModifierFlags(parameter) & 92); + } function getNodeCheckFlags(node) { node = ts.getParseTreeNode(node); return node ? getNodeLinks(node).flags : undefined; @@ -36564,7 +38693,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 261) { + if (node.kind === 263) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -36580,15 +38709,17 @@ var ts; } function getTypeReferenceSerializationKind(typeName, location) { var valueSymbol = resolveEntityName(typeName, 107455, true, false, location); - var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); - if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { - return ts.TypeReferenceSerializationKind.Promise; - } - var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; - if (constructorType && isConstructorType(constructorType)) { - return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; - } var typeSymbol = resolveEntityName(typeName, 793064, true, false, location); + if (valueSymbol && valueSymbol === typeSymbol) { + var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); + if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { + return ts.TypeReferenceSerializationKind.Promise; + } + var constructorType = getTypeOfSymbol(valueSymbol); + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + } if (!typeSymbol) { return ts.TypeReferenceSerializationKind.ObjectType; } @@ -36632,6 +38763,9 @@ var ts; var type = symbol && !(symbol.flags & (2048 | 131072)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : unknownType; + if (flags & 4096) { + type = includeFalsyTypes(type, 2048); + } getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { @@ -36646,10 +38780,13 @@ var ts; var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(node)); resolveBaseTypesOfClass(classType); var baseType = classType.resolvedBaseTypes.length ? classType.resolvedBaseTypes[0] : unknownType; + if (!baseType.symbol) { + writer.reportIllegalExtends(); + } getSymbolDisplayBuilder().buildTypeDisplay(baseType, writer, enclosingDeclaration, flags); } function hasGlobalName(name) { - return !!globals[name]; + return globals.has(name); } function getReferencedValueSymbol(reference, startInDeclarationContainer) { var resolvedSymbol = getNodeLinks(reference).resolvedSymbol; @@ -36658,9 +38795,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_12 = reference.parent; - if (ts.isDeclaration(parent_12) && reference === parent_12.name) { - location = getDeclarationContainer(parent_12); + var parent = reference.parent; + if (ts.isDeclaration(parent) && reference === parent.name) { + location = getDeclarationContainer(parent); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -36693,14 +38830,13 @@ var ts; var fileToDirective; if (resolvedTypeReferenceDirectives) { fileToDirective = ts.createFileMap(); - for (var key in resolvedTypeReferenceDirectives) { - var resolvedDirective = resolvedTypeReferenceDirectives[key]; + resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) { if (!resolvedDirective) { - continue; + return; } var file = host.getSourceFile(resolvedDirective.resolvedFileName); fileToDirective.set(file.path, key); - } + }); } return { getReferencedExportContainer: getReferencedExportContainer, @@ -36714,6 +38850,7 @@ var ts; isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, + isRequiredInitializedParameter: isRequiredInitializedParameter, writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, writeTypeOfExpression: writeTypeOfExpression, @@ -36738,7 +38875,7 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 177) || (node.kind === 70 && isInTypeQuery(node)) + var meaning = (node.kind === 178) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -36773,15 +38910,15 @@ var ts; } var current = symbol; while (true) { - var parent_13 = getParentOfSymbol(current); - if (parent_13) { - current = parent_13; + var parent = getParentOfSymbol(current); + if (parent) { + current = parent; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 262 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 264 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -36800,7 +38937,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 262); + return ts.getDeclarationOfKind(moduleSymbol, 264); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -36821,11 +38958,11 @@ var ts; } if (file.symbol && file.symbol.globalExports) { var source = file.symbol.globalExports; - for (var id in source) { - if (!(id in globals)) { - globals[id] = source[id]; + source.forEach(function (sourceSymbol, id) { + if (!globals.has(id)) { + globals.set(id, sourceSymbol); } - } + }); } } if (augmentations) { @@ -36891,10 +39028,10 @@ var ts; var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1; helper <= 128; helper <<= 1) { if (uncheckedHelpers & helper) { - var name_28 = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_28), 107455); + var name = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name), 107455); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_28); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); } } } @@ -36929,7 +39066,7 @@ var ts; return emptyObjectType; } function createThenableType() { - var thenPropertySymbol = createSymbol(67108864 | 4, "then"); + var thenPropertySymbol = createSymbol(4, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; var thenableType = createObjectType(16); thenableType.properties = [thenPropertySymbol]; @@ -36943,14 +39080,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 149 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 150 && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 151 || node.kind === 152) { + else if (node.kind === 152 || node.kind === 153) { 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); @@ -36968,16 +39105,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 130) { - if (node.kind === 146 || node.kind === 148) { + if (node.kind === 147 || node.kind === 149) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 155) { + if (node.kind === 156) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 75: - if (node.kind !== 230 && node.parent.kind === 227) { + if (node.kind !== 231 && node.parent.kind === 228) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -37003,7 +39140,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 232 || node.parent.kind === 262) { + else if (node.parent.kind === 233 || node.parent.kind === 264) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -37026,10 +39163,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 232 || node.parent.kind === 262) { + else if (node.parent.kind === 233 || node.parent.kind === 264) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -37042,7 +39179,7 @@ var ts; if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 147 && node.kind !== 146 && node.kind !== 155 && node.kind !== 144) { + else if (node.kind !== 148 && node.kind !== 147 && node.kind !== 156 && node.kind !== 145) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; @@ -37061,10 +39198,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 228) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; @@ -37076,13 +39213,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 228) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 232) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 233) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -37092,14 +39229,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 227) { - if (node.kind !== 149 && - node.kind !== 147 && - node.kind !== 151 && - node.kind !== 152) { + if (node.kind !== 228) { + if (node.kind !== 150 && + node.kind !== 148 && + node.kind !== 152 && + node.kind !== 153) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 227 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 228 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -37118,7 +39255,7 @@ var ts; 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 === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -37126,7 +39263,7 @@ var ts; break; } } - if (node.kind === 150) { + if (node.kind === 151) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -37141,13 +39278,13 @@ var ts; } return; } - else if ((node.kind === 236 || node.kind === 235) && flags & 2) { + else if ((node.kind === 237 || node.kind === 236) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 144 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 145 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 144 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 145 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -37163,37 +39300,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 151: case 152: - case 150: - case 147: - case 146: - case 149: + case 153: + case 151: case 148: - case 155: - case 231: + case 147: + case 150: + case 149: + case 156: + case 232: + case 237: case 236: - case 235: + case 243: case 242: - case 241: - case 184: case 185: - case 144: + case 186: + case 145: return false; default: - if (node.parent.kind === 232 || node.parent.kind === 262) { + if (node.parent.kind === 233 || node.parent.kind === 264) { return false; } switch (node.kind) { - case 226: - return nodeHasAnyModifiersExcept(node, 119); case 227: - return nodeHasAnyModifiersExcept(node, 116); + return nodeHasAnyModifiersExcept(node, 119); case 228: - case 206: + return nodeHasAnyModifiersExcept(node, 116); case 229: - return true; + case 207: case 230: + return true; + case 231: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -37206,10 +39343,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 149: - case 226: - case 184: + case 150: + case 227: case 185: + case 186: if (!node.asteriskToken) { return false; } @@ -37271,7 +39408,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 185) { + if (node.kind === 186) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -37306,7 +39443,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 !== 134 && parameter.type.kind !== 132) { + if (parameter.type.kind !== 135 && parameter.type.kind !== 132) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -37333,7 +39470,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 198) { + if (arg.kind === 199) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -37403,19 +39540,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 142) { + if (node.kind !== 143) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 192 && computedPropertyName.expression.operatorToken.kind === 25) { + if (computedPropertyName.expression.kind === 193 && computedPropertyName.expression.operatorToken.kind === 25) { 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 === 226 || - node.kind === 184 || - node.kind === 149); + ts.Debug.assert(node.kind === 227 || + node.kind === 185 || + node.kind === 150); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -37440,87 +39577,87 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 260) { + if (prop.kind === 262) { continue; } - var name_29 = prop.name; - if (name_29.kind === 142) { - checkGrammarComputedPropertyName(name_29); + var name = prop.name; + if (name.kind === 143) { + checkGrammarComputedPropertyName(name); } - if (prop.kind === 259 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 261 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 || prop.kind !== 149) { + if (mod.kind !== 119 || prop.kind !== 150) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; - if (prop.kind === 258 || prop.kind === 259) { + if (prop.kind === 260 || prop.kind === 261) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_29.kind === 8) { - checkGrammarNumericLiteral(name_29); + if (name.kind === 8) { + checkGrammarNumericLiteral(name); } currentKind = Property; } - else if (prop.kind === 149) { + else if (prop.kind === 150) { currentKind = Property; } - else if (prop.kind === 151) { + else if (prop.kind === 152) { currentKind = GetAccessor; } - else if (prop.kind === 152) { + else if (prop.kind === 153) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_29); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { continue; } - if (!seen[effectiveName]) { - seen[effectiveName] = currentKind; + var existingKind = seen.get(effectiveName); + if (!existingKind) { + seen.set(effectiveName, currentKind); } else { - var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_29, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_29)); + grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[effectiveName] = currentKind | existingKind; + seen.set(effectiveName, currentKind | existingKind); } else { - return grammarErrorOnNode(name_29, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_29, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } } function checkGrammarJsxElement(node) { var seen = ts.createMap(); - for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 252) { + if (attr.kind === 254) { continue; } var jsxAttr = attr; - var name_30 = jsxAttr.name; - if (!seen[name_30.text]) { - seen[name_30.text] = true; + var name = jsxAttr.name; + if (!seen.get(name.text)) { + seen.set(name.text, true); } else { - return grammarErrorOnNode(name_30, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 253 && !initializer.expression) { + if (initializer && initializer.kind === 255 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -37529,7 +39666,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 225) { + if (forInOrOfStatement.initializer.kind === 226) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -37537,20 +39674,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 213 + var diagnostic = forInOrOfStatement.kind === 214 ? 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 = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 213 + var diagnostic = forInOrOfStatement.kind === 214 ? 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 === 213 + var diagnostic = forInOrOfStatement.kind === 214 ? 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); @@ -37577,11 +39714,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 151 ? + return grammarErrorOnNode(accessor.name, kind === 152 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 152) { + else if (kind === 153) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -37600,10 +39737,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 151 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 152 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 151 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 152 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -37618,7 +39755,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 176) { + if (node.parent.kind === 177) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -37634,10 +39771,10 @@ 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 === 228) { + else if (node.parent.kind === 229) { 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 === 161) { + else if (node.parent.kind === 162) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -37648,9 +39785,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 220: + case 221: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 215 + var isMisplacedContinueLabel = node.kind === 216 && !ts.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); @@ -37658,8 +39795,8 @@ var ts; return false; } break; - case 219: - if (node.kind === 216 && !node.label) { + case 220: + if (node.kind === 217 && !node.label) { return false; } break; @@ -37672,13 +39809,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 216 + var message = node.kind === 217 ? 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 === 216 + var message = node.kind === 217 ? 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); @@ -37690,7 +39827,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 173 || node.name.kind === 172) { + if (node.name.kind === 174 || node.name.kind === 173) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -37700,11 +39837,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 190 && expr.operator === 37 && + expr.kind === 191 && expr.operator === 37 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 213 && node.parent.parent.kind !== 214) { + if (node.parent.parent.kind !== 214 && node.parent.parent.kind !== 215) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -37731,9 +39868,29 @@ var ts; } } } + if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && + !ts.isInAmbientContext(node.parent.parent) && ts.hasModifier(node.parent.parent, 1)) { + checkESModuleMarker(node.name); + } var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } + function checkESModuleMarker(name) { + if (name.kind === 70) { + if (ts.unescapeIdentifier(name.text) === "__esModule") { + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); + } + } + else { + var elements = name.elements; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; + if (!ts.isOmittedExpression(element)) { + return checkESModuleMarker(element.name); + } + } + } + } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 70) { if (name.originalKeywordKind === 109) { @@ -37742,8 +39899,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { - var element = elements_2[_i]; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var element = elements_3[_i]; if (!ts.isOmittedExpression(element)) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -37761,15 +39918,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 209: case 210: case 211: - case 218: case 212: + case 219: case 213: case 214: + case 215: return false; - case 220: + case 221: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -37831,7 +39988,7 @@ var ts; return true; } } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 229) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -37839,7 +39996,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 161) { + else if (node.parent.kind === 162) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -37852,13 +40009,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 228 || - node.kind === 229 || + if (node.kind === 229 || + node.kind === 230 || + node.kind === 237 || node.kind === 236 || - node.kind === 235 || + node.kind === 243 || node.kind === 242 || - node.kind === 241 || - node.kind === 234 || + node.kind === 235 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -37867,7 +40024,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 === 206) { + if (ts.isDeclaration(decl) || decl.kind === 207) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -37886,7 +40043,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 === 205 || node.parent.kind === 232 || node.parent.kind === 262) { + if (node.parent.kind === 206 || node.parent.kind === 233 || node.parent.kind === 264) { 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); @@ -37902,10 +40059,10 @@ var ts; if (languageVersion >= 1) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 171)) { + else if (ts.isChildOfNodeWithKind(node, 172)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 261)) { + else if (ts.isChildOfNodeWithKind(node, 263)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -37925,11 +40082,11 @@ var ts; } function getAmbientModules() { var result = []; - for (var sym in globals) { + globals.forEach(function (global, sym) { if (ambientModuleSymbolRegex.test(sym)) { - result.push(globals[sym]); + result.push(global); } - } + }); return result; } } @@ -37937,55 +40094,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ; - var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[141] = [ - { name: "left", test: ts.isEntityName }, - { name: "right", test: ts.isIdentifier } - ], - _a[145] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[182] = [ - { name: "type", test: ts.isTypeNode }, - { name: "expression", test: ts.isUnaryExpression } - ], - _a[200] = [ - { name: "expression", test: ts.isExpression }, - { name: "type", test: ts.isTypeNode } - ], - _a[201] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[230] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "members", test: ts.isEnumMember } - ], - _a[231] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isModuleName }, - { name: "body", test: ts.isModuleBody } - ], - _a[232] = [ - { name: "statements", test: ts.isStatement } - ], - _a[235] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "moduleReference", test: ts.isModuleReference } - ], - _a[246] = [ - { name: "expression", test: ts.isExpression, optional: true } - ], - _a[261] = [ - { name: "name", test: ts.isPropertyName }, - { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } - ], - _a)); function reduceNode(node, f, initial) { return node ? f(initial, node) : initial; } @@ -37999,41 +40107,45 @@ var ts; var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; - if ((kind > 0 && kind <= 140)) { + if ((kind > 0 && kind <= 141)) { return initial; } - if ((kind >= 156 && kind <= 171)) { + if ((kind >= 157 && kind <= 172)) { return initial; } var result = initial; switch (node.kind) { - case 204: - case 207: - case 198: - case 223: - case 294: + case 205: + case 208: + case 199: + case 224: + case 297: break; case 142: - result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); break; - case 144: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); + case 143: + result = reduceNode(node.expression, cbNode, result); break; case 145: - result = reduceNode(node.expression, cbNode, result); - break; - case 147: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 149: + case 146: + result = reduceNode(node.expression, cbNode, result); + break; + case 148: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 150: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38042,53 +40154,48 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 150: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; case 151: - result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; case 152: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 153: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 172: case 173: + case 174: result = reduceNodes(node.elements, cbNodes, result); break; - case 174: + case 175: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 175: + case 176: result = reduceNodes(node.elements, cbNodes, result); break; - case 176: - result = reduceNodes(node.properties, cbNodes, result); - break; case 177: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.properties, cbNodes, result); break; case 178: result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.argumentExpression, cbNode, result); + result = reduceNode(node.name, cbNode, result); break; case 179: result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); + result = reduceNode(node.argumentExpression, cbNode, result); break; case 180: result = reduceNode(node.expression, cbNode, result); @@ -38096,10 +40203,19 @@ var ts; result = reduceNodes(node.arguments, cbNodes, result); break; case 181: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 182: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 184: + case 183: + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 185: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -38107,126 +40223,133 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 185: + case 186: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 183: - case 186: + case 184: case 187: case 188: case 189: - case 195: + case 190: case 196: - case 201: + case 197: + case 202: result = reduceNode(node.expression, cbNode, result); break; - case 190: case 191: + case 192: result = reduceNode(node.operand, cbNode, result); break; - case 192: + case 193: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 193: + case 194: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 194: + case 195: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 197: + case 198: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 199: + case 200: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 203: + case 201: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.type, cbNode, result); + break; + case 202: + result = reduceNode(node.expression, cbNode, result); + break; + case 204: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 205: + case 206: result = reduceNodes(node.statements, cbNodes, result); break; - case 206: + case 207: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 208: + case 209: result = reduceNode(node.expression, cbNode, result); break; - case 209: + case 210: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 210: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; case 211: - case 218: - result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); break; case 212: + case 219: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 213: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 213: case 214: + case 215: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 217: - case 221: + case 218: + case 222: result = reduceNode(node.expression, cbNode, result); break; - case 219: + case 220: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 220: + case 221: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 222: + case 223: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 224: + case 225: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 225: - result = reduceNodes(node.declarations, cbNodes, result); - break; case 226: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); + result = reduceNodes(node.declarations, cbNodes, result); break; case 227: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 228: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38234,113 +40357,131 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; + case 231: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 232: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; case 233: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 234: result = reduceNodes(node.clauses, cbNodes, result); break; case 236: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.moduleReference, cbNode, result); + break; + case 237: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 237: + case 238: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 238: - result = reduceNode(node.name, cbNode, result); - break; case 239: - case 243: - result = reduceNodes(node.elements, cbNodes, result); + result = reduceNode(node.name, cbNode, result); break; case 240: case 244: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 241: + case 245: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 241: + case 242: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 242: + case 243: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; case 247: + result = reduceNode(node.expression, cbNode, result); + break; + case 248: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 248: case 249: - result = reduceNode(node.tagName, cbNode, result); - result = reduceNodes(node.attributes, cbNodes, result); - break; case 250: result = reduceNode(node.tagName, cbNode, result); + result = reduceNode(node.attributes, cbNode, result); break; case 251: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 252: - result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.tagName, cbNode, result); break; case 253: - result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.properties, cbNodes, result); + break; + case 252: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); break; case 254: result = reduceNode(node.expression, cbNode, result); + break; case 255: - result = reduceNodes(node.statements, cbNodes, result); + result = reduceNode(node.expression, cbNode, result); break; case 256: + result = reduceNode(node.expression, cbNode, result); + case 257: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 258: result = reduceNodes(node.types, cbNodes, result); break; - case 257: + case 259: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 258: + case 260: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 259: + case 261: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 260: + case 262: result = reduceNode(node.expression, cbNode, result); break; - case 262: + case 263: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + case 264: result = reduceNodes(node.statements, cbNodes, result); break; - case 295: + case 298: result = reduceNode(node.expression, cbNode, result); break; default: - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_1 = edgeTraversalPath; _i < edgeTraversalPath_1.length; _i++) { - var edge = edgeTraversalPath_1[_i]; - var value = node[edge.name]; - if (value !== undefined) { - result = ts.isArray(value) - ? reduceNodes(value, cbNodes, result) - : cbNode(result, value); - } - } - } break; } return result; } ts.reduceEachChild = reduceEachChild; - function visitNode(node, visitor, test, optional, lift, parenthesize, parentNode) { + function visitNode(node, visitor, test, optional, lift) { if (node === undefined || visitor === undefined) { return node; } @@ -38362,15 +40503,12 @@ var ts; else { visitedNode = visited; } - if (parenthesize !== undefined) { - visitedNode = parenthesize(visitedNode, parentNode); - } Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); return visitedNode; } ts.visitNode = visitNode; - function visitNodes(nodes, visitor, test, start, count, parenthesize, parentNode) { + function visitNodes(nodes, visitor, test, start, count) { if (nodes === undefined) { return undefined; } @@ -38383,7 +40521,7 @@ var ts; count = length - start; } if (start > 0 || count < length) { - updated = ts.createNodeArray([], undefined, nodes.hasTrailingComma && start + count === length); + updated = ts.createNodeArray([], nodes.hasTrailingComma && start + count === length); } for (var i = 0; i < count; i++) { var node = nodes[i + start]; @@ -38391,27 +40529,22 @@ var ts; var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { - updated = ts.createNodeArray(nodes.slice(0, i), nodes, nodes.hasTrailingComma); + updated = ts.createNodeArray(nodes.slice(0, i), nodes.hasTrailingComma); + ts.setTextRange(updated, nodes); } if (visited) { if (ts.isArray(visited)) { for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) { var visitedNode = visited_1[_i]; - visitedNode = parenthesize - ? parenthesize(visitedNode, parentNode) - : visitedNode; Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); updated.push(visitedNode); } } else { - var visitedNode = parenthesize - ? parenthesize(visited, parentNode) - : visited; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); - updated.push(visitedNode); + Debug.assertNode(visited, test); + aggregateTransformFlags(visited); + updated.push(visited); } } } @@ -38423,10 +40556,10 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); - return ts.createNodeArray(ts.concatenate(statements, declarations), statements); + return ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements); } ts.visitLexicalEnvironment = visitLexicalEnvironment; function visitParameterList(nodes, visitor, context) { @@ -38453,203 +40586,206 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 140)) { + if ((kind > 0 && kind <= 141)) { return node; } - if ((kind >= 156 && kind <= 171)) { + if ((kind >= 157 && kind <= 172)) { return node; } switch (node.kind) { - case 204: - case 207: - case 198: - case 223: + case 205: + case 208: + case 199: + case 224: return node; case 142: + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); + case 143: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 144: + case 145: return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), node.dotDotDotToken, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 147: + case 146: + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); + case 148: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 149: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 150: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); + return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 151: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); case 152: + return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 153: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 172: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 173: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 174: - return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); case 175: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); case 176: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); case 177: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); case 178: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); case 179: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); case 180: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); case 181: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 182: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); case 183: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 184: - return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 185: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 186: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 187: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 188: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); case 189: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); case 190: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 191: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); case 193: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 191: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 192: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); case 194: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 195: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); case 196: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); case 197: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 198: return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 199: + case 200: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 203: + case 201: + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); + case 202: + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + case 204: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 205: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); case 206: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 207: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 208: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 209: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 210: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); case 211: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 212: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 213: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 214: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 215: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 216: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 217: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 218: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); case 219: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 220: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); case 221: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 222: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 223: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); - case 224: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 225: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 226: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); case 227: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 228: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); + case 231: + return ts.updateEnumDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNodes(node.members, visitor, ts.isEnumMember)); + case 232: + return ts.updateModuleDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); case 233: + return ts.updateModuleBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 234: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 236: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + return ts.updateImportEqualsDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); case 237: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 238: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 239: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 240: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 241: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 242: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 243: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); case 244: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 245: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 247: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); case 248: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 249: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 250: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 251: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 252: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 253: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxAttributes(node, visitNodes(node.properties, visitor, ts.isJsxAttributeLike)); + case 249: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 250: + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 251: + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + case 252: + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 254: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 255: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 256: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); case 257: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); case 258: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); case 259: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 260: - return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 261: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); case 262: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 263: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 264: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 295: + case 298: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: - var updated = void 0; - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_2 = edgeTraversalPath; _i < edgeTraversalPath_2.length; _i++) { - var edge = edgeTraversalPath_2[_i]; - var value = node[edge.name]; - if (value !== undefined) { - var visited = ts.isArray(value) - ? visitNodes(value, visitor, edge.test, 0, value.length, edge.parenthesize, node) - : visitNode(value, visitor, edge.test, edge.optional, edge.lift, edge.parenthesize, node); - if (updated !== undefined || visited !== value) { - if (updated === undefined) { - updated = ts.getMutableClone(node); - } - if (visited !== value) { - updated[edge.name] = visited; - } - } - } - } - } - return updated ? ts.updateNode(updated, node) : node; + return node; } } ts.visitEachChild = visitEachChild; @@ -38658,17 +40794,17 @@ var ts; return statements; } return ts.isNodeArray(statements) - ? ts.createNodeArray(ts.concatenate(statements, declarations), statements) + ? ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements) : ts.addRange(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; function mergeFunctionBodyLexicalEnvironment(body, declarations) { if (body && declarations !== undefined && declarations.length > 0) { if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.createNodeArray(ts.concatenate(body.statements, declarations), body.statements)); + return ts.updateBlock(body, ts.setTextRange(ts.createNodeArray(ts.concatenate(body.statements, declarations)), body.statements)); } else { - return ts.createBlock(ts.createNodeArray([ts.createReturn(body, body)].concat(declarations), body), body, true); + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray([ts.setTextRange(ts.createReturn(body), body)].concat(declarations)), body), true), body); } } return body; @@ -38713,7 +40849,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 199)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 200)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -38761,10 +40897,14 @@ var ts; } } })(Debug = ts.Debug || (ts.Debug = {})); - var _a; })(ts || (ts = {})); var ts; (function (ts) { + var FlattenLevel; + (function (FlattenLevel) { + FlattenLevel[FlattenLevel["All"] = 0] = "All"; + FlattenLevel[FlattenLevel["ObjectRest"] = 1] = "ObjectRest"; + })(FlattenLevel = ts.FlattenLevel || (ts.FlattenLevel = {})); function flattenDestructuringAssignment(node, visitor, context, level, needsValue, createAssignmentCallback) { var location = node; var value; @@ -38818,7 +40958,7 @@ var ts; ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression); var expression = createAssignmentCallback ? createAssignmentCallback(target, value, location) - : ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value, location); + : ts.setTextRange(ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location); expression.original = original; emitExpression(expression); } @@ -38856,10 +40996,11 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_31 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_31, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value); variable.original = original; - if (ts.isIdentifier(name_31)) { + ts.setTextRange(variable, location); + if (ts.isIdentifier(name)) { ts.setEmitFlags(variable, 64); } ts.aggregateTransformFlags(variable); @@ -39005,8 +41146,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_32 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_32); + var name = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name); } } function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) { @@ -39017,7 +41158,7 @@ var ts; var temp = ts.createTempVariable(undefined); if (flattenContext.hoistTempVariables) { flattenContext.context.hoistVariableDeclaration(temp); - flattenContext.emitExpression(ts.createAssignment(temp, value, location)); + flattenContext.emitExpression(ts.setTextRange(ts.createAssignment(temp, value), location)); } else { flattenContext.emitBindingOrAssignment(temp, value, location, undefined); @@ -39067,12 +41208,21 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), undefined, [value, ts.createArrayLiteral(propertyNames, location)]); + return ts.createCall(ts.getHelperName("__rest"), undefined, [ + value, + ts.setTextRange(ts.createArrayLiteral(propertyNames), location) + ]); } })(ts || (ts = {})); var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; + var TypeScriptSubstitutionFlags; + (function (TypeScriptSubstitutionFlags) { + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; + })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); function transformTypeScript(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -39083,8 +41233,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(177); context.enableSubstitution(178); + context.enableSubstitution(179); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -39117,15 +41267,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 262: + case 264: + case 234: case 233: - case 232: - case 205: + case 206: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 228: case 227: - case 226: if (ts.hasModifier(node, 2)) { break; } @@ -39150,13 +41300,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 236: + case 237: return visitImportDeclaration(node); - case 235: + case 236: return visitImportEqualsDeclaration(node); - case 241: - return visitExportAssignment(node); case 242: + return visitExportAssignment(node); + case 243: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -39166,11 +41316,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 242 || - node.kind === 236 || + if (node.kind === 243 || node.kind === 237 || - (node.kind === 235 && - node.moduleReference.kind === 246)) { + node.kind === 238 || + (node.kind === 236 && + node.moduleReference.kind === 247)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -39186,15 +41336,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 150: - return undefined; - case 147: - case 155: case 151: + return undefined; + case 148: + case 156: case 152: - case 149: + case 153: + case 150: return visitorWorker(node); - case 204: + case 205: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -39225,23 +41375,22 @@ var ts; case 75: case 123: case 130: - case 162: case 163: - case 161: - case 156: - case 143: + case 164: + case 162: + case 157: + case 144: case 118: case 121: - case 134: + case 135: case 132: case 129: case 104: - case 135: - case 159: - case 158: + case 136: case 160: - case 157: - case 164: + case 159: + case 161: + case 158: case 165: case 166: case 167: @@ -39249,57 +41398,58 @@ var ts; case 169: case 170: case 171: - case 155: - case 145: - case 229: - case 147: - return undefined; - case 150: - return visitConstructor(node); - case 228: - return ts.createNotEmittedStatement(node); - case 227: - return visitClassDeclaration(node); - case 197: - return visitClassExpression(node); - case 256: - return visitHeritageClause(node); - case 199: - return visitExpressionWithTypeArguments(node); - case 149: - return visitMethodDeclaration(node); - case 151: - return visitGetAccessor(node); - case 152: - return visitSetAccessor(node); - case 226: - return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); - case 185: - return visitArrowFunction(node); - case 144: - return visitParameter(node); - case 183: - return visitParenthesizedExpression(node); - case 182: - case 200: - return visitAssertionExpression(node); - case 179: - return visitCallExpression(node); - case 180: - return visitNewExpression(node); - case 201: - return visitNonNullExpression(node); + case 172: + case 156: + case 146: case 230: - return visitEnumDeclaration(node); - case 206: - return visitVariableStatement(node); - case 224: - return visitVariableDeclaration(node); + case 148: + return undefined; + case 151: + return visitConstructor(node); + case 229: + return ts.createNotEmittedStatement(node); + case 228: + return visitClassDeclaration(node); + case 198: + return visitClassExpression(node); + case 258: + return visitHeritageClause(node); + case 200: + return visitExpressionWithTypeArguments(node); + case 150: + return visitMethodDeclaration(node); + case 152: + return visitGetAccessor(node); + case 153: + return visitSetAccessor(node); + case 227: + return visitFunctionDeclaration(node); + case 185: + return visitFunctionExpression(node); + case 186: + return visitArrowFunction(node); + case 145: + return visitParameter(node); + case 184: + return visitParenthesizedExpression(node); + case 183: + case 201: + return visitAssertionExpression(node); + case 180: + return visitCallExpression(node); + case 181: + return visitNewExpression(node); + case 202: + return visitNonNullExpression(node); case 231: + return visitEnumDeclaration(node); + case 207: + return visitVariableStatement(node); + case 225: + return visitVariableDeclaration(node); + case 232: return visitModuleDeclaration(node); - case 235: + case 236: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39359,11 +41509,12 @@ var ts; return ts.singleOrMany(statements); } function createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, hasStaticProperties) { - var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); + var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause)); var emitFlags = ts.getEmitFlags(node); if (hasStaticProperties) { emitFlags |= 32; } + ts.setTextRange(classDeclaration, node); ts.setOriginalNode(classDeclaration, node); ts.setEmitFlags(classDeclaration, emitFlags); return classDeclaration; @@ -39374,10 +41525,14 @@ var ts; var declName = ts.getLocalName(node, false, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, hasExtendsClause); - var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members, location); + var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); - var statement = ts.createLetStatement(declName, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression, location); + ts.setTextRange(classExpression, location); + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declName, undefined, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression) + ], 1)); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, location); ts.setCommentRange(statement, node); return statement; } @@ -39385,7 +41540,9 @@ var ts; var staticProperties = getInitializedProperties(node, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84; })); - var classExpression = ts.setOriginalNode(ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members, node), node); + var classExpression = ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members); + ts.setOriginalNode(classExpression, node); + ts.setTextRange(classExpression, node); if (staticProperties.length > 0) { var expressions = []; var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -39408,7 +41565,7 @@ var ts; members.push(constructor); } ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); - return ts.createNodeArray(members, node.members); + return ts.setTextRange(ts.createNodeArray(members), node.members); } function transformConstructor(node, hasExtendsClause) { var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); @@ -39419,7 +41576,7 @@ var ts; } var parameters = transformConstructorParameters(constructor); var body = transformConstructorBody(node, constructor, hasExtendsClause); - return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor(undefined, undefined, parameters, body, constructor || node), constructor)); + return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor(undefined, undefined, parameters, body), constructor || node), constructor)); } function transformConstructorParameters(constructor) { return ts.visitParameterList(constructor && constructor.parameters, visitor, context) @@ -39443,7 +41600,7 @@ var ts; ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } ts.addRange(statements, endLexicalEnvironment()); - return ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : undefined, true); + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined); } function addPrologueDirectivesAndInitialSuperCall(ctor, result) { if (ctor.body) { @@ -39453,7 +41610,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -39475,7 +41632,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 | 48); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536); - return ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), propertyName, node.name), localName), ts.moveRangePos(node, -1))); + return ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1))); } function getInitializedProperties(node, isStatic) { return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); @@ -39487,7 +41644,7 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 147 + return member.kind === 148 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } @@ -39560,12 +41717,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 151: case 152: + case 153: return getAllDecoratorsOfAccessors(node, member); - case 149: + case 150: return getAllDecoratorsOfMethod(member); - case 147: + case 148: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -39644,7 +41801,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 147 + ? member.kind === 148 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -39722,43 +41879,43 @@ var ts; (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, undefined, true))); + decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, true))); } } } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 149 - || kind === 151 + return kind === 150 || kind === 152 - || kind === 147; + || kind === 153 + || kind === 148; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 149; + return node.kind === 150; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 227: - case 197: + case 228: + case 198: return ts.getFirstConstructorWithBody(node) !== undefined; - case 149: - case 151: + case 150: case 152: + case 153: return true; } return false; } function serializeTypeOfNode(node) { switch (node.kind) { - case 147: - case 144: - case 151: - return serializeTypeNode(node.type); + case 148: + case 145: case 152: + return serializeTypeNode(node.type); + case 153: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 227: - case 197: - case 149: + case 228: + case 198: + case 150: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -39790,7 +41947,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 151) { + if (container && node.kind === 152) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -39813,24 +41970,24 @@ var ts; } switch (node.kind) { case 104: - case 137: + case 138: case 94: case 129: return ts.createVoidZero(); - case 166: + case 167: return serializeTypeNode(node.type); - case 158: case 159: + case 160: return ts.createIdentifier("Function"); - case 162: case 163: + case 164: return ts.createIdentifier("Array"); - case 156: + case 157: case 121: return ts.createIdentifier("Boolean"); - case 134: + case 135: return ts.createIdentifier("String"); - case 171: + case 172: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); @@ -39846,22 +42003,22 @@ var ts; break; case 132: return ts.createIdentifier("Number"); - case 135: + case 136: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 157: + case 158: return serializeTypeReferenceNode(node); + case 166: case 165: - case 164: return serializeUnionOrIntersectionType(node); - case 160: - case 168: + case 161: case 169: case 170: - case 161: + case 171: + case 162: case 118: - case 167: + case 168: break; default: ts.Debug.failBadSyntaxKind(node); @@ -39929,15 +42086,15 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 70: - var name_33 = ts.getMutableClone(node); - name_33.flags &= ~8; - name_33.original = undefined; - name_33.parent = currentScope; + var name = ts.getMutableClone(node); + name.flags &= ~8; + name.original = undefined; + name.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_33), ts.createLiteral("undefined")), name_33); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } - return name_33; - case 141: + return name; + case 142: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -39981,7 +42138,7 @@ var ts; hoistVariableDeclaration(generatedName); expression = ts.createAssignment(generatedName, expression); } - return ts.setOriginalNode(ts.createComputedPropertyName(expression, name), name); + return ts.updateComputedPropertyName(name, expression); } else { return name; @@ -39990,13 +42147,12 @@ var ts; function visitHeritageClause(node) { if (node.token === 84) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(84, types, node); + return ts.setTextRange(ts.createHeritageClause(84, types), node); } return undefined; } function visitExpressionWithTypeArguments(node) { - var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); - return ts.createExpressionWithTypeArguments(undefined, expression, node); + return ts.updateExpressionWithTypeArguments(node, undefined, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); } function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); @@ -40070,8 +42226,9 @@ var ts; if (ts.parameterIsThisKeyword(node)) { return undefined; } - var parameter = ts.createParameter(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), ts.moveRangePastModifiers(node)); + var parameter = ts.createParameter(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); ts.setOriginalNode(parameter, node); + ts.setTextRange(parameter, ts.moveRangePastModifiers(node)); ts.setCommentRange(parameter, node); ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); ts.setEmitFlags(parameter.name, 32); @@ -40083,7 +42240,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); + return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -40095,7 +42252,7 @@ var ts; return ts.flattenDestructuringAssignment(node, visitor, context, 0, false, createNamespaceExportExpression); } else { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), node); + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node); } } function visitVariableDeclaration(node) { @@ -40149,8 +42306,9 @@ var ts; var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg]), node); + var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg])); ts.setOriginalNode(enumStatement, node); + ts.setTextRange(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); statements.push(ts.createEndOfDeclarationMarker(node)); @@ -40164,11 +42322,11 @@ var ts; ts.addRange(statements, ts.map(node.members, transformEnumMember)); ts.addRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceLocalName; - return ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); + return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true); } function transformEnumMember(member) { var name = getExpressionForPropertyName(member, false); - return ts.createStatement(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name, member), member); + return ts.setTextRange(ts.createStatement(ts.setTextRange(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name), member)), member); } function transformEnumMemberDeclarationValue(member) { var value = resolver.getConstantValue(member); @@ -40200,16 +42358,16 @@ var ts; if (!currentScopeFirstDeclarationsOfName) { currentScopeFirstDeclarationsOfName = ts.createMap(); } - if (!(name in currentScopeFirstDeclarationsOfName)) { - currentScopeFirstDeclarationsOfName[name] = node; + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_34 = node.symbol && node.symbol.name; - if (name_34) { - return currentScopeFirstDeclarationsOfName[name_34] === node; + var name = node.symbol && node.symbol.name; + if (name) { + return currentScopeFirstDeclarationsOfName.get(name) === node; } } return false; @@ -40221,7 +42379,7 @@ var ts; ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 230) { + if (node.kind === 231) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -40262,8 +42420,9 @@ var ts; var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); + var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg])); ts.setOriginalNode(moduleStatement, node); + ts.setTextRange(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); statements.push(ts.createEndOfDeclarationMarker(node)); @@ -40281,7 +42440,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 232) { + if (body.kind === 233) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -40303,14 +42462,15 @@ var ts; currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 232) { + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); + ts.setTextRange(block, blockLocation); + if (body.kind !== 233) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 231) { + if (moduleDeclaration.body.kind === 232) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -40330,7 +42490,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 238) { + if (node.kind === 239) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -40382,9 +42542,9 @@ var ts; var moduleReference = ts.createExpressionFromEntityName(node.moduleReference); ts.setEmitFlags(moduleReference, 1536 | 2048); if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { - return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ + return ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.setOriginalNode(ts.createVariableDeclaration(node.name, undefined, moduleReference), node) - ]), node), node); + ])), node), node); } else { return ts.setOriginalNode(createNamespaceExport(node.name, moduleReference, node), node); @@ -40405,7 +42565,7 @@ var ts; && ts.hasModifier(node, 512); } function expressionToStatement(expression) { - return ts.createStatement(expression, undefined); + return ts.createStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), ts.getLocalName(node)); @@ -40415,10 +42575,10 @@ var ts; statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue), location); + return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue, location); + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); } function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) { return ts.getNamespaceMemberName(currentNamespaceContainerName, name, false, true); @@ -40434,7 +42594,7 @@ var ts; function getClassAliasIfNeeded(node) { if (resolver.getNodeCheckFlags(node) & 8388608) { enableSubstitutionForClassAliases(); - var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); + var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.unescapeIdentifier(node.name.text) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; hoistVariableDeclaration(classAlias); return classAlias; @@ -40458,24 +42618,24 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(70); - classAliases = ts.createMap(); + classAliases = []; } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(259); - context.enableEmitNotification(231); + context.enableSubstitution(261); + context.enableEmitNotification(232); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 231; + return ts.getOriginalNode(node).kind === 232; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 230; + return ts.getOriginalNode(node).kind === 231; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2; @@ -40483,12 +42643,12 @@ var ts; if (enabledSubstitutions & 8 && isTransformedEnumDeclaration(node)) { applicableSubstitutions |= 8; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -40498,14 +42658,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_35 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_35); + var name = node.name; + var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_35, initializer, node); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); } - return ts.createPropertyAssignment(name_35, exportedName, node); + return ts.setTextRange(ts.createPropertyAssignment(name, exportedName), node); } } return node; @@ -40514,9 +42674,9 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 177: - return substitutePropertyAccessExpression(node); case 178: + return substitutePropertyAccessExpression(node); + case 179: return substituteElementAccessExpression(node); } return node; @@ -40546,11 +42706,11 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 262) { - var substitute = (applicableSubstitutions & 2 && container.kind === 231) || - (applicableSubstitutions & 8 && container.kind === 230); + if (container && container.kind !== 264) { + var substitute = (applicableSubstitutions & 2 && container.kind === 232) || + (applicableSubstitutions & 8 && container.kind === 231); if (substitute) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } } } @@ -40597,10 +42757,10 @@ var ts; }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(paramHelper); - return ts.createCall(ts.getHelperName("__param"), undefined, [ + return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), undefined, [ ts.createLiteral(parameterOffset), expression - ], location); + ]), location); } var metadataHelper = { name: "typescript:metadata", @@ -40624,7 +42784,7 @@ var ts; function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) { context.requestEmitHelper(decorateHelper); var argumentsArray = []; - argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, undefined, true)); + argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, true)); argumentsArray.push(target); if (memberName) { argumentsArray.push(memberName); @@ -40632,7 +42792,7 @@ var ts; argumentsArray.push(descriptor); } } - return ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray, location); + return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray), location); } })(ts || (ts = {})); var ts; @@ -40659,37 +42819,37 @@ var ts; return node; } switch (node.kind) { - case 176: + case 177: return visitObjectLiteralExpression(node); - case 192: + case 193: return visitBinaryExpression(node, noDestructuringValue); - case 224: + case 225: return visitVariableDeclaration(node); - case 214: + case 215: return visitForOfStatement(node); - case 212: + case 213: return visitForStatement(node); - case 188: + case 189: return visitVoidExpression(node); - case 150: - return visitConstructorDeclaration(node); - case 149: - return visitMethodDeclaration(node); case 151: - return visitGetAccessorDeclaration(node); + return visitConstructorDeclaration(node); + case 150: + return visitMethodDeclaration(node); case 152: + return visitGetAccessorDeclaration(node); + case 153: return visitSetAccessorDeclaration(node); - case 226: + case 227: return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); case 185: + return visitFunctionExpression(node); + case 186: return visitArrowFunction(node); - case 144: + case 145: return visitParameter(node); - case 208: + case 209: return visitExpressionStatement(node); - case 183: + case 184: return visitParenthesizedExpression(node, noDestructuringValue); default: return ts.visitEachChild(node, visitor, context); @@ -40698,9 +42858,9 @@ var ts; function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; - for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { - var e = elements_3[_i]; - if (e.kind === 260) { + for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { + var e = elements_4[_i]; + if (e.kind === 262) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -40712,7 +42872,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 258) { + if (e.kind === 260) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -40729,7 +42889,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 1048576) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 176) { + if (objects.length && objects[0].kind !== 177) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -40773,25 +42933,26 @@ var ts; var firstDeclaration = ts.firstOrUndefined(initializer.declarations); var declarations = ts.flattenDestructuringBinding(firstDeclaration, visitor, context, 1, temp, false, true); if (ts.some(declarations)) { - var statement = ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(initializer, declarations), initializer); + var statement = ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(initializer, declarations)); + ts.setTextRange(statement, initializer); leadingStatements = ts.append(leadingStatements, statement); } } else if (ts.isAssignmentPattern(initializer)) { temp = ts.createTempVariable(undefined); - var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.createAssignment(initializer, temp, node.initializer)), visitor, context, 1); - leadingStatements = ts.append(leadingStatements, ts.createStatement(expression, node.initializer)); + var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.setTextRange(ts.createAssignment(initializer, temp), node.initializer)), visitor, context, 1); + leadingStatements = ts.append(leadingStatements, ts.setTextRange(ts.createStatement(expression), node.initializer)); } } if (temp) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var statement = ts.visitNode(node.statement, visitor, ts.isStatement); var block = ts.isBlock(statement) - ? ts.updateBlock(statement, ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements), statement.statements)) - : ts.createBlock(ts.append(leadingStatements, statement), statement, true); - return ts.updateForOf(node, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, undefined, undefined, node.initializer) - ], node.initializer, 1), expression, block); + ? ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements)), statement.statements)) + : ts.setTextRange(ts.createBlock(ts.append(leadingStatements, statement), true), statement); + return ts.updateForOf(node, ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer) + ], 1), node.initializer), expression, block); } return ts.visitEachChild(node, visitor, context); } @@ -40841,7 +43002,7 @@ var ts; var trailingStatements = endLexicalEnvironment(); if (ts.some(leadingStatements) || ts.some(trailingStatements)) { var block = ts.convertToFunctionBody(body, true); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements)), block.statements)); } return body; } @@ -40854,6 +43015,9 @@ var ts; text: "\n var __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };" }; function createAssignHelper(context, attributesSegments) { + if (context.getCompilerOptions().target >= 2) { + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), undefined, attributesSegments); + } context.requestEmitHelper(assignHelper); return ts.createCall(ts.getHelperName("__assign"), undefined, attributesSegments); } @@ -40885,11 +43049,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 247: - return visitJsxElement(node, false); case 248: + return visitJsxElement(node, false); + case 249: return visitJsxSelfClosingElement(node, false); - case 253: + case 255: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40899,11 +43063,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 253: + case 255: return visitJsxExpression(node); - case 247: - return visitJsxElement(node, true); case 248: + return visitJsxElement(node, true); + case 249: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -40919,7 +43083,7 @@ var ts; function visitJsxOpeningLikeElement(node, children, isChild, location) { var tagName = getTagName(node); var objectProperties; - var attrs = node.attributes; + var attrs = node.attributes.properties; if (attrs.length === 0) { objectProperties = ts.createNull(); } @@ -40951,15 +43115,15 @@ var ts; } function transformJsxAttributeInitializer(node) { if (node === undefined) { - return ts.createLiteral(true); + return ts.createTrue(); } else if (node.kind === 9) { var decoded = tryDecodeEntities(node.text); - return decoded ? ts.createLiteral(decoded, node) : node; + return decoded ? ts.setTextRange(ts.createLiteral(decoded), node) : node; } - else if (node.kind === 253) { + else if (node.kind === 255) { if (node.expression === undefined) { - return ts.createLiteral(true); + return ts.createTrue(); } return visitJsxExpression(node); } @@ -40968,43 +43132,35 @@ var ts; } } function visitJsxText(node) { - var text = ts.getTextOfNode(node, true); - var parts; + var fixed = fixupWhitespaceAndDecodeEntities(ts.getTextOfNode(node, true)); + return fixed === undefined ? undefined : ts.createLiteral(fixed); + } + function fixupWhitespaceAndDecodeEntities(text) { + var acc; 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); - if (!parts) { - parts = []; - } - parts.push(ts.createLiteral(decodeEntities(part))); + if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) { + acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); } firstNonWhitespace = -1; } - else if (!ts.isWhiteSpace(c)) { + else if (!ts.isWhiteSpaceSingleLine(c)) { lastNonWhitespace = i; if (firstNonWhitespace === -1) { firstNonWhitespace = i; } } } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - if (!parts) { - parts = []; - } - parts.push(ts.createLiteral(decodeEntities(part))); - } - if (parts) { - return ts.reduceLeft(parts, aggregateJsxTextParts); - } - return undefined; + return firstNonWhitespace !== -1 + ? addLineOfJsxText(acc, text.substr(firstNonWhitespace)) + : acc; } - function aggregateJsxTextParts(left, right) { - return ts.createAdd(ts.createAdd(left, ts.createLiteral(" ")), right); + function addLineOfJsxText(acc, trimmedLine) { + var decoded = decodeEntities(trimmedLine); + return acc === undefined ? decoded : acc + " " + decoded; } function decodeEntities(text) { return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) { @@ -41015,7 +43171,7 @@ var ts; return String.fromCharCode(parseInt(hex, 16)); } else { - var ch = entities[word]; + var ch = entities.get(word); return ch ? String.fromCharCode(ch) : match; } }); @@ -41025,16 +43181,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 247) { + if (node.kind === 248) { return getTagName(node.openingElement); } else { - var name_36 = node.tagName; - if (ts.isIdentifier(name_36) && ts.isIntrinsicJsxName(name_36.text)) { - return ts.createLiteral(name_36.text); + var name = node.tagName; + if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.text)) { + return ts.createLiteral(name.text); } else { - return ts.createExpressionFromEntityName(name_36); + return ts.createExpressionFromEntityName(name); } } } @@ -41052,7 +43208,7 @@ var ts; } } ts.transformJsx = transformJsx; - var entities = ts.createMap({ + var entities = ts.createMapFromTemplate({ "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, @@ -41310,6 +43466,10 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); function transformES2017(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var resolver = context.getEmitResolver(); @@ -41340,22 +43500,22 @@ var ts; switch (node.kind) { case 119: return undefined; - case 189: + case 190: return visitAwaitExpression(node); - case 149: + case 150: return visitMethodDeclaration(node); - case 226: + case 227: return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); case 185: + return visitFunctionExpression(node); + case 186: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); } function visitMethodDeclaration(node) { return ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) @@ -41385,14 +43545,15 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 185; + var isArrowFunction = node.kind === 186; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(statements, node.body, true); + var block = ts.createBlock(statements, true); + ts.setTextRange(block, node.body); if (languageVersion >= 2) { if (resolver.getNodeCheckFlags(node) & 4096) { enableSubstitutionForAsyncMethodsWithSuper(); @@ -41410,7 +43571,7 @@ var ts; var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(block.statements, declarations), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); } return expression; } @@ -41423,7 +43584,7 @@ var ts; startLexicalEnvironment(); var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); var declarations = endLexicalEnvironment(); - return ts.updateBlock(visited, ts.createNodeArray(ts.concatenate(visited.statements, declarations), visited.statements)); + return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); } } function getPromiseConstructor(type) { @@ -41440,23 +43601,23 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(179); - context.enableSubstitution(177); + context.enableSubstitution(180); context.enableSubstitution(178); - context.enableEmitNotification(227); - context.enableEmitNotification(149); - context.enableEmitNotification(151); - context.enableEmitNotification(152); + context.enableSubstitution(179); + context.enableEmitNotification(228); context.enableEmitNotification(150); + context.enableEmitNotification(152); + context.enableEmitNotification(153); + context.enableEmitNotification(151); } } function substituteExpression(node) { switch (node.kind) { - case 177: - return substitutePropertyAccessExpression(node); case 178: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 179: + return substituteElementAccessExpression(node); + case 180: if (enabledSubstitutions & 1) { return substituteCallExpression(node); } @@ -41499,36 +43660,36 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 227 - || kind === 150 - || kind === 149 + return kind === 228 || kind === 151 - || kind === 152; + || kind === 150 + || kind === 152 + || kind === 153; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { if (enabledSubstitutions & 1 && isSuperContainer(node)) { var savedCurrentSuperContainer = currentSuperContainer; currentSuperContainer = node; - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSuperContainer = savedCurrentSuperContainer; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } return node; } function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { if (flags & 4096) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value"), location); } else { - return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), location); } } function getSuperContainerAsyncMethodFlags() { @@ -41581,7 +43742,7 @@ var ts; return node; } switch (node.kind) { - case 192: + case 193: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -41605,19 +43766,19 @@ var ts; if (ts.isElementAccessExpression(left)) { var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, left.argumentExpression), left); - value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, left); + target = ts.setTextRange(ts.createElementAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(ts.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left); + value = ts.setTextRange(ts.createElementAccess(expressionTemp, argumentExpressionTemp), left); } else if (ts.isPropertyAccessExpression(left)) { var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), left.name, left); - value = ts.createPropertyAccess(expressionTemp, left.name, left); + target = ts.setTextRange(ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), left.name), left); + value = ts.setTextRange(ts.createPropertyAccess(expressionTemp, left.name), left); } else { target = left; value = left; } - return ts.createAssignment(target, ts.createMathPow(value, right, node), node); + return ts.setTextRange(ts.createAssignment(target, ts.createMathPow(value, right, node)), node); } function visitExponentiationExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); @@ -41629,6 +43790,75 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var ES2015SubstitutionFlags; + (function (ES2015SubstitutionFlags) { + ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; + ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; + })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); + var HierarchyFacts; + (function (HierarchyFacts) { + HierarchyFacts[HierarchyFacts["None"] = 0] = "None"; + HierarchyFacts[HierarchyFacts["Function"] = 1] = "Function"; + HierarchyFacts[HierarchyFacts["ArrowFunction"] = 2] = "ArrowFunction"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBody"] = 4] = "AsyncFunctionBody"; + HierarchyFacts[HierarchyFacts["NonStaticClassElement"] = 8] = "NonStaticClassElement"; + HierarchyFacts[HierarchyFacts["CapturesThis"] = 16] = "CapturesThis"; + HierarchyFacts[HierarchyFacts["ExportedVariableStatement"] = 32] = "ExportedVariableStatement"; + HierarchyFacts[HierarchyFacts["TopLevel"] = 64] = "TopLevel"; + HierarchyFacts[HierarchyFacts["Block"] = 128] = "Block"; + HierarchyFacts[HierarchyFacts["IterationStatement"] = 256] = "IterationStatement"; + HierarchyFacts[HierarchyFacts["IterationStatementBlock"] = 512] = "IterationStatementBlock"; + HierarchyFacts[HierarchyFacts["ForStatement"] = 1024] = "ForStatement"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 2048] = "ForInOrForOfStatement"; + HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 4096] = "ConstructorWithCapturedSuper"; + HierarchyFacts[HierarchyFacts["ComputedPropertyName"] = 8192] = "ComputedPropertyName"; + HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask"; + HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes"; + HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 4032] = "BlockScopeExcludes"; + HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 64] = "SourceFileIncludes"; + HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 3968] = "SourceFileExcludes"; + HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes"; + HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 16256] = "ArrowFunctionExcludes"; + HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes"; + HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes"; + HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 256] = "DoOrWhileStatementIncludes"; + HierarchyFacts[HierarchyFacts["DoOrWhileStatementExcludes"] = 0] = "DoOrWhileStatementExcludes"; + HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 1280] = "ForStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 3008] = "ForStatementExcludes"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 2304] = "ForInOrForOfStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 1984] = "ForInOrForOfStatementExcludes"; + HierarchyFacts[HierarchyFacts["BlockIncludes"] = 128] = "BlockIncludes"; + HierarchyFacts[HierarchyFacts["BlockExcludes"] = 3904] = "BlockExcludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 4032] = "IterationStatementBlockExcludes"; + HierarchyFacts[HierarchyFacts["ComputedPropertyNameIncludes"] = 8192] = "ComputedPropertyNameIncludes"; + HierarchyFacts[HierarchyFacts["ComputedPropertyNameExcludes"] = 0] = "ComputedPropertyNameExcludes"; + HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget"; + HierarchyFacts[HierarchyFacts["NewTargetInComputedPropertyName"] = 32768] = "NewTargetInComputedPropertyName"; + HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask"; + HierarchyFacts[HierarchyFacts["PropagateNewTargetMask"] = 49152] = "PropagateNewTargetMask"; + })(HierarchyFacts || (HierarchyFacts = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -41665,7 +43895,7 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return hierarchyFacts & 4096 - && node.kind === 217 + && node.kind === 218 && !node.expression; } function shouldVisitNode(node) { @@ -41698,91 +43928,91 @@ var ts; switch (node.kind) { case 114: return undefined; - case 227: + case 228: return visitClassDeclaration(node); - case 197: + case 198: return visitClassExpression(node); - case 144: + case 145: return visitParameter(node); - case 226: + case 227: return visitFunctionDeclaration(node); - case 185: + case 186: return visitArrowFunction(node); - case 184: + case 185: return visitFunctionExpression(node); - case 224: + case 225: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 225: + case 226: return visitVariableDeclarationList(node); - case 219: - return visitSwitchStatement(node); - case 233: - return visitCaseBlock(node); - case 205: - return visitBlock(node, false); - case 216: - case 215: - return visitBreakOrContinueStatement(node); case 220: + return visitSwitchStatement(node); + case 234: + return visitCaseBlock(node); + case 206: + return visitBlock(node, false); + case 217: + case 216: + return visitBreakOrContinueStatement(node); + case 221: return visitLabeledStatement(node); - case 210: case 211: - return visitDoOrWhileStatement(node, undefined); case 212: - return visitForStatement(node, undefined); + return visitDoOrWhileStatement(node, undefined); case 213: - return visitForInStatement(node, undefined); + return visitForStatement(node, undefined); case 214: + return visitForInStatement(node, undefined); + case 215: return visitForOfStatement(node, undefined); - case 208: + case 209: return visitExpressionStatement(node); - case 176: + case 177: return visitObjectLiteralExpression(node); - case 257: - return visitCatchClause(node); case 259: + return visitCatchClause(node); + case 261: return visitShorthandPropertyAssignment(node); - case 142: + case 143: return visitComputedPropertyName(node); - case 175: + case 176: return visitArrayLiteralExpression(node); - case 179: - return visitCallExpression(node); case 180: + return visitCallExpression(node); + case 181: return visitNewExpression(node); - case 183: + case 184: return visitParenthesizedExpression(node, true); - case 192: + case 193: return visitBinaryExpression(node, true); case 12: case 13: case 14: case 15: return visitTemplateLiteral(node); - case 181: + case 182: return visitTaggedTemplateExpression(node); - case 194: - return visitTemplateExpression(node); case 195: - return visitYieldExpression(node); + return visitTemplateExpression(node); case 196: + return visitYieldExpression(node); + case 197: return visitSpreadElement(node); case 96: return visitSuperKeyword(false); case 98: return visitThisKeyword(node); - case 202: + case 203: return visitMetaProperty(node); - case 149: + case 150: return visitMethodDeclaration(node); - case 151: case 152: + case 153: return visitAccessorDeclaration(node); - case 206: + case 207: return visitVariableStatement(node); - case 217: + case 218: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -41797,7 +44027,7 @@ var ts; ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, 0, 0); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } function visitSwitchStatement(node) { if (convertedLoopState !== undefined) { @@ -41852,20 +44082,20 @@ var ts; if (ts.isGeneratedIdentifier(node)) { return node; } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + if (node.text !== "arguments" || !resolver.isArgumentsLocalBinding(node)) { return node; } return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 216 ? 2 : 4; - var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + var jump = node.kind === 217 ? 2 : 4; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 216) { + if (node.kind === 217) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -41875,7 +44105,7 @@ var ts; } } else { - if (node.kind === 216) { + if (node.kind === 217) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -41908,8 +44138,9 @@ var ts; var variable = ts.createVariableDeclaration(ts.getLocalName(node, true), undefined, transformClassLikeDeclarationToExpression(node)); ts.setOriginalNode(variable, node); var statements = []; - var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable]), node); + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable])); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, node); ts.startOnNewLine(statement); statements.push(statement); if (ts.hasModifier(node, 1)) { @@ -41964,13 +44195,13 @@ var ts; ts.setEmitFlags(statement, 1536 | 384); statements.push(statement); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true); ts.setEmitFlags(block, 1536); return block; } function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node)), extendsClauseElement)); + statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node))), extendsClauseElement)); } } function addConstructor(statements, node, extendsClauseElement) { @@ -41979,7 +44210,8 @@ var ts; var ancestorFacts = enterSubtree(16278, 73); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); + ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 8); } @@ -42026,24 +44258,25 @@ var ts; if (constructor) { prependCaptureNewTargetIfNeeded(statements, constructor, false); } - var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true); + ts.setTextRange(block, constructor ? constructor.body : node); if (!constructor) { ts.setEmitFlags(block, 1536); } return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 217) { + if (statement.kind === 218) { return true; } - else if (statement.kind === 209) { + else if (statement.kind === 210) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 205) { + else if (statement.kind === 206) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -42072,7 +44305,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 208 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 209 && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -42080,8 +44313,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 | 32768))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 192 - || superCallExpression.left.kind !== 179) { + if (superCallExpression.kind !== 193 + || superCallExpression.left.kind !== 180) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } ts.setCommentRange(returnStatement, ts.getCommentRange(ts.setEmitFlags(superCallExpression.left, 1536))); @@ -42105,10 +44338,10 @@ var ts; return undefined; } else if (ts.isBindingPattern(node.name)) { - return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined, node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined), node), node); } else if (node.initializer) { - return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined, node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined), node), node); } else { return node; @@ -42123,15 +44356,15 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_37 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_37)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_37, initializer); + if (ts.isBindingPattern(name)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_37, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer); } } } @@ -42146,10 +44379,11 @@ var ts; } function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer)), parameter)) - ], parameter), 1 | 32 | 384), undefined, parameter); + var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([ + ts.createStatement(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer))), parameter)) + ]), parameter), 1 | 32 | 384)); statement.startsOnNewLine = true; + ts.setTextRange(statement, parameter); ts.setEmitFlags(statement, 384 | 32 | 524288); statements.push(statement); } @@ -42166,22 +44400,22 @@ var ts; var expressionName = ts.getSynthesizedClone(parameter.name); var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) - ]), parameter), 524288)); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ])), parameter), 524288)); + var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) - ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 + ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ + ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp - : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) + : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), parameter)) ])); ts.setEmitFlags(forStatement, 524288); ts.startOnNewLine(forStatement); statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 && node.kind !== 185) { + if (node.transformFlags & 32768 && node.kind !== 186) { captureThisForNode(statements, node, ts.createThis()); } } @@ -42189,8 +44423,9 @@ var ts; enableSubstitutionsForCapturedThis(); var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("_this", undefined, initializer) - ]), originalStatement); + ])); ts.setEmitFlags(captureThisStatement, 1536 | 524288); + ts.setTextRange(captureThisStatement, originalStatement); ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } @@ -42198,18 +44433,18 @@ var ts; if (hierarchyFacts & 16384) { var newTarget = void 0; switch (node.kind) { - case 185: + case 186: return statements; - case 149: - case 151: + case 150: case 152: + case 153: newTarget = ts.createVoidZero(); break; - case 150: + case 151: newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); break; - case 226: - case 184: + case 227: + case 185: newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 92, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); break; default: @@ -42230,20 +44465,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 204: + case 205: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 149: + case 150: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 151: case 152: + case 153: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 150: + case 151: break; default: ts.Debug.failBadSyntaxKind(node); @@ -42252,7 +44487,7 @@ var ts; } } function transformSemicolonClassElementToStatement(member) { - return ts.createEmptyStatement(member); + return ts.setTextRange(ts.createEmptyStatement(), member); } function transformClassMethodDeclarationToStatement(receiver, member, container) { var ancestorFacts = enterSubtree(0, 0); @@ -42262,7 +44497,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); ts.setEmitFlags(memberFunction, 1536); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), member); + var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); ts.setEmitFlags(statement, 48); @@ -42270,8 +44505,9 @@ var ts; return statement; } function transformAccessorsToStatement(receiver, accessors, container) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false), ts.getSourceMapRange(accessors.firstAccessor)); + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false)); ts.setEmitFlags(statement, 1536); + ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { @@ -42300,11 +44536,11 @@ var ts; ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } - properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); + properties.push(ts.createPropertyAssignment("enumerable", ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue())); var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ target, propertyName, - ts.createObjectLiteral(properties, undefined, true) + ts.createObjectLiteral(properties, true) ]); if (startsOnNewLine) { call.startsOnNewLine = true; @@ -42319,7 +44555,8 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = enterSubtree(16256, 66); - var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node), node); + var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + ts.setTextRange(func, node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8); exitSubtree(ancestorFacts, 0, 0); @@ -42366,12 +44603,12 @@ var ts; : enterSubtree(16286, 65); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 && !name && (node.kind === 226 || node.kind === 184)) { + if (hierarchyFacts & 16384 && !name && (node.kind === 227 || node.kind === 185)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152, 0); convertedLoopState = savedConvertedLoopState; - return ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body, location), node); + return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body), location), node); } function transformFunctionBody(node) { var multiLine = false; @@ -42399,7 +44636,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 185); + ts.Debug.assert(node.kind === 186); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -42411,7 +44648,8 @@ var ts; } } var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, body); + var returnStatement = ts.createReturn(expression); + ts.setTextRange(returnStatement, body); ts.setEmitFlags(returnStatement, 384 | 32 | 1024); statements.push(returnStatement); closeBraceLocation = body; @@ -42422,7 +44660,8 @@ var ts; if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), multiLine); + ts.setTextRange(block, node.body); if (!multiLine && singleLine) { ts.setEmitFlags(block, 1); } @@ -42434,7 +44673,7 @@ var ts; } function visitFunctionBodyDownLevel(node) { var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); - return ts.updateBlock(updated, ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, true), updated.statements)); + return ts.updateBlock(updated, ts.setTextRange(ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, true)), updated.statements)); } function visitBlock(node, isFunctionBody) { if (isFunctionBody) { @@ -42449,9 +44688,9 @@ var ts; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 183: + case 184: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 192: + case 193: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -42459,9 +44698,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 183: + case 184: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 192: + case 193: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -42493,7 +44732,7 @@ var ts; } } if (assignments) { - updated = ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); + updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); })), node); } else { updated = undefined; @@ -42513,8 +44752,9 @@ var ts; var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 ? visitVariableDeclarationInLetDeclarationList : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, node); + var declarationList = ts.createVariableDeclarationList(declarations); ts.setOriginalNode(declarationList, node); + ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); if (node.transformFlags & 8388608 && (ts.isBindingPattern(node.declarations[0].name) @@ -42568,10 +44808,10 @@ var ts; return updated; } function recordLabel(node) { - convertedLoopState.labels[node.label.text] = node.label.text; + convertedLoopState.labels.set(node.label.text, node.label.text); } function resetLabel(node) { - convertedLoopState.labels[node.label.text] = undefined; + convertedLoopState.labels.set(node.label.text, undefined); } function visitLabeledStatement(node) { if (convertedLoopState && !convertedLoopState.labels) { @@ -42606,7 +44846,7 @@ var ts; var statements = []; var counter = ts.createLoopVariable(); var rhsReference = expression.kind === 70 - ? ts.createUniqueName(expression.text) + ? ts.createUniqueName(ts.unescapeIdentifier(expression.text)) : ts.createTempVariable(undefined); var elementAccess = ts.createElementAccess(rhsReference, counter); if (ts.isVariableDeclarationList(initializer)) { @@ -42616,17 +44856,18 @@ var ts; var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, elementAccess); - var declarationList = ts.createVariableDeclarationList(declarations, initializer); + var declarationList = ts.createVariableDeclarationList(declarations); ts.setOriginalNode(declarationList, initializer); + ts.setTextRange(declarationList, initializer); var firstDeclaration = declarations[0]; var lastDeclaration = ts.lastOrUndefined(declarations); ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); statements.push(ts.createVariableStatement(undefined, declarationList)); } else { - statements.push(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.createVariableDeclarationList([ + statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) - ], ts.moveRangePos(initializer, -1)), initializer), ts.moveRangeEnd(initializer, -1))); + ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); } } else { @@ -42636,7 +44877,7 @@ var ts; } else { assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createStatement(assignment), ts.moveRangeEnd(initializer, -1))); } } var bodyLocation; @@ -42645,7 +44886,7 @@ var ts; ts.addRange(statements, convertedLoopBodyStatements); } else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -42656,25 +44897,27 @@ var ts; } } ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression)); - var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); + var body = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation)); + ts.setTextRange(body, bodyLocation); ts.setEmitFlags(body, 48 | 384); - var forStatement = ts.createFor(ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) - ], node.expression), 1048576), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); + var forStatement = ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)), + ts.setTextRange(ts.createVariableDeclaration(rhsReference, undefined, expression), node.expression) + ]), node.expression), 1048576), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), body); ts.setEmitFlags(forStatement, 256); + ts.setTextRange(forStatement, node); return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 210: case 211: - return visitDoOrWhileStatement(node, outermostLabeledStatement); case 212: - return visitForStatement(node, outermostLabeledStatement); + return visitDoOrWhileStatement(node, outermostLabeledStatement); case 213: - return visitForInStatement(node, outermostLabeledStatement); + return visitForStatement(node, outermostLabeledStatement); case 214: + return visitForInStatement(node, outermostLabeledStatement); + case 215: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -42689,7 +44932,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 142) { + if (property.name.kind === 143) { numInitialProperties = i; break; } @@ -42700,7 +44943,7 @@ var ts; } var temp = ts.createTempVariable(hoistVariableDeclaration); var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 32768)); if (node.multiLine) { assignment.startsOnNewLine = true; } @@ -42751,11 +44994,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 212: case 213: case 214: + case 215: var initializer = node.initializer; - if (initializer && initializer.kind === 225) { + if (initializer && initializer.kind === 226) { loopInitializer = initializer; } break; @@ -42792,13 +45035,13 @@ var ts; copyOutParameters(loopOutParameters, 1, statements_4); } ts.addRange(statements_4, lexicalEnvironment); - loopBody = ts.createBlock(statements_4, undefined, true); + loopBody = ts.createBlock(statements_4, true); } if (ts.isBlock(loopBody)) { loopBody.multiLine = true; } else { - loopBody = ts.createBlock([loopBody], undefined, true); + loopBody = ts.createBlock([loopBody], true); } var isAsyncBlockContainingAwait = hierarchyFacts & 4 && (node.statement.transformFlags & 16777216) !== 0; @@ -42865,7 +45108,7 @@ var ts; var clone_4 = ts.getMutableClone(node); clone_4.statement = undefined; clone_4 = ts.visitEachChild(clone_4, visitor, context); - clone_4.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, true); clone_4.transformFlags = 0; ts.aggregateTransformFlags(clone_4); loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); @@ -42929,23 +45172,22 @@ var ts; if (!state.labeledNonLocalBreaks) { state.labeledNonLocalBreaks = ts.createMap(); } - state.labeledNonLocalBreaks[labelText] = labelMarker; + state.labeledNonLocalBreaks.set(labelText, labelMarker); } else { if (!state.labeledNonLocalContinues) { state.labeledNonLocalContinues = ts.createMap(); } - state.labeledNonLocalContinues[labelText] = labelMarker; + state.labeledNonLocalContinues.set(labelText, labelMarker); } } function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { if (!table) { return; } - for (var labelText in table) { - var labelMarker = table[labelText]; + table.forEach(function (labelMarker, labelText) { var statements = []; - if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) { var label = ts.createIdentifier(labelText); statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); } @@ -42954,7 +45196,7 @@ var ts; statements.push(ts.createReturn(loopResultName)); } caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); - } + }); } function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { var name = decl.name; @@ -42969,7 +45211,7 @@ var ts; else { loopParameters.push(ts.createParameter(undefined, undefined, undefined, name)); if (resolver.getNodeCheckFlags(decl) & 2097152) { - var outParamName = ts.createUniqueName("out_" + name.text); + var outParamName = ts.createUniqueName("out_" + ts.unescapeIdentifier(name.text)); loopOutParameters.push({ originalName: name, outParamName: outParamName }); } } @@ -42980,20 +45222,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 151: case 152: + case 153: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 149: + case 150: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 258: + case 260: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 259: + case 261: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -43003,14 +45245,16 @@ var ts; } } function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -43018,7 +45262,8 @@ var ts; } function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { var ancestorFacts = enterSubtree(0, 0); - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container), method); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container)); + ts.setTextRange(expression, method); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -43030,9 +45275,11 @@ var ts; var updated; if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var newVariableDeclaration = ts.createVariableDeclaration(temp); + ts.setTextRange(newVariableDeclaration, node.variableDeclaration); var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); - var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); + var list = ts.createVariableDeclarationList(vars); + ts.setTextRange(list, node.variableDeclaration); var destructure = ts.createVariableStatement(undefined, list); updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); } @@ -43050,7 +45297,7 @@ var ts; ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined); ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression)); - return ts.createPropertyAssignment(node.name, functionExpression, node); + return ts.setTextRange(ts.createPropertyAssignment(node.name, functionExpression), node); } function visitAccessorDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); @@ -43063,7 +45310,7 @@ var ts; return updated; } function visitShorthandPropertyAssignment(node) { - return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), node); + return ts.setTextRange(ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name)), node); } function visitComputedPropertyName(node) { var ancestorFacts = enterSubtree(0, 8192); @@ -43125,7 +45372,7 @@ var ts; })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 175 + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 176 ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -43140,7 +45387,7 @@ var ts; return ts.map(chunk, visitExpressionOfSpread); } function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { - return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, undefined, hasTrailingComma), visitor, ts.isExpression), undefined, multiLine); + return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -43149,7 +45396,7 @@ var ts; return ts.visitNode(node.expression, visitor, ts.isExpression); } function visitTemplateLiteral(node) { - return ts.createLiteral(node.text, node); + return ts.setTextRange(ts.createLiteral(node.text), node); } function visitTaggedTemplateExpression(node) { var tag = ts.visitNode(node.tag, visitor, ts.isExpression); @@ -43183,7 +45430,7 @@ var ts; var isLast = node.kind === 12 || node.kind === 15; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); - return ts.createLiteral(text, node); + return ts.setTextRange(ts.createLiteral(text), node); } function visitTemplateExpression(node) { var expressions = []; @@ -43191,7 +45438,8 @@ var ts; addTemplateSpans(expressions, node); var expression = ts.reduceLeft(expressions, ts.createAdd); if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); + expression.pos = node.pos; + expression.end = node.end; } return expression; } @@ -43232,16 +45480,16 @@ var ts; } return node; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8 ? 65 | 16 : 65); - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); exitSubtree(ancestorFacts, 0, 0); return; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { @@ -43253,18 +45501,18 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(98); - context.enableEmitNotification(150); - context.enableEmitNotification(149); context.enableEmitNotification(151); + context.enableEmitNotification(150); context.enableEmitNotification(152); + context.enableEmitNotification(153); + context.enableEmitNotification(186); context.enableEmitNotification(185); - context.enableEmitNotification(184); - context.enableEmitNotification(226); + context.enableEmitNotification(227); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -43284,10 +45532,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 174: - case 227: - case 230: - case 224: + case 175: + case 228: + case 231: + case 225: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -43314,7 +45562,7 @@ var ts; function substituteThisKeyword(node) { if (enabledSubstitutions & 1 && hierarchyFacts & 16) { - return ts.createIdentifier("_this", node); + return ts.setTextRange(ts.createIdentifier("_this"), node); } return node; } @@ -43330,11 +45578,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 208) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 209) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 179) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 180) { return false; } var callTarget = statementExpression.expression; @@ -43342,7 +45590,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 196) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 197) { return false; } var expression = callArgument.expression; @@ -43366,13 +45614,60 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var instructionNames = ts.createMap((_a = {}, - _a[2] = "return", - _a[3] = "break", - _a[4] = "yield", - _a[5] = "yield*", - _a[7] = "endfinally", - _a)); + var OpCode; + (function (OpCode) { + OpCode[OpCode["Nop"] = 0] = "Nop"; + OpCode[OpCode["Statement"] = 1] = "Statement"; + OpCode[OpCode["Assign"] = 2] = "Assign"; + OpCode[OpCode["Break"] = 3] = "Break"; + OpCode[OpCode["BreakWhenTrue"] = 4] = "BreakWhenTrue"; + OpCode[OpCode["BreakWhenFalse"] = 5] = "BreakWhenFalse"; + OpCode[OpCode["Yield"] = 6] = "Yield"; + OpCode[OpCode["YieldStar"] = 7] = "YieldStar"; + OpCode[OpCode["Return"] = 8] = "Return"; + OpCode[OpCode["Throw"] = 9] = "Throw"; + OpCode[OpCode["Endfinally"] = 10] = "Endfinally"; + })(OpCode || (OpCode = {})); + var BlockAction; + (function (BlockAction) { + BlockAction[BlockAction["Open"] = 0] = "Open"; + BlockAction[BlockAction["Close"] = 1] = "Close"; + })(BlockAction || (BlockAction = {})); + var CodeBlockKind; + (function (CodeBlockKind) { + CodeBlockKind[CodeBlockKind["Exception"] = 0] = "Exception"; + CodeBlockKind[CodeBlockKind["With"] = 1] = "With"; + CodeBlockKind[CodeBlockKind["Switch"] = 2] = "Switch"; + CodeBlockKind[CodeBlockKind["Loop"] = 3] = "Loop"; + CodeBlockKind[CodeBlockKind["Labeled"] = 4] = "Labeled"; + })(CodeBlockKind || (CodeBlockKind = {})); + var ExceptionBlockState; + (function (ExceptionBlockState) { + ExceptionBlockState[ExceptionBlockState["Try"] = 0] = "Try"; + ExceptionBlockState[ExceptionBlockState["Catch"] = 1] = "Catch"; + ExceptionBlockState[ExceptionBlockState["Finally"] = 2] = "Finally"; + ExceptionBlockState[ExceptionBlockState["Done"] = 3] = "Done"; + })(ExceptionBlockState || (ExceptionBlockState = {})); + var Instruction; + (function (Instruction) { + Instruction[Instruction["Next"] = 0] = "Next"; + Instruction[Instruction["Throw"] = 1] = "Throw"; + Instruction[Instruction["Return"] = 2] = "Return"; + Instruction[Instruction["Break"] = 3] = "Break"; + Instruction[Instruction["Yield"] = 4] = "Yield"; + Instruction[Instruction["YieldStar"] = 5] = "YieldStar"; + Instruction[Instruction["Catch"] = 6] = "Catch"; + Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; + })(Instruction || (Instruction = {})); + function getInstructionName(instruction) { + switch (instruction) { + case 2: return "return"; + case 3: return "break"; + case 4: return "yield"; + case 5: return "yield*"; + case 7: return "endfinally"; + } + } function transformGenerators(context) { var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); @@ -43438,13 +45733,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 210: - return visitDoStatement(node); case 211: + return visitDoStatement(node); + case 212: return visitWhileStatement(node); - case 219: - return visitSwitchStatement(node); case 220: + return visitSwitchStatement(node); + case 221: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -43452,24 +45747,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 226: + case 227: return visitFunctionDeclaration(node); - case 184: + case 185: return visitFunctionExpression(node); - case 151: case 152: + case 153: return visitAccessorDeclaration(node); - case 206: + case 207: return visitVariableStatement(node); - case 212: - return visitForStatement(node); case 213: + return visitForStatement(node); + case 214: return visitForInStatement(node); - case 216: - return visitBreakStatement(node); - case 215: - return visitContinueStatement(node); case 217: + return visitBreakStatement(node); + case 216: + return visitContinueStatement(node); + case 218: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -43485,21 +45780,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 192: - return visitBinaryExpression(node); case 193: + return visitBinaryExpression(node); + case 194: return visitConditionalExpression(node); - case 195: + case 196: return visitYieldExpression(node); - case 175: - return visitArrayLiteralExpression(node); case 176: + return visitArrayLiteralExpression(node); + case 177: return visitObjectLiteralExpression(node); - case 178: - return visitElementAccessExpression(node); case 179: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 180: + return visitCallExpression(node); + case 181: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -43507,9 +45802,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 226: + case 227: return visitFunctionDeclaration(node); - case 184: + case 185: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -43518,7 +45813,7 @@ var ts; } function visitFunctionDeclaration(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { - node = ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -43539,7 +45834,7 @@ var ts; } function visitFunctionExpression(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { - node = ts.setOriginalNode(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -43609,7 +45904,7 @@ var ts; operationArguments = savedOperationArguments; operationLocations = savedOperationLocations; state = savedState; - return ts.createBlock(statements, body, body.multiLine); + return ts.setTextRange(ts.createBlock(statements, body.multiLine), body); } function visitVariableStatement(node) { if (node.transformFlags & 16777216) { @@ -43666,10 +45961,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 177: + case 178: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 178: + case 179: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -43678,7 +45973,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 57, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.setTextRange(ts.createAssignment(target, ts.setTextRange(ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -43777,13 +46072,13 @@ var ts; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, location, multiLine); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { emitAssignment(temp, hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, undefined, multiLine)); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); hasAssignedTemp = true; leadingElement = undefined; expressions = []; @@ -43797,7 +46092,7 @@ var ts; var multiLine = node.multiLine; var numInitialProperties = countInitialNodesWithoutYield(properties); var temp = declareLocal(); - emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, multiLine)); + emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine)); var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties); expressions.push(multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); return ts.inlineExpressions(expressions); @@ -43836,7 +46131,7 @@ var ts; function visitNewExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, ts.createVoidZero())), undefined, [], node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, ts.createVoidZero())), undefined, []), node), node); } return ts.visitEachChild(node, visitor, context); } @@ -43865,35 +46160,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 205: + case 206: return transformAndEmitBlock(node); - case 208: - return transformAndEmitExpressionStatement(node); case 209: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 210: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 211: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 212: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 213: + return transformAndEmitForStatement(node); + case 214: return transformAndEmitForInStatement(node); - case 215: - return transformAndEmitContinueStatement(node); case 216: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 217: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 218: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 219: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 220: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 221: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 222: + return transformAndEmitThrowStatement(node); + case 223: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -43913,9 +46208,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - var name_38 = ts.getSynthesizedClone(variable.name); - ts.setCommentRange(name_38, variable.name); - hoistVariableDeclaration(name_38); + var name = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name, variable.name); + hoistVariableDeclaration(name); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -44024,7 +46319,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression), initializer)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -44034,7 +46329,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression), node.incrementor)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -44179,7 +46474,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 255 && defaultClauseIndex === -1) { + if (clause.kind === 257 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -44189,7 +46484,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 254) { + if (clause.kind === 256) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -44291,9 +46586,9 @@ var ts; } return -1; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } return node; @@ -44305,14 +46600,14 @@ var ts; return node; } function substituteExpressionIdentifier(node) { - if (renamedCatchVariables && ts.hasProperty(renamedCatchVariables, node.text)) { + if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { var original = ts.getOriginalNode(node); if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_39 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_39) { - var clone_7 = ts.getMutableClone(name_39); + var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; + if (name) { + var clone_7 = ts.getMutableClone(name); ts.setSourceMapRange(clone_7, node); ts.setCommentRange(clone_7, node); return clone_7; @@ -44420,10 +46715,10 @@ var ts; var name = declareLocal(text); if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = ts.createMap(); + renamedCatchVariableDeclarations = []; context.enableSubstitution(70); } - renamedCatchVariables[text] = true; + renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; var exception = peekBlock(); ts.Debug.assert(exception.state < 1); @@ -44624,23 +46919,23 @@ var ts; } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); - literal.trailingComment = instructionNames[instruction]; + literal.trailingComment = getInstructionName(instruction); return literal; } function createInlineBreak(label, location) { ts.Debug.assert(label > 0, "Invalid label: " + label); - return ts.createReturn(ts.createArrayLiteral([ + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), location); + ])), location); } function createInlineReturn(expression, location) { - return ts.createReturn(ts.createArrayLiteral(expression + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), location); + : [createInstruction(2)])), location); } function createGeneratorResume(location) { - return ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, [], location); + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, []), location); } function emitNop() { emitWorker(0); @@ -44706,7 +47001,7 @@ var ts; currentExceptionBlock = undefined; withBlockStack = undefined; var buildResult = buildStatements(); - return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 262144)); + return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, buildResult.length > 0)), 262144)); } function buildStatements() { if (operations) { @@ -44915,51 +47210,51 @@ var ts; } } function writeAssign(left, right, operationLocation) { - writeStatement(ts.createStatement(ts.createAssignment(left, right), operationLocation)); + writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); } function writeThrow(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createThrow(expression, operationLocation)); + writeStatement(ts.setTextRange(ts.createThrow(expression), operationLocation)); } function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), operationLocation), 384)); + : [createInstruction(2)])), operationLocation), 384)); } function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation), 384)); + ])), operationLocation), 384)); } function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation), 384)), 1)); + ])), operationLocation), 384)), 1)); } function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation), 384)), 1)); + ])), operationLocation), 384)), 1)); } function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4), expression] - : [createInstruction(4)]), operationLocation), 384)); + : [createInstruction(4)])), operationLocation), 384)); } function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(5), expression - ]), operationLocation), 384)); + ])), operationLocation), 384)); } function writeEndfinally() { lastOperationWasAbrupt = true; @@ -44979,7 +47274,6 @@ var ts; priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; - var _a; })(ts || (ts = {})); var ts; (function (ts) { @@ -44987,38 +47281,38 @@ var ts; var compilerOptions = context.getCompilerOptions(); var previousOnEmitNode; var noSubstitution; - if (compilerOptions.jsx === 1) { + if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(249); context.enableEmitNotification(250); - context.enableEmitNotification(248); + context.enableEmitNotification(251); + context.enableEmitNotification(249); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(177); - context.enableSubstitution(258); + context.enableSubstitution(178); + context.enableSubstitution(260); return transformSourceFile; function transformSourceFile(node) { return node; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 249: case 250: - case 248: + case 251: + case 249: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } - function onSubstituteNode(emitContext, node) { + function onSubstituteNode(hint, node) { if (node.id && noSubstitution && noSubstitution[node.id]) { - return previousOnSubstituteNode(emitContext, node); + return previousOnSubstituteNode(hint, node); } - node = previousOnSubstituteNode(emitContext, node); + node = previousOnSubstituteNode(hint, node); if (ts.isPropertyAccessExpression(node)) { return substitutePropertyAccessExpression(node); } @@ -45030,7 +47324,7 @@ var ts; function substitutePropertyAccessExpression(node) { var literalName = trySubstituteReservedName(node.name); if (literalName) { - return ts.createElementAccess(node.expression, literalName, node); + return ts.setTextRange(ts.createElementAccess(node.expression, literalName), node); } return node; } @@ -45044,7 +47338,7 @@ var ts; function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); if (token >= 71 && token <= 106) { - return ts.createLiteral(name, name); + return ts.setTextRange(ts.createLiteral(name), name); } return undefined; } @@ -45054,12 +47348,13 @@ var ts; var ts; (function (ts) { function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); + function getTransformModuleDelegate(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.AMD: return transformAMDModule; + case ts.ModuleKind.UMD: return transformUMDModule; + default: return transformCommonJSModule; + } + } var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); @@ -45071,13 +47366,13 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70); - context.enableSubstitution(192); - context.enableSubstitution(190); + context.enableSubstitution(193); context.enableSubstitution(191); - context.enableSubstitution(259); - context.enableEmitNotification(262); - var moduleInfoMap = ts.createMap(); - var deferredExports = ts.createMap(); + context.enableSubstitution(192); + context.enableSubstitution(261); + context.enableEmitNotification(264); + var moduleInfoMap = []; + var deferredExports = []; var currentSourceFile; var currentModuleInfo; var noSubstitution; @@ -45089,8 +47384,9 @@ var ts; return node; } currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); - var transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; + currentModuleInfo = ts.collectExternalModuleInfo(node, resolver, compilerOptions); + moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo; + var transformModule = getTransformModuleDelegate(moduleKind); var updated = transformModule(node); currentSourceFile = undefined; currentModuleInfo = undefined; @@ -45100,11 +47396,14 @@ var ts; startLexicalEnvironment(); var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, false); - var updated = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues) { ts.addEmitHelper(updated, exportStarHelper); } @@ -45114,7 +47413,7 @@ var ts; var define = ts.createIdentifier("define"); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - return ts.updateSourceFileNode(node, ts.createNodeArray([ + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), @@ -45125,11 +47424,11 @@ var ts; ts.createParameter(undefined, undefined, undefined, "exports") ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) ]))) - ], node.statements)); + ]), node.statements)); } function transformUMDModule(node) { var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.createBlock([ + var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(ts.createBlock([ ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ ts.createVariableStatement(undefined, [ ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [ @@ -45147,15 +47446,15 @@ var ts; ts.createIdentifier("factory") ])) ]))) - ], undefined, true)); - return ts.updateSourceFileNode(node, ts.createNodeArray([ + ], true), undefined)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createStatement(ts.createCall(umdHeader, undefined, [ ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ ts.createParameter(undefined, undefined, undefined, "require"), ts.createParameter(undefined, undefined, undefined, "exports") ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) ])) - ], node.statements)); + ]), node.statements)); } function collectAsynchronousDependencies(node, includeNonAmdDependencies) { var aliasedModuleNames = []; @@ -45190,11 +47489,14 @@ var ts; startLexicalEnvironment(); var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, true); - var body = ts.createBlock(statements, undefined, true); + var body = ts.createBlock(statements, true); if (currentModuleInfo.hasExportStarsToExportValues) { ts.addEmitHelper(body, exportStarHelper); } @@ -45203,12 +47505,14 @@ var ts; function addExportEqualsIfNeeded(statements, emitAsReturn) { if (currentModuleInfo.exportEquals) { if (emitAsReturn) { - var statement = ts.createReturn(currentModuleInfo.exportEquals.expression, currentModuleInfo.exportEquals); + var statement = ts.createReturn(currentModuleInfo.exportEquals.expression); + ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 384 | 1536); statements.push(statement); } else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression), currentModuleInfo.exportEquals); + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression)); + ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 1536); statements.push(statement); } @@ -45216,23 +47520,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 236: + case 237: return visitImportDeclaration(node); - case 235: + case 236: return visitImportEqualsDeclaration(node); - case 242: + case 243: return visitExportDeclaration(node); - case 241: + case 242: return visitExportAssignment(node); - case 206: + case 207: return visitVariableStatement(node); - case 226: - return visitFunctionDeclaration(node); case 227: + return visitFunctionDeclaration(node); + case 228: return visitClassDeclaration(node); - case 296: + case 299: return visitMergeDeclarationMarker(node); - case 297: + case 300: return visitEndOfDeclarationMarker(node); default: return node; @@ -45243,7 +47547,7 @@ var ts; var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { - return ts.createStatement(createRequireCall(node), node); + return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); } else { var variables = []; @@ -45256,13 +47560,13 @@ var ts; variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node))); } } - statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, undefined, languageVersion >= 2 ? 2 : 0), node)); + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, languageVersion >= 2 ? 2 : 0)), node)); } } else if (namespaceDeclaration && ts.isDefaultImport(node)) { statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node), node) - ], undefined, languageVersion >= 2 ? 2 : 0))); + ts.setTextRange(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node)), node) + ], languageVersion >= 2 ? 2 : 0))); } if (hasAssociatedEndOfDeclarationMarker(node)) { var id = ts.getOriginalNodeId(node); @@ -45286,17 +47590,17 @@ var ts; var statements; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(node.name, createRequireCall(node)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(node.name, createRequireCall(node))), node)); } else { - statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node)) - ], undefined, languageVersion >= 2 ? 2 : 0), node)); + ], languageVersion >= 2 ? 2 : 0)), node)); } } else { if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); } } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -45316,23 +47620,23 @@ var ts; if (node.exportClause) { var statements = []; if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node)) - ]), node)); + ])), node)); } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue), specifier)); + statements.push(ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); } return ts.singleOrMany(statements); } else { - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ + return ts.setTextRange(ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName - ]), node); + ])), node); } } function visitExportAssignment(node) { @@ -45353,7 +47657,7 @@ var ts; function visitFunctionDeclaration(node) { var statements; if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, node.parameters, undefined, node.body, node), node)); + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, node.parameters, undefined, node.body), node), node)); } else { statements = ts.append(statements, node); @@ -45370,7 +47674,7 @@ var ts; function visitClassDeclaration(node) { var statements; if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, node.heritageClauses, node.members, node), node)); + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, node.heritageClauses, node.members), node), node)); } else { statements = ts.append(statements, node); @@ -45406,7 +47710,7 @@ var ts; statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); } if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); } } else { @@ -45426,11 +47730,11 @@ var ts; return ts.flattenDestructuringAssignment(node, undefined, context, 0, false, createExportExpression); } else { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name, node.name), node.initializer); + return ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name), node.name), node.initializer); } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -45462,10 +47766,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 238: + case 239: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 239: + case 240: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -45523,7 +47827,7 @@ var ts; } function appendExportsOfDeclaration(statements, decl) { var name = ts.getDeclarationName(decl); - var exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; + var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { var exportSpecifier = exportSpecifiers_1[_i]; @@ -45533,28 +47837,28 @@ var ts; return statements; } function appendExportStatement(statements, exportName, expression, location, allowComments) { - if (exportName.text === "default") { - var sourceFile = ts.getOriginalNode(currentSourceFile, ts.isSourceFile); - if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 0) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements = ts.append(statements, ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); return statements; } + function createUnderscoreUnderscoreESModule() { + var statement; + if (languageVersion === 0) { + statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true))); + } + else { + statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ])); + } + ts.setEmitFlags(statement, 524288); + return statement; + } function createExportStatement(name, value, location, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value), location); + var statement = ts.setTextRange(ts.createStatement(createExportExpression(name, value)), location); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536); @@ -45562,7 +47866,7 @@ var ts; return statement; } function createExportExpression(name, value, location) { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value, location); + return ts.setTextRange(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location); } function modifierVisitor(node) { switch (node.kind) { @@ -45572,26 +47876,26 @@ var ts; } return node; } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 262) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; - noSubstitution = ts.createMap(); - previousOnEmitNode(emitContext, node, emitCallback); + noSubstitution = []; + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; currentModuleInfo = undefined; noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); if (node.id && noSubstitution[node.id]) { return node; } - if (emitContext === 1) { + if (hint === 1) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -45605,9 +47909,9 @@ var ts; if (exportedOrImportedName !== name) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, node); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); } - return ts.createPropertyAssignment(name, exportedOrImportedName, node); + return ts.setTextRange(ts.createPropertyAssignment(name, exportedOrImportedName), node); } return node; } @@ -45615,10 +47919,10 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 192: + case 193: return substituteBinaryExpression(node); + case 192: case 191: - case 190: return substituteUnaryExpression(node); } return node; @@ -45633,17 +47937,17 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 262) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); + if (exportContainer && exportContainer.kind === 264) { + return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_40 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); + var name = importDeclaration.propertyName || importDeclaration.name; + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name)), node); } } } @@ -45676,8 +47980,8 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 191 - ? ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1), node) + var expression = node.kind === 192 + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1)), node) : node; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; @@ -45699,7 +48003,6 @@ var ts; } } } - var _a; } ts.transformModule = transformModule; var exportStarHelper = { @@ -45720,14 +48023,14 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70); - context.enableSubstitution(192); - context.enableSubstitution(190); + context.enableSubstitution(193); context.enableSubstitution(191); - context.enableEmitNotification(262); - var moduleInfoMap = ts.createMap(); - var deferredExports = ts.createMap(); - var exportFunctionsMap = ts.createMap(); - var noSubstitutionMap = ts.createMap(); + context.enableSubstitution(192); + context.enableEmitNotification(264); + var moduleInfoMap = []; + var deferredExports = []; + var exportFunctionsMap = []; + var noSubstitutionMap = []; var currentSourceFile; var moduleInfo; var exportFunction; @@ -45746,7 +48049,8 @@ var ts; currentSourceFile = node; enclosingBlockScopedContainer = node; moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); - exportFunction = exportFunctionsMap[id] = ts.createUniqueName("exports"); + exportFunction = ts.createUniqueName("exports"); + exportFunctionsMap[id] = exportFunction; contextObject = ts.createUniqueName("context"); var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); @@ -45756,11 +48060,11 @@ var ts; ], undefined, moduleBodyBlock); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); - var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.createNodeArray([ + var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ], node.statements)), 1024); + ]), node.statements)), 1024); if (!(compilerOptions.outFile || compilerOptions.out)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -45783,12 +48087,12 @@ var ts; var externalImport = externalImports[i]; var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; + var groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { dependencyGroups[groupIndex].externalImports.push(externalImport); } else { - groupIndices[text] = dependencyGroups.length; + groupIndices.set(text, dependencyGroups.length); dependencyGroups.push({ name: externalModuleName, externalImports: [externalImport] @@ -45809,21 +48113,23 @@ var ts; ts.addRange(statements, hoistedStatements); ts.addRange(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + var moduleObject = ts.createObjectLiteral([ ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) - ]), true))); - return ts.createBlock(statements, undefined, true); + ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, true))) + ]); + moduleObject.multiLine = true; + statements.push(ts.createReturn(moduleObject)); + return ts.createBlock(statements, true); } function addExportStarIfNeeded(statements) { if (!moduleInfo.hasExportStarsToExportValues) { return; } - if (!moduleInfo.exportedNames && ts.isEmpty(moduleInfo.exportSpecifiers)) { + if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) { var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 242 && externalImport.exportClause) { + if (externalImport.kind === 243 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -45841,12 +48147,12 @@ var ts; if (exportedLocalName.text === "default") { continue; } - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createTrue())); } } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 242) { + if (externalImport.kind !== 243) { continue; } var exportDecl = externalImport; @@ -45855,12 +48161,12 @@ var ts; } for (var _f = 0, _g = exportDecl.exportClause.elements; _f < _g.length; _f++) { var element = _g[_f]; - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createTrue())); } } var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, undefined, true)) + ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, true)) ]))); var exportStarFunction = createExportStarFunction(exportedNamesStorageRef); statements.push(exportStarFunction); @@ -45885,7 +48191,7 @@ var ts; ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1) ])), ts.createStatement(ts.createCall(exportFunction, undefined, [exports])) - ], undefined, true)); + ], true)); } function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; @@ -45898,15 +48204,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 236: + case 237: if (!entry.importClause) { break; } - case 235: + case 236: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 242: + case 243: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -45914,7 +48220,7 @@ var ts; var e = _d[_c]; properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); } - statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, undefined, true)]))); + statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, true)]))); } else { statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); @@ -45922,19 +48228,19 @@ var ts; break; } } - setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, undefined, true))); + setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, true))); } - return ts.createArrayLiteral(setters, undefined, true); + return ts.createArrayLiteral(setters, true); } function sourceElementVisitor(node) { switch (node.kind) { - case 236: + case 237: return visitImportDeclaration(node); - case 235: + case 236: return visitImportEqualsDeclaration(node); - case 242: + case 243: return undefined; - case 241: + case 242: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -46001,7 +48307,7 @@ var ts; var statements; var name = ts.getLocalName(node); hoistVariableDeclaration(name); - statements = ts.append(statements, ts.createStatement(ts.createAssignment(name, ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement), node)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); @@ -46029,7 +48335,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { var id = ts.getOriginalNodeId(node); @@ -46055,7 +48361,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 1048576) === 0 - && (enclosingBlockScopedContainer.kind === 262 + && (enclosingBlockScopedContainer.kind === 264 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -46073,11 +48379,11 @@ var ts; function createVariableAssignment(name, value, location, isExportedDeclaration) { hoistVariableDeclaration(ts.getSynthesizedClone(name)); return isExportedDeclaration - ? createExportExpression(name, preventSubstitution(ts.createAssignment(name, value, location))) - : preventSubstitution(ts.createAssignment(name, value, location)); + ? createExportExpression(name, preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location))) + : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -46110,10 +48416,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 238: + case 239: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 239: + case 240: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -46183,7 +48489,7 @@ var ts; return statements; } var name = ts.getDeclarationName(decl); - var exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + var exportSpecifiers = moduleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { var exportSpecifier = exportSpecifiers_2[_i]; @@ -46212,43 +48518,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 206: + case 207: return visitVariableStatement(node); - case 226: - return visitFunctionDeclaration(node); case 227: + return visitFunctionDeclaration(node); + case 228: return visitClassDeclaration(node); - case 212: - return visitForStatement(node); case 213: - return visitForInStatement(node); + return visitForStatement(node); case 214: + return visitForInStatement(node); + case 215: return visitForOfStatement(node); - case 210: - return visitDoStatement(node); case 211: + return visitDoStatement(node); + case 212: return visitWhileStatement(node); - case 220: + case 221: return visitLabeledStatement(node); - case 218: - return visitWithStatement(node); case 219: + return visitWithStatement(node); + case 220: return visitSwitchStatement(node); - case 233: + case 234: return visitCaseBlock(node); - case 254: + case 256: return visitCaseClause(node); - case 255: - return visitDefaultClause(node); - case 222: - return visitTryStatement(node); case 257: + return visitDefaultClause(node); + case 223: + return visitTryStatement(node); + case 259: return visitCatchClause(node); - case 205: + case 206: return visitBlock(node); - case 296: + case 299: return visitMergeDeclarationMarker(node); - case 297: + case 300: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -46339,7 +48645,7 @@ var ts; } function destructuringVisitor(node) { if (node.transformFlags & 1024 - && node.kind === 192) { + && node.kind === 193) { return visitDestructuringAssignment(node); } else if (node.transformFlags & 2048) { @@ -46376,7 +48682,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 262; + return container !== undefined && container.kind === 264; } else { return false; @@ -46390,8 +48696,8 @@ var ts; } return node; } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 262) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -46400,22 +48706,22 @@ var ts; if (noSubstitution) { delete noSubstitutionMap[id]; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); if (isSubstitutionPrevented(node)) { return node; } - if (emitContext === 1) { + if (hint === 1) { return substituteExpression(node); } return node; @@ -46424,10 +48730,10 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 192: + case 193: return substituteBinaryExpression(node); - case 190: case 191: + case 192: return substituteUnaryExpression(node); } return node; @@ -46444,10 +48750,10 @@ var ts; var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node); } else if (ts.isImportSpecifier(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name), node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name)), node); } } } @@ -46479,14 +48785,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 191 - ? ts.createPrefix(node.operator, node.operand, node) + var expression = node.kind === 192 + ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { var exportName = exportedNames_4[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 191) { + if (node.kind === 192) { expression = node.operator === 42 ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -46503,7 +48809,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 262) { + if (exportContainer && exportContainer.kind === 264) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -46513,7 +48819,7 @@ var ts; } function preventSubstitution(node) { if (noSubstitution === undefined) - noSubstitution = ts.createMap(); + noSubstitution = []; noSubstitution[ts.getNodeId(node)] = true; return node; } @@ -46531,7 +48837,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(262); + context.enableEmitNotification(264); context.enableSubstitution(70); var currentSourceFile; return transformSourceFile; @@ -46546,7 +48852,7 @@ var ts; var statementOffset = ts.addPrologueDirectives(statements, node.statements); ts.append(statements, ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } else { return ts.visitEachChild(node, visitor, context); @@ -46556,9 +48862,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 235: + case 236: return undefined; - case 241: + case 242: return visitExportAssignment(node); } return node; @@ -46566,19 +48872,19 @@ var ts; function visitExportAssignment(node) { return node.isExportEquals ? undefined : node; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { if (ts.isSourceFile(node)) { currentSourceFile = node; - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (ts.isIdentifier(node) && emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (ts.isIdentifier(node) && hint === 1) { return substituteExpressionIdentifier(node); } return node; @@ -46597,14 +48903,21 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, - _a[ts.ModuleKind.System] = ts.transformSystemModule, - _a[ts.ModuleKind.AMD] = ts.transformModule, - _a[ts.ModuleKind.CommonJS] = ts.transformModule, - _a[ts.ModuleKind.UMD] = ts.transformModule, - _a[ts.ModuleKind.None] = ts.transformModule, - _a)); + function getModuleTransformer(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.ES2015: + return ts.transformES2015Module; + case ts.ModuleKind.System: + return ts.transformSystemModule; + default: + return ts.transformModule; + } + } + var SyntaxKindFeatureFlags; + (function (SyntaxKindFeatureFlags) { + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; + })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); function getTransformers(compilerOptions) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -46627,7 +48940,7 @@ var ts; transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); + transformers.push(getModuleTransformer(moduleKind)); if (languageVersion < 1) { transformers.push(ts.transformES5); } @@ -46635,7 +48948,7 @@ var ts; } ts.getTransformers = getTransformers; function transformFiles(resolver, host, sourceFiles, transformers) { - var enabledSyntaxKindFeatures = new Array(298); + var enabledSyntaxKindFeatures = new Array(301); var lexicalEnvironmentDisabled = false; var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; @@ -46656,16 +48969,19 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, - onSubstituteNode: function (_emitContext, node) { return node; }, + onSubstituteNode: function (_, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, + onEmitNode: function (hint, node, callback) { return callback(hint, node); }, enableEmitNotification: enableEmitNotification, isEmitNotificationEnabled: isEmitNotificationEnabled }; + ts.performance.mark("beforeTransform"); var transformation = ts.chain.apply(void 0, transformers)(context); var transformed = ts.map(sourceFiles, transformSourceFile); lexicalEnvironmentDisabled = true; + ts.performance.mark("afterTransform"); + ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { transformed: transformed, emitNodeWithSubstitution: emitNodeWithSubstitution, @@ -46684,16 +49000,12 @@ var ts; return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0 && (ts.getEmitFlags(node) & 4) === 0; } - function emitNodeWithSubstitution(emitContext, node, emitCallback) { + function emitNodeWithSubstitution(hint, node, emitCallback) { if (node) { if (isSubstitutionEnabled(node)) { - var substitute = context.onSubstituteNode(emitContext, node); - if (substitute && substitute !== node) { - emitCallback(emitContext, substitute); - return; - } + node = context.onSubstituteNode(hint, node) || node; } - emitCallback(emitContext, node); + emitCallback(hint, node); } } function enableEmitNotification(kind) { @@ -46703,13 +49015,13 @@ var ts; return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0 || (ts.getEmitFlags(node) & 2) !== 0; } - function emitNodeWithNotification(emitContext, node, emitCallback) { + function emitNodeWithNotification(hint, node, emitCallback) { if (node) { if (isEmitNotificationEnabled(node)) { - context.onEmitNode(emitContext, node, emitCallback); + context.onEmitNode(hint, node, emitCallback); } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } } @@ -46791,21 +49103,22 @@ var ts; } } ts.transformFiles = transformFiles; - var _a; })(ts || (ts = {})); var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, targetSourceFile) { var declarationDiagnostics = ts.createDiagnosticCollection(); - ts.forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); + ts.forEachEmittedFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); - function getDeclarationDiagnosticsFromFile(_a, sources, isBundledEmit) { + function getDeclarationDiagnosticsFromFile(_a, sourceFileOrBundle) { var declarationFilePath = _a.declarationFilePath; - emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit, false); + emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sourceFileOrBundle, false); } } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles) { + function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles) { + var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var isBundledEmit = sourceFileOrBundle.kind === 265; var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -46867,7 +49180,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 236); + ts.Debug.assert(aliasEmitInfo.node.kind === 237); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -46890,9 +49203,9 @@ var ts; } }); if (usedTypeDirectiveReferences) { - for (var directive in usedTypeDirectiveReferences) { + ts.forEachKey(usedTypeDirectiveReferences, function (directive) { referencesOutput += "/// " + newLine; - } + }); } return { reportedDeclarationError: reportedDeclarationError, @@ -46917,6 +49230,7 @@ var ts; var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; writer.reportInaccessibleThisError = reportInaccessibleThisError; + writer.reportIllegalExtends = reportIllegalExtends; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -46939,10 +49253,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 224) { + if (declaration.kind === 225) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 239 || declaration.kind === 240 || declaration.kind === 237) { + else if (declaration.kind === 240 || declaration.kind === 241 || declaration.kind === 238) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -46953,7 +49267,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 236) { + if (moduleElementEmitInfo.node.kind === 237) { moduleElementEmitInfo.isVisible = true; } else { @@ -46961,12 +49275,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 231) { + if (nodeToCheck.kind === 232) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 231) { + if (nodeToCheck.kind === 232) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -46985,8 +49299,8 @@ var ts; } for (var _i = 0, typeReferenceDirectives_1 = typeReferenceDirectives; _i < typeReferenceDirectives_1.length; _i++) { var directive = typeReferenceDirectives_1[_i]; - if (!(directive in usedTypeDirectiveReferences)) { - usedTypeDirectiveReferences[directive] = directive; + if (!usedTypeDirectiveReferences.has(directive)) { + usedTypeDirectiveReferences.set(directive, directive); } } } @@ -47013,6 +49327,12 @@ var ts; handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); } + function reportIllegalExtends() { + if (errorNameNode) { + reportedDeclarationError = true; + emitterDiagnostics.add(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced, ts.declarationNameToString(errorNameNode))); + } + } function reportInaccessibleThisError() { if (errorNameNode) { reportedDeclarationError = true; @@ -47022,12 +49342,16 @@ var ts; function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); - if (type) { + var shouldUseResolverType = declaration.kind === 145 && + resolver.isRequiredInitializedParameter(declaration); + if (type && !shouldUseResolverType) { emitType(type); } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 | 1024, writer); + var format = 2 | 1024 | + (shouldUseResolverType ? 4096 : 0); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer); errorNameNode = undefined; } } @@ -47079,49 +49403,50 @@ var ts; function emitType(type) { switch (type.kind) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 133: + case 136: case 104: - case 137: + case 138: case 94: case 129: - case 167: - case 171: - return writeTextOfNode(currentText, type); - case 199: - return emitExpressionWithTypeArguments(type); - case 157: - return emitTypeReference(type); - case 160: - return emitTypeQuery(type); - case 162: - return emitArrayType(type); - case 163: - return emitTupleType(type); - case 164: - return emitUnionType(type); - case 165: - return emitIntersectionType(type); - case 166: - return emitParenType(type); case 168: - return emitTypeOperator(type); - case 169: - return emitIndexedAccessType(type); - case 170: - return emitMappedType(type); + case 172: + return writeTextOfNode(currentText, type); + case 200: + return emitExpressionWithTypeArguments(type); case 158: - case 159: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 161: + return emitTypeQuery(type); + case 163: + return emitArrayType(type); + case 164: + return emitTupleType(type); + case 165: + return emitUnionType(type); + case 166: + return emitIntersectionType(type); + case 167: + return emitParenType(type); + case 169: + return emitTypeOperator(type); + case 170: + return emitIndexedAccessType(type); + case 171: + return emitMappedType(type); + case 159: + case 160: + return emitSignatureDeclarationWithJsDocComments(type); + case 162: return emitTypeLiteral(type); case 70: return emitEntityName(type); - case 141: + case 142: return emitEntityName(type); - case 156: + case 157: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -47129,22 +49454,22 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 141 ? entityName.left : entityName.expression; - var right = entityName.kind === 141 ? entityName.right : entityName.name; + var left = entityName.kind === 142 ? entityName.left : entityName.expression; + var right = entityName.kind === 142 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 235 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 236 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 177); + ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 178); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -47248,15 +49573,15 @@ var ts; } function getExportDefaultTempVariableName() { var baseName = "_default"; - if (!(baseName in currentIdentifiers)) { + if (!currentIdentifiers.has(baseName)) { return baseName; } var count = 0; while (true) { count++; - var name_41 = baseName + "_" + count; - if (!(name_41 in currentIdentifiers)) { - return name_41; + var name = baseName + "_" + count; + if (!currentIdentifiers.has(name)) { + return name; } } } @@ -47300,10 +49625,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 235 || - (node.parent.kind === 262 && isCurrentFileExternalModule)) { + else if (node.kind === 236 || + (node.parent.kind === 264 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 262) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 264) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -47312,7 +49637,7 @@ var ts; }); } else { - if (node.kind === 236) { + if (node.kind === 237) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -47330,30 +49655,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 226: - return writeFunctionDeclaration(node); - case 206: - return writeVariableStatement(node); - case 228: - return writeInterfaceDeclaration(node); case 227: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 207: + return writeVariableStatement(node); case 229: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 228: + return writeClassDeclaration(node); case 230: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 231: + return writeEnumDeclaration(node); + case 232: return writeModuleDeclaration(node); - case 235: - return writeImportEqualsDeclaration(node); case 236: + return writeImportEqualsDeclaration(node); + case 237: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 262) { + if (node.parent.kind === 264) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -47361,7 +49686,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 228 && !noDeclare) { + else if (node.kind !== 229 && !noDeclare) { write("declare "); } } @@ -47411,7 +49736,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 238) { + if (namedBindings.kind === 239) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -47434,7 +49759,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 238) { + if (node.importClause.namedBindings.kind === 239) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -47451,13 +49776,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 231; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 232; var moduleSpecifier; - if (parent.kind === 235) { + if (parent.kind === 236) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 231) { + else if (parent.kind === 232) { moduleSpecifier = parent.name; } else { @@ -47525,7 +49850,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 232) { + while (node.body && node.body.kind !== 233) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -47595,7 +49920,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 149 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 150 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -47605,52 +49930,69 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 158 || - node.parent.kind === 159 || - (node.parent.parent && node.parent.parent.kind === 161)) { - ts.Debug.assert(node.parent.kind === 149 || - node.parent.kind === 148 || - node.parent.kind === 158 || + if (node.parent.kind === 159 || + node.parent.kind === 160 || + (node.parent.parent && node.parent.parent.kind === 162)) { + ts.Debug.assert(node.parent.kind === 150 || + node.parent.kind === 149 || node.parent.kind === 159 || - node.parent.kind === 153 || - node.parent.kind === 154); + node.parent.kind === 160 || + node.parent.kind === 154 || + node.parent.kind === 155); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } + if (node.default && !isPrivateMethodTypeParameter(node)) { + write(" = "); + if (node.parent.kind === 159 || + node.parent.kind === 160 || + (node.parent.parent && node.parent.parent.kind === 162)) { + ts.Debug.assert(node.parent.kind === 150 || + node.parent.kind === 149 || + node.parent.kind === 159 || + node.parent.kind === 160 || + node.parent.kind === 154 || + node.parent.kind === 155); + emitType(node.default); + } + else { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.default, getTypeParameterConstraintVisibilityError); + } + } function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 227: + case 228: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 228: + case 229: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 154: + case 155: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 153: + case 154: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 150: case 149: - case 148: if (ts.hasModifier(node.parent, 32)) { 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 === 227) { + else if (node.parent.parent.kind === 228) { 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 226: + case 227: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 229: + case 230: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -47669,7 +50011,7 @@ var ts; write(">"); } } - function emitHeritageClause(typeReferences, isImplementsList) { + function emitHeritageClause(className, typeReferences, isImplementsList) { if (typeReferences) { write(isImplementsList ? " implements " : " extends "); emitCommaList(typeReferences, emitTypeOfTypeReference); @@ -47683,17 +50025,19 @@ var ts; } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; + errorNameNode = className; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 | 1024, writer); + errorNameNode = undefined; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 227) { + if (node.parent.parent.kind === 228) { 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; + ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } else { - diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; + diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; } return { diagnosticMessage: diagnosticMessage, @@ -47725,9 +50069,10 @@ var ts; emitTypeParameters(node.typeParameters); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); + node.name; + emitHeritageClause(node.name, [baseTypeNode], false); } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), true); + emitHeritageClause(node.name, ts.getClassImplementsHeritageClauseElements(node), true); write(" {"); writeLine(); increaseIndent(); @@ -47748,7 +50093,7 @@ var ts; emitTypeParameters(node.typeParameters); var interfaceExtendsTypes = ts.filter(ts.getInterfaceBaseTypeNodes(node), function (base) { return ts.isEntityNameExpression(base.expression); }); if (interfaceExtendsTypes && interfaceExtendsTypes.length) { - emitHeritageClause(interfaceExtendsTypes, false); + emitHeritageClause(node.name, interfaceExtendsTypes, false); } write(" {"); writeLine(); @@ -47770,17 +50115,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 224 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 225 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 147 || node.kind === 146 || - (node.kind === 144 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 148 || node.kind === 147 || + (node.kind === 145 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 147 || node.kind === 146) && node.parent.kind === 161) { + if ((node.kind === 148 || node.kind === 147) && node.parent.kind === 162) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -47793,14 +50138,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 224) { + if (node.kind === 225) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 === 147 || node.kind === 146) { + else if (node.kind === 148 || node.kind === 147) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -47808,7 +50153,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 === 227) { + else if (node.parent.kind === 228) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47834,7 +50179,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 198) { + if (element.kind !== 199) { elements.push(element); } } @@ -47900,7 +50245,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 151 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 152 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -47913,7 +50258,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 151 + return accessor.kind === 152 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -47922,7 +50267,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 152) { + if (accessorWithTypeAnnotation.kind === 153) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -47968,17 +50313,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 226) { + if (node.kind === 227) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 149 || node.kind === 150) { + else if (node.kind === 150 || node.kind === 151) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 226) { + if (node.kind === 227) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 150) { + else if (node.kind === 151) { write("constructor"); } else { @@ -47998,15 +50343,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 155) { + if (node.kind === 156) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 154 || node.kind === 159) { + if (node.kind === 155 || node.kind === 160) { write("new "); } - else if (node.kind === 158) { + else if (node.kind === 159) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -48017,20 +50362,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 155) { + if (node.kind === 156) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 158 || node.kind === 159; - if (isFunctionTypeOrConstructorType || node.parent.kind === 161) { + var isFunctionTypeOrConstructorType = node.kind === 159 || node.kind === 160; + if (isFunctionTypeOrConstructorType || node.parent.kind === 162) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 150 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 151 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -48044,23 +50389,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 154: + case 155: diagnosticMessage = symbolAccessibilityResult.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 153: + case 154: diagnosticMessage = symbolAccessibilityResult.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 155: + case 156: diagnosticMessage = symbolAccessibilityResult.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 150: case 149: - case 148: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -48068,7 +50413,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 === 227) { + else if (node.parent.kind === 228) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -48081,7 +50426,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 226: + case 227: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -48113,9 +50458,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 158 || - node.parent.kind === 159 || - node.parent.parent.kind === 161) { + if (node.parent.kind === 159 || + node.parent.kind === 160 || + node.parent.parent.kind === 162) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -48131,26 +50476,26 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 150: + case 151: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 154: + case 155: return symbolAccessibilityResult.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 153: + case 154: return symbolAccessibilityResult.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 155: + case 156: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; + case 150: case 149: - case 148: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -48158,7 +50503,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 === 227) { + else if (node.parent.parent.kind === 228) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -48170,7 +50515,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 226: + case 227: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -48181,12 +50526,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 172) { + if (bindingPattern.kind === 173) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 173) { + else if (bindingPattern.kind === 174) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -48197,10 +50542,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 198) { + if (bindingElement.kind === 199) { write(" "); } - else if (bindingElement.kind === 174) { + else if (bindingElement.kind === 175) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -48222,39 +50567,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 226: - case 231: - case 235: - case 228: case 227: - case 229: - case 230: - return emitModuleElement(node, isModuleElementVisible(node)); - case 206: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 232: case 236: + case 229: + case 228: + case 230: + case 231: + return emitModuleElement(node, isModuleElementVisible(node)); + case 207: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 237: return emitModuleElement(node, !node.importClause); - case 242: + case 243: return emitExportDeclaration(node); + case 151: case 150: case 149: - case 148: return writeFunctionDeclaration(node); - case 154: - case 153: case 155: + case 154: + case 156: return emitSignatureDeclarationWithJsDocComments(node); - case 151: case 152: + case 153: return emitAccessorDeclaration(node); + case 148: case 147: - case 146: return emitPropertyDeclaration(node); - case 261: + case 263: return emitEnumMemberDeclaration(node); - case 241: + case 242: return emitExportAssignment(node); - case 262: + case 264: return emitSourceFile(node); } } @@ -48265,14 +50610,15 @@ var ts; declFileName = referencedFile.fileName; } else { - ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(declarationFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, sourceFileOrBundle) { + var isBundledEmit = sourceFileOrBundle.kind === 265; if (isBundledEmit && !addBundledFileReference) { return; } @@ -48282,10 +50628,11 @@ var ts; } } } - function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { - var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles); + function writeDeclarationFile(declarationFilePath, sourceFileOrBundle, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { + var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { + var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; var declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); ts.writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); @@ -48339,7 +50686,7 @@ var ts; getText: getText, getSourceMappingURL: getSourceMappingURL, }; - function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { + function initialize(filePath, sourceMapFilePath, sourceFileOrBundle) { if (disabled) { return; } @@ -48370,9 +50717,8 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (!isBundledEmit) { - ts.Debug.assert(sourceFiles.length === 1); - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFiles[0], host, sourceMapDir)); + if (sourceFileOrBundle.kind === 264) { + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); @@ -48463,28 +50809,28 @@ var ts; ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); } } - function emitNodeWithSourceMap(emitContext, node, emitCallback) { + function emitNodeWithSourceMap(hint, node, emitCallback) { if (disabled) { - return emitCallback(emitContext, node); + return emitCallback(hint, node); } if (node) { var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 294 + if (node.kind !== 297 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); } if (emitFlags & 64) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } - if (node.kind !== 294 + if (node.kind !== 297 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -48585,11 +50931,10 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function createCommentWriter(host, writer, sourceMap) { - var compilerOptions = host.getCompilerOptions(); - var extendedDiagnostics = compilerOptions.extendedDiagnostics; - var newLine = host.getNewLine(); - var emitPos = sourceMap.emitPos; + function createCommentWriter(printerOptions, emitPos) { + var extendedDiagnostics = printerOptions.extendedDiagnostics; + var newLine = ts.getNewLineCharacter(printerOptions); + var writer; var containerPos = -1; var containerEnd = -1; var declarationListContainerEnd = -1; @@ -48598,17 +50943,19 @@ var ts; var currentLineMap; var detachedCommentsInfo; var hasWrittenComment = false; - var disabled = compilerOptions.removeComments; + var disabled = printerOptions.removeComments; return { reset: reset, + setWriter: setWriter, setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, + emitLeadingCommentsOfPosition: emitLeadingCommentsOfPosition, }; - function emitNodeWithComments(emitContext, node, emitCallback) { + function emitNodeWithComments(hint, node, emitCallback) { if (disabled) { - emitCallback(emitContext, node); + emitCallback(hint, node); return; } if (node) { @@ -48617,18 +50964,18 @@ var ts; if ((pos < 0 && end < 0) || (pos === end)) { if (emitFlags & 2048) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } else { if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 294; + var isEmittedNode = node.kind !== 297; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { @@ -48642,7 +50989,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 225) { + if (node.kind === 226) { declarationListContainerEnd = end; } } @@ -48651,11 +50998,11 @@ var ts; } if (emitFlags & 2048) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } if (extendedDiagnostics) { ts.performance.mark("beginEmitNodeWithComment"); @@ -48726,9 +51073,11 @@ var ts; ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; } - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -48736,6 +51085,12 @@ var ts; writer.write(" "); } } + function emitLeadingCommentsOfPosition(pos) { + if (disabled || pos === -1) { + return; + } + emitLeadingComments(pos, true); + } function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } @@ -48743,9 +51098,11 @@ var ts; if (!writer.isAtStartOfLine()) { writer.write(" "); } - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -48763,9 +51120,11 @@ var ts; } } function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -48794,6 +51153,9 @@ var ts; currentLineMap = undefined; detachedCommentsInfo = undefined; } + function setWriter(output) { + writer = output; + } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; currentText = currentSourceFile.text; @@ -48825,9 +51187,11 @@ var ts; } } function writeComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); } function isTripleSlashComment(commentPos, commentEnd) { if (currentText.charCodeAt(commentPos + 1) === 47 && @@ -48845,44 +51209,39 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var id = function (s) { return s; }; - var nullTransformers = [function (_) { return id; }]; + var delimiters = createDelimiterMap(); + var brackets = createBracketsMap(); function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { - var delimiters = createDelimiterMap(); - var brackets = createBracketsMap(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = emitOnlyDtsFiles ? nullTransformers : ts.getTransformers(compilerOptions); + var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); - var write = writer.write, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var sourceMap = ts.createSourceMapWriter(host, writer); - var emitNodeWithSourceMap = sourceMap.emitNodeWithSourceMap, emitTokenWithSourceMap = sourceMap.emitTokenWithSourceMap; - var comments = ts.createCommentWriter(host, writer, sourceMap); - var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition; - var nodeIdToGeneratedName; - var autoGeneratedIdToGeneratedName; - var generatedNameSet; - var tempFlags; var currentSourceFile; - var currentText; - var currentFileIdentifiers; var bundledHelpers; var isOwnFileEmit; var emitSkipped = false; var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); - ts.performance.mark("beforeTransform"); - var _a = ts.transformFiles(resolver, host, sourceFiles, transformers), transformed = _a.transformed, emitNodeWithSubstitution = _a.emitNodeWithSubstitution, emitNodeWithNotification = _a.emitNodeWithNotification; - ts.performance.measure("transformTime", "beforeTransform"); + var transform = ts.transformFiles(resolver, host, sourceFiles, transformers); + var printer = createPrinter(compilerOptions, { + hasGlobalName: resolver.hasGlobalName, + onEmitNode: transform.emitNodeWithNotification, + onSubstituteNode: transform.emitNodeWithSubstitution, + onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, + onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, + onEmitSourceMapOfPosition: sourceMap.emitPos, + onEmitHelpers: emitHelpers, + onSetSourceFile: setSourceFile, + }); ts.performance.mark("beforePrint"); - ts.forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); - for (var _b = 0, sourceFiles_4 = sourceFiles; _b < sourceFiles_4.length; _b++) { - var sourceFile = sourceFiles_4[_b]; + for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { + var sourceFile = sourceFiles_2[_a]; ts.disposeEmitNodes(sourceFile); } return { @@ -48891,17 +51250,18 @@ var ts; emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList }; - function emitFile(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, isBundledEmit) { + function emitSourceFileOrBundle(_a, sourceFileOrBundle) { + var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath; if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { if (!emitOnlyDtsFiles) { - printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle); } } else { emitSkipped = true; } if (declarationFilePath) { - emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; + emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFileOrBundle(sourceFileOrBundle), host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; } if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { @@ -48915,24 +51275,24 @@ var ts; } } } - function printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit) { - sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); - nodeIdToGeneratedName = []; - autoGeneratedIdToGeneratedName = []; - generatedNameSet = ts.createMap(); - bundledHelpers = isBundledEmit ? ts.createMap() : undefined; - isOwnFileEmit = !isBundledEmit; - if (isBundledEmit && moduleKind) { - for (var _a = 0, sourceFiles_5 = sourceFiles; _a < sourceFiles_5.length; _a++) { - var sourceFile = sourceFiles_5[_a]; - emitHelpers(sourceFile, true); - } + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle) { + var bundle = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 264 ? sourceFileOrBundle : undefined; + var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; + sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFileOrBundle); + if (bundle) { + bundledHelpers = ts.createMap(); + isOwnFileEmit = false; + printer.writeBundle(bundle, writer); } - ts.forEach(sourceFiles, printSourceFile); - writeLine(); + else { + isOwnFileEmit = true; + printer.writeFile(sourceFile, writer); + } + writer.writeLine(); var sourceMappingURL = sourceMap.getSourceMappingURL(); if (sourceMappingURL) { - write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); + writer.write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); } if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) { ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), false, sourceFiles); @@ -48942,23 +51302,165 @@ var ts; } ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles); sourceMap.reset(); - comments.reset(); writer.reset(); - tempFlags = 0; currentSourceFile = undefined; - currentText = undefined; + bundledHelpers = undefined; isOwnFileEmit = false; } - function printSourceFile(node) { + function setSourceFile(node) { currentSourceFile = node; - currentText = node.text; - currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); - comments.setSourceFile(node); - pipelineEmitWithNotification(0, node); } - function emit(node) { - pipelineEmitWithNotification(3, node); + function emitHelpers(node, writeLines) { + var helpersEmitted = false; + var bundle = node.kind === 265 ? node : undefined; + if (bundle && moduleKind === ts.ModuleKind.None) { + return; + } + var numNodes = bundle ? bundle.sourceFiles.length : 1; + for (var i = 0; i < numNodes; i++) { + var currentNode = bundle ? bundle.sourceFiles[i] : node; + var sourceFile = ts.isSourceFile(currentNode) ? currentNode : currentSourceFile; + var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = ts.isSourceFile(currentNode) && !isOwnFileEmit; + var helpers = ts.getEmitHelpers(currentNode); + if (helpers) { + for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { + var helper = _b[_a]; + if (!helper.scoped) { + if (shouldSkip) + continue; + if (shouldBundle) { + if (bundledHelpers.get(helper.name)) { + continue; + } + bundledHelpers.set(helper.name, true); + } + } + else if (bundle) { + continue; + } + writeLines(helper.text); + helpersEmitted = true; + } + } + } + return helpersEmitted; + } + } + ts.emitFiles = emitFiles; + function createPrinter(printerOptions, handlers) { + if (printerOptions === void 0) { printerOptions = {}; } + if (handlers === void 0) { handlers = {}; } + var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, onSubstituteNode = handlers.onSubstituteNode; + var newLine = ts.getNewLineCharacter(printerOptions); + var languageVersion = ts.getEmitScriptTarget(printerOptions); + var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); + var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; + var currentSourceFile; + var nodeIdToGeneratedName; + var autoGeneratedIdToGeneratedName; + var generatedNames; + var tempFlagsStack; + var tempFlags; + var writer; + var ownWriter; + reset(); + return { + printNode: printNode, + printFile: printFile, + printBundle: printBundle, + writeNode: writeNode, + writeFile: writeFile, + writeBundle: writeBundle + }; + function printNode(hint, node, sourceFile) { + switch (hint) { + case 0: + ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); + break; + case 2: + ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); + break; + case 1: + ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); + break; + } + switch (node.kind) { + case 264: return printFile(node); + case 265: return printBundle(node); + } + writeNode(hint, node, sourceFile, beginPrint()); + return endPrint(); + } + function printBundle(bundle) { + writeBundle(bundle, beginPrint()); + return endPrint(); + } + function printFile(sourceFile) { + writeFile(sourceFile, beginPrint()); + return endPrint(); + } + function writeNode(hint, node, sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(hint, node, sourceFile); + reset(); + writer = previousWriter; + } + function writeBundle(bundle, output) { + var previousWriter = writer; + setWriter(output); + emitHelpersIndirect(bundle); + for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + print(0, sourceFile, sourceFile); + } + reset(); + writer = previousWriter; + } + function writeFile(sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(0, sourceFile, sourceFile); + reset(); + writer = previousWriter; + } + function beginPrint() { + return ownWriter || (ownWriter = ts.createTextWriter(newLine)); + } + function endPrint() { + var text = ownWriter.getText(); + ownWriter.reset(); + return text; + } + function print(hint, node, sourceFile) { + setSourceFile(sourceFile); + pipelineEmitWithNotification(hint, node); + } + function setSourceFile(sourceFile) { + currentSourceFile = sourceFile; + comments.setSourceFile(sourceFile); + if (onSetSourceFile) { + onSetSourceFile(sourceFile); + } + } + function setWriter(output) { + writer = output; + comments.setWriter(output); + } + function reset() { + nodeIdToGeneratedName = []; + autoGeneratedIdToGeneratedName = []; + generatedNames = ts.createMap(); + tempFlagsStack = []; + tempFlags = 0; + comments.reset(); + setWriter(undefined); + } + function emit(node, hint) { + if (hint === void 0) { hint = 3; } + pipelineEmitWithNotification(hint, node); } function emitIdentifierName(node) { pipelineEmitWithNotification(2, node); @@ -48966,51 +51468,60 @@ var ts; function emitExpression(node) { pipelineEmitWithNotification(1, node); } - function pipelineEmitWithNotification(emitContext, node) { - emitNodeWithNotification(emitContext, node, pipelineEmitWithComments); + function pipelineEmitWithNotification(hint, node) { + if (onEmitNode) { + onEmitNode(hint, node, pipelineEmitWithComments); + } + else { + pipelineEmitWithComments(hint, node); + } } - function pipelineEmitWithComments(emitContext, node) { - if (emitContext === 0) { - pipelineEmitWithSourceMap(emitContext, node); + function pipelineEmitWithComments(hint, node) { + if (emitNodeWithComments && hint !== 0) { + emitNodeWithComments(hint, node, pipelineEmitWithSourceMap); + } + else { + pipelineEmitWithSourceMap(hint, node); + } + } + function pipelineEmitWithSourceMap(hint, node) { + if (onEmitSourceMapOfNode && hint !== 0 && hint !== 2) { + onEmitSourceMapOfNode(hint, node, pipelineEmitWithSubstitution); + } + else { + pipelineEmitWithSubstitution(hint, node); + } + } + function pipelineEmitWithSubstitution(hint, node) { + if (onSubstituteNode) { + onSubstituteNode(hint, node, pipelineEmitWithHint); + } + else { + pipelineEmitWithHint(hint, node); + } + } + function pipelineEmitWithHint(hint, node) { + switch (hint) { + case 0: return pipelineEmitSourceFile(node); + case 2: return pipelineEmitIdentifierName(node); + case 1: return pipelineEmitExpression(node); + case 3: return pipelineEmitUnspecified(node); + } + } + function pipelineEmitSourceFile(node) { + ts.Debug.assertNode(node, ts.isSourceFile); + emitSourceFile(node); + } + function pipelineEmitIdentifierName(node) { + ts.Debug.assertNode(node, ts.isIdentifier); + emitIdentifier(node); + } + function pipelineEmitUnspecified(node) { + var kind = node.kind; + if (ts.isKeyword(kind)) { + writeTokenText(kind); return; } - emitNodeWithComments(emitContext, node, pipelineEmitWithSourceMap); - } - function pipelineEmitWithSourceMap(emitContext, node) { - if (emitContext === 0 - || emitContext === 2) { - pipelineEmitWithSubstitution(emitContext, node); - return; - } - emitNodeWithSourceMap(emitContext, node, pipelineEmitWithSubstitution); - } - function pipelineEmitWithSubstitution(emitContext, node) { - emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext); - } - function pipelineEmitForContext(emitContext, node) { - switch (emitContext) { - case 0: return pipelineEmitInSourceFileContext(node); - case 2: return pipelineEmitInIdentifierNameContext(node); - case 3: return pipelineEmitInUnspecifiedContext(node); - case 1: return pipelineEmitInExpressionContext(node); - } - } - function pipelineEmitInSourceFileContext(node) { - var kind = node.kind; - switch (kind) { - case 262: - return emitSourceFile(node); - } - } - function pipelineEmitInIdentifierNameContext(node) { - var kind = node.kind; - switch (kind) { - case 70: - return emitIdentifier(node); - } - } - function pipelineEmitInUnspecifiedContext(node) { - var kind = node.kind; switch (kind) { case 13: case 14: @@ -49018,229 +51529,197 @@ var ts; return emitLiteral(node); case 70: return emitIdentifier(node); - case 75: - case 78: - case 83: - case 104: - case 111: - case 112: - case 113: - case 114: - case 116: - case 117: - case 118: - case 119: - case 120: - case 121: - case 122: - case 123: - case 124: - case 125: - case 127: - case 128: - case 129: - case 130: - case 131: - case 132: - case 133: - case 134: - case 135: - case 136: - case 137: - case 138: - case 139: - case 140: - writeTokenText(kind); - return; - case 141: - return emitQualifiedName(node); case 142: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 143: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 144: - return emitParameter(node); + return emitTypeParameter(node); case 145: - return emitDecorator(node); + return emitParameter(node); case 146: - return emitPropertySignature(node); + return emitDecorator(node); case 147: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 148: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 149: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 150: - return emitConstructor(node); + return emitMethodDeclaration(node); case 151: + return emitConstructor(node); case 152: - return emitAccessorDeclaration(node); case 153: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 154: - return emitConstructSignature(node); + return emitCallSignature(node); case 155: - return emitIndexSignature(node); + return emitConstructSignature(node); case 156: - return emitTypePredicate(node); + return emitIndexSignature(node); case 157: - return emitTypeReference(node); + return emitTypePredicate(node); case 158: - return emitFunctionType(node); + return emitTypeReference(node); case 159: - return emitConstructorType(node); + return emitFunctionType(node); case 160: - return emitTypeQuery(node); + return emitConstructorType(node); case 161: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 162: - return emitArrayType(node); + return emitTypeLiteral(node); case 163: - return emitTupleType(node); + return emitArrayType(node); case 164: - return emitUnionType(node); + return emitTupleType(node); case 165: - return emitIntersectionType(node); + return emitUnionType(node); case 166: - return emitParenthesizedType(node); - case 199: - return emitExpressionWithTypeArguments(node); + return emitIntersectionType(node); case 167: - return emitThisType(); + return emitParenthesizedType(node); + case 200: + return emitExpressionWithTypeArguments(node); case 168: - return emitTypeOperator(node); + return emitThisType(); case 169: - return emitIndexedAccessType(node); + return emitTypeOperator(node); case 170: - return emitMappedType(node); + return emitIndexedAccessType(node); case 171: - return emitLiteralType(node); + return emitMappedType(node); case 172: - return emitObjectBindingPattern(node); + return emitLiteralType(node); case 173: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 174: + return emitArrayBindingPattern(node); + case 175: return emitBindingElement(node); - case 203: - return emitTemplateSpan(node); case 204: - return emitSemicolonClassElement(); + return emitTemplateSpan(node); case 205: - return emitBlock(node); + return emitSemicolonClassElement(); case 206: - return emitVariableStatement(node); + return emitBlock(node); case 207: - return emitEmptyStatement(); + return emitVariableStatement(node); case 208: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 209: - return emitIfStatement(node); + return emitExpressionStatement(node); case 210: - return emitDoStatement(node); + return emitIfStatement(node); case 211: - return emitWhileStatement(node); + return emitDoStatement(node); case 212: - return emitForStatement(node); + return emitWhileStatement(node); case 213: - return emitForInStatement(node); + return emitForStatement(node); case 214: - return emitForOfStatement(node); + return emitForInStatement(node); case 215: - return emitContinueStatement(node); + return emitForOfStatement(node); case 216: - return emitBreakStatement(node); + return emitContinueStatement(node); case 217: - return emitReturnStatement(node); + return emitBreakStatement(node); case 218: - return emitWithStatement(node); + return emitReturnStatement(node); case 219: - return emitSwitchStatement(node); + return emitWithStatement(node); case 220: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 221: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 222: - return emitTryStatement(node); + return emitThrowStatement(node); case 223: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 224: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 225: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 226: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 227: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 228: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 229: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 230: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 231: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 232: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 233: + return emitModuleBlock(node); + case 234: return emitCaseBlock(node); - case 235: - return emitImportEqualsDeclaration(node); case 236: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 237: - return emitImportClause(node); + return emitImportDeclaration(node); case 238: - return emitNamespaceImport(node); + return emitImportClause(node); case 239: - return emitNamedImports(node); + return emitNamespaceImport(node); case 240: - return emitImportSpecifier(node); + return emitNamedImports(node); case 241: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 242: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 243: - return emitNamedExports(node); + return emitExportDeclaration(node); case 244: - return emitExportSpecifier(node); + return emitNamedExports(node); case 245: - return; + return emitExportSpecifier(node); case 246: + return; + case 247: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 249: - return emitJsxOpeningElement(node); case 250: - return emitJsxClosingElement(node); + return emitJsxOpeningElement(node); case 251: - return emitJsxAttribute(node); + return emitJsxClosingElement(node); case 252: - return emitJsxSpreadAttribute(node); + return emitJsxAttribute(node); case 253: - return emitJsxExpression(node); + return emitJsxAttributes(node); case 254: - return emitCaseClause(node); + return emitJsxSpreadAttribute(node); case 255: - return emitDefaultClause(node); + return emitJsxExpression(node); case 256: - return emitHeritageClause(node); + return emitCaseClause(node); case 257: - return emitCatchClause(node); + return emitDefaultClause(node); case 258: - return emitPropertyAssignment(node); + return emitHeritageClause(node); case 259: - return emitShorthandPropertyAssignment(node); + return emitCatchClause(node); case 260: - return emitSpreadAssignment(node); + return emitPropertyAssignment(node); case 261: + return emitShorthandPropertyAssignment(node); + case 262: + return emitSpreadAssignment(node); + case 263: return emitEnumMember(node); } if (ts.isExpression(node)) { return pipelineEmitWithSubstitution(1, node); } } - function pipelineEmitInExpressionContext(node) { + function pipelineEmitExpression(node) { var kind = node.kind; switch (kind) { case 8: @@ -49258,68 +51737,81 @@ var ts; case 98: writeTokenText(kind); return; - case 175: - return emitArrayLiteralExpression(node); case 176: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 177: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 178: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 179: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 180: - return emitNewExpression(node); + return emitCallExpression(node); case 181: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 182: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 183: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 184: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 185: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 186: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 187: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 188: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 189: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 190: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 191: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 192: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 193: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 194: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 195: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 196: - return emitSpreadExpression(node); + return emitYieldExpression(node); case 197: - return emitClassExpression(node); + return emitSpreadExpression(node); case 198: + return emitClassExpression(node); + case 199: return; - case 200: - return emitAsExpression(node); case 201: - return emitNonNullExpression(node); + return emitAsExpression(node); case 202: + return emitNonNullExpression(node); + case 203: return emitMetaProperty(node); - case 247: - return emitJsxElement(node); case 248: + return emitJsxElement(node); + case 249: return emitJsxSelfClosingElement(node); - case 295: + case 298: return emitPartiallyEmittedExpression(node); } } + function emitBodyIndirect(node, elements, emitCallback) { + if (emitBodyWithDetachedComments) { + emitBodyWithDetachedComments(node, elements, emitCallback); + } + else { + emitCallback(node); + } + } + function emitHelpersIndirect(node) { + if (onEmitHelpers) { + onEmitHelpers(node, writeLines); + } + } function emitNumericLiteral(node) { emitLiteral(node); if (node.trailingComment) { @@ -49328,7 +51820,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralTextOfNode(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) + if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } @@ -49415,7 +51907,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 151 ? "get " : "set "); + write(node.kind === 152 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -49515,17 +52007,13 @@ var ts; write("{"); writeLine(); increaseIndent(); - if (node.readonlyToken) { - write("readonly "); - } + writeIfPresent(node.readonlyToken, "readonly "); write("["); emit(node.typeParameter.name); write(" in "); emit(node.typeParameter.constraint); write("]"); - if (node.questionToken) { - write("?"); - } + writeIfPresent(node.questionToken, "?"); write(": "); emit(node.type); write(";"); @@ -49597,7 +52085,7 @@ var ts; var indentAfterDot = false; if (!(ts.getEmitFlags(node) & 65536)) { var dotRangeStart = node.expression.end; - var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; + var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; var dotToken = { kind: 22, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); @@ -49613,13 +52101,15 @@ var ts; function needsDotDotForPropertyAccess(expression) { if (expression.kind === 8) { var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(22)) < 0; + return ts.getNumericLiteralFlags(text, 15) === 0 + && !expression.isOctalLiteral + && text.indexOf(ts.tokenToString(22)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); return isFinite(constantValue) && Math.floor(constantValue) === constantValue - && compilerOptions.removeComments; + && printerOptions.removeComments; } } function emitElementAccessExpression(node) { @@ -49645,11 +52135,9 @@ var ts; emitExpression(node.template); } function emitTypeAssertionExpression(node) { - if (node.type) { - write("<"); - emit(node.type); - write(">"); - } + write("<"); + emit(node.type); + write(">"); emitExpression(node.expression); } function emitParenthesizedExpression(node) { @@ -49696,7 +52184,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 190 + return operand.kind === 191 && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } @@ -49780,6 +52268,9 @@ var ts; else { writeToken(16, node.pos, node); emitBlockStatements(node); + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); writeToken(17, node.statements.end, node); } } @@ -49813,7 +52304,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 209) { + if (node.elseStatement.kind === 210) { write(" "); emit(node.elseStatement); } @@ -49875,7 +52366,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 225) { + if (node.kind === 226) { emit(node); } else { @@ -49972,11 +52463,10 @@ var ts; emitBlockFunctionBody(body); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); emitSignatureHead(node); emitBlockFunctionBody(body); - tempFlags = savedTempFlags; + popNameGenerationScope(); } if (indentedFlag) { decreaseIndent(); @@ -50025,9 +52515,10 @@ var ts; function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) + var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine - : emitBlockFunctionBodyWorker); + : emitBlockFunctionBodyWorker; + emitBodyIndirect(body, body.statements, emitBlockFunctionBody); decreaseIndent(); writeToken(17, body.statements.end, body); } @@ -50036,8 +52527,9 @@ var ts; } function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) { var statementOffset = emitPrologueDirectives(body.statements, true); - var helpersEmitted = emitHelpers(body); - if (statementOffset === 0 && !helpersEmitted && emitBlockFunctionBodyOnSingleLine) { + var pos = writer.getTextPos(); + emitHelpersIndirect(body); + if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); emitList(body, body.statements, 384); increaseIndent(); @@ -50060,15 +52552,14 @@ var ts; } emitTypeParameters(node, node.typeParameters); emitList(node, node.heritageClauses, 256); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 65); write("}"); + popNameGenerationScope(); if (indentedFlag) { decreaseIndent(); } - tempFlags = savedTempFlags; } function emitInterfaceDeclaration(node) { emitDecorators(node, node.decorators); @@ -50095,19 +52586,18 @@ var ts; emitModifiers(node, node.modifiers); write("enum "); emit(node.name); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 81); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 231) { + while (body.kind === 232) { write("."); emit(body.name); body = body.body; @@ -50120,13 +52610,12 @@ var ts; write("{ }"); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write("{"); increaseIndent(); emitBlockStatements(node); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } } function emitCaseBlock(node) { @@ -50228,14 +52717,18 @@ var ts; write("<"); emitJsxTagName(node.tagName); write(" "); - emitList(node, node.attributes, 131328); + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write("/>"); } function emitJsxOpeningElement(node) { write("<"); emitJsxTagName(node.tagName); - writeIfAny(node.attributes, " "); - emitList(node, node.attributes, 131328); + writeIfAny(node.attributes.properties, " "); + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write(">"); } function emitJsxText(node) { @@ -50246,6 +52739,9 @@ var ts; emitJsxTagName(node.tagName); write(">"); } + function emitJsxAttributes(node) { + emitList(node, node.properties, 131328); + } function emitJsxAttribute(node) { emit(node.name); emitWithPrefix("=", node.initializer); @@ -50303,7 +52799,6 @@ var ts; emitList(node, node.types, 272); } function emitCatchClause(node) { - writeLine(); var openParenPos = writeToken(73, node.pos); write(" "); writeToken(18, openParenPos); @@ -50316,7 +52811,7 @@ var ts; emit(node.name); write(": "); var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512) === 0) { + if (emitTrailingCommentsOfPosition && (ts.getEmitFlags(initializer) & 512) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -50342,16 +52837,15 @@ var ts; function emitSourceFile(node) { writeLine(); emitShebang(); - emitBodyWithDetachedComments(node, node.statements, emitSourceFileWorker); + emitBodyIndirect(node, node.statements, emitSourceFileWorker); } function emitSourceFileWorker(node) { var statements = node.statements; var statementOffset = emitPrologueDirectives(statements); - var savedTempFlags = tempFlags; - tempFlags = 0; - emitHelpers(node); + pushNameGenerationScope(); + emitHelpersIndirect(node); emitList(node, statements, 1, statementOffset); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitPartiallyEmittedExpression(node) { emitExpression(node.expression); @@ -50370,67 +52864,8 @@ var ts; } return statements.length; } - function emitHelpers(node, isBundle) { - var sourceFile = ts.isSourceFile(node) ? node : currentSourceFile; - var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); - var shouldBundle = ts.isSourceFile(node) && !isOwnFileEmit; - var helpersEmitted = false; - var helpers = ts.getEmitHelpers(node); - if (helpers) { - for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { - var helper = _b[_a]; - if (!helper.scoped) { - if (shouldSkip) - continue; - if (shouldBundle) { - if (bundledHelpers[helper.name]) { - continue; - } - bundledHelpers[helper.name] = true; - } - } - else if (isBundle) { - continue; - } - writeLines(helper.text); - helpersEmitted = true; - } - } - if (helpersEmitted) { - writeLine(); - } - return helpersEmitted; - } - function writeLines(text) { - var lines = text.split(/\r\n?|\n/g); - var indentation = guessIndentation(lines); - for (var i = 0; i < lines.length; i++) { - var line = indentation ? lines[i].slice(indentation) : lines[i]; - if (line.length) { - if (i > 0) { - writeLine(); - } - write(line); - } - } - } - function guessIndentation(lines) { - var indentation; - for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { - var line = lines_1[_a]; - for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { - if (!ts.isWhiteSpace(line.charCodeAt(i))) { - if (indentation === undefined || i < indentation) { - indentation = i; - break; - } - } - } - } - return indentation; - } function emitShebang() { - var shebang = ts.getShebang(currentText); + var shebang = ts.getShebang(currentSourceFile.text); if (shebang) { write(shebang); writeLine(); @@ -50545,6 +52980,9 @@ var ts; for (var i = 0; i < count; i++) { var child = children[start + i]; if (previousSibling) { + if (delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } write(delimiter); if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { if ((format & (3 | 64)) === 0) { @@ -50559,8 +52997,10 @@ var ts; } } if (shouldEmitInterveningComments) { - var commentRange = ts.getCommentRange(child); - emitTrailingCommentsOfPosition(commentRange.pos); + if (emitTrailingCommentsOfPosition) { + var commentRange = ts.getCommentRange(child); + emitTrailingCommentsOfPosition(commentRange.pos); + } } else { shouldEmitInterveningComments = mayEmitInterveningComments; @@ -50576,6 +53016,9 @@ var ts; if (format & 16 && hasTrailingComma) { write(","); } + if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } if (format & 64) { decreaseIndent(); } @@ -50590,6 +53033,38 @@ var ts; write(getClosingBracket(format)); } } + function write(s) { + writer.write(s); + } + function writeLine() { + writer.writeLine(); + } + function increaseIndent() { + writer.increaseIndent(); + } + function decreaseIndent() { + writer.decreaseIndent(); + } + function writeIfAny(nodes, text) { + if (ts.some(nodes)) { + write(text); + } + } + function writeIfPresent(node, text) { + if (node) { + write(text); + } + } + function writeToken(token, pos, contextNode) { + return onEmitSourceMapOfToken + ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) + : writeTokenText(token, pos); + } + function writeTokenText(token, pos) { + var tokenString = ts.tokenToString(token); + write(tokenString); + return pos < 0 ? pos : pos + tokenString.length; + } function writeLineOrSpace(node) { if (ts.getEmitFlags(node) & 1) { write(" "); @@ -50598,23 +53073,32 @@ var ts; writeLine(); } } - function writeIfAny(nodes, text) { - if (nodes && nodes.length > 0) { - write(text); + function writeLines(text) { + var lines = text.split(/\r\n?|\n/g); + var indentation = guessIndentation(lines); + for (var i = 0; i < lines.length; i++) { + var line = indentation ? lines[i].slice(indentation) : lines[i]; + if (line.length) { + writeLine(); + write(line); + writeLine(); + } } } - function writeIfPresent(node, text) { - if (node !== undefined) { - write(text); + function guessIndentation(lines) { + var indentation; + for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { + var line = lines_1[_a]; + for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { + if (!ts.isWhiteSpace(line.charCodeAt(i))) { + if (indentation === undefined || i < indentation) { + indentation = i; + break; + } + } + } } - } - function writeToken(token, pos, contextNode) { - return emitTokenWithSourceMap(contextNode, token, pos, writeTokenText); - } - function writeTokenText(token, pos) { - var tokenString = ts.tokenToString(token); - write(tokenString); - return pos < 0 ? pos : pos + tokenString.length; + return indentation; } function increaseIndentIf(value, valueToWriteWhenNotIndenting) { if (value) { @@ -50720,15 +53204,23 @@ var ts; && !ts.nodeIsSynthesized(node2) && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } + function isSingleLineEmptyBlock(block) { + return !block.multiLine + && isEmptyBlock(block); + } + function isEmptyBlock(block) { + return block.statements.length === 0 + && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + } function skipSynthesizedParentheses(node) { - while (node.kind === 183 && ts.nodeIsSynthesized(node)) { + while (node.kind === 184 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; } function getTextOfNode(node, includeTrivia) { if (ts.isGeneratedIdentifier(node)) { - return getGeneratedIdentifier(node); + return generateName(node); } else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { return ts.unescapeIdentifier(node.text); @@ -50753,23 +53245,37 @@ var ts; } return ts.getLiteralText(node, currentSourceFile, languageVersion); } - function isSingleLineEmptyBlock(block) { - return !block.multiLine - && isEmptyBlock(block); + function pushNameGenerationScope() { + tempFlagsStack.push(tempFlags); + tempFlags = 0; } - function isEmptyBlock(block) { - return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + function popNameGenerationScope() { + tempFlags = tempFlagsStack.pop(); + } + function generateName(name) { + if (name.autoGenerateKind === 4) { + var node = getNodeForGeneratedName(name); + return generateNameCached(node); + } + else { + var autoGenerateId = name.autoGenerateId; + return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(makeName(name))); + } + } + function generateNameCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); } function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentFileIdentifiers, name) && - !ts.hasProperty(generatedNameSet, name); + return !(hasGlobalName && hasGlobalName(name)) + && !currentSourceFile.identifiers.has(name) + && !generatedNames.has(name); } function isUniqueLocalName(name, container) { for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { + if (node.locals) { + var local = node.locals.get(name); + if (local && local.flags & (107455 | 1048576 | 8388608)) { return false; } } @@ -50778,21 +53284,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_42 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_42)) { + var name = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name)) { tempFlags |= flags; - return name_42; + return name; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_43 = count < 26 + var name = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_43)) { - return name_43; + if (isUniqueName(name)) { + return name; } } } @@ -50805,7 +53311,8 @@ var ts; while (true) { var generatedName = baseName + i; if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; + generatedNames.set(generatedName, generatedName); + return generatedName; } i++; } @@ -50828,7 +53335,7 @@ var ts; } function generateNameForMethodOrAccessor(node) { if (ts.isIdentifier(node.name)) { - return generateNameForNodeCached(node.name); + return generateNameCached(node.name); } return makeTempVariableName(0); } @@ -50836,34 +53343,34 @@ var ts; switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); + case 232: case 231: - case 230: return generateNameForModuleOrEnum(node); - case 236: - case 242: + case 237: + case 243: return generateNameForImportOrExportDeclaration(node); - case 226: case 227: - case 241: + case 228: + case 242: return generateNameForExportDefault(); - case 197: + case 198: return generateNameForClassExpression(); - case 149: - case 151: + case 150: case 152: + case 153: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); } } - function generateName(name) { + function makeName(name) { switch (name.autoGenerateKind) { case 1: return makeTempVariableName(0); case 2: return makeTempVariableName(268435456); case 3: - return makeUniqueName(name.text); + return makeUniqueName(ts.unescapeIdentifier(name.text)); } ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } @@ -50882,47 +53389,101 @@ var ts; } return node; } - function generateNameForNodeCached(node) { - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); - } - function getGeneratedIdentifier(name) { - if (name.autoGenerateKind === 4) { - var node = getNodeForGeneratedName(name); - return generateNameForNodeCached(node); - } - else { - var autoGenerateId = name.autoGenerateId; - return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(generateName(name))); - } - } - function createDelimiterMap() { - var delimiters = []; - delimiters[0] = ""; - delimiters[16] = ","; - delimiters[4] = " |"; - delimiters[8] = " &"; - return delimiters; - } - function getDelimiter(format) { - return delimiters[format & 28]; - } - function createBracketsMap() { - var brackets = []; - brackets[512] = ["{", "}"]; - brackets[1024] = ["(", ")"]; - brackets[2048] = ["<", ">"]; - brackets[4096] = ["[", "]"]; - return brackets; - } - function getOpeningBracket(format) { - return brackets[format & 7680][0]; - } - function getClosingBracket(format) { - return brackets[format & 7680][1]; - } } - ts.emitFiles = emitFiles; + ts.createPrinter = createPrinter; + function createDelimiterMap() { + var delimiters = []; + delimiters[0] = ""; + delimiters[16] = ","; + delimiters[4] = " |"; + delimiters[8] = " &"; + return delimiters; + } + function getDelimiter(format) { + return delimiters[format & 28]; + } + function createBracketsMap() { + var brackets = []; + brackets[512] = ["{", "}"]; + brackets[1024] = ["(", ")"]; + brackets[2048] = ["<", ">"]; + brackets[4096] = ["[", "]"]; + return brackets; + } + function getOpeningBracket(format) { + return brackets[format & 7680][0]; + } + function getClosingBracket(format) { + return brackets[format & 7680][1]; + } + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); + var ListFormat; + (function (ListFormat) { + ListFormat[ListFormat["None"] = 0] = "None"; + ListFormat[ListFormat["SingleLine"] = 0] = "SingleLine"; + ListFormat[ListFormat["MultiLine"] = 1] = "MultiLine"; + ListFormat[ListFormat["PreserveLines"] = 2] = "PreserveLines"; + ListFormat[ListFormat["LinesMask"] = 3] = "LinesMask"; + ListFormat[ListFormat["NotDelimited"] = 0] = "NotDelimited"; + ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; + ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; + ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; + ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; + ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; + ListFormat[ListFormat["Indented"] = 64] = "Indented"; + ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; + ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; + ListFormat[ListFormat["Braces"] = 512] = "Braces"; + ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; + ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; + ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; + ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; + ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; + ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; + ListFormat[ListFormat["Optional"] = 24576] = "Optional"; + ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; + ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; + ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; + ListFormat[ListFormat["Modifiers"] = 256] = "Modifiers"; + ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; + ListFormat[ListFormat["TypeLiteralMembers"] = 65] = "TypeLiteralMembers"; + ListFormat[ListFormat["TupleTypeElements"] = 336] = "TupleTypeElements"; + ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; + ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; + ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; + ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; + ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; + ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; + ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; + ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; + ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; + ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; + ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; + ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; + ListFormat[ListFormat["ClassHeritageClauses"] = 256] = "ClassHeritageClauses"; + ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; + ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; + ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; + ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; + ListFormat[ListFormat["NamedImportsOrExportsElements"] = 432] = "NamedImportsOrExportsElements"; + ListFormat[ListFormat["JsxElementChildren"] = 131072] = "JsxElementChildren"; + ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; + ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; + ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; + ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; + ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; + ListFormat[ListFormat["TypeArguments"] = 26960] = "TypeArguments"; + ListFormat[ListFormat["TypeParameters"] = 26960] = "TypeParameters"; + ListFormat[ListFormat["Parameters"] = 1360] = "Parameters"; + ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; + })(ListFormat || (ListFormat = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -51006,11 +53567,11 @@ var ts; return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; } function directoryExists(directoryPath) { - if (directoryPath in existingDirectories) { + if (existingDirectories.has(directoryPath)) { return true; } if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; + existingDirectories.set(directoryPath, true); return true; } return false; @@ -51029,9 +53590,10 @@ var ts; } var hash = ts.sys.createHash(data); var mtimeBefore = ts.sys.getModifiedTime(fileName); - if (mtimeBefore && fileName in outputFingerprints) { - var fingerprint = outputFingerprints[fileName]; - if (fingerprint.byteOrderMark === writeByteOrderMark && + if (mtimeBefore) { + var fingerprint = outputFingerprints.get(fileName); + if (fingerprint && + fingerprint.byteOrderMark === writeByteOrderMark && fingerprint.hash === hash && fingerprint.mtime.getTime() === mtimeBefore.getTime()) { return; @@ -51039,11 +53601,11 @@ var ts; } ts.sys.writeFile(fileName, data, writeByteOrderMark); var mtimeAfter = ts.sys.getModifiedTime(fileName); - outputFingerprints[fileName] = { + outputFingerprints.set(fileName, { hash: hash, byteOrderMark: writeByteOrderMark, mtime: mtimeAfter - }; + }); } function writeFile(fileName, data, writeByteOrderMark, onError) { try { @@ -51142,10 +53704,14 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_44 = names_1[_i]; - var result = name_44 in cache - ? cache[name_44] - : cache[name_44] = loader(name_44, containingFile); + var name = names_1[_i]; + var result = void 0; + if (cache.has(name)) { + result = cache.get(name); + } + else { + cache.set(name, result = loader(name, containingFile)); + } resolutions.push(result); } return resolutions; @@ -51254,7 +53820,7 @@ var ts; return program; function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); } @@ -51273,7 +53839,7 @@ var ts; classifiableNames = ts.createMap(); for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { var sourceFile = files_2[_i]; - ts.copyProperties(sourceFile.classifiableNames, classifiableNames); + ts.copyEntries(sourceFile.classifiableNames, classifiableNames); } } return classifiableNames; @@ -51456,7 +54022,7 @@ var ts; }; } function isSourceFileFromExternalLibrary(file) { - return sourceFilesFoundSearchingNodeModules[file.path]; + return sourceFilesFoundSearchingNodeModules.get(file.path); } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); @@ -51573,57 +54139,57 @@ var ts; return diagnostics; function walk(node) { switch (parent.kind) { - case 144: - case 147: + case 145: + case 148: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 184: - case 226: + case 153: case 185: - case 226: - case 224: + case 227: + case 186: + case 227: + case 225: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 235: + case 236: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 241: + case 242: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 256: + case 258: var heritageClause = node; if (heritageClause.token === 107) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 228: + case 229: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 231: + case 232: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 229: + case 230: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 230: + case 231: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 182: + case 183: var typeAssertionExpression = node; diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; @@ -51638,26 +54204,26 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 227: - case 149: - case 148: + case 228: case 150: + case 149: case 151: case 152: - case 184: - case 226: + case 153: case 185: - case 226: + case 227: + case 186: + case 227: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 206: + case 207: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 206); + return checkModifiers(nodes, parent.kind === 207); } break; - case 147: + case 148: if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; @@ -51668,15 +54234,15 @@ var ts; return; } break; - case 144: + case 145: if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 179: case 180: - case 199: + case 181: + case 200: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; @@ -51764,11 +54330,10 @@ var ts; if (options.importHelpers && (options.isolatedModules || isExternalModuleFile) && !file.isDeclarationFile) { - var externalHelpersModuleReference = ts.createSynthesizedNode(9); - externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(236); - importDecl.parent = file; + var externalHelpersModuleReference = ts.createLiteral(ts.externalHelpersModuleNameText); + var importDecl = ts.createImportDeclaration(undefined, undefined, undefined); externalHelpersModuleReference.parent = importDecl; + importDecl.parent = file; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -51784,9 +54349,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 237: case 236: - case 235: - case 242: + case 243: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -51798,7 +54363,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 231: + case 232: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -51882,18 +54447,18 @@ var ts; if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd); } - if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { - sourceFilesFoundSearchingNodeModules[file_1.path] = false; + if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth == 0) { + sourceFilesFoundSearchingNodeModules.set(file_1.path, false); if (!options.noResolve) { processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } - else if (file_1 && modulesWithElidedImports[file_1.path]) { + else if (file_1 && modulesWithElidedImports.get(file_1.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } } @@ -51909,7 +54474,7 @@ var ts; }); filesByName.set(path, file); if (file) { - sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0); + sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; if (host.useCaseSensitiveFileNames()) { var existingFile = filesByNameIgnoreCase.get(path); @@ -51953,7 +54518,7 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { - var previousResolution = resolvedTypeReferenceDirectives[typeReferenceDirective]; + var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { return; } @@ -51981,7 +54546,7 @@ var ts; fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { - resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective; + resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); } } function createDiagnostic(refFile, refPos, refEnd, message) { @@ -52022,7 +54587,7 @@ var ts; var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { - modulesWithElidedImports[file.path] = true; + modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = ts.toPath(resolvedFileName, currentDirectory, getCanonicalFileName); @@ -52040,8 +54605,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var file = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var file = sourceFiles_3[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -52052,8 +54617,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -52204,7 +54769,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { + ts.forEachEmittedFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -52327,6 +54892,22 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + var OutputFileType; + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(OutputFileType = ts.OutputFileType || (ts.OutputFileType = {})); + var EndOfLineState; + (function (EndOfLineState) { + EndOfLineState[EndOfLineState["None"] = 0] = "None"; + EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; + EndOfLineState[EndOfLineState["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate"; + EndOfLineState[EndOfLineState["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail"; + EndOfLineState[EndOfLineState["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition"; + })(EndOfLineState = ts.EndOfLineState || (ts.EndOfLineState = {})); var TokenClass; (function (TokenClass) { TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; @@ -52373,6 +54954,7 @@ var ts; ScriptElementKind.letElement = "let"; ScriptElementKind.directory = "directory"; ScriptElementKind.externalModuleName = "external module name"; + ScriptElementKind.jsxAttribute = "JSX attribute"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { @@ -52414,40 +54996,76 @@ var ts; ClassificationTypeNames.jsxText = "jsx text"; ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; ts.ClassificationTypeNames = ClassificationTypeNames; + var ClassificationType; + (function (ClassificationType) { + ClassificationType[ClassificationType["comment"] = 1] = "comment"; + ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; + ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; + ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; + ClassificationType[ClassificationType["operator"] = 5] = "operator"; + ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; + ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; + ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; + ClassificationType[ClassificationType["text"] = 9] = "text"; + ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; + ClassificationType[ClassificationType["className"] = 11] = "className"; + ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; + ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; + ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; + ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; + ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; + ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; + ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName"; + ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName"; + ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName"; + ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName"; + ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; + ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; + ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; + })(ClassificationType = ts.ClassificationType || (ts.ClassificationType = {})); })(ts || (ts = {})); var ts; (function (ts) { ts.scanner = ts.createScanner(5, true); ts.emptyArray = []; + var SemanticMeaning; + (function (SemanticMeaning) { + SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; + SemanticMeaning[SemanticMeaning["Value"] = 1] = "Value"; + SemanticMeaning[SemanticMeaning["Type"] = 2] = "Type"; + SemanticMeaning[SemanticMeaning["Namespace"] = 4] = "Namespace"; + SemanticMeaning[SemanticMeaning["All"] = 7] = "All"; + })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 144: - case 224: - case 174: - case 147: - case 146: - case 258: - case 259: - case 261: - case 149: + case 145: + case 225: + case 175: case 148: + case 147: + case 260: + case 261: + case 263: case 150: + case 149: case 151: case 152: - case 226: - case 184: - case 185: - case 257: - return 1; - case 143: - case 228: - case 229: - case 161: - return 2; + case 153: case 227: + case 185: + case 186: + case 259: + case 252: + return 1; + case 144: + case 229: case 230: - return 1 | 2; + case 162: + return 2; + case 228: case 231: + return 1 | 2; + case 232: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -52457,21 +55075,24 @@ var ts; else { return 4; } - case 239: case 240: - case 235: - case 236: case 241: + case 236: + case 237: case 242: + case 243: return 1 | 2 | 4; - case 262: + case 264: return 4 | 1; } return 1 | 2 | 4; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 241) { + if (node.kind === 264) { + return 1; + } + else if (node.parent.kind === 242) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -52493,15 +55114,15 @@ var ts; ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { ts.Debug.assert(node.kind === 70); - if (node.parent.kind === 141 && + if (node.parent.kind === 142 && node.parent.right === node && - node.parent.parent.kind === 235) { + node.parent.parent.kind === 236) { return 1 | 2 | 4; } return 4; } function isInRightSideOfImport(node) { - while (node.parent.kind === 141) { + while (node.parent.kind === 142) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -52512,27 +55133,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 141) { - while (root.parent && root.parent.kind === 141) { + if (root.parent.kind === 142) { + while (root.parent && root.parent.kind === 142) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 157 && !isLastClause; + return root.parent.kind === 158 && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 177) { - while (root.parent && root.parent.kind === 177) { + if (root.parent.kind === 178) { + while (root.parent && root.parent.kind === 178) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 199 && root.parent.parent.kind === 256) { + if (!isLastClause && root.parent.kind === 200 && root.parent.parent.kind === 258) { var decl = root.parent.parent.parent; - return (decl.kind === 227 && root.parent.parent.token === 107) || - (decl.kind === 228 && root.parent.parent.token === 84); + return (decl.kind === 228 && root.parent.parent.token === 107) || + (decl.kind === 229 && root.parent.parent.token === 84); } return false; } @@ -52540,17 +55161,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 157 || - (node.parent.kind === 199 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 158 || + (node.parent.kind === 200 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 98 && !ts.isPartOfExpression(node)) || - node.kind === 167; + node.kind === 168; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 179); + return isCallOrNewExpressionTarget(node, 180); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 180); + return isCallOrNewExpressionTarget(node, 181); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -52563,7 +55184,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 220 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 221 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -52573,13 +55194,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 && - (node.parent.kind === 216 || node.parent.kind === 215) && + (node.parent.kind === 217 || node.parent.kind === 216) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 && - node.parent.kind === 220 && + node.parent.kind === 221 && node.parent.label === node; } function isLabelName(node) { @@ -52587,15 +55208,15 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 141 && node.parent.right === node; + return node.parent.kind === 142 && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 177 && node.parent.name === node; + return node && node.parent && node.parent.kind === 178 && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 231 && node.parent.name === node; + return node.parent.kind === 232 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -52606,19 +55227,19 @@ var ts; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { - case 147: - case 146: - case 258: - case 261: - case 149: case 148: - case 151: + case 147: + case 260: + case 263: + case 150: + case 149: case 152: - case 231: + case 153: + case 232: return node.parent.name === node; - case 178: + case 179: return node.parent.argumentExpression === node; - case 142: + case 143: return true; } } @@ -52662,17 +55283,17 @@ var ts; return undefined; } switch (node.kind) { - case 262: + case 264: + case 150: case 149: - case 148: - case 226: - case 184: - case 151: - case 152: case 227: + case 185: + case 152: + case 153: case 228: - case 230: + case 229: case 231: + case 232: return node; } } @@ -52680,46 +55301,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 262: + case 264: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 231: + case 232: return ts.ScriptElementKind.moduleElement; - case 227: - case 197: + case 228: + case 198: return ts.ScriptElementKind.classElement; - case 228: return ts.ScriptElementKind.interfaceElement; - case 229: return ts.ScriptElementKind.typeElement; - case 230: return ts.ScriptElementKind.enumElement; - case 224: + case 229: return ts.ScriptElementKind.interfaceElement; + case 230: return ts.ScriptElementKind.typeElement; + case 231: return ts.ScriptElementKind.enumElement; + case 225: return getKindOfVariableDeclaration(node); - case 174: + case 175: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); + case 186: + case 227: case 185: - case 226: - case 184: return ts.ScriptElementKind.functionElement; - case 151: return ts.ScriptElementKind.memberGetAccessorElement; - case 152: return ts.ScriptElementKind.memberSetAccessorElement; + case 152: return ts.ScriptElementKind.memberGetAccessorElement; + case 153: return ts.ScriptElementKind.memberSetAccessorElement; + case 150: case 149: - case 148: return ts.ScriptElementKind.memberFunctionElement; + case 148: case 147: - case 146: return ts.ScriptElementKind.memberVariableElement; - case 155: return ts.ScriptElementKind.indexSignatureElement; - case 154: return ts.ScriptElementKind.constructSignatureElement; - case 153: return ts.ScriptElementKind.callSignatureElement; - case 150: return ts.ScriptElementKind.constructorImplementationElement; - case 143: return ts.ScriptElementKind.typeParameterElement; - case 261: return ts.ScriptElementKind.enumMemberElement; - case 144: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 235: - case 240: - case 237: - case 244: + case 156: return ts.ScriptElementKind.indexSignatureElement; + case 155: return ts.ScriptElementKind.constructSignatureElement; + case 154: return ts.ScriptElementKind.callSignatureElement; + case 151: return ts.ScriptElementKind.constructorImplementationElement; + case 144: return ts.ScriptElementKind.typeParameterElement; + case 263: return ts.ScriptElementKind.enumMemberElement; + case 145: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 236: + case 241: case 238: + case 245: + case 239: return ts.ScriptElementKind.alias; - case 286: + case 289: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -52734,7 +55355,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 171 ? node.parent : node; + var searchNode = node.parent.kind === 172 ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32) { return type; @@ -52747,7 +55368,7 @@ var ts; case 98: return true; case 70: - return ts.identifierIsThisKeyword(node) && node.parent.kind === 144; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 145; default: return false; } @@ -52791,41 +55412,41 @@ var ts; return false; } switch (n.kind) { - case 227: case 228: - case 230: - case 176: - case 172: - case 161: - case 205: - case 232: + case 229: + case 231: + case 177: + case 173: + case 162: + case 206: case 233: - case 239: - case 243: + case 234: + case 240: + case 244: return nodeEndsWith(n, 17, sourceFile); - case 257: + case 259: return isCompletedNode(n.block, sourceFile); - case 180: + case 181: if (!n.arguments) { return true; } - case 179: - case 183: - case 166: + case 180: + case 184: + case 167: return nodeEndsWith(n, 19, sourceFile); - case 158: case 159: + case 160: return isCompletedNode(n.type, sourceFile); - case 150: case 151: case 152: - case 226: - case 184: - case 149: - case 148: - case 154: case 153: + case 227: case 185: + case 150: + case 149: + case 155: + case 154: + case 186: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -52833,65 +55454,65 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19, sourceFile); - case 231: + case 232: return n.body && isCompletedNode(n.body, sourceFile); - case 209: + case 210: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 208: + case 209: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24); - case 175: - case 173: - case 178: - case 142: - case 163: + case 176: + case 174: + case 179: + case 143: + case 164: return nodeEndsWith(n, 21, sourceFile); - case 155: + case 156: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21, sourceFile); - case 254: - case 255: + case 256: + case 257: return false; - case 212: case 213: case 214: - case 211: + case 215: + case 212: return isCompletedNode(n.statement, sourceFile); - case 210: + case 211: var hasWhileKeyword = findChildOfKind(n, 105, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 19, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 160: + case 161: return isCompletedNode(n.exprName, sourceFile); - case 187: - case 186: case 188: - case 195: + case 187: + case 189: case 196: + case 197: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 181: + case 182: return isCompletedNode(n.template, sourceFile); - case 194: + case 195: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 203: + case 204: return ts.nodeIsPresent(n.literal); - case 242: - case 236: + case 243: + case 237: return ts.nodeIsPresent(n.moduleSpecifier); - case 190: + case 191: return isCompletedNode(n.operand, sourceFile); - case 192: - return isCompletedNode(n.right, sourceFile); case 193: + return isCompletedNode(n.right, sourceFile); + case 194: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -52934,7 +55555,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 293 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 296 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -53069,7 +55690,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 262); + ts.Debug.assert(startNode !== undefined || n.kind === 264); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -53114,13 +55735,13 @@ var ts; if (token.kind === 26 && token.parent.kind === 10) { return true; } - if (token.kind === 26 && token.parent.kind === 253) { + if (token.kind === 26 && token.parent.kind === 255) { return true; } - if (token && token.kind === 17 && token.parent.kind === 253) { + if (token && token.kind === 17 && token.parent.kind === 255) { return true; } - if (token.kind === 26 && token.parent.kind === 250) { + if (token.kind === 26 && token.parent.kind === 251) { return true; } return false; @@ -53211,17 +55832,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 157 || node.kind === 179) { + if (node.kind === 158 || node.kind === 180) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 227 || node.kind === 228) { + if (ts.isFunctionLike(node) || node.kind === 228 || node.kind === 229) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 140; + return n.kind >= 0 && n.kind <= 141; } ts.isToken = isToken; function isWord(kind) { @@ -53280,18 +55901,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 175 || - node.kind === 176) { - if (node.parent.kind === 192 && + if (node.kind === 176 || + node.kind === 177) { + if (node.parent.kind === 193 && node.parent.left === node && node.parent.operatorToken.kind === 57) { return true; } - if (node.parent.kind === 214 && + if (node.parent.kind === 215 && node.parent.initializer === node) { return true; } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 258 ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 260 ? node.parent.parent : node.parent)) { return true; } } @@ -53319,10 +55940,30 @@ var ts; } } ts.isInNonReferenceComment = isInNonReferenceComment; + function createTextSpanFromNode(node, sourceFile) { + return ts.createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); + } + ts.createTextSpanFromNode = createTextSpanFromNode; + function isTypeKeyword(kind) { + switch (kind) { + case 118: + case 121: + case 129: + case 132: + case 133: + case 135: + case 136: + case 104: + return true; + default: + return false; + } + } + ts.isTypeKeyword = isTypeKeyword; })(ts || (ts = {})); (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 144; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 145; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -53346,7 +55987,8 @@ var ts; decreaseIndent: function () { indent--; }, clear: resetWriter, trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop }; function writeIndent() { if (lineStart) { @@ -53498,7 +56140,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location) && - location.parent.kind === 142) { + location.parent.kind === 143) { return location.text; } var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); @@ -53508,7 +56150,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 240 || location.parent.kind === 244) && + (location.parent.kind === 241 || location.parent.kind === 245) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -53617,89 +56259,89 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 206: + case 207: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 224: - case 147: - case 146: - return spanInVariableDeclaration(node); - case 144: - return spanInParameterDeclaration(node); - case 226: - case 149: + case 225: case 148: - case 151: - case 152: + case 147: + return spanInVariableDeclaration(node); + case 145: + return spanInParameterDeclaration(node); + case 227: case 150: - case 184: + case 149: + case 152: + case 153: + case 151: case 185: + case 186: return spanInFunctionDeclaration(node); - case 205: + case 206: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 232: + case 233: return spanInBlock(node); - case 257: + case 259: return spanInBlock(node.block); - case 208: - return textSpan(node.expression); - case 217: - return textSpan(node.getChildAt(0), node.expression); - case 211: - return textSpanEndingAtNextToken(node, node.expression); - case 210: - return spanInNode(node.statement); - case 223: - return textSpan(node.getChildAt(0)); case 209: - return textSpanEndingAtNextToken(node, node.expression); - case 220: - return spanInNode(node.statement); - case 216: - case 215: - return textSpan(node.getChildAt(0), node.label); + return textSpan(node.expression); + case 218: + return textSpan(node.getChildAt(0), node.expression); case 212: - return spanInForStatement(node); - case 213: return textSpanEndingAtNextToken(node, node.expression); - case 214: - return spanInInitializerOfForLike(node); - case 219: + case 211: + return spanInNode(node.statement); + case 224: + return textSpan(node.getChildAt(0)); + case 210: return textSpanEndingAtNextToken(node, node.expression); - case 254: - case 255: - return spanInNode(node.statements[0]); - case 222: - return spanInBlock(node.tryBlock); case 221: + return spanInNode(node.statement); + case 217: + case 216: + return textSpan(node.getChildAt(0), node.label); + case 213: + return spanInForStatement(node); + case 214: + return textSpanEndingAtNextToken(node, node.expression); + case 215: + return spanInInitializerOfForLike(node); + case 220: + return textSpanEndingAtNextToken(node, node.expression); + case 256: + case 257: + return spanInNode(node.statements[0]); + case 223: + return spanInBlock(node.tryBlock); + case 222: return textSpan(node, node.expression); - case 241: - return textSpan(node, node.expression); - case 235: - return textSpan(node, node.moduleReference); - case 236: - return textSpan(node, node.moduleSpecifier); case 242: + return textSpan(node, node.expression); + case 236: + return textSpan(node, node.moduleReference); + case 237: return textSpan(node, node.moduleSpecifier); - case 231: + case 243: + return textSpan(node, node.moduleSpecifier); + case 232: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 227: - case 230: - case 261: - case 174: - return textSpan(node); - case 218: - return spanInNode(node.statement); - case 145: - return spanInNodeArray(node.parent.decorators); - case 172: - case 173: - return spanInBindingPattern(node); case 228: + case 231: + case 263: + case 175: + return textSpan(node); + case 219: + return spanInNode(node.statement); + case 146: + return spanInNodeArray(node.parent.decorators); + case 173: + case 174: + return spanInBindingPattern(node); case 229: + case 230: return undefined; case 24: case 1: @@ -53727,20 +56369,20 @@ var ts; case 73: case 86: return spanInNextNode(node); - case 140: + case 141: return spanInOfKeyword(node); default: if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); } if ((node.kind === 70 || - node.kind == 196 || - node.kind === 258 || - node.kind === 259) && + node.kind == 197 || + node.kind === 260 || + node.kind === 261) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 192) { + if (node.kind === 193) { var binaryExpression = node; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); @@ -53755,38 +56397,38 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 210: + case 211: return spanInPreviousNode(node); - case 145: + case 146: return spanInNode(node.parent); - case 212: - case 214: + case 213: + case 215: return textSpan(node); - case 192: + case 193: if (node.parent.operatorToken.kind === 25) { return textSpan(node); } break; - case 185: + case 186: if (node.parent.body === node) { return textSpan(node); } break; } } - if (node.parent.kind === 258 && + if (node.parent.kind === 260 && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 182 && node.parent.type === node) { + if (node.parent.kind === 183 && node.parent.type === node) { return spanInNextNode(node.parent.type); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); } - if ((node.parent.kind === 224 || - node.parent.kind === 144)) { + if ((node.parent.kind === 225 || + node.parent.kind === 145)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -53794,7 +56436,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 192) { + if (node.parent.kind === 193) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -53815,7 +56457,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 213) { + if (variableDeclaration.parent.parent.kind === 214) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -53823,7 +56465,7 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 214) { + variableDeclaration.parent.parent.kind === 215) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -53855,7 +56497,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 227 && functionDeclaration.kind !== 150); + (functionDeclaration.parent.kind === 228 && functionDeclaration.kind !== 151); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -53875,22 +56517,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 231: + case 232: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 211: - case 209: - case 213: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 212: + case 210: case 214: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 213: + case 215: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 225) { + if (forLikeStatement.initializer.kind === 226) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -53912,62 +56554,62 @@ var ts; } } function spanInBindingPattern(bindingPattern) { - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 198 ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 199 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - if (bindingPattern.parent.kind === 174) { + if (bindingPattern.parent.kind === 175) { return textSpan(bindingPattern.parent); } return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 173 && node.kind !== 172); - var elements = node.kind === 175 ? + ts.Debug.assert(node.kind !== 174 && node.kind !== 173); + var elements = node.kind === 176 ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 198 ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 199 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - return textSpan(node.parent.kind === 192 ? node.parent : node); + return textSpan(node.parent.kind === 193 ? node.parent : node); } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 230: + case 231: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 227: + case 228: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 233: + case 234: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 232: + case 233: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 230: - case 227: + case 231: + case 228: return textSpan(node); - case 205: + case 206: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 257: + case 259: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 233: + case 234: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 172: + case 173: var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -53980,7 +56622,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 173: + case 174: var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -53992,33 +56634,33 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 210 || - node.parent.kind === 179 || - node.parent.kind === 180) { + if (node.parent.kind === 211 || + node.parent.kind === 180 || + node.parent.kind === 181) { return spanInPreviousNode(node); } - if (node.parent.kind === 183) { + if (node.parent.kind === 184) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 184: - case 226: case 185: - case 149: - case 148: - case 151: - case 152: + case 227: + case 186: case 150: - case 211: - case 210: + case 149: + case 152: + case 153: + case 151: case 212: - case 214: - case 179: + case 211: + case 213: + case 215: case 180: - case 183: + case 181: + case 184: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -54026,26 +56668,26 @@ var ts; } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || - node.parent.kind === 258 || - node.parent.kind === 144) { + node.parent.kind === 260 || + node.parent.kind === 145) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 182) { + if (node.parent.kind === 183) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 210) { + if (node.parent.kind === 211) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 214) { + if (node.parent.kind === 215) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -54076,7 +56718,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 124 || - keyword2 === 133 || + keyword2 === 134 || keyword2 === 122 || keyword2 === 114) { return true; @@ -54192,10 +56834,10 @@ var ts; angleBracketStack--; } else if (token === 118 || - token === 134 || + token === 135 || token === 132 || token === 121 || - token === 135) { + token === 136) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { token = 70; } @@ -54350,7 +56992,7 @@ var ts; } } function isKeyword(token) { - return token >= 71 && token <= 140; + return token >= 71 && token <= 141; } function classFromKind(token) { if (isKeyword(token)) { @@ -54396,10 +57038,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { - case 231: - case 227: + case 232: case 228: - case 226: + case 229: + case 227: cancellationToken.throwIfCancellationRequested(); } } @@ -54443,7 +57085,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 231 && + return declaration.kind === 232 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -54454,7 +57096,7 @@ var ts; checkForClassificationCancellation(cancellationToken, kind); if (kind === 70 && !ts.nodeIsMissing(node)) { var identifier = node; - if (classifiableNames[identifier.text]) { + if (classifiableNames.get(identifier.text)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var type = classifySymbol(symbol, ts.getMeaningFromLocation(node)); @@ -54584,16 +57226,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 282: + case 285: processJSDocParameterTag(tag); break; - case 285: + case 288: processJSDocTemplateTag(tag); break; - case 284: + case 287: processElement(tag.typeExpression); break; - case 283: + case 286: processElement(tag.typeExpression); break; } @@ -54674,22 +57316,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 249: + case 250: if (token.parent.tagName === token) { return 19; } break; - case 250: + case 251: if (token.parent.tagName === token) { return 20; } break; - case 248: + case 249: if (token.parent.tagName === token) { return 21; } break; - case 251: + case 252: if (token.parent.name === token) { return 22; } @@ -54709,17 +57351,17 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 57) { - if (token.parent.kind === 224 || - token.parent.kind === 147 || - token.parent.kind === 144 || - token.parent.kind === 251) { + if (token.parent.kind === 225 || + token.parent.kind === 148 || + token.parent.kind === 145 || + token.parent.kind === 252) { return 5; } } - if (token.parent.kind === 192 || - token.parent.kind === 190 || + if (token.parent.kind === 193 || token.parent.kind === 191 || - token.parent.kind === 193) { + token.parent.kind === 192 || + token.parent.kind === 194) { return 5; } } @@ -54729,7 +57371,7 @@ var ts; return 4; } else if (tokenKind === 9) { - return token.parent.kind === 251 ? 24 : 6; + return token.parent.kind === 252 ? 24 : 6; } else if (tokenKind === 11) { return 6; @@ -54743,32 +57385,32 @@ var ts; else if (tokenKind === 70) { if (token) { switch (token.parent.kind) { - case 227: + case 228: if (token.parent.name === token) { return 11; } return; - case 143: + case 144: if (token.parent.name === token) { return 15; } return; - case 228: + case 229: if (token.parent.name === token) { return 13; } return; - case 230: + case 231: if (token.parent.name === token) { return 12; } return; - case 231: + case 232: if (token.parent.name === token) { return 14; } return; - case 144: + case 145: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 : 17; } @@ -54801,10 +57443,10 @@ var ts; (function (Completions) { function getCompletionsAtPosition(host, typeChecker, log, compilerOptions, sourceFile, position) { if (ts.isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position); + return getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); } if (ts.isInString(sourceFile, position)) { - return getStringLiteralCompletionEntries(sourceFile, position); + return getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log); } var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (!completionData) { @@ -54816,13 +57458,13 @@ var ts; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, true); - ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, true, typeChecker, compilerOptions.target, log); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target)); } else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 && - location.parent && location.parent.kind === 250) { + location.parent && location.parent.kind === 251) { var tagName = location.parent.parent.openingElement.tagName; entries.push({ name: tagName.text, @@ -54835,531 +57477,535 @@ var ts; return undefined; } } - getCompletionEntriesFromSymbols(symbols, entries, location, true); + getCompletionEntriesFromSymbols(symbols, entries, location, true, typeChecker, compilerOptions.target, log); } if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { - var entries = []; - var nameTable = ts.getNameTable(sourceFile); - for (var name_45 in nameTable) { - if (nameTable[name_45] === position) { - continue; + } + Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames, target) { + var entries = []; + var nameTable = ts.getNameTable(sourceFile); + nameTable.forEach(function (pos, name) { + if (pos === position) { + return; + } + if (!uniqueNames.get(name)) { + uniqueNames.set(name, name); + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name), target, true); + if (displayName) { + var entry = { + name: displayName, + kind: ts.ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } - if (!uniqueNames[name_45]) { - uniqueNames[name_45] = name_45; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_45), compilerOptions.target, true); - if (displayName) { - var entry = { - name: displayName, - kind: ts.ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; + } + }); + return entries; + } + function createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target) { + var displayName = getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, target, performCharacterChecks, location); + if (!displayName) { + return undefined; + } + return { + name: displayName, + kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), + kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), + sortText: "0", + }; + } + function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks, typeChecker, target, log) { + var start = ts.timestamp(); + var uniqueNames = ts.createMap(); + if (symbols) { + for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { + var symbol = symbols_4[_i]; + var entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + if (entry) { + var id = ts.escapeIdentifier(entry.name); + if (!uniqueNames.get(id)) { entries.push(entry); + uniqueNames.set(id, id); } } } - return entries; } - function createCompletionEntry(symbol, location, performCharacterChecks) { - var displayName = getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, compilerOptions.target, performCharacterChecks, location); - if (!displayName) { - return undefined; + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); + return uniqueNames; + } + function getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log) { + var node = ts.findPrecedingToken(position, sourceFile); + if (!node || node.kind !== 9) { + return undefined; + } + if (node.parent.kind === 260 && + node.parent.parent.kind === 177 && + node.parent.name === node) { + return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent, typeChecker, compilerOptions.target, log); + } + else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { + return getStringLiteralCompletionEntriesFromElementAccess(node.parent, typeChecker, compilerOptions.target, log); + } + else if (node.parent.kind === 237 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + return getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); + } + else if (isEqualityExpression(node.parent)) { + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.left === node ? node.parent.right : node.parent.left), typeChecker); + } + else if (ts.isCaseOrDefaultClause(node.parent)) { + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.parent.parent.expression), typeChecker); + } + else { + var argumentInfo = ts.SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); + if (argumentInfo) { + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker); } - return { - name: displayName, - kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0", - }; + return getStringLiteralCompletionEntriesFromType(typeChecker.getContextualType(node), typeChecker); } - function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { - var start = ts.timestamp(); - var uniqueNames = ts.createMap(); - if (symbols) { - for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { - var symbol = symbols_4[_i]; - var entry = createCompletionEntry(symbol, location, performCharacterChecks); - if (entry) { - var id = ts.escapeIdentifier(entry.name); - if (!uniqueNames[id]) { - entries.push(entry); - uniqueNames[id] = id; + } + function getStringLiteralCompletionEntriesFromPropertyAssignment(element, typeChecker, target, log) { + var type = typeChecker.getContextualType(element.parent); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + } + } + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker) { + var candidates = []; + var entries = []; + typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); + for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { + var candidate = candidates_3[_i]; + addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries, typeChecker); + } + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; + } + return undefined; + } + function getStringLiteralCompletionEntriesFromElementAccess(node, typeChecker, target, log) { + var type = typeChecker.getTypeAtLocation(node.expression); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + } + return undefined; + } + function getStringLiteralCompletionEntriesFromType(type, typeChecker) { + if (type) { + var entries = []; + addStringLiteralCompletionsFromType(type, entries, typeChecker); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; + } + } + return undefined; + } + function addStringLiteralCompletionsFromType(type, result, typeChecker) { + if (type && type.flags & 16384) { + type = typeChecker.getApparentType(type); + } + if (!type) { + return; + } + if (type.flags & 65536) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + addStringLiteralCompletionsFromType(t, result, typeChecker); + } + } + else if (type.flags & 32) { + result.push({ + name: type.text, + kindModifiers: ts.ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.variableElement, + sortText: "0" + }); + } + } + function getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker) { + var literalValue = ts.normalizeSlashes(node.text); + var scriptPath = node.getSourceFile().path; + var scriptDirectory = ts.getDirectoryPath(scriptPath); + var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); + var entries; + if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { + var extensions = ts.getSupportedExtensions(compilerOptions); + if (compilerOptions.rootDirs) { + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, false, span, compilerOptions, host, scriptPath); + } + else { + entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, false, span, host, scriptPath); + } + } + else { + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); + } + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: entries + }; + } + function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { + rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); + var relativeDirectory; + for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { + var rootDirectory = rootDirs_1[_i]; + if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + break; + } + } + return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); + } + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, compilerOptions, host, exclude) { + var basePath = compilerOptions.project || host.getCurrentDirectory(); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + var result = []; + for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { + var baseDirectory = baseDirectories_1[_i]; + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); + } + return result; + } + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, host, exclude, result) { + if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); + fragment = ts.getDirectoryPath(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; + } + fragment = ts.ensureTrailingDirectorySeparator(fragment); + var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); + var baseDirectory = ts.getDirectoryPath(absolutePath); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + if (tryDirectoryExists(host, baseDirectory)) { + var files = tryReadDirectory(host, baseDirectory, extensions, undefined, ["./*"]); + if (files) { + var foundFiles = ts.createMap(); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var filePath = files_3[_i]; + filePath = ts.normalizePath(filePath); + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0) { + continue; + } + var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + if (!foundFiles.get(foundFileName)) { + foundFiles.set(foundFileName, true); + } + } + ts.forEachKey(foundFiles, function (foundFile) { + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); + }); + } + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { + var directory = directories_2[_a]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); + } + } + } + return result; + } + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span, compilerOptions, host, typeChecker) { + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var result; + if (baseUrl) { + var fileExtensions = ts.getSupportedExtensions(compilerOptions); + var projectDir = compilerOptions.project || host.getCurrentDirectory(); + var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); + result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, false, span, host); + if (paths) { + for (var path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { + var pattern = _a[_i]; + for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { + var match = _c[_b]; + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + else if (ts.startsWith(path, fragment)) { + var entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); + } } } } } - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); - return uniqueNames; } - function getStringLiteralCompletionEntries(sourceFile, position) { - var node = ts.findPrecedingToken(position, sourceFile); - if (!node || node.kind !== 9) { - return undefined; + else { + result = []; + } + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); + for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { + var moduleName = _e[_d]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + return result; + } + function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { + if (host.readDirectory) { + var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; + if (parsed) { + var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); + var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); + var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; + var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; + var normalizedSuffix = ts.normalizePath(parsed.suffix); + var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); + var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + var includeGlob = normalizedSuffix ? "**/*" : "./*"; + var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); + if (matches) { + var result = []; + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; + var normalizedMatch = ts.normalizePath(match); + if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { + continue; + } + var start = completePrefix.length; + var length_5 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); + } + return result; + } } - if (node.parent.kind === 258 && - node.parent.parent.kind === 176 && - node.parent.name === node) { - return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); + } + return undefined; + } + function enumeratePotentialNonRelativeModules(fragment, scriptPath, options, typeChecker, host) { + var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; + var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; + var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); + var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); + if (isNestedModule) { + var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { + if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { + return moduleName.substr(moduleNameWithSeperator_1.length); + } + return moduleName; + }); + } + if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { + for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { + var visibleModule = _a[_i]; + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.moduleName); + } + else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { + var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, undefined, ["./*"]); + if (nestedFiles) { + for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { + var f = nestedFiles_1[_b]; + f = ts.normalizePath(f); + var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + } + } + } } - else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { - return getStringLiteralCompletionEntriesFromElementAccess(node.parent); - } - else if (node.parent.kind === 236 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { - return getStringLiteralCompletionEntriesFromModuleNames(node); + } + return ts.deduplicate(nonRelativeModules); + } + function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { + var token = ts.getTokenAtPosition(sourceFile, position); + if (!token) { + return undefined; + } + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + if (!commentRanges || !commentRanges.length) { + return undefined; + } + var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); + if (!range) { + return undefined; + } + var completionInfo = { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: [] + }; + var text = sourceFile.text.substr(range.pos, position - range.pos); + var match = tripleSlashDirectiveFragmentRegex.exec(text); + if (match) { + var prefix = match[1]; + var kind = match[2]; + var toComplete = match[3]; + var scriptPath = ts.getDirectoryPath(sourceFile.path); + if (kind === "path") { + var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, host, sourceFile.path); } else { - var argumentInfo = ts.SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); - if (argumentInfo) { - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); - } - return getStringLiteralCompletionEntriesFromContextualType(node); + var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); } } - function getStringLiteralCompletionEntriesFromPropertyAssignment(element) { - var type = typeChecker.getContextualType(element.parent); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + return completionInfo; + } + function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { + if (result === void 0) { result = []; } + if (options.types) { + for (var _i = 0, _a = options.types; _i < _a.length; _i++) { + var moduleName = _a[_i]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + } + else if (host.getDirectories) { + var typeRoots = void 0; + try { + typeRoots = ts.getEffectiveTypeRoots(options, host); + } + catch (e) { } + if (typeRoots) { + for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { + var root = typeRoots_2[_b]; + getCompletionEntriesFromDirectories(host, root, span, result); } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo) { - var candidates = []; - var entries = []; - typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); - for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { - var candidate = candidates_3[_i]; - if (candidate.parameters.length > argumentInfo.argumentIndex) { - var parameter = candidate.parameters[argumentInfo.argumentIndex]; - addStringLiteralCompletionsFromType(typeChecker.getTypeAtLocation(parameter.valueDeclaration), entries); + if (host.getDirectories) { + for (var _c = 0, _d = findPackageJsons(scriptPath, host); _c < _d.length; _c++) { + var packageJson = _d[_c]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, typesDir, span, result); + } + } + return result; + } + function getCompletionEntriesFromDirectories(host, directory, span, result) { + if (host.getDirectories && tryDirectoryExists(host, directory)) { + var directories = tryGetDirectories(host, directory); + if (directories) { + for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { + var typeDirectory = directories_3[_i]; + typeDirectory = ts.normalizePath(typeDirectory); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); } } - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; - } - return undefined; } - function getStringLiteralCompletionEntriesFromElementAccess(node) { - var type = typeChecker.getTypeAtLocation(node.expression); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + function findPackageJsons(currentDir, host) { + var paths = []; + var currentConfigPath; + while (true) { + currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + currentDir = ts.getDirectoryPath(currentConfigPath); + var parent = ts.getDirectoryPath(currentDir); + if (currentDir === parent) { + break; } - } - return undefined; - } - function getStringLiteralCompletionEntriesFromContextualType(node) { - var type = typeChecker.getContextualType(node); - if (type) { - var entries_2 = []; - addStringLiteralCompletionsFromType(type, entries_2); - if (entries_2.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; - } - } - return undefined; - } - function addStringLiteralCompletionsFromType(type, result) { - if (type && type.flags & 16384) { - type = typeChecker.getApparentType(type); - } - if (!type) { - return; - } - if (type.flags & 65536) { - ts.forEach(type.types, function (t) { return addStringLiteralCompletionsFromType(t, result); }); + currentDir = parent; } else { - if (type.flags & 32) { + break; + } + } + return paths; + } + function enumerateNodeModulesVisibleToScript(host, scriptPath) { + var result = []; + if (host.readFile && host.fileExists) { + for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + var packageJson = _a[_i]; + var contents = tryReadingPackageJson(packageJson); + if (!contents) { + return; + } + var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); + var foundModuleNames = []; + for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { + var key = nodeModulesDependencyKeys_1[_b]; + addPotentialPackageNames(contents[key], foundModuleNames); + } + for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { + var moduleName = foundModuleNames_1[_c]; + var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); result.push({ - name: type.text, - kindModifiers: ts.ScriptElementKindModifier.none, - kind: ts.ScriptElementKind.variableElement, - sortText: "0" + moduleName: moduleName, + moduleDir: moduleDir }); } } } - function getStringLiteralCompletionEntriesFromModuleNames(node) { - var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; - var scriptDirectory = ts.getDirectoryPath(scriptPath); - var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); - var entries; - if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { - if (compilerOptions.rootDirs) { - entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), false, span, scriptPath); - } - else { - entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), false, span, scriptPath); - } + return result; + function tryReadingPackageJson(filePath) { + try { + var fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; } - else { - entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); - } - return { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: entries - }; - } - function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { - rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); - var relativeDirectory; - for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { - var rootDirectory = rootDirs_1[_i]; - if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { - relativeDirectory = scriptPath.substr(rootDirectory.length); - break; - } - } - return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); - } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, exclude) { - var basePath = compilerOptions.project || host.getCurrentDirectory(); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); - var result = []; - for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { - var baseDirectory = baseDirectories_1[_i]; - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, exclude, result); - } - return result; - } - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, exclude, result) { - if (result === void 0) { result = []; } - if (fragment === undefined) { - fragment = ""; - } - fragment = ts.normalizeSlashes(fragment); - fragment = ts.getDirectoryPath(fragment); - if (fragment === "") { - fragment = "." + ts.directorySeparator; - } - fragment = ts.ensureTrailingDirectorySeparator(fragment); - var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); - var baseDirectory = ts.getDirectoryPath(absolutePath); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (tryDirectoryExists(host, baseDirectory)) { - var files = tryReadDirectory(host, baseDirectory, extensions, undefined, ["./*"]); - if (files) { - var foundFiles = ts.createMap(); - for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { - var filePath = files_3[_i]; - filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0) { - continue; - } - var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); - if (!foundFiles[foundFileName]) { - foundFiles[foundFileName] = true; - } - } - for (var foundFile in foundFiles) { - result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); - } - } - var directories = tryGetDirectories(host, baseDirectory); - if (directories) { - for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { - var directory = directories_2[_a]; - var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); - } - } - } - return result; - } - function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span) { - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var result; - if (baseUrl) { - var fileExtensions = ts.getSupportedExtensions(compilerOptions); - var projectDir = compilerOptions.project || host.getCurrentDirectory(); - var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, false, span); - if (paths) { - for (var path in paths) { - if (paths.hasOwnProperty(path)) { - if (path === "*") { - if (paths[path]) { - for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { - var pattern = _a[_i]; - for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions); _b < _c.length; _b++) { - var match = _c[_b]; - result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - else if (ts.startsWith(path, fragment)) { - var entry = paths[path] && paths[path].length === 1 && paths[path][0]; - if (entry) { - result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - } - } - else { - result = []; - } - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions); _d < _e.length; _d++) { - var moduleName = _e[_d]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - return result; - } - function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions) { - if (host.readDirectory) { - var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; - if (parsed) { - var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); - var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); - var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); - var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; - var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; - var normalizedSuffix = ts.normalizePath(parsed.suffix); - var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); - var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); - if (matches) { - var result = []; - for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { - var match = matches_1[_i]; - var normalizedMatch = ts.normalizePath(match); - if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { - continue; - } - var start = completePrefix.length; - var length_5 = normalizedMatch.length - start - normalizedSuffix.length; - result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); - } - return result; - } - } - } - return undefined; - } - function enumeratePotentialNonRelativeModules(fragment, scriptPath, options) { - var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; - var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; - var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); - var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); - if (isNestedModule) { - var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); - nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { - if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { - return moduleName.substr(moduleNameWithSeperator_1.length); - } - return moduleName; - }); - } - if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { - for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { - var visibleModule = _a[_i]; - if (!isNestedModule) { - nonRelativeModules.push(visibleModule.moduleName); - } - else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { - var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, undefined, ["./*"]); - if (nestedFiles) { - for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { - var f = nestedFiles_1[_b]; - f = ts.normalizePath(f); - var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); - nonRelativeModules.push(nestedModule); - } - } - } - } - } - return ts.deduplicate(nonRelativeModules); - } - function getTripleSlashReferenceCompletion(sourceFile, position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (!token) { + catch (e) { return undefined; } - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - if (!commentRanges || !commentRanges.length) { - return undefined; - } - var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); - if (!range) { - return undefined; - } - var completionInfo = { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: [] - }; - var text = sourceFile.text.substr(range.pos, position - range.pos); - var match = tripleSlashDirectiveFragmentRegex.exec(text); - if (match) { - var prefix = match[1]; - var kind = match[2]; - var toComplete = match[3]; - var scriptPath = ts.getDirectoryPath(sourceFile.path); - if (kind === "path") { - var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, sourceFile.path); - } - else { - var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); - } - } - return completionInfo; } - function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { - if (result === void 0) { result = []; } - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch (e) { } - if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, root, span, result); + function addPotentialPackageNames(dependencies, result) { + if (dependencies) { + for (var dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { + result.push(dep); } } } - if (host.getDirectories) { - for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { - var packageJson = _d[_c]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, typesDir, span, result); - } - } - return result; - } - function getCompletionEntriesFromDirectories(host, directory, span, result) { - if (host.getDirectories && tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { - var typeDirectory = directories_3[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - function findPackageJsons(currentDir) { - var paths = []; - var currentConfigPath; - while (true) { - currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_14 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_14) { - break; - } - currentDir = parent_14; - } - else { - break; - } - } - return paths; - } - function enumerateNodeModulesVisibleToScript(host, scriptPath) { - var result = []; - if (host.readFile && host.fileExists) { - for (var _i = 0, _a = findPackageJsons(scriptPath); _i < _a.length; _i++) { - var packageJson = _a[_i]; - var contents = tryReadingPackageJson(packageJson); - if (!contents) { - return; - } - var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); - var foundModuleNames = []; - for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { - var key = nodeModulesDependencyKeys_1[_b]; - addPotentialPackageNames(contents[key], foundModuleNames); - } - for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { - var moduleName = foundModuleNames_1[_c]; - var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName: moduleName, - moduleDir: moduleDir - }); - } - } - } - return result; - function tryReadingPackageJson(filePath) { - try { - var fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; - } - catch (e) { - return undefined; - } - } - function addPotentialPackageNames(dependencies, result) { - if (dependencies) { - for (var dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { - result.push(dep); - } - } - } - } - } - function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; - } - function getDirectoryFragmentTextSpan(text, textStart) { - var index = text.lastIndexOf(ts.directorySeparator); - var offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset }; - } - function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 ? 2 : 1; - var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 || slashCharCode === 92; - } - return false; - } - function normalizeAndPreserveTrailingSlash(path) { - return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); } } - Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function createCompletionEntryForModule(name, kind, replacementSpan) { + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; + } + function getDirectoryFragmentTextSpan(text, textStart) { + var index = text.lastIndexOf(ts.directorySeparator); + var offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset }; + } + function isPathRelativeToScript(path) { + if (path && path.length >= 2 && path.charCodeAt(0) === 46) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 ? 2 : 1; + var slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === 47 || slashCharCode === 92; + } + return false; + } + function normalizeAndPreserveTrailingSlash(path) { + return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); + } function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_3 = completionData.location; - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_3) === entryName ? s : undefined; }); + var symbols = completionData.symbols, location_1 = completionData.location; + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_1) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_3, location_3, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), @@ -55385,8 +58031,8 @@ var ts; function getCompletionEntrySymbol(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_4 = completionData.location; - return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_4) === entryName ? s : undefined; }); + var symbols = completionData.symbols, location_2 = completionData.location; + return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_2) === entryName ? s : undefined; }); } return undefined; } @@ -55411,9 +58057,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 284: - case 282: - case 283: + case 287: + case 285: + case 286: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -55448,13 +58094,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_15 = contextToken.parent, kind = contextToken.kind; + var parent = contextToken.parent, kind = contextToken.kind; if (kind === 22) { - if (parent_15.kind === 177) { + if (parent.kind === 178) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_15.kind === 141) { + else if (parent.kind === 142) { node = contextToken.parent.left; isRightOfDot = true; } @@ -55463,13 +58109,25 @@ var ts; } } else if (sourceFile.languageVariant === 1) { - if (kind === 26) { - isRightOfOpenTag = true; - location = contextToken; - } - else if (kind === 40 && contextToken.parent.kind === 250) { - isStartingCloseTag = true; - location = contextToken; + switch (contextToken.parent.kind) { + case 251: + if (kind === 40) { + isStartingCloseTag = true; + location = contextToken; + } + break; + case 193: + if (!(contextToken.parent.left.flags & 32768)) { + break; + } + case 249: + case 248: + case 250: + if (kind === 26) { + isRightOfOpenTag = true; + location = contextToken; + } + break; } } } @@ -55512,7 +58170,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 70 || node.kind === 141 || node.kind === 177) { + if (node.kind === 70 || node.kind === 142 || node.kind === 178) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -55558,10 +58216,10 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 248) || (jsxContainer.kind === 249)) { - attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + if ((jsxContainer.kind === 249) || (jsxContainer.kind === 250)) { + attrsType = typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); if (attrsType) { - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); + symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes.properties); isMemberCompletion = true; isNewIdentifierLocation = false; return true; @@ -55579,9 +58237,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 262 || - scopeNode.kind === 194 || - scopeNode.kind === 253 || + scopeNode.kind === 264 || + scopeNode.kind === 195 || + scopeNode.kind === 255 || ts.isStatement(scopeNode); } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; @@ -55609,11 +58267,11 @@ var ts; return true; } if (contextToken.kind === 28 && contextToken.parent) { - if (contextToken.parent.kind === 249) { + if (contextToken.parent.kind === 250) { return true; } - if (contextToken.parent.kind === 250 || contextToken.parent.kind === 248) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 247; + if (contextToken.parent.kind === 251 || contextToken.parent.kind === 249) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 248; } } return false; @@ -55623,40 +58281,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 25: - return containingNodeKind === 179 - || containingNodeKind === 150 - || containingNodeKind === 180 - || containingNodeKind === 175 - || containingNodeKind === 192 - || containingNodeKind === 158; + return containingNodeKind === 180 + || containingNodeKind === 151 + || containingNodeKind === 181 + || containingNodeKind === 176 + || containingNodeKind === 193 + || containingNodeKind === 159; case 18: - return containingNodeKind === 179 - || containingNodeKind === 150 - || containingNodeKind === 180 - || containingNodeKind === 183 - || containingNodeKind === 166; + return containingNodeKind === 180 + || containingNodeKind === 151 + || containingNodeKind === 181 + || containingNodeKind === 184 + || containingNodeKind === 167; case 20: - return containingNodeKind === 175 - || containingNodeKind === 155 - || containingNodeKind === 142; + return containingNodeKind === 176 + || containingNodeKind === 156 + || containingNodeKind === 143; case 127: case 128: return true; case 22: - return containingNodeKind === 231; + return containingNodeKind === 232; case 16: - return containingNodeKind === 227; + return containingNodeKind === 228; case 57: - return containingNodeKind === 224 - || containingNodeKind === 192; + return containingNodeKind === 225 + || containingNodeKind === 193; case 13: - return containingNodeKind === 194; + return containingNodeKind === 195; case 14: - return containingNodeKind === 203; + return containingNodeKind === 204; case 113: case 111: case 112: - return containingNodeKind === 147; + return containingNodeKind === 148; } switch (previousToken.getText()) { case "public": @@ -55687,22 +58345,22 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 176) { + if (objectLikeContainer.kind === 177) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 172) { + else if (objectLikeContainer.kind === 173) { isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (ts.isVariableLike(rootDeclaration)) { var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 144) { + if (!canGetType && rootDeclaration.kind === 145) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 149 || rootDeclaration.parent.kind === 152) { + else if (rootDeclaration.parent.kind === 150 || rootDeclaration.parent.kind === 153) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -55728,9 +58386,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 239 ? - 236 : - 242; + var declarationKind = namedImportsOrExports.kind === 240 ? + 237 : + 243; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -55738,12 +58396,13 @@ var ts; } isMemberCompletion = true; isNewIdentifierLocation = false; - var exports; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); + if (!moduleSpecifierSymbol) { + symbols = ts.emptyArray; + return true; } - symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : ts.emptyArray; + var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); + symbols = filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements); return true; } function tryGetObjectLikeCompletionContainer(contextToken) { @@ -55751,9 +58410,9 @@ var ts; switch (contextToken.kind) { case 16: case 25: - var parent_16 = contextToken.parent; - if (parent_16 && (parent_16.kind === 176 || parent_16.kind === 172)) { - return parent_16; + var parent = contextToken.parent; + if (parent && (parent.kind === 177 || parent.kind === 173)) { + return parent; } break; } @@ -55766,8 +58425,8 @@ var ts; case 16: case 25: switch (contextToken.parent.kind) { - case 239: - case 243: + case 240: + case 244: return contextToken.parent; } } @@ -55776,34 +58435,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_17 = contextToken.parent; + var parent = contextToken.parent; switch (contextToken.kind) { case 27: case 40: case 70: - case 251: + case 253: case 252: - if (parent_17 && (parent_17.kind === 248 || parent_17.kind === 249)) { - return parent_17; + case 254: + if (parent && (parent.kind === 249 || parent.kind === 250)) { + return parent; } - else if (parent_17.kind === 251) { - return parent_17.parent; + else if (parent.kind === 252) { + return parent.parent.parent; } break; case 9: - if (parent_17 && ((parent_17.kind === 251) || (parent_17.kind === 252))) { - return parent_17.parent; + if (parent && ((parent.kind === 252) || (parent.kind === 254))) { + return parent.parent.parent; } break; case 17: - if (parent_17 && - parent_17.kind === 253 && - parent_17.parent && - (parent_17.parent.kind === 251)) { - return parent_17.parent.parent; + if (parent && + parent.kind === 255 && + parent.parent && parent.parent.kind === 252) { + return parent.parent.parent.parent; } - if (parent_17 && parent_17.kind === 252) { - return parent_17.parent; + if (parent && parent.kind === 254) { + return parent.parent.parent; } break; } @@ -55812,16 +58471,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 184: case 185: - case 226: + case 186: + case 227: + case 150: case 149: - case 148: - case 151: case 152: case 153: case 154: case 155: + case 156: return true; } return false; @@ -55830,66 +58489,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25: - return containingNodeKind === 224 || - containingNodeKind === 225 || - containingNodeKind === 206 || - containingNodeKind === 230 || + return containingNodeKind === 225 || + containingNodeKind === 226 || + containingNodeKind === 207 || + containingNodeKind === 231 || isFunction(containingNodeKind) || - containingNodeKind === 227 || - containingNodeKind === 197 || containingNodeKind === 228 || - containingNodeKind === 173 || - containingNodeKind === 229; + containingNodeKind === 198 || + containingNodeKind === 229 || + containingNodeKind === 174 || + containingNodeKind === 230; case 22: - return containingNodeKind === 173; - case 55: return containingNodeKind === 174; + case 55: + return containingNodeKind === 175; case 20: - return containingNodeKind === 173; + return containingNodeKind === 174; case 18: - return containingNodeKind === 257 || + return containingNodeKind === 259 || isFunction(containingNodeKind); case 16: - return containingNodeKind === 230 || - containingNodeKind === 228 || - containingNodeKind === 161; - case 24: - return containingNodeKind === 146 && - contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 228 || - contextToken.parent.parent.kind === 161); - case 26: - return containingNodeKind === 227 || - containingNodeKind === 197 || - containingNodeKind === 228 || + return containingNodeKind === 231 || containingNodeKind === 229 || + containingNodeKind === 162; + case 24: + return containingNodeKind === 147 && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 229 || + contextToken.parent.parent.kind === 162); + case 26: + return containingNodeKind === 228 || + containingNodeKind === 198 || + containingNodeKind === 229 || + containingNodeKind === 230 || isFunction(containingNodeKind); case 114: - return containingNodeKind === 147; + return containingNodeKind === 148; case 23: - return containingNodeKind === 144 || + return containingNodeKind === 145 || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 173); + contextToken.parent.parent.kind === 174); case 113: case 111: case 112: - return containingNodeKind === 144; + return containingNodeKind === 145; case 117: - return containingNodeKind === 240 || - containingNodeKind === 244 || - containingNodeKind === 238; + return containingNodeKind === 241 || + containingNodeKind === 245 || + containingNodeKind === 239; case 74: case 82: case 108: case 88: case 103: case 124: - case 133: + case 134: case 90: case 109: case 75: case 115: - case 136: + case 137: return true; } switch (contextToken.getText()) { @@ -55926,13 +58585,13 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_46 = element.propertyName || element.name; - existingImportsOrExports[name_46.text] = true; + var name = element.propertyName || element.name; + existingImportsOrExports.set(name.text, true); } - if (!ts.someProperties(existingImportsOrExports)) { + if (existingImportsOrExports.size === 0) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); } - return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports[e.name]; }); + return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports.get(e.name); }); } function filterObjectMembersList(contextualMemberSymbols, existingMembers) { if (!existingMembers || existingMembers.length === 0) { @@ -55941,19 +58600,19 @@ var ts; var existingMemberNames = ts.createMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; - if (m.kind !== 258 && - m.kind !== 259 && - m.kind !== 174 && - m.kind !== 149 && - m.kind !== 151 && - m.kind !== 152) { + if (m.kind !== 260 && + m.kind !== 261 && + m.kind !== 175 && + m.kind !== 150 && + m.kind !== 152 && + m.kind !== 153) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 174 && m.propertyName) { + if (m.kind === 175 && m.propertyName) { if (m.propertyName.kind === 70) { existingName = m.propertyName.text; } @@ -55961,9 +58620,9 @@ var ts; else { existingName = m.name.text; } - existingMemberNames[existingName] = true; + existingMemberNames.set(existingName, true); } - return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames[m.name]; }); + return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames.get(m.name); }); } function filterJsxAttributes(symbols, attributes) { var seenNames = ts.createMap(); @@ -55972,11 +58631,11 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 251) { - seenNames[attr.name.text] = true; + if (attr.kind === 252) { + seenNames.set(attr.name.text, true); } } - return ts.filter(symbols, function (a) { return !seenNames[a.name]; }); + return ts.filter(symbols, function (a) { return !seenNames.get(a.name); }); } } function getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, target, performCharacterChecks, location) { @@ -56005,7 +58664,7 @@ var ts; return name; } var keywordCompletions = []; - for (var i = 71; i <= 140; i++) { + for (var i = 71; i <= 141; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -56045,6 +58704,15 @@ var ts; catch (e) { } return undefined; } + function isEqualityExpression(node) { + return ts.isBinaryExpression(node) && isEqualityOperatorKind(node.operatorToken.kind); + } + function isEqualityOperatorKind(kind) { + return kind == 31 || + kind === 32 || + kind === 33 || + kind === 34; + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); var ts; @@ -56053,495 +58721,480 @@ var ts; (function (DocumentHighlights) { function getDocumentHighlights(typeChecker, cancellationToken, sourceFile, position, sourceFilesToSearch) { var node = ts.getTouchingWord(sourceFile, position); + return node && (getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) || getSyntacticDocumentHighlights(node, sourceFile)); + } + DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + function getHighlightSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var end = node.getEnd(); + return { + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(start, end), + kind: ts.HighlightSpanKind.none + }; + } + function getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) { + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch); + return referencedSymbols && convertReferencedSymbols(referencedSymbols); + } + function convertReferencedSymbols(referencedSymbols) { + var fileNameToDocumentHighlights = ts.createMap(); + var result = []; + for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { + var referencedSymbol = referencedSymbols_1[_i]; + for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { + var referenceEntry = _b[_a]; + var fileName = referenceEntry.fileName; + var documentHighlights = fileNameToDocumentHighlights.get(fileName); + if (!documentHighlights) { + documentHighlights = { fileName: fileName, highlightSpans: [] }; + fileNameToDocumentHighlights.set(fileName, documentHighlights); + result.push(documentHighlights); + } + documentHighlights.highlightSpans.push({ + textSpan: referenceEntry.textSpan, + kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference + }); + } + } + return result; + } + function getSyntacticDocumentHighlights(node, sourceFile) { + var highlightSpans = getHighlightSpans(node, sourceFile); + if (!highlightSpans || highlightSpans.length === 0) { + return undefined; + } + return [{ fileName: sourceFile.fileName, highlightSpans: highlightSpans }]; + } + function hasKind(node, kind) { + return node !== undefined && node.kind === kind; + } + function parent(node) { + return node && node.parent; + } + function getHighlightSpans(node, sourceFile) { if (!node) { return undefined; } - return getSemanticDocumentHighlights(node) || getSyntacticDocumentHighlights(node); - function getHighlightSpanForNode(node) { - var start = node.getStart(); - var end = node.getEnd(); - return { - fileName: sourceFile.fileName, - textSpan: ts.createTextSpanFromBounds(start, end), - kind: ts.HighlightSpanKind.none - }; + switch (node.kind) { + case 89: + case 81: + if (hasKind(node.parent, 210)) { + return getIfElseOccurrences(node.parent, sourceFile); + } + break; + case 95: + if (hasKind(node.parent, 218)) { + return highlightSpans(getReturnOccurrences(node.parent)); + } + break; + case 99: + if (hasKind(node.parent, 222)) { + return highlightSpans(getThrowOccurrences(node.parent)); + } + break; + case 101: + case 73: + case 86: + var tryStatement = node.kind === 73 ? parent(parent(node)) : parent(node); + if (hasKind(tryStatement, 223)) { + return highlightSpans(getTryCatchFinallyOccurrences(tryStatement, sourceFile)); + } + break; + case 97: + if (hasKind(node.parent, 220)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent)); + } + break; + case 72: + case 78: + if (hasKind(parent(parent(parent(node))), 220)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent.parent.parent)); + } + break; + case 71: + case 76: + if (hasKind(node.parent, 217) || hasKind(node.parent, 216)) { + return highlightSpans(getBreakOrContinueStatementOccurrences(node.parent)); + } + break; + case 87: + if (hasKind(node.parent, 213) || + hasKind(node.parent, 214) || + hasKind(node.parent, 215)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case 105: + case 80: + if (hasKind(node.parent, 212) || hasKind(node.parent, 211)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case 122: + if (hasKind(node.parent, 151)) { + return highlightSpans(getConstructorOccurrences(node.parent)); + } + break; + case 124: + case 134: + if (hasKind(node.parent, 152) || hasKind(node.parent, 153)) { + return highlightSpans(getGetAndSetOccurrences(node.parent)); + } + break; + default: + if (ts.isModifierKind(node.kind) && node.parent && + (ts.isDeclaration(node.parent) || node.parent.kind === 207)) { + return highlightSpans(getModifierOccurrences(node.kind, node.parent)); + } } - function getSemanticDocumentHighlights(node) { - if (node.kind === 70 || - node.kind === 98 || - node.kind === 167 || - node.kind === 96 || - node.kind === 9 || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, false, false, false); - return convertReferencedSymbols(referencedSymbols); - } - return undefined; - function convertReferencedSymbols(referencedSymbols) { - if (!referencedSymbols) { - return undefined; - } - var fileNameToDocumentHighlights = ts.createMap(); - var result = []; - for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { - var referencedSymbol = referencedSymbols_1[_i]; - for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { - var referenceEntry = _b[_a]; - var fileName = referenceEntry.fileName; - var documentHighlights = fileNameToDocumentHighlights[fileName]; - if (!documentHighlights) { - documentHighlights = { fileName: fileName, highlightSpans: [] }; - fileNameToDocumentHighlights[fileName] = documentHighlights; - result.push(documentHighlights); - } - documentHighlights.highlightSpans.push({ - textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference - }); - } - } - return result; - } + function highlightSpans(nodes) { + return nodes && nodes.map(function (node) { return getHighlightSpanForNode(node, sourceFile); }); } - function getSyntacticDocumentHighlights(node) { - var fileName = sourceFile.fileName; - var highlightSpans = getHighlightSpans(node); - if (!highlightSpans || highlightSpans.length === 0) { - return undefined; + } + function aggregateOwnedThrowStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 222) { + statementAccumulator.push(node); } - return [{ fileName: fileName, highlightSpans: highlightSpans }]; - function hasKind(node, kind) { - return node !== undefined && node.kind === kind; - } - function parent(node) { - return node && node.parent; - } - function getHighlightSpans(node) { - if (node) { - switch (node.kind) { - case 89: - case 81: - if (hasKind(node.parent, 209)) { - return getIfElseOccurrences(node.parent); - } - break; - case 95: - if (hasKind(node.parent, 217)) { - return getReturnOccurrences(node.parent); - } - break; - case 99: - if (hasKind(node.parent, 221)) { - return getThrowOccurrences(node.parent); - } - break; - case 73: - if (hasKind(parent(parent(node)), 222)) { - return getTryCatchFinallyOccurrences(node.parent.parent); - } - break; - case 101: - case 86: - if (hasKind(parent(node), 222)) { - return getTryCatchFinallyOccurrences(node.parent); - } - break; - case 97: - if (hasKind(node.parent, 219)) { - return getSwitchCaseDefaultOccurrences(node.parent); - } - break; - case 72: - case 78: - if (hasKind(parent(parent(parent(node))), 219)) { - return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); - } - break; - case 71: - case 76: - if (hasKind(node.parent, 216) || hasKind(node.parent, 215)) { - return getBreakOrContinueStatementOccurrences(node.parent); - } - break; - case 87: - if (hasKind(node.parent, 212) || - hasKind(node.parent, 213) || - hasKind(node.parent, 214)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 105: - case 80: - if (hasKind(node.parent, 211) || hasKind(node.parent, 210)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 122: - if (hasKind(node.parent, 150)) { - return getConstructorOccurrences(node.parent); - } - break; - case 124: - case 133: - if (hasKind(node.parent, 151) || hasKind(node.parent, 152)) { - return getGetAndSetOccurrences(node.parent); - } - break; - default: - if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 206)) { - return getModifierOccurrences(node.kind, node.parent); - } - } - } - return undefined; - } - function aggregateOwnedThrowStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 221) { - statementAccumulator.push(node); - } - else if (node.kind === 222) { - var tryStatement = node; - if (tryStatement.catchClause) { - aggregate(tryStatement.catchClause); - } - else { - aggregate(tryStatement.tryBlock); - } - if (tryStatement.finallyBlock) { - aggregate(tryStatement.finallyBlock); - } - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, aggregate); - } - } - } - function getThrowStatementOwner(throwStatement) { - var child = throwStatement; - while (child.parent) { - var parent_18 = child.parent; - if (ts.isFunctionBlock(parent_18) || parent_18.kind === 262) { - return parent_18; - } - if (parent_18.kind === 222) { - var tryStatement = parent_18; - if (tryStatement.tryBlock === child && tryStatement.catchClause) { - return child; - } - } - child = parent_18; - } - return undefined; - } - function aggregateAllBreakAndContinueStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 216 || node.kind === 215) { - statementAccumulator.push(node); - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, aggregate); - } - } - } - function ownsBreakOrContinueStatement(owner, statement) { - var actualOwner = getBreakOrContinueOwner(statement); - return actualOwner && actualOwner === owner; - } - function getBreakOrContinueOwner(statement) { - for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { - switch (node_2.kind) { - case 219: - if (statement.kind === 215) { - continue; - } - case 212: - case 213: - case 214: - case 211: - case 210: - if (!statement.label || isLabeledBy(node_2, statement.label.text)) { - return node_2; - } - break; - default: - if (ts.isFunctionLike(node_2)) { - return undefined; - } - break; - } - } - return undefined; - } - function getModifierOccurrences(modifier, declaration) { - var container = declaration.parent; - if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 227 || - container.kind === 197 || - (declaration.kind === 144 && hasKind(container, 150)))) { - return undefined; - } - } - else if (modifier === 114) { - if (!(container.kind === 227 || container.kind === 197)) { - return undefined; - } - } - else if (modifier === 83 || modifier === 123) { - if (!(container.kind === 232 || container.kind === 262)) { - return undefined; - } - } - else if (modifier === 116) { - if (!(container.kind === 227 || declaration.kind === 227)) { - return undefined; - } + else if (node.kind === 223) { + var tryStatement = node; + if (tryStatement.catchClause) { + aggregate(tryStatement.catchClause); } else { - return undefined; - } - var keywords = []; - var modifierFlag = getFlagFromModifier(modifier); - var nodes; - switch (container.kind) { - case 232: - case 262: - if (modifierFlag & 128) { - nodes = declaration.members.concat(declaration); - } - else { - nodes = container.statements; - } - break; - case 150: - nodes = container.parameters.concat(container.parent.members); - break; - case 227: - case 197: - nodes = container.members; - if (modifierFlag & 28) { - var constructor = ts.forEach(container.members, function (member) { - return member.kind === 150 && member; - }); - if (constructor) { - nodes = nodes.concat(constructor.parameters); - } - } - else if (modifierFlag & 128) { - nodes = nodes.concat(container); - } - break; - default: - ts.Debug.fail("Invalid container kind."); - } - ts.forEach(nodes, function (node) { - if (ts.getModifierFlags(node) & modifierFlag) { - ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - function getFlagFromModifier(modifier) { - switch (modifier) { - case 113: - return 4; - case 111: - return 8; - case 112: - return 16; - case 114: - return 32; - case 83: - return 1; - case 123: - return 2; - case 116: - return 128; - default: - ts.Debug.fail(); - } - } - } - function pushKeywordIf(keywordList, token) { - var expected = []; - for (var _i = 2; _i < arguments.length; _i++) { - expected[_i - 2] = arguments[_i]; - } - if (token && ts.contains(expected, token.kind)) { - keywordList.push(token); - return true; - } - return false; - } - function getGetAndSetOccurrences(accessorDeclaration) { - var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 151); - tryPushAccessorKeyword(accessorDeclaration.symbol, 152); - 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, 124, 133); }); - } - } - } - function getConstructorOccurrences(constructorDeclaration) { - var declarations = constructorDeclaration.symbol.getDeclarations(); - var keywords = []; - ts.forEach(declarations, function (declaration) { - ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 122); - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getLoopBreakContinueOccurrences(loopNode) { - var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { - if (loopNode.kind === 210) { - var loopTokens = loopNode.getChildren(); - for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 105)) { - break; - } - } - } - } - var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71, 76); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { - var owner = getBreakOrContinueOwner(breakOrContinueStatement); - if (owner) { - switch (owner.kind) { - case 212: - case 213: - case 214: - case 210: - case 211: - return getLoopBreakContinueOccurrences(owner); - case 219: - return getSwitchCaseDefaultOccurrences(owner); - } - } - return undefined; - } - function getSwitchCaseDefaultOccurrences(switchStatement) { - var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 97); - ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 72, 78); - var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71); - } - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getTryCatchFinallyOccurrences(tryStatement) { - var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 101); - if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73); + aggregate(tryStatement.tryBlock); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 86); + aggregate(tryStatement.finallyBlock); } - return ts.map(keywords, getHighlightSpanForNode); } - function getThrowOccurrences(throwStatement) { - var owner = getThrowStatementOwner(throwStatement); - if (!owner) { - return undefined; - } - var keywords = []; - ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); - }); - if (ts.isFunctionBlock(owner)) { - ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); - }); - } - return ts.map(keywords, getHighlightSpanForNode); - } - function getReturnOccurrences(returnStatement) { - var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 205))) { - return undefined; - } - var keywords = []; - ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); - }); - ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getIfElseOccurrences(ifStatement) { - var keywords = []; - while (hasKind(ifStatement.parent, 209) && ifStatement.parent.elseStatement === ifStatement) { - ifStatement = ifStatement.parent; - } - while (ifStatement) { - var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 89); - for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 81)) { - break; - } - } - if (!hasKind(ifStatement.elseStatement, 209)) { - break; - } - ifStatement = ifStatement.elseStatement; - } - var result = []; - for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 81 && i < keywords.length - 1) { - var elseKeyword = keywords[i]; - var ifKeyword = keywords[i + 1]; - var shouldCombindElseAndIf = true; - for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { - if (!ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { - shouldCombindElseAndIf = false; - break; - } - } - if (shouldCombindElseAndIf) { - result.push({ - fileName: fileName, - textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: ts.HighlightSpanKind.reference - }); - i++; - continue; - } - } - result.push(getHighlightSpanForNode(keywords[i])); - } - return result; + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); } } } - DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + function getThrowStatementOwner(throwStatement) { + var child = throwStatement; + while (child.parent) { + var parent_2 = child.parent; + if (ts.isFunctionBlock(parent_2) || parent_2.kind === 264) { + return parent_2; + } + if (parent_2.kind === 223) { + var tryStatement = parent_2; + if (tryStatement.tryBlock === child && tryStatement.catchClause) { + return child; + } + } + child = parent_2; + } + return undefined; + } + function aggregateAllBreakAndContinueStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 217 || node.kind === 216) { + statementAccumulator.push(node); + } + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); + } + } + } + function ownsBreakOrContinueStatement(owner, statement) { + var actualOwner = getBreakOrContinueOwner(statement); + return actualOwner && actualOwner === owner; + } + function getBreakOrContinueOwner(statement) { + for (var node = statement.parent; node; node = node.parent) { + switch (node.kind) { + case 220: + if (statement.kind === 216) { + continue; + } + case 213: + case 214: + case 215: + case 212: + case 211: + if (!statement.label || isLabeledBy(node, statement.label.text)) { + return node; + } + break; + default: + if (ts.isFunctionLike(node)) { + return undefined; + } + break; + } + } + return undefined; + } + function getModifierOccurrences(modifier, declaration) { + var container = declaration.parent; + if (ts.isAccessibilityModifier(modifier)) { + if (!(container.kind === 228 || + container.kind === 198 || + (declaration.kind === 145 && hasKind(container, 151)))) { + return undefined; + } + } + else if (modifier === 114) { + if (!(container.kind === 228 || container.kind === 198)) { + return undefined; + } + } + else if (modifier === 83 || modifier === 123) { + if (!(container.kind === 233 || container.kind === 264)) { + return undefined; + } + } + else if (modifier === 116) { + if (!(container.kind === 228 || declaration.kind === 228)) { + return undefined; + } + } + else { + return undefined; + } + var keywords = []; + var modifierFlag = getFlagFromModifier(modifier); + var nodes; + switch (container.kind) { + case 233: + case 264: + if (modifierFlag & 128) { + nodes = declaration.members.concat(declaration); + } + else { + nodes = container.statements; + } + break; + case 151: + nodes = container.parameters.concat(container.parent.members); + break; + case 228: + case 198: + nodes = container.members; + if (modifierFlag & 28) { + var constructor = ts.forEach(container.members, function (member) { + return member.kind === 151 && member; + }); + if (constructor) { + nodes = nodes.concat(constructor.parameters); + } + } + else if (modifierFlag & 128) { + nodes = nodes.concat(container); + } + break; + default: + ts.Debug.fail("Invalid container kind."); + } + ts.forEach(nodes, function (node) { + if (ts.getModifierFlags(node) & modifierFlag) { + ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); + } + }); + return keywords; + function getFlagFromModifier(modifier) { + switch (modifier) { + case 113: + return 4; + case 111: + return 8; + case 112: + return 16; + case 114: + return 32; + case 83: + return 1; + case 123: + return 2; + case 116: + return 128; + default: + ts.Debug.fail(); + } + } + } + function pushKeywordIf(keywordList, token) { + var expected = []; + for (var _i = 2; _i < arguments.length; _i++) { + expected[_i - 2] = arguments[_i]; + } + if (token && ts.contains(expected, token.kind)) { + keywordList.push(token); + return true; + } + return false; + } + function getGetAndSetOccurrences(accessorDeclaration) { + var keywords = []; + tryPushAccessorKeyword(accessorDeclaration.symbol, 152); + tryPushAccessorKeyword(accessorDeclaration.symbol, 153); + return keywords; + function tryPushAccessorKeyword(accessorSymbol, accessorKind) { + var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); + if (accessor) { + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124, 134); }); + } + } + } + function getConstructorOccurrences(constructorDeclaration) { + var declarations = constructorDeclaration.symbol.getDeclarations(); + var keywords = []; + ts.forEach(declarations, function (declaration) { + ts.forEach(declaration.getChildren(), function (token) { + return pushKeywordIf(keywords, token, 122); + }); + }); + return keywords; + } + function getLoopBreakContinueOccurrences(loopNode) { + var keywords = []; + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { + if (loopNode.kind === 211) { + var loopTokens = loopNode.getChildren(); + for (var i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], 105)) { + break; + } + } + } + } + var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(loopNode, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71, 76); + } + }); + return keywords; + } + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { + var owner = getBreakOrContinueOwner(breakOrContinueStatement); + if (owner) { + switch (owner.kind) { + case 213: + case 214: + case 215: + case 211: + case 212: + return getLoopBreakContinueOccurrences(owner); + case 220: + return getSwitchCaseDefaultOccurrences(owner); + } + } + return undefined; + } + function getSwitchCaseDefaultOccurrences(switchStatement) { + var keywords = []; + pushKeywordIf(keywords, switchStatement.getFirstToken(), 97); + ts.forEach(switchStatement.caseBlock.clauses, function (clause) { + pushKeywordIf(keywords, clause.getFirstToken(), 72, 78); + var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(switchStatement, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71); + } + }); + }); + return keywords; + } + function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { + var keywords = []; + pushKeywordIf(keywords, tryStatement.getFirstToken(), 101); + if (tryStatement.catchClause) { + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73); + } + if (tryStatement.finallyBlock) { + var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 86); + } + return keywords; + } + function getThrowOccurrences(throwStatement) { + var owner = getThrowStatementOwner(throwStatement); + if (!owner) { + return undefined; + } + var keywords = []; + ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); + }); + if (ts.isFunctionBlock(owner)) { + ts.forEachReturnStatement(owner, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); + }); + } + return keywords; + } + function getReturnOccurrences(returnStatement) { + var func = ts.getContainingFunction(returnStatement); + if (!(func && hasKind(func.body, 206))) { + return undefined; + } + var keywords = []; + ts.forEachReturnStatement(func.body, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); + }); + ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); + }); + return keywords; + } + function getIfElseOccurrences(ifStatement, sourceFile) { + var keywords = []; + while (hasKind(ifStatement.parent, 210) && ifStatement.parent.elseStatement === ifStatement) { + ifStatement = ifStatement.parent; + } + while (ifStatement) { + var children = ifStatement.getChildren(); + pushKeywordIf(keywords, children[0], 89); + for (var i = children.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, children[i], 81)) { + break; + } + } + if (!hasKind(ifStatement.elseStatement, 210)) { + break; + } + ifStatement = ifStatement.elseStatement; + } + var result = []; + for (var i = 0; i < keywords.length; i++) { + if (keywords[i].kind === 81 && i < keywords.length - 1) { + var elseKeyword = keywords[i]; + var ifKeyword = keywords[i + 1]; + var shouldCombindElseAndIf = true; + for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { + if (!ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { + shouldCombindElseAndIf = false; + break; + } + } + if (shouldCombindElseAndIf) { + result.push({ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), + kind: ts.HighlightSpanKind.reference + }); + i++; + continue; + } + } + result.push(getHighlightSpanForNode(keywords[i], sourceFile)); + } + return result; + } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 220; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 221; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -56560,15 +59213,15 @@ var ts; return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + "|" + settings.allowJs + "|" + settings.baseUrl + "|" + JSON.stringify(settings.typeRoots) + "|" + JSON.stringify(settings.rootDirs) + "|" + JSON.stringify(settings.paths); } function getBucketForCompilationSettings(key, createIfMissing) { - var bucket = buckets[key]; + var bucket = buckets.get(key); if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(); + buckets.set(key, bucket = ts.createFileMap()); } return bucket; } function reportStats() { - var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { - var entries = buckets[name]; + var bucketInfoArray = ts.arrayFrom(buckets.keys()).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { + var entries = buckets.get(name); var sourceFiles = []; entries.forEachValue(function (key, entry) { sourceFiles.push({ @@ -56656,881 +59309,937 @@ var ts; (function (ts) { var FindAllReferences; (function (FindAllReferences) { - function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments) { + function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments, isForRename) { var node = ts.getTouchingPropertyName(sourceFile, position, true); - if (node === sourceFile) { - return undefined; - } - switch (node.kind) { - case 8: - if (!ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - break; - } - case 70: - case 98: - case 122: - case 9: - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, false); - } - return undefined; + return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename); } FindAllReferences.findReferencedSymbols = findReferencedSymbols; - function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, implementations) { + function convertReferences(referenceSymbols) { + return referenceSymbols && ts.flatMap(referenceSymbols, function (r) { return r.references; }); + } + FindAllReferences.convertReferences = convertReferences; + function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename, implementations) { if (!implementations) { - if (ts.isLabelName(node)) { - if (ts.isJumpStatementTarget(node)) { - var labelDefinition = ts.getTargetLabel(node.parent, node.text); - return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; - } - else { - return getLabelReferencesInNode(node.parent, node); - } - } - if (ts.isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles); - } - if (node.kind === 96) { - return getReferencesForSuperKeyword(node); + var special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken); + if (special) { + return special; } } var symbol = typeChecker.getSymbolAtLocation(node); - if (!implementations && !symbol && node.kind === 9) { - return getReferencesForStringLiteral(node, sourceFiles); - } if (!symbol) { + if (!implementations && node.kind === 9) { + return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); + } return undefined; } var declarations = symbol.declarations; if (!declarations || !declarations.length) { return undefined; } - var result; + var _a = followAliases(symbol, node, typeChecker, isForRename), aliasedSymbol = _a.symbol, shorthandModuleSymbol = _a.shorthandModuleSymbol; + symbol = aliasedSymbol; + var searchSymbols = populateSearchSymbolSet(symbol, node, typeChecker, implementations); + if (shorthandModuleSymbol) { + searchSymbols.push(shorthandModuleSymbol); + } var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), declarations); + var result = []; + var symbolToIndex = []; + var inheritsFromCache = ts.createMap(); var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); var scope = getSymbolScope(symbol); - var symbolToIndex = []; if (scope) { - result = []; - getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + getRefs(scope, declaredName); } else { - var internedName = getInternedName(symbol, node); - for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { - var sourceFile = sourceFiles_8[_i]; + var isDefault = ts.isExportDefaultSymbol(symbol); + var internedName = isDefault ? symbol.valueDeclaration.localSymbol.name : getInternedName(symbol, node); + for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { + var sourceFile = sourceFiles_5[_i]; cancellationToken.throwIfCancellationRequested(); - var nameTable = ts.getNameTable(sourceFile); - if (nameTable[internedName] !== undefined) { - result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + var searchName = (isDefault ? getDefaultImportName(symbol, sourceFile, typeChecker) : undefined) || + (sourceFileHasName(sourceFile, internedName) ? declaredName : undefined); + if (searchName !== undefined) { + getRefs(sourceFile, searchName); } } } return result; - function getDefinition(symbol) { - var info = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node); - var name = ts.map(info.displayParts, function (p) { return p.text; }).join(""); - var declarations = symbol.declarations; - if (!declarations || declarations.length === 0) { - return undefined; - } - return { - containerKind: "", - containerName: "", - name: name, - kind: info.symbolKind, - fileName: declarations[0].getSourceFile().fileName, - textSpan: ts.createTextSpan(declarations[0].getStart(), 0), - displayParts: info.displayParts - }; + function getRefs(scope, searchName) { + getReferencesInNode(scope, symbol, searchName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache); } - function getAliasSymbolForPropertyNameSymbol(symbol, location) { - if (symbol.flags & 8388608) { - var defaultImport = ts.getDeclarationOfKind(symbol, 237); - if (defaultImport) { - return typeChecker.getAliasedSymbol(symbol); - } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 240 || - declaration.kind === 244) ? declaration : undefined; }); - if (importOrExportSpecifier && - (!importOrExportSpecifier.propertyName || - importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 240 ? - typeChecker.getAliasedSymbol(symbol) : - typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); - } + } + FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; + function getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken) { + if (ts.isTypeKeyword(node.kind)) { + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + } + if (ts.isLabelName(node)) { + if (ts.isJumpStatementTarget(node)) { + var labelDefinition = ts.getTargetLabel(node.parent, node.text); + return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, cancellationToken); } + else { + return getLabelReferencesInNode(node.parent, node, cancellationToken); + } + } + if (ts.isThis(node)) { + return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); + } + if (node.kind === 96) { + return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); + } + return undefined; + } + function followAliases(symbol, node, typeChecker, isForRename) { + while (true) { + if (isForRename && isImportDefaultSymbol(symbol)) { + return { symbol: symbol }; + } + var aliasedSymbol = getAliasSymbolForPropertyNameSymbol(symbol, node, typeChecker); + if (!aliasedSymbol || !aliasedSymbol.declarations) { + return { symbol: symbol }; + } + if (ts.isShorthandAmbientModuleSymbol(aliasedSymbol)) { + return { symbol: symbol, shorthandModuleSymbol: aliasedSymbol }; + } + symbol = aliasedSymbol; + } + } + function sourceFileHasName(sourceFile, name) { + return ts.getNameTable(sourceFile).get(name) !== undefined; + } + function getDefaultImportName(symbol, sourceFile, checker) { + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var importSpecifier = _a[_i]; + var importDecl = importSpecifier.parent; + ts.Debug.assert(importDecl.moduleSpecifier === importSpecifier); + var defaultName = importDecl.importClause.name; + var defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName)); + if (symbol === defaultReferencedSymbol) { + return defaultName.text; + } + } + return undefined; + } + function getDefinition(symbol, node, typeChecker) { + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node), displayParts = _a.displayParts, symbolKind = _a.symbolKind; + var name = displayParts.map(function (p) { return p.text; }).join(""); + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { return undefined; } - function followAliasIfNecessary(symbol, location) { - return getAliasSymbolForPropertyNameSymbol(symbol, location) || symbol; - } - function getPropertySymbolOfDestructuringAssignment(location) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - typeChecker.getPropertySymbolOfDestructuringAssignment(location); - } - function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 174); - return bindingElement && - bindingElement.parent.kind === 172 && - !bindingElement.propertyName; - } - function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 174); - var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); - } + return { + containerKind: "", + containerName: "", + name: name, + kind: symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: ts.createTextSpan(declarations[0].getStart(), 0), + displayParts: displayParts + }; + } + function getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) { + if (!(symbol.flags & 8388608)) { return undefined; } - function getInternedName(symbol, location) { - if (ts.isImportOrExportSpecifierName(location)) { - return location.getText(); - } - var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); - symbol = localExportDefaultSymbol || symbol; - return ts.stripQuotes(symbol.name); + var defaultImport = ts.getDeclarationOfKind(symbol, 238); + if (defaultImport) { + return typeChecker.getAliasedSymbol(symbol); } - function getSymbolScope(symbol) { - var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 184 || valueDeclaration.kind === 197)) { - return valueDeclaration; - } - if (symbol.flags & (4 | 8192)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); - if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 227); - } - } - if (symbol.flags & 8388608) { - return undefined; - } - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - return undefined; - } - if (symbol.parent || (symbol.flags & 268435456)) { - return undefined; - } - var scope; - var declarations = symbol.getDeclarations(); - if (declarations) { - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; - var container = ts.getContainerNode(declaration); - if (!container) { - return undefined; - } - if (scope && scope !== container) { - return undefined; - } - if (container.kind === 262 && !ts.isExternalModule(container)) { - return undefined; - } - scope = container; - } - } - return scope; + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 241 || + declaration.kind === 245) ? declaration : undefined; }); + if (importOrExportSpecifier && + (!importOrExportSpecifier.propertyName || + importOrExportSpecifier.propertyName === location)) { + return importOrExportSpecifier.kind === 241 ? + typeChecker.getAliasedSymbol(symbol) : + typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } - function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { - var positions = []; - if (!symbolName || !symbolName.length) { - return positions; + } + function followAliasIfNecessary(symbol, location, typeChecker) { + return getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) || symbol; + } + function getPropertySymbolOfDestructuringAssignment(location, typeChecker) { + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && + typeChecker.getPropertySymbolOfDestructuringAssignment(location); + } + function isObjectBindingPatternElementWithoutPropertyName(symbol) { + var bindingElement = ts.getDeclarationOfKind(symbol, 175); + return bindingElement && + bindingElement.parent.kind === 173 && + !bindingElement.propertyName; + } + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker) { + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + var bindingElement = ts.getDeclarationOfKind(symbol, 175); + var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); + return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + } + return undefined; + } + function getInternedName(symbol, location) { + if (ts.isImportOrExportSpecifierName(location)) { + return location.text; + } + return ts.stripQuotes(symbol.name); + } + function getSymbolScope(symbol) { + var valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && (valueDeclaration.kind === 185 || valueDeclaration.kind === 198)) { + return valueDeclaration; + } + if (symbol.flags & (4 | 8192)) { + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); + if (privateDeclaration) { + return ts.getAncestor(privateDeclaration, 228); } - var text = sourceFile.text; - var sourceLength = text.length; - var symbolNameLength = symbolName.length; - var position = text.indexOf(symbolName, start); - while (position >= 0) { - cancellationToken.throwIfCancellationRequested(); - if (position > end) - break; - var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5))) { - positions.push(position); + } + if (symbol.flags & 8388608) { + return undefined; + } + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + return undefined; + } + if (symbol.parent || (symbol.flags & 134217728 && symbol.checkFlags & 2)) { + return undefined; + } + var scope; + var declarations = symbol.getDeclarations(); + if (declarations) { + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; + var container = ts.getContainerNode(declaration); + if (!container) { + return undefined; } - position = text.indexOf(symbolName, position + symbolNameLength + 1); + if (scope && scope !== container) { + return undefined; + } + if (container.kind === 264 && !ts.isExternalModule(container)) { + return undefined; + } + scope = container; } + } + return scope; + } + function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end, cancellationToken) { + var positions = []; + if (!symbolName || !symbolName.length) { return positions; } - function getLabelReferencesInNode(container, targetLabel) { - var references = []; - var sourceFile = container.getSourceFile(); - var labelName = targetLabel.text; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.getWidth() !== labelName.length) { - return; - } - if (node === targetLabel || - (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ts.ScriptElementKind.label, - name: labelName, - textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()), - displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] - }; - return [{ definition: definition, references: references }]; + var text = sourceFile.text; + var sourceLength = text.length; + var symbolNameLength = symbolName.length; + var position = text.indexOf(symbolName, start); + while (position >= 0) { + cancellationToken.throwIfCancellationRequested(); + if (position > end) + break; + var endPosition = position + symbolNameLength; + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5))) { + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); } - function isValidReferencePosition(node, searchSymbolName) { - if (node) { - switch (node.kind) { - case 70: - return node.getWidth() === searchSymbolName.length; - case 9: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - return node.getWidth() === searchSymbolName.length + 2; + return positions; + } + function getLabelReferencesInNode(container, targetLabel, cancellationToken) { + var references = []; + var sourceFile = container.getSourceFile(); + var labelName = targetLabel.text; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { + return; + } + if (node === targetLabel || + (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { + references.push(getReferenceEntryFromNode(node)); + } + }); + var definition = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ts.ScriptElementKind.label, + name: labelName, + textSpan: ts.createTextSpanFromNode(targetLabel, sourceFile), + displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] + }; + return [{ definition: definition, references: references }]; + } + function isValidReferencePosition(node, searchSymbolName) { + switch (node && node.kind) { + case 70: + return node.getWidth() === searchSymbolName.length; + case 9: + return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + node.getWidth() === searchSymbolName.length + 2; + case 8: + return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; + default: + return false; + } + } + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + var name = ts.tokenToString(keywordKind); + var references = []; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var sourceFile = sourceFiles_6[_i]; + cancellationToken.throwIfCancellationRequested(); + addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); + } + if (!references.length) + return undefined; + var definition = { + containerKind: "", + containerName: "", + fileName: references[0].fileName, + kind: ts.ScriptElementKind.keyword, + name: name, + textSpan: references[0].textSpan, + displayParts: [{ text: name, kind: ts.ScriptElementKind.keyword }] + }; + return [{ definition: definition, references: references }]; + } + function addReferencesForKeywordInFile(sourceFile, kind, searchText, cancellationToken, references) { + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { + var position = possiblePositions_1[_i]; + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (referenceLocation.kind === kind) { + references.push({ + textSpan: ts.createTextSpanFromNode(referenceLocation), + fileName: sourceFile.fileName, + isWriteAccess: false, + isDefinition: false, + }); + } + } + } + function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache) { + var sourceFile = container.getSourceFile(); + var start = findInComments ? container.getFullStart() : container.getStart(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); + var parents = getParentSymbolsOfPropertyAccess(); + for (var _i = 0, possiblePositions_2 = possiblePositions; _i < possiblePositions_2.length; _i++) { + var position = possiblePositions_2[_i]; + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (!isValidReferencePosition(referenceLocation, searchText)) { + if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { + result.push({ + definition: undefined, + references: [{ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpan(position, searchText.length), + isWriteAccess: false, + isDefinition: false + }] + }); + } + continue; + } + if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { + continue; + } + var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); + if (referenceSymbol) { + var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); + var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocation.kind === 122, parents, inheritsFromCache, typeChecker); + if (relatedSymbol) { + addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); + } + else if (!(referenceSymbol.flags & 134217728) && ts.contains(searchSymbols, shorthandValueSymbol)) { + addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); + } + else if (searchLocation.kind === 122) { + findAdditionalConstructorReferences(referenceSymbol, referenceLocation); + } + } + } + return; + function getParentSymbolsOfPropertyAccess() { + if (implementations) { + var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); + if (propertyAccessExpression) { + var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); + if (localParentType) { + if (localParentType.symbol && localParentType.symbol.flags & (32 | 64) && localParentType.symbol !== searchSymbol.parent) { + return [localParentType.symbol]; } - break; - case 8: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return node.getWidth() === searchSymbolName.length; + else if (localParentType.flags & 196608) { + return getSymbolsForClassAndInterfaceComponents(localParentType); } - break; + } + } + } + } + function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { + ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); + var referenceClass = referenceLocation.parent; + if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { + ts.Debug.assert(referenceClass.name === referenceLocation); + addReferences(findOwnConstructorCalls(searchSymbol, sourceFile)); + } + else { + var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); + if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation, typeChecker) === searchSymbol) { + addReferences(superConstructorAccesses(classExtending)); + } + } + } + function addReferences(references) { + if (references.length) { + var referencedSymbol = getReferencedSymbol(searchSymbol); + ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); + } + } + function getReferencedSymbol(symbol) { + var symbolId = ts.getSymbolId(symbol); + var index = symbolToIndex[symbolId]; + if (index === undefined) { + index = result.length; + symbolToIndex[symbolId] = index; + result.push({ + definition: getDefinition(symbol, searchLocation, typeChecker), + references: [] + }); + } + return result[index]; + } + function addReferenceToRelatedSymbol(node, relatedSymbol) { + var references = getReferencedSymbol(relatedSymbol).references; + if (implementations) { + getImplementationReferenceEntryForNode(node, references, typeChecker); + } + else { + references.push(getReferenceEntryFromNode(node)); + } + } + } + function getPropertyAccessExpressionFromRightHandSide(node) { + return ts.isRightSideOfPropertyAccess(node) && node.parent; + } + function findOwnConstructorCalls(classSymbol, sourceFile) { + var result = []; + for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var ctrKeyword = ts.findChildOfKind(decl, 122, sourceFile); + ts.Debug.assert(decl.kind === 151 && !!ctrKeyword); + result.push(ctrKeyword); + } + classSymbol.exports.forEach(function (member) { + var decl = member.valueDeclaration; + if (decl && decl.kind === 150) { + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 98, function (thisKeyword) { + if (ts.isNewExpressionTarget(thisKeyword)) { + result.push(thisKeyword); + } + }); + } + } + }); + return result; + } + function superConstructorAccesses(cls) { + var symbol = cls.symbol; + var ctr = symbol.members.get("__constructor"); + if (!ctr) { + return []; + } + var result = []; + for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.Debug.assert(decl.kind === 151); + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 96, function (node) { + if (ts.isCallExpressionTarget(node)) { + result.push(node); + } + }); + } + } + ; + return result; + } + function getImplementationReferenceEntryForNode(refNode, result, typeChecker) { + if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { + result.push(getReferenceEntryFromNode(refNode.parent)); + } + else if (refNode.kind === 70) { + if (refNode.parent.kind === 261) { + getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + } + var containingClass = getContainingClassIfInHeritageClause(refNode); + if (containingClass) { + result.push(getReferenceEntryFromNode(containingClass)); + return; + } + var containingTypeReference = getContainingTypeReference(refNode); + if (containingTypeReference) { + var parent = containingTypeReference.parent; + if (ts.isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent.initializer)); + } + else if (ts.isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { + if (parent.body.kind === 206) { + ts.forEachReturnStatement(parent.body, function (returnStatement) { + if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { + maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); + } + }); + } + else if (isImplementationExpression(parent.body)) { + maybeAdd(getReferenceEntryFromNode(parent.body)); + } + } + else if (ts.isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { + maybeAdd(getReferenceEntryFromNode(parent.expression)); + } + } + } + function maybeAdd(a) { + if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { + result.push(a); + } + } + } + function getSymbolsForClassAndInterfaceComponents(type, result) { + if (result === void 0) { result = []; } + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var componentType = _a[_i]; + if (componentType.symbol && componentType.symbol.getFlags() & (32 | 64)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & 196608) { + getSymbolsForClassAndInterfaceComponents(componentType, result); + } + } + return result; + } + function getContainingTypeReference(node) { + var topLevelTypeReference = undefined; + while (node) { + if (ts.isTypeNode(node)) { + topLevelTypeReference = node; + } + node = node.parent; + } + return topLevelTypeReference; + } + function getContainingClassIfInHeritageClause(node) { + if (node && node.parent) { + if (node.kind === 200 + && node.parent.kind === 258 + && ts.isClassLike(node.parent.parent)) { + return node.parent.parent; + } + else if (node.kind === 70 || node.kind === 178) { + return getContainingClassIfInHeritageClause(node.parent); + } + } + return undefined; + } + function isImplementationExpression(node) { + switch (node.kind) { + case 184: + return isImplementationExpression(node.expression); + case 186: + case 185: + case 177: + case 198: + case 176: + return true; + default: + return false; + } + } + function explicitlyInheritsFrom(child, parent, cachedResults, typeChecker) { + var parentIsInterface = parent.getFlags() & 64; + return searchHierarchy(child); + function searchHierarchy(symbol) { + if (symbol === parent) { + return true; + } + var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); + var cached = cachedResults.get(key); + if (cached !== undefined) { + return cached; + } + cachedResults.set(key, false); + var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + if (parentIsInterface) { + var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { + var typeReference = interfaceReferences_1[_i]; + if (searchTypeReference(typeReference)) { + return true; + } + } + } + } + return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + } + else if (declaration.kind === 229) { + if (parentIsInterface) { + return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); + } + } + return false; + }); + cachedResults.set(key, inherits); + return inherits; + } + function searchTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); } } return false; } - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { - var sourceFile = container.getSourceFile(); - var start = findInComments ? container.getFullStart() : container.getStart(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd()); - var parents = getParentSymbolsOfPropertyAccess(); - var inheritsFromCache = ts.createMap(); - if (possiblePositions.length) { - var searchSymbols_1 = populateSearchSymbolSet(searchSymbol, searchLocation); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { - if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || - (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: ts.createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); - } - return; - } - if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { - return; - } - var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, searchLocation.kind === 122, parents, inheritsFromCache); - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); - } - else if (!(referenceSymbol.flags & 67108864) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); - } - else if (searchLocation.kind === 122) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); - } - } - }); - } - return; - function getParentSymbolsOfPropertyAccess() { - if (implementations) { - var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); - if (propertyAccessExpression) { - var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); - if (localParentType) { - if (localParentType.symbol && localParentType.symbol.flags & (32 | 64) && localParentType.symbol !== searchSymbol.parent) { - return [localParentType.symbol]; - } - else if (localParentType.flags & 196608) { - return getSymbolsForClassAndInterfaceComponents(localParentType); - } - } - } - } - } - function getPropertyAccessExpressionFromRightHandSide(node) { - return ts.isRightSideOfPropertyAccess(node) && node.parent; - } - function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { - ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); - var referenceClass = referenceLocation.parent; - if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { - ts.Debug.assert(referenceClass.name === referenceLocation); - addReferences(findOwnConstructorCalls(searchSymbol)); - } - else { - var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); - if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) { - addReferences(superConstructorAccesses(classExtending)); - } - } - } - function addReferences(references) { - if (references.length) { - var referencedSymbol = getReferencedSymbol(searchSymbol); - ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); - } - } - function findOwnConstructorCalls(classSymbol) { - var result = []; - for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 150); - var ctrKeyword = decl.getChildAt(0); - ts.Debug.assert(ctrKeyword.kind === 122); - result.push(ctrKeyword); - } - ts.forEachProperty(classSymbol.exports, function (member) { - var decl = member.valueDeclaration; - if (decl && decl.kind === 149) { - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 98, function (thisKeyword) { - if (ts.isNewExpressionTarget(thisKeyword)) { - result.push(thisKeyword); - } - }); - } - } - }); - return result; - } - function superConstructorAccesses(cls) { - var symbol = cls.symbol; - var ctr = symbol.members["__constructor"]; - if (!ctr) { - return []; - } - var result = []; - for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 150); - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 96, function (node) { - if (ts.isCallExpressionTarget(node)) { - result.push(node); - } - }); - } - } - ; - return result; - } - function getReferencedSymbol(symbol) { - var symbolId = ts.getSymbolId(symbol); - var index = symbolToIndex[symbolId]; - if (index === undefined) { - index = result.length; - symbolToIndex[symbolId] = index; - result.push({ - definition: getDefinition(symbol), - references: [] - }); - } - return result[index]; - } - function addReferenceToRelatedSymbol(node, relatedSymbol) { - var references = getReferencedSymbol(relatedSymbol).references; - if (implementations) { - getImplementationReferenceEntryForNode(node, references); - } - else { - references.push(getReferenceEntryFromNode(node)); - } - } - } - function getImplementationReferenceEntryForNode(refNode, result) { - if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); - } - else if (refNode.kind === 70) { - if (refNode.parent.kind === 259) { - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); - } - var containingClass = getContainingClassIfInHeritageClause(refNode); - if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); - return; - } - var containingTypeReference = getContainingTypeReference(refNode); - if (containingTypeReference) { - var parent_19 = containingTypeReference.parent; - if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_19.initializer)); - } - else if (ts.isFunctionLike(parent_19) && parent_19.type === containingTypeReference && parent_19.body) { - if (parent_19.body.kind === 205) { - ts.forEachReturnStatement(parent_19.body, function (returnStatement) { - if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); - } - }); - } - else if (isImplementationExpression(parent_19.body)) { - maybeAdd(getReferenceEntryFromNode(parent_19.body)); - } - } - else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_19.expression)); - } - } - } - function maybeAdd(a) { - if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { - result.push(a); - } - } - } - function getSymbolsForClassAndInterfaceComponents(type, result) { - if (result === void 0) { result = []; } - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var componentType = _a[_i]; - if (componentType.symbol && componentType.symbol.getFlags() & (32 | 64)) { - result.push(componentType.symbol); - } - if (componentType.getFlags() & 196608) { - getSymbolsForClassAndInterfaceComponents(componentType, result); - } - } - return result; - } - function getContainingTypeReference(node) { - var topLevelTypeReference = undefined; - while (node) { - if (ts.isTypeNode(node)) { - topLevelTypeReference = node; - } - node = node.parent; - } - return topLevelTypeReference; - } - function getContainingClassIfInHeritageClause(node) { - if (node && node.parent) { - if (node.kind === 199 - && node.parent.kind === 256 - && ts.isClassLike(node.parent.parent)) { - return node.parent.parent; - } - else if (node.kind === 70 || node.kind === 177) { - return getContainingClassIfInHeritageClause(node.parent); - } - } + } + function getReferencesForSuperKeyword(superKeyword, typeChecker, cancellationToken) { + var searchSpaceNode = ts.getSuperContainer(superKeyword, false); + if (!searchSpaceNode) { return undefined; } - function isImplementationExpression(node) { - if (node.kind === 183) { - return isImplementationExpression(node.expression); - } - return node.kind === 185 || - node.kind === 184 || - node.kind === 176 || - node.kind === 197 || - node.kind === 175; - } - function explicitlyInheritsFrom(child, parent, cachedResults) { - var parentIsInterface = parent.getFlags() & 64; - return searchHierarchy(child); - function searchHierarchy(symbol) { - if (symbol === parent) { - return true; - } - var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); - if (key in cachedResults) { - return cachedResults[key]; - } - cachedResults[key] = false; - var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - if (parentIsInterface) { - var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); - if (interfaceReferences) { - for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { - var typeReference = interfaceReferences_1[_i]; - if (searchTypeReference(typeReference)) { - return true; - } - } - } - } - return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - } - else if (declaration.kind === 228) { - if (parentIsInterface) { - return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); - } - } - return false; - }); - cachedResults[key] = inherits; - return inherits; - } - function searchTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type && type.symbol) { - return searchHierarchy(type.symbol); - } - } - return false; - } - } - function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, false); - if (!searchSpaceNode) { + var staticFlag = 32; + switch (searchSpaceNode.kind) { + case 148: + case 147: + case 150: + case 149: + case 151: + case 152: + case 153: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; + break; + default: return undefined; + } + var references = []; + var sourceFile = searchSpaceNode.getSourceFile(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + for (var _i = 0, possiblePositions_3 = possiblePositions; _i < possiblePositions_3.length; _i++) { + var position = possiblePositions_3[_i]; + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 96) { + continue; } - var staticFlag = 32; - switch (searchSpaceNode.kind) { - case 147: - case 146: - case 149: - case 148: - case 150: - case 151: - case 152: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; + var container = ts.getSuperContainer(node, false); + if (container && (32 & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(getReferenceEntryFromNode(node)); + } + } + var definition = getDefinition(searchSpaceNode.symbol, superKeyword, typeChecker); + return [{ definition: definition, references: references }]; + } + function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, typeChecker, cancellationToken) { + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); + var staticFlag = 32; + switch (searchSpaceNode.kind) { + case 150: + case 149: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; - default: + } + case 148: + case 147: + case 151: + case 152: + case 153: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; + break; + case 264: + if (ts.isExternalModule(searchSpaceNode)) { return undefined; - } - var references = []; + } + case 227: + case 185: + break; + default: + return undefined; + } + var references = []; + var possiblePositions; + if (searchSpaceNode.kind === 264) { + ts.forEach(sourceFiles, function (sourceFile) { + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { var sourceFile = searchSpaceNode.getSourceFile(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); + var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: thisOrSuperKeyword.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: "this", + textSpan: ts.createTextSpanFromNode(thisOrSuperKeyword), + displayParts: displayParts + }, + references: references + }]; + function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 96) { + if (!node || !ts.isThis(node)) { return; } - var container = ts.getSuperContainer(node, false); - if (container && (32 & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); + var container = ts.getThisContainer(node, false); + switch (searchSpaceNode.kind) { + case 185: + case 227: + if (searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 150: + case 149: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 198: + case 228: + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 264: + if (container.kind === 264 && !ts.isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); + } + break; } }); - var definition = getDefinition(searchSpaceNode.symbol); - return [{ definition: definition, references: references }]; } - function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); - var staticFlag = 32; - switch (searchSpaceNode.kind) { - case 149: - case 148: - if (ts.isObjectLiteralMethod(searchSpaceNode)) { - break; + } + function getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (!type) { + return undefined; + } + var references = []; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); + } + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: type.text, + textSpan: ts.createTextSpanFromNode(node), + displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] + }, + references: references + }]; + function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { + for (var _i = 0, possiblePositions_4 = possiblePositions; _i < possiblePositions_4.length; _i++) { + var position = possiblePositions_4[_i]; + cancellationToken.throwIfCancellationRequested(); + var node_2 = ts.getTouchingWord(sourceFile, position); + if (!node_2 || node_2.kind !== 9) { + return; + } + var type_2 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + if (type_2 === searchType) { + references.push(getReferenceEntryFromNode(node_2)); + } + } + } + } + function populateSearchSymbolSet(symbol, location, typeChecker, implementations) { + var result = [symbol]; + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 261) { + var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, typeChecker); + if (propertySymbol) { + result.push(propertySymbol); + } + } + if (containingObjectLiteralElement) { + ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { + ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); + }); + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } + } + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 145 && + ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + ts.addRange(result, typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); + } + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker); + if (bindingElementPropertySymbol) { + result.push(bindingElementPropertySymbol); + } + for (var _i = 0, _a = typeChecker.getRootSymbols(symbol); _i < _a.length; _i++) { + var rootSymbol = _a[_i]; + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap(), typeChecker); + } + } + return result; + } + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, typeChecker) { + if (!symbol) { + return; + } + if (previousIterationSymbolsCache.has(symbol.name)) { + return; + } + if (symbol.flags & (32 | 64)) { + ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === 229) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); + } + }); + } + return; + function getPropertySymbolFromTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type) { + var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); + if (propertySymbol) { + result.push.apply(result, typeChecker.getRootSymbols(propertySymbol)); } - case 147: - case 146: - case 150: - case 151: - case 152: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; - break; - case 262: - if (ts.isExternalModule(searchSpaceNode)) { + previousIterationSymbolsCache.set(symbol.name, symbol); + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, typeChecker); + } + } + } + } + function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker) { + if (ts.contains(searchSymbols, referenceSymbol)) { + return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) ? referenceSymbol : undefined; + } + var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation, typeChecker); + if (aliasSymbol) { + return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker); + } + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { + return ts.find(typeChecker.getRootSymbols(contextualSymbol), function (symbol) { return ts.contains(searchSymbols, symbol); }); + }); + if (contextualSymbol) { + return contextualSymbol; + } + var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, typeChecker); + if (propertySymbol && ts.contains(searchSymbols, propertySymbol)) { + return propertySymbol; + } + } + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, typeChecker); + if (bindingElementPropertySymbol && ts.contains(searchSymbols, bindingElementPropertySymbol)) { + return bindingElementPropertySymbol; + } + return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { + if (ts.contains(searchSymbols, rootSymbol)) { + return rootSymbol; + } + if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + if (parents) { + if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache, typeChecker); })) { return undefined; } - case 226: - case 184: - break; - default: - return undefined; - } - var references = []; - var possiblePositions; - if (searchSpaceNode.kind === 262) { - ts.forEach(sourceFiles, function (sourceFile) { - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); - }); - } - else { - var sourceFile = searchSpaceNode.getSourceFile(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); - } - var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: "this", - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: displayParts - }, - references: references - }]; - function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || !ts.isThis(node)) { - return; - } - var container = ts.getThisContainer(node, false); - switch (searchSpaceNode.kind) { - case 184: - case 226: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 149: - case 148: - if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 197: - case 227: - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 262: - if (container.kind === 262 && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); - } - } - function getReferencesForStringLiteral(node, sourceFiles) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (!type) { - return undefined; - } - var references = []; - for (var _i = 0, sourceFiles_9 = sourceFiles; _i < sourceFiles_9.length; _i++) { - var sourceFile = sourceFiles_9[_i]; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd()); - getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); - } - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: type.text, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] - }, - references: references - }]; - function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { - for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { - var position = possiblePositions_1[_i]; - cancellationToken.throwIfCancellationRequested(); - var node_3 = ts.getTouchingWord(sourceFile, position); - if (!node_3 || node_3.kind !== 9) { - return; - } - var type_1 = ts.getStringLiteralTypeForNode(node_3, typeChecker); - if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_3)); - } } + var result = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap(), typeChecker); + return ts.find(result, function (symbol) { return ts.contains(searchSymbols, symbol); }); } - } - function populateSearchSymbolSet(symbol, location) { - var result = [symbol]; - var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 259) { - var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); - if (propertySymbol) { - result.push(propertySymbol); - } - } - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(symbol, location); - if (aliasSymbol) { - result = result.concat(populateSearchSymbolSet(aliasSymbol, location)); - } - if (containingObjectLiteralElement) { - ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (contextualSymbol) { - ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); - }); - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); - } - } - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 144 && - ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { - result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); - } - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol); - if (bindingElementPropertySymbol) { - result.push(bindingElementPropertySymbol); - } - ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap()); - } - }); - return result; - } - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache) { - if (!symbol) { - return; - } - if (symbol.name in previousIterationSymbolsCache) { - return; - } - if (symbol.flags & (32 | 64)) { - ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === 228) { - ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); - } - }); - } - return; - function getPropertySymbolFromTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type) { - var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); - if (propertySymbol) { - result.push.apply(result, typeChecker.getRootSymbols(propertySymbol)); - } - previousIterationSymbolsCache[symbol.name] = symbol; - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); - } - } - } - } - function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache) { - if (ts.contains(searchSymbols, referenceSymbol)) { - return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) && referenceSymbol; - } - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); - if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache); - } - var containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); - if (containingObjectLiteralElement) { - var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (contextualSymbol) { - return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - }); - if (contextualSymbol) { - return contextualSymbol; - } - var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation); - if (propertySymbol && searchSymbols.indexOf(propertySymbol) >= 0) { - return propertySymbol; - } - } - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol); - if (bindingElementPropertySymbol && searchSymbols.indexOf(bindingElementPropertySymbol) >= 0) { - return bindingElementPropertySymbol; - } - return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { - if (searchSymbols.indexOf(rootSymbol) >= 0) { - return rootSymbol; - } - if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - if (parents) { - if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache); })) { - return undefined; - } - } - var result_4 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_4, ts.createMap()); - return ts.forEach(result_4, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - } - return undefined; - }); - } - function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 142) { - var nameExpression = node.name.expression; - if (ts.isStringOrNumericLiteral(nameExpression)) { - return nameExpression.text; - } - return undefined; - } - return node.name.text; - } - function getPropertySymbolsFromContextualType(node) { - var objectLiteral = node.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - var name = getNameFromObjectLiteralElement(node); - if (name && contextualType) { - var result_5 = []; - var symbol_2 = contextualType.getProperty(name); - if (symbol_2) { - result_5.push(symbol_2); - } - if (contextualType.flags & 65536) { - ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name); - if (symbol) { - result_5.push(symbol); - } - }); - } - return result_5; + return undefined; + }); + } + function getNameFromObjectLiteralElement(node) { + if (node.name.kind === 143) { + var nameExpression = node.name.expression; + if (ts.isStringOrNumericLiteral(nameExpression)) { + return nameExpression.text; } return undefined; } - function getIntersectingMeaningFromDeclarations(meaning, declarations) { - if (declarations) { - var lastIterationMeaning = void 0; - do { - lastIterationMeaning = meaning; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; - var declarationMeaning = ts.getMeaningFromDeclaration(declaration); - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; - } - } - } while (meaning !== lastIterationMeaning); + return node.name.text; + } + function getPropertySymbolsFromContextualType(node, typeChecker) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + var result_4 = []; + var symbol = contextualType.getProperty(name); + if (symbol) { + result_4.push(symbol); } - return meaning; + if (contextualType.flags & 65536) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_4.push(symbol); + } + }); + } + return result_4; } + return undefined; } - FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; - function convertReferences(referenceSymbols) { - if (!referenceSymbols) { - return undefined; + function getIntersectingMeaningFromDeclarations(meaning, declarations) { + if (declarations) { + var lastIterationMeaning = void 0; + do { + lastIterationMeaning = meaning; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + var declarationMeaning = ts.getMeaningFromDeclaration(declaration); + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } while (meaning !== lastIterationMeaning); } - var referenceEntries = []; - for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) { - var referenceSymbol = referenceSymbols_1[_i]; - ts.addRange(referenceEntries, referenceSymbol.references); - } - return referenceEntries; + return meaning; } - FindAllReferences.convertReferences = convertReferences; function isImplementation(node) { if (!node) { return false; @@ -57539,7 +60248,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 224) { + else if (node.kind === 225) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2); } @@ -57549,18 +60258,18 @@ var ts; } else { switch (node.kind) { - case 227: - case 197: - case 230: + case 228: + case 198: case 231: + case 232: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 206) { - ts.Debug.assert(node.parent.kind === 225); + if (node.parent && node.parent.parent && node.parent.parent.kind === 207) { + ts.Debug.assert(node.parent.kind === 226); return node.parent.parent; } } @@ -57598,10 +60307,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 191 || parent.kind === 190) { + if (parent.kind === 192 || parent.kind === 191) { return true; } - else if (parent.kind === 192 && parent.left === node) { + else if (parent.kind === 193 && parent.left === node) { var operator = parent.operatorToken.kind; return 57 <= operator && operator <= 69; } @@ -57616,29 +60325,6 @@ var ts; forEachDescendantOfKind(child, kind, action); }); } - function getContainingObjectLiteralElement(node) { - switch (node.kind) { - case 9: - case 8: - if (node.parent.kind === 142) { - return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; - } - case 70: - return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; - } - return undefined; - } - function isObjectLiteralPropertyDeclaration(node) { - switch (node.kind) { - case 258: - case 259: - case 149: - case 151: - case 152: - return true; - } - return false; - } function tryGetClassByExtendingIdentifier(node) { return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); } @@ -57648,6 +60334,9 @@ var ts; } return false; } + function isImportDefaultSymbol(symbol) { + return symbol.declarations[0].kind === 238; + } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); var ts; @@ -57665,11 +60354,9 @@ var ts; } var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { - var referenceFile = program.getResolvedTypeReferenceDirectives()[typeReferenceDirective.fileName]; - if (referenceFile && referenceFile.resolvedFileName) { - return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; - } - return undefined; + var referenceFile = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); + return referenceFile && referenceFile.resolvedFileName && + [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; } var node = ts.getTouchingPropertyName(sourceFile, position); if (node === sourceFile) { @@ -57678,7 +60365,7 @@ var ts; if (ts.isJumpStatementTarget(node)) { var labelName = node.text; var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ts.ScriptElementKind.label, labelName, undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, ts.ScriptElementKind.label, labelName, undefined)] : undefined; } var typeChecker = program.getTypeChecker(); var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); @@ -57693,11 +60380,11 @@ var ts; var declaration = symbol.declarations[0]; if (node.kind === 70 && (node.parent === declaration || - (declaration.kind === 240 && declaration.parent && declaration.parent.kind === 239))) { + (declaration.kind === 241 && declaration.parent && declaration.parent.kind === 240))) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 259) { + if (node.parent.kind === 261) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -57708,6 +60395,22 @@ var ts; var shorthandContainerName_1 = typeChecker.symbolToString(symbol.parent, node); return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind_1, shorthandSymbolName_1, shorthandContainerName_1); }); } + if (ts.isJsxOpeningLikeElement(node.parent)) { + var _a = getSymbolInfo(typeChecker, symbol, node), symbolName = _a.symbolName, symbolKind = _a.symbolKind, containerName = _a.containerName; + return [createDefinitionInfo(symbol.valueDeclaration, symbolKind, symbolName, containerName)]; + } + var element = ts.getContainingObjectLiteralElement(node); + if (element) { + if (typeChecker.getContextualType(element.parent)) { + var result = []; + var propertySymbols = ts.getPropertySymbolsFromContextualType(typeChecker, element); + for (var _i = 0, propertySymbols_1 = propertySymbols; _i < propertySymbols_1.length; _i++) { + var propertySymbol = propertySymbols_1[_i]; + result.push.apply(result, getDefinitionFromSymbol(typeChecker, propertySymbol, node)); + } + return result; + } + } return getDefinitionFromSymbol(typeChecker, symbol, node); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; @@ -57725,13 +60428,13 @@ var ts; return undefined; } if (type.flags & 65536 && !(type.flags & 16)) { - var result_6 = []; + var result_5 = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(result_6, getDefinitionFromSymbol(typeChecker, t.symbol, node)); + ts.addRange(result_5, getDefinitionFromSymbol(typeChecker, t.symbol, node)); } }); - return result_6; + return result_5; } if (!type.symbol) { return undefined; @@ -57773,29 +60476,40 @@ var ts; function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { var declarations = []; var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 150) || - (!selectConstructors && (d.kind === 226 || d.kind === 149 || d.kind === 148))) { + for (var _i = 0, signatureDeclarations_1 = signatureDeclarations; _i < signatureDeclarations_1.length; _i++) { + var d = signatureDeclarations_1[_i]; + if (selectConstructors ? d.kind === 151 : isSignatureDeclaration(d)) { declarations.push(d); if (d.body) definition = d; } - }); - if (definition) { - result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); - return true; } - else if (declarations.length) { - result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); + if (declarations.length) { + result.push(createDefinitionInfo(definition || ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); return true; } return false; } } + function isSignatureDeclaration(node) { + switch (node.kind) { + case 151: + case 227: + case 150: + case 149: + return true; + default: + return false; + } + } function createDefinitionInfo(node, symbolKind, symbolName, containerName) { + return createDefinitionInfoFromName(node.name || node, symbolKind, symbolName, containerName); + } + function createDefinitionInfoFromName(name, symbolKind, symbolName, containerName) { + var sourceFile = name.getSourceFile(); return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromNode(name, sourceFile), kind: symbolKind, name: symbolName, containerKind: undefined, @@ -57842,7 +60556,14 @@ var ts; } function tryGetSignatureDeclaration(typeChecker, node) { var callLike = getAncestorCallLikeExpression(node); - return callLike && typeChecker.getResolvedSignature(callLike).declaration; + var signature = callLike && typeChecker.getResolvedSignature(callLike); + if (signature) { + var decl = signature.declaration; + if (decl && isSignatureDeclaration(decl)) { + return decl; + } + } + return undefined; } })(GoToDefinition = ts.GoToDefinition || (ts.GoToDefinition = {})); })(ts || (ts = {})); @@ -57851,7 +60572,7 @@ var ts; var GoToImplementation; (function (GoToImplementation) { function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { - if (node.parent.kind === 259) { + if (node.parent.kind === 261) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -57861,7 +60582,7 @@ var ts; return symbol.valueDeclaration && [ts.FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; } else { - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, false, false, true); + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, false, false, false, true); var result = ts.flatMap(referencedSymbols, function (symbol) { return ts.map(symbol.references, function (_a) { var textSpan = _a.textSpan, fileName = _a.fileName; @@ -57977,16 +60698,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 226: - case 149: - case 150: case 227: - case 206: + case 150: + case 151: + case 228: + case 207: break findOwner; - case 262: + case 264: return undefined; - case 231: - if (commentOwner.parent.kind === 231) { + case 232: + if (commentOwner.parent.kind === 232) { return undefined; } break findOwner; @@ -58026,7 +60747,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 206) { + if (commentOwner.kind === 207) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -58036,17 +60757,17 @@ var ts; return ts.emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 183) { + while (rightHandSide.kind === 184) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 184: case 185: + case 186: return rightHandSide.parameters; - case 197: + case 198: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150) { + if (member.kind === 151) { return member.parameters; } } @@ -58084,7 +60805,7 @@ var ts; }); if (!safeList) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = result.config ? ts.createMap(result.config) : EmptySafeList; + safeList = result.config ? ts.createMapFromTemplate(result.config) : EmptySafeList; } var filesToWatch = []; var searchDirs = []; @@ -58109,31 +60830,31 @@ var ts; if (unresolvedImports) { for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { var moduleId = unresolvedImports_1[_a]; - var typingName = moduleId in nodeCoreModules ? "node" : moduleId; - if (!(typingName in inferredTypings)) { - inferredTypings[typingName] = undefined; + var typingName = nodeCoreModules.has(moduleId) ? "node" : moduleId; + if (!inferredTypings.has(typingName)) { + inferredTypings.set(typingName, undefined); } } } - for (var name_47 in packageNameToTypingLocation) { - if (name_47 in inferredTypings && !inferredTypings[name_47]) { - inferredTypings[name_47] = packageNameToTypingLocation[name_47]; + packageNameToTypingLocation.forEach(function (typingLocation, name) { + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined) { + inferredTypings.set(name, typingLocation); } - } + }); for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { var excludeTypingName = exclude_1[_b]; - delete inferredTypings[excludeTypingName]; + inferredTypings.delete(excludeTypingName); } var newTypingNames = []; var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); + inferredTypings.forEach(function (inferred, typing) { + if (inferred !== undefined) { + cachedTypingPaths.push(inferred); } else { newTypingNames.push(typing); } - } + }); return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; function mergeTypings(typingNames) { if (!typingNames) { @@ -58141,8 +60862,8 @@ var ts; } for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { var typing = typingNames_1[_i]; - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; + if (!inferredTypings.has(typing)) { + inferredTypings.set(typing, undefined); } } } @@ -58172,7 +60893,7 @@ var ts; var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); if (safeList !== EmptySafeList) { - mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return safeList.has(f); })); } var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); if (hasJsxFile) { @@ -58205,7 +60926,7 @@ var ts; } if (packageJson.typings) { var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; + inferredTypings.set(packageJson.name, absolutePath); } else { typingNames.push(packageJson.name); @@ -58224,41 +60945,43 @@ var ts; function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; - ts.forEach(sourceFiles, function (sourceFile) { + var _loop_4 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { - return; + return "continue"; } - var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_48 in nameToDeclarations) { - var declarations = nameToDeclarations[name_48]; + ts.forEachEntry(sourceFile.getNamedDeclarations(), function (declarations, name) { if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_48); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); if (!matches) { - continue; + return; } - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { + var declaration = declarations_12[_i]; if (patternMatcher.patternContainsDots) { var containers = getContainers(declaration); if (!containers) { - return undefined; + return true; } - matches = patternMatcher.getMatches(containers, name_48); + matches = patternMatcher.getMatches(containers, name); if (!matches) { - continue; + return; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_48, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } - } - }); + }); + }; + for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { + var sourceFile = sourceFiles_8[_i]; + _loop_4(sourceFile); + } rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 237 || decl.kind === 240 || decl.kind === 235) { + if (decl.kind === 238 || decl.kind === 241 || decl.kind === 236) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -58299,7 +61022,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 142) { + else if (declaration.name.kind === 143) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -58316,7 +61039,7 @@ var ts; } return true; } - if (expression.kind === 177) { + if (expression.kind === 178) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -58327,7 +61050,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 142) { + if (declaration.name.kind === 143) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -58368,7 +61091,7 @@ var ts; matchKind: ts.PatternMatchKind[rawItem.matchKind], isCaseSensitive: rawItem.isCaseSensitive, fileName: rawItem.fileName, - textSpan: ts.createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), + textSpan: ts.createTextSpanFromNode(declaration), containerName: container && container.name ? container.name.text : "", containerKind: container && container.name ? ts.getNodeKind(container) : "" }; @@ -58459,7 +61182,7 @@ var ts; return; } switch (node.kind) { - case 150: + case 151: var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { @@ -58469,28 +61192,28 @@ var ts; } } break; - case 149: - case 151: + case 150: case 152: - case 148: + case 153: + case 149: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; + case 148: case 147: - case 146: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 237: + case 238: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 238) { + if (namedBindings.kind === 239) { addLeafNode(namedBindings); } else { @@ -58501,12 +61224,12 @@ var ts; } } break; - case 174: - case 224: + case 175: + case 225: var decl = node; - var name_49 = decl.name; - if (ts.isBindingPattern(name_49)) { - addChildrenRecursively(name_49); + var name = decl.name; + if (ts.isBindingPattern(name)) { + addChildrenRecursively(name); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { addChildrenRecursively(decl.initializer); @@ -58515,12 +61238,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; + case 186: + case 227: case 185: - case 226: - case 184: addNodeWithRecursiveChild(node, node.body); break; - case 230: + case 231: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -58530,9 +61253,9 @@ var ts; } endNode(); break; - case 227: - case 197: case 228: + case 198: + case 229: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -58540,21 +61263,21 @@ var ts; } endNode(); break; - case 231: + case 232: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 244: - case 235: - case 155: - case 153: + case 245: + case 236: + case 156: case 154: - case 229: + case 155: + case 230: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 286) { + if (tag.kind === 289) { addLeafNode(tag); } }); @@ -58570,9 +61293,9 @@ var ts; if (!name) { return true; } - var itemsWithSameName = nameToItems[name]; + var itemsWithSameName = nameToItems.get(name); if (!itemsWithSameName) { - nameToItems[name] = child; + nameToItems.set(name, child); return true; } if (itemsWithSameName instanceof Array) { @@ -58590,7 +61313,7 @@ var ts; if (tryMerge(itemWithSameName, child)) { return false; } - nameToItems[name] = [itemWithSameName, child]; + nameToItems.set(name, [itemWithSameName, child]); return true; } function tryMerge(a, b) { @@ -58602,12 +61325,12 @@ var ts; } }); function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 231 || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 232 || areSameModule(a, b)); function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 231) { + if (a.body.kind !== 232) { return true; } return areSameModule(a.body, b.body); @@ -58633,32 +61356,15 @@ var ts; function compareChildren(child1, child2) { var name1 = tryGetName(child1.node), name2 = tryGetName(child2.node); if (name1 && name2) { - var cmp = localeCompareFix(name1, name2); + var cmp = ts.compareStringsCaseInsensitive(name1, name2); return cmp !== 0 ? cmp : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } else { return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } } - var localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; - var localeCompareFix = localeCompareIsCorrect ? ts.collator.compare : function (a, b) { - for (var i = 0; i < Math.min(a.length, b.length); i++) { - var chA = a.charAt(i), chB = b.charAt(i); - if (chA === "\"" && chB === "'") { - return 1; - } - if (chA === "'" && chB === "\"") { - return -1; - } - var cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); - if (cmp !== 0) { - return cmp; - } - } - return a.length - b.length; - }; function tryGetName(node) { - if (node.kind === 231) { + if (node.kind === 232) { return getModuleName(node); } var decl = node; @@ -58666,18 +61372,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 184: case 185: - case 197: + case 186: + case 198: return getFunctionOrClassName(node); - case 286: + case 289: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 231) { + if (node.kind === 232) { return getModuleName(node); } var name = node.name; @@ -58688,29 +61394,29 @@ var ts; } } switch (node.kind) { - case 262: + case 264: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 185: - case 226: - case 184: + case 186: case 227: - case 197: + case 185: + case 228: + case 198: if (ts.getModifierFlags(node) & 512) { return "default"; } return getFunctionOrClassName(node); - case 150: + case 151: return "constructor"; - case 154: - return "new()"; - case 153: - return "()"; case 155: + return "new()"; + case 154: + return "()"; + case 156: return "[]"; - case 286: + case 289: return getJSDocTypedefTagName(node); default: return ""; @@ -58722,7 +61428,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 206) { + if (parentNode && parentNode.kind === 207) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -58750,24 +61456,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 227: - case 197: - case 230: case 228: + case 198: case 231: - case 262: case 229: - case 286: + case 232: + case 264: + case 230: + case 289: return true; - case 150: - case 149: case 151: + case 150: case 152: - case 224: + case 153: + case 225: return hasSomeImportantChild(item); + case 186: + case 227: case 185: - case 226: - case 184: return isTopLevelFunctionDeclaration(item); default: return false; @@ -58777,10 +61483,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 232: - case 262: - case 149: + case 233: + case 264: case 150: + case 151: return true; default: return hasSomeImportantChild(item); @@ -58789,7 +61495,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 224 && childKind !== 174; + return childKind !== 225 && childKind !== 175; }); } } @@ -58799,7 +61505,7 @@ var ts; return { text: getItemName(n.node), kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: ts.map(n.children, convertToTree) }; @@ -58808,7 +61514,7 @@ var ts; return { text: getItemName(n.node), kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, indent: n.indent, @@ -58844,35 +61550,41 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 231) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 232) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } return result.join("."); } function getInteriorModule(decl) { - return decl.body.kind === 231 ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 232 ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 142; + return !member.name || member.name.kind === 143; } function getNodeSpan(node) { - return node.kind === 262 + return node.kind === 264 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) - : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); + : ts.createTextSpanFromNode(node, curSourceFile); + } + function getModifiers(node) { + if (node.parent && node.parent.kind === 225) { + node = node.parent; + } + return ts.getNodeModifiers(node); } function getFunctionOrClassName(node) { if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 224) { + else if (node.parent.kind === 225) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 192 && + else if (node.parent.kind === 193 && node.parent.operatorToken.kind === 57) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 258 && node.parent.name) { + else if (node.parent.kind === 260 && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512) { @@ -58883,7 +61595,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 184 || node.kind === 185 || node.kind === 197; + return node.kind === 185 || node.kind === 186 || node.kind === 198; } var whiteSpaceRegex = /\s+/g; })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); @@ -58899,7 +61611,7 @@ var ts; if (hintSpanNode && startElement && endElement) { var span_12 = { textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), - hintSpan: ts.createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), + hintSpan: ts.createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse }; @@ -58956,7 +61668,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 185; + return ts.isFunctionBlock(node) && node.parent.kind !== 186; } var depth = 0; var maxDepth = 20; @@ -58968,26 +61680,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 205: + case 206: if (!ts.isFunctionBlock(n)) { - var parent_20 = n.parent; + var parent = n.parent; var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); - if (parent_20.kind === 210 || - parent_20.kind === 213 || - parent_20.kind === 214 || - parent_20.kind === 212 || - parent_20.kind === 209 || - parent_20.kind === 211 || - parent_20.kind === 218 || - parent_20.kind === 257) { - addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); + if (parent.kind === 211 || + parent.kind === 214 || + parent.kind === 215 || + parent.kind === 213 || + parent.kind === 210 || + parent.kind === 212 || + parent.kind === 219 || + parent.kind === 259) { + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_20.kind === 222) { - var tryStatement = parent_20; + if (parent.kind === 223) { + var tryStatement = parent; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -58998,7 +61710,7 @@ var ts; } } } - var span_14 = ts.createTextSpanFromBounds(n.getStart(), n.end); + var span_14 = ts.createTextSpanFromNode(n); elements.push({ textSpan: span_14, hintSpan: span_14, @@ -59007,23 +61719,23 @@ var ts; }); break; } - case 232: { + case 233: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 227: case 228: - case 230: - case 176: - case 233: { + case 229: + case 231: + case 177: + case 234: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 175: + case 176: var openBracket = ts.findChildOfKind(n, 20, sourceFile); var closeBracket = ts.findChildOfKind(n, 21, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -59100,10 +61812,11 @@ var ts; return totalMatch; } function getWordSpans(word) { - if (!(word in stringToWordSpans)) { - stringToWordSpans[word] = breakIntoWordSpans(word); + var spans = stringToWordSpans.get(word); + if (!spans) { + stringToWordSpans.set(word, spans = breakIntoWordSpans(word)); } - return stringToWordSpans[word]; + return spans; } function matchTextChunk(candidate, chunk, punctuationStripped) { var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); @@ -59536,7 +62249,7 @@ var ts; else { if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59562,7 +62275,7 @@ var ts; } if (token === 17) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59576,7 +62289,7 @@ var ts; token = nextToken(); if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59602,7 +62315,7 @@ var ts; } if (token === 17) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59612,7 +62325,7 @@ var ts; } else if (token === 38) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59739,90 +62452,82 @@ var ts; var Rename; (function (Rename) { function getRenameInfo(typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile, position) { - var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); + var getCanonicalDefaultLibName = ts.memoize(function () { return getCanonicalFileName(ts.normalizePath(defaultLibFileName)); }); var node = ts.getTouchingWord(sourceFile, position, true); - if (node) { - if (node.kind === 70 || - node.kind === 9 || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - ts.isThis(node)) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var declarations = symbol.getDeclarations(); - if (declarations && declarations.length > 0) { - if (ts.forEach(declarations, isDefinedInLibraryFile)) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); - var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - if (kind) { - return { - canRename: true, - kind: kind, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: typeChecker.getFullyQualifiedName(symbol), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - else if (node.kind === 9) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (type) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - else { - var displayName = ts.stripQuotes(type.text); - return { - canRename: true, - kind: ts.ScriptElementKind.variableElement, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: displayName, - kindModifiers: ts.ScriptElementKindModifier.none, - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - } - } - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element)); - function getRenameInfoError(localizedErrorMessage) { - return { - canRename: false, - localizedErrorMessage: localizedErrorMessage, - displayName: undefined, - fullDisplayName: undefined, - kind: undefined, - kindModifiers: undefined, - triggerSpan: undefined - }; - } + var renameInfo = node && nodeIsEligibleForRename(node) + ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) + : undefined; + return renameInfo || getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); function isDefinedInLibraryFile(declaration) { - if (defaultLibFileName) { - var sourceFile_1 = declaration.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_1.fileName)); - if (canonicalName === canonicalDefaultLibName) { - return true; - } + if (!defaultLibFileName) { + return false; } - return false; - } - function createTriggerSpanForNode(node, sourceFile) { - var start = node.getStart(sourceFile); - var width = node.getWidth(sourceFile); - if (node.kind === 9) { - start += 1; - width -= 2; - } - return ts.createTextSpan(start, width); + var sourceFile = declaration.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); + return canonicalName === getCanonicalDefaultLibName(); } } Rename.getRenameInfo = getRenameInfo; + function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + var declarations = symbol.getDeclarations(); + if (declarations && declarations.length > 0) { + if (ts.some(declarations, isDefinedInLibraryFile)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); + } + var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); + var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); + return kind ? getRenameInfoSuccess(displayName, typeChecker.getFullyQualifiedName(symbol), kind, ts.SymbolDisplay.getSymbolModifiers(symbol), node, sourceFile) : undefined; + } + } + else if (node.kind === 9) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (type) { + if (isDefinedInLibraryFile(node)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); + } + var displayName = ts.stripQuotes(type.text); + return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); + } + } + } + function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { + return { + canRename: true, + kind: kind, + displayName: displayName, + localizedErrorMessage: undefined, + fullDisplayName: fullDisplayName, + kindModifiers: kindModifiers, + triggerSpan: createTriggerSpanForNode(node, sourceFile) + }; + } + function getRenameInfoError(diagnostic) { + return { + canRename: false, + localizedErrorMessage: ts.getLocaleSpecificMessage(diagnostic), + displayName: undefined, + fullDisplayName: undefined, + kind: undefined, + kindModifiers: undefined, + triggerSpan: undefined + }; + } + function createTriggerSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var width = node.getWidth(sourceFile); + if (node.kind === 9) { + start += 1; + width -= 2; + } + return ts.createTextSpan(start, width); + } + function nodeIsEligibleForRename(node) { + return node.kind === 70 || node.kind === 9 || + ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + ts.isThis(node); + } })(Rename = ts.Rename || (ts.Rename = {})); })(ts || (ts = {})); var ts; @@ -59830,6 +62535,13 @@ var ts; var SignatureHelp; (function (SignatureHelp) { var emptyArray = []; + var ArgumentListKind; + (function (ArgumentListKind) { + ArgumentListKind[ArgumentListKind["TypeArguments"] = 0] = "TypeArguments"; + ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; + ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; + ArgumentListKind[ArgumentListKind["JSXAttributesArguments"] = 3] = "JSXAttributesArguments"; + })(ArgumentListKind = SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); @@ -59855,14 +62567,14 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 179) { + if (argumentInfo.invocation.kind !== 180) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; var name = expression.kind === 70 ? expression - : expression.kind === 177 + : expression.kind === 178 ? expression.name : undefined; if (!name || !name.text) { @@ -59872,10 +62584,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameToDeclarations = sourceFile.getNamedDeclarations(); - var declarations = nameToDeclarations[name.text]; + var declarations = nameToDeclarations.get(name.text); if (declarations) { - for (var _b = 0, declarations_10 = declarations; _b < declarations_10.length; _b++) { - var declaration = declarations_10[_b]; + for (var _b = 0, declarations_13 = declarations; _b < declarations_13.length; _b++) { + var declaration = declarations_13[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -59891,7 +62603,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 179 || node.parent.kind === 180) { + if (node.parent.kind === 180 || node.parent.kind === 181) { var callExpression = node.parent; if (node.kind === 26 || node.kind === 18) { @@ -59923,23 +62635,23 @@ var ts; } return undefined; } - else if (node.kind === 12 && node.parent.kind === 181) { + else if (node.kind === 12 && node.parent.kind === 182) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0, sourceFile); } } - else if (node.kind === 13 && node.parent.parent.kind === 181) { + else if (node.kind === 13 && node.parent.parent.kind === 182) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 194); + ts.Debug.assert(templateExpression.kind === 195); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 203 && node.parent.parent.parent.kind === 181) { + else if (node.parent.kind === 204 && node.parent.parent.parent.kind === 182) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 194); + ts.Debug.assert(templateExpression.kind === 195); if (node.kind === 15 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -59947,8 +62659,20 @@ var ts; var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position); return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } + else if (node.parent && ts.isJsxOpeningLikeElement(node.parent)) { + var attributeSpanStart = node.parent.attributes.getFullStart(); + var attributeSpanEnd = ts.skipTrivia(sourceFile.text, node.parent.attributes.getEnd(), false); + return { + kind: 3, + invocation: node.parent, + argumentsSpan: ts.createTextSpan(attributeSpanStart, attributeSpanEnd - attributeSpanStart), + argumentIndex: 0, + argumentCount: 1 + }; + } return undefined; } + SignatureHelp.getImmediatelyContainingArgumentInfo = getImmediatelyContainingArgumentInfo; function getArgumentIndex(argumentsList, node) { var argumentIndex = 0; var listChildren = argumentsList.getChildren(); @@ -60003,7 +62727,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 194) { + if (template.kind === 195) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -60012,7 +62736,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 262; n = n.parent) { + for (var n = node; n.kind !== 264; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -60144,7 +62868,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 197) ? + return ts.getDeclarationOfKind(symbol, 198) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384) return ts.ScriptElementKind.enumElement; @@ -60201,7 +62925,7 @@ var ts; if (flags & 16384) return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4) { - if (flags & 268435456) { + if (flags & 134217728 && symbol.checkFlags & 2) { var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); if (rootSymbolFlags & (98308 | 3)) { @@ -60218,6 +62942,9 @@ var ts; } return unionPropertyKind; } + if (location.parent && ts.isJsxAttribute(location.parent)) { + return ts.ScriptElementKind.jsxAttribute; + } return ts.ScriptElementKind.memberVariableElement; } return ts.ScriptElementKind.unknown; @@ -60244,26 +62971,29 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 177) { + if (location.parent && location.parent.kind === 178) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } - var callExpression = void 0; - if (location.kind === 179 || location.kind === 180) { - callExpression = location; + var callExpressionLike = void 0; + if (location.kind === 180 || location.kind === 181) { + callExpressionLike = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { - callExpression = location.parent; + callExpressionLike = location.parent; } - if (callExpression) { + else if (location.parent && ts.isJsxOpeningLikeElement(location.parent) && ts.isFunctionLike(symbol.valueDeclaration)) { + callExpressionLike = location.parent; + } + if (callExpressionLike) { var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 180 || callExpression.expression.kind === 96; + var useConstructSignatures = callExpressionLike.kind === 181 || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 96); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -60287,6 +63017,7 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { + case ts.ScriptElementKind.jsxAttribute: case ts.ScriptElementKind.memberVariableElement: case ts.ScriptElementKind.variableElement: case ts.ScriptElementKind.constElement: @@ -60311,21 +63042,21 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 122 && location.parent.kind === 150)) { + (location.kind === 122 && location.parent.kind === 151)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 150 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 151 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 150) { + if (functionDeclaration.kind === 151) { symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 153 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 154 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -60334,7 +63065,7 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 197)) { + if (ts.getDeclarationOfKind(symbol, 198)) { pushTypePart(ts.ScriptElementKind.localClassElement); } else { @@ -60353,7 +63084,7 @@ var ts; } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(136)); + displayParts.push(ts.keywordPart(137)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -60374,7 +63105,7 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 231); + var declaration = ts.getDeclarationOfKind(symbol, 232); var isNamespace = declaration && declaration.name && declaration.name.kind === 70; displayParts.push(ts.keywordPart(isNamespace ? 128 : 127)); displayParts.push(ts.spacePart()); @@ -60393,25 +63124,25 @@ var ts; writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var declaration = ts.getDeclarationOfKind(symbol, 143); + var declaration = ts.getDeclarationOfKind(symbol, 144); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 154) { + if (declaration.kind === 155) { displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 153 && declaration.name) { + else if (declaration.kind !== 154 && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } - else if (declaration.kind === 229) { + else if (declaration.kind === 230) { addInPrefix(); - displayParts.push(ts.keywordPart(136)); + displayParts.push(ts.keywordPart(137)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -60422,7 +63153,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 261) { + if (declaration.kind === 263) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -60434,7 +63165,7 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 234) { + if (symbol.declarations[0].kind === 235) { displayParts.push(ts.keywordPart(83)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(128)); @@ -60445,7 +63176,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 235) { + if (declaration.kind === 236) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -60480,6 +63211,7 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } if (symbolKind === ts.ScriptElementKind.memberVariableElement || + symbolKind === ts.ScriptElementKind.jsxAttribute || symbolFlags & 3 || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { @@ -60513,10 +63245,10 @@ var ts; if (!documentation) { documentation = symbol.getDocumentationComment(); if (documentation.length === 0 && symbol.flags & 4) { - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 262; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 264; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 192) { + if (!declaration.parent || declaration.parent.kind !== 193) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -60596,14 +63328,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 184) { + if (declaration.kind === 185) { return true; } - if (declaration.kind !== 224 && declaration.kind !== 226) { + if (declaration.kind !== 225 && declaration.kind !== 227) { return false; } - for (var parent_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { - if (parent_21.kind === 262 || parent_21.kind === 232) { + for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { + if (parent.kind === 264 || parent.kind === 233) { return false; } } @@ -60638,7 +63370,7 @@ var ts; sourceFile.moduleName = transpileOptions.moduleName; } if (transpileOptions.renamedDependencies) { - sourceFile.renamedDependencies = ts.createMap(transpileOptions.renamedDependencies); + sourceFile.renamedDependencies = ts.createMapFromTemplate(transpileOptions.renamedDependencies); } var newLine = ts.getNewLineCharacter(options); var outputText; @@ -60684,10 +63416,10 @@ var ts; var commandLineOptionsStringToEnum; function fixupCompilerOptions(options, diagnostics) { commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { - return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); + return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_3 = function (opt) { + var _loop_5 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -60696,14 +63428,14 @@ var ts; options[opt.name] = ts.parseCustomTypeOption(opt, value, diagnostics); } else { - if (!ts.forEachProperty(opt.type, function (v) { return v === value; })) { + if (!ts.forEachEntry(opt.type, function (v) { return v === value; })) { diagnostics.push(ts.createCompilerDiagnosticForInvalidCustomType(opt)); } } }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_3(opt); + _loop_5(opt); } return options; } @@ -60715,6 +63447,15 @@ var ts; var standardScanner = ts.createScanner(5, false, 0); var jsxScanner = ts.createScanner(5, false, 1); var scanner; + var ScanAction; + (function (ScanAction) { + ScanAction[ScanAction["Scan"] = 0] = "Scan"; + ScanAction[ScanAction["RescanGreaterThanToken"] = 1] = "RescanGreaterThanToken"; + ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken"; + ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken"; + ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; + ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; + })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; @@ -60794,10 +63535,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { + case 252: + case 250: case 251: case 249: - case 250: - case 248: return node.kind === 70; } } @@ -61008,6 +63749,20 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + var FormattingRequestKind; + (function (FormattingRequestKind) { + FormattingRequestKind[FormattingRequestKind["FormatDocument"] = 0] = "FormatDocument"; + FormattingRequestKind[FormattingRequestKind["FormatSelection"] = 1] = "FormatSelection"; + FormattingRequestKind[FormattingRequestKind["FormatOnEnter"] = 2] = "FormatOnEnter"; + FormattingRequestKind[FormattingRequestKind["FormatOnSemicolon"] = 3] = "FormatOnSemicolon"; + FormattingRequestKind[FormattingRequestKind["FormatOnClosingCurlyBrace"] = 4] = "FormatOnClosingCurlyBrace"; + })(FormattingRequestKind = formatting.FormattingRequestKind || (formatting.FormattingRequestKind = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -61029,6 +63784,19 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleAction; + (function (RuleAction) { + RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; + RuleAction[RuleAction["Space"] = 2] = "Space"; + RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; + RuleAction[RuleAction["Delete"] = 8] = "Delete"; + })(RuleAction = formatting.RuleAction || (formatting.RuleAction = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -61059,6 +63827,17 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleFlags; + (function (RuleFlags) { + RuleFlags[RuleFlags["None"] = 0] = "None"; + RuleFlags[RuleFlags["CanDeleteNewLines"] = 1] = "CanDeleteNewLines"; + })(RuleFlags = formatting.RuleFlags || (formatting.RuleFlags = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -61130,7 +63909,7 @@ var ts; this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromRange(0, 140, [19])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromRange(0, 141, [19])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17, 81), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17, 105), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); @@ -61173,14 +63952,14 @@ var ts; this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([19, 80, 81, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2)); this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101, 86]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 133]), 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 134]), 70), 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127, 131]), 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 130, 133, 114, 136, 138, 126]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 138])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 130, 134, 114, 137, 139, 126]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 139])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); @@ -61194,7 +63973,7 @@ var ts; this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 133, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 134, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38, formatting.Shared.TokenRange.FromTokens([70, 18])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); @@ -61300,44 +64079,44 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_50 in o) { - if (o[name_50] === rule) { - return name_50; + for (var name in o) { + if (o[name] === rule) { + return name; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 212; + return context.contextNode.kind === 213; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 192: case 193: - case 200: - case 244: - case 240: - case 156: - case 164: + case 194: + case 201: + case 245: + case 241: + case 157: case 165: + case 166: return true; - case 174: - case 229: - case 235: - case 224: - case 144: - case 261: + case 175: + case 230: + case 236: + case 225: + case 145: + case 263: + case 148: case 147: - case 146: return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; - case 213: - case 143: - return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; case 214: - return context.currentTokenSpan.kind === 140 || context.nextTokenSpan.kind === 140; + case 144: + return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; + case 215: + return context.currentTokenSpan.kind === 141 || context.nextTokenSpan.kind === 141; } return false; }; @@ -61345,13 +64124,13 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 193; + return context.contextNode.kind === 194; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; Rules.IsBraceWrappedContext = function (context) { - return context.contextNode.kind === 172 || Rules.IsSingleLineBlockContext(context); + return context.contextNode.kind === 173 || Rules.IsSingleLineBlockContext(context); }; Rules.IsBeforeMultilineBlockContext = function (context) { return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); @@ -61373,65 +64152,65 @@ var ts; return true; } switch (node.kind) { - case 205: + case 206: + case 234: + case 177: case 233: - case 176: - case 232: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 226: + case 227: + case 150: case 149: - case 148: - case 151: case 152: case 153: - case 184: - case 150: + case 154: case 185: - case 228: + case 151: + case 186: + case 229: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 226 || context.contextNode.kind === 184; + return context.contextNode.kind === 227 || context.contextNode.kind === 185; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 227: - case 197: case 228: - case 230: - case 161: + case 198: + case 229: case 231: - case 242: + case 162: + case 232: case 243: - case 236: - case 239: + case 244: + case 237: + case 240: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 227: - case 231: - case 230: - case 257: + case 228: case 232: - case 219: + case 231: + case 259: + case 233: + case 220: return true; - case 205: { + case 206: { var blockParent = context.currentTokenParent.parent; - if (blockParent.kind !== 185 && - blockParent.kind !== 184) { + if (blockParent.kind !== 186 && + blockParent.kind !== 185) { return true; } } @@ -61440,29 +64219,29 @@ var ts; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 209: - case 219: - case 212: + case 210: + case 220: case 213: case 214: + case 215: + case 212: + case 223: case 211: - case 222: - case 210: - case 218: - case 257: + case 219: + case 259: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 176; + return context.contextNode.kind === 177; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 179; + return context.contextNode.kind === 180; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 180; + return context.contextNode.kind === 181; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -61474,25 +64253,25 @@ var ts; return context.nextTokenSpan.kind !== 21; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 185; + return context.contextNode.kind === 186; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 247; + return context.contextNode.kind !== 248; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 253; + return context.contextNode.kind === 255; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 251; + return context.nextTokenParent.kind === 252; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 251; + return context.contextNode.kind === 252; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 248; + return context.contextNode.kind === 249; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -61507,42 +64286,42 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 145; + return node.kind === 146; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 225 && + return context.currentTokenParent.kind === 226 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 231; + return context.contextNode.kind === 232; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 161; + return context.contextNode.kind === 162; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 26 && token.kind !== 28) { return false; } switch (parent.kind) { - case 157: - case 182: + case 158: + case 183: + case 230: + case 228: + case 198: case 229: case 227: - case 197: - case 228: - case 226: - case 184: case 185: + case 186: + case 150: case 149: - case 148: - case 153: case 154: - case 179: + case 155: case 180: - case 199: + case 181: + case 200: return true; default: return false; @@ -61553,16 +64332,16 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 182; + return context.contextNode.kind === 183; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 188; + return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 189; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 195 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 196 && context.contextNode.expression !== undefined; }; Rules.IsNonNullAssertionContext = function (context) { - return context.contextNode.kind === 201; + return context.contextNode.kind === 202; }; return Rules; }()); @@ -61584,7 +64363,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 140 + 1; + this.mapRowLength = 141 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -61597,7 +64376,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - ts.Debug.assert(row <= 140 && column <= 140, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 141 && column <= 141, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -61761,7 +64540,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 140; token++) { + for (var token = 0; token <= 141; token++) { result.push(token); } return result; @@ -61805,9 +64584,9 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(71, 140); + TokenRange.Keywords = TokenRange.FromRange(71, 141); TokenRange.BinaryOperators = TokenRange.FromRange(26, 69); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 140, 117, 125]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 141, 117, 125]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42, 43, 51, 50]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 70, 18, 20, 16, 98, 93]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); @@ -61815,7 +64594,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([70, 132, 134, 121, 135, 104, 118]); + TokenRange.TypeNames = TokenRange.FromTokens([70, 132, 135, 121, 136, 104, 118]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -61963,6 +64742,10 @@ var ts; (function (ts) { var formatting; (function (formatting) { + var Constants; + (function (Constants) { + Constants[Constants["Unknown"] = -1] = "Unknown"; + })(Constants || (Constants = {})); function formatOnEnter(position, sourceFile, rulesProvider, options) { var line = sourceFile.getLineAndCharacterOfPosition(position).line; if (line === 0) { @@ -62035,17 +64818,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 227: case 228: + case 229: return ts.rangeContainsRange(parent.members, node); - case 231: - var body = parent.body; - return body && body.kind === 232 && ts.rangeContainsRange(body.statements, node); - case 262: - case 205: case 232: + var body = parent.body; + return body && body.kind === 233 && ts.rangeContainsRange(body.statements, node); + case 264: + case 206: + case 233: return ts.rangeContainsRange(parent.statements, node); - case 257: + case 259: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -62201,18 +64984,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 227: return 74; - case 228: return 108; - case 226: return 88; - case 230: return 230; - case 151: return 124; - case 152: return 133; - case 149: + case 228: return 74; + case 229: return 108; + case 227: return 88; + case 231: return 231; + case 152: return 124; + case 153: return 134; + case 150: if (node.asteriskToken) { return 38; } - case 147: - case 144: + case 148: + case 145: return node.name.kind; } } @@ -62244,16 +65027,16 @@ var ts; return indentation; case 40: case 28: { - if (container.kind === 249 || - container.kind === 250 || - container.kind === 248) { + if (container.kind === 250 || + container.kind === 251 || + container.kind === 249) { return indentation; } break; } case 20: case 21: { - if (container.kind !== 170) { + if (container.kind !== 171) { return indentation; } break; @@ -62341,11 +65124,11 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 145 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 146 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 175 && inheritedIndentation === -1) { + if (isFirstListItem && parent.kind === 176 && inheritedIndentation === -1) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -62661,12 +65444,12 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 150: - case 226: - case 184: - case 149: - case 148: + case 151: + case 227: case 185: + case 150: + case 149: + case 186: if (node.typeParameters === list) { return 26; } @@ -62674,8 +65457,8 @@ var ts; return 18; } break; - case 179: case 180: + case 181: if (node.typeArguments === list) { return 26; } @@ -62683,7 +65466,7 @@ var ts; return 18; } break; - case 157: + case 158: if (node.typeArguments === list) { return 26; } @@ -62756,6 +65539,10 @@ var ts; (function (formatting) { var SmartIndenter; (function (SmartIndenter) { + var Value; + (function (Value) { + Value[Value["Unknown"] = -1] = "Unknown"; + })(Value || (Value = {})); function getIndentation(position, sourceFile, options) { if (position > sourceFile.text.length) { return getBaseIndentation(options); @@ -62784,7 +65571,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 25 && precedingToken.parent.kind !== 192) { + if (precedingToken.kind === 25 && precedingToken.parent.kind !== 193) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -62886,7 +65673,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 262 || !parentAndChildShareLine); + (parent.kind === 264 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -62910,7 +65697,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 209 && parent.elseStatement === child) { + if (parent.kind === 210 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -62922,23 +65709,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 157: + case 158: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 176: + case 177: return node.parent.properties; - case 175: + case 176: return node.parent.elements; - case 226: - case 184: + case 227: case 185: + case 186: + case 150: case 149: - case 148: - case 153: - case 154: { + case 154: + case 155: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -62949,8 +65736,8 @@ var ts; } break; } - case 180: - case 179: { + case 181: + case 180: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -62978,8 +65765,8 @@ var ts; if (node.kind === 19) { return -1; } - if (node.parent && (node.parent.kind === 179 || - node.parent.kind === 180) && + if (node.parent && (node.parent.kind === 180 || + node.parent.kind === 181) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -62997,10 +65784,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 179: case 180: - case 177: + case 181: case 178: + case 179: node = node.expression; break; default: @@ -63054,49 +65841,49 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 208: - case 227: - case 197: + case 209: case 228: - case 230: + case 198: case 229: - case 175: - case 205: - case 232: + case 231: + case 230: case 176: - case 161: - case 170: - case 163: - case 233: - case 255: - case 254: - case 183: - case 177: - case 179: - case 180: case 206: - case 224: - case 241: - case 217: - case 193: - case 173: - case 172: - case 249: - case 248: - case 253: - case 148: - case 153: - case 154: - case 144: - case 158: - case 159: - case 166: + case 233: + case 177: + case 162: + case 171: + case 164: + case 234: + case 257: + case 256: + case 184: + case 178: + case 180: case 181: - case 189: - case 243: - case 239: + case 207: + case 225: + case 242: + case 218: + case 194: + case 174: + case 173: + case 250: + case 249: + case 255: + case 149: + case 154: + case 155: + case 145: + case 159: + case 160: + case 167: + case 182: + case 190: case 244: case 240: + case 245: + case 241: return true; } return false; @@ -63104,27 +65891,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 210: case 211: - case 213: - case 214: case 212: - case 209: - case 226: - case 184: - case 149: + case 214: + case 215: + case 213: + case 210: + case 227: case 185: case 150: + case 186: case 151: case 152: - return childKind !== 205; - case 242: - return childKind !== 243; - case 236: - return childKind !== 237 || - (child.namedBindings && child.namedBindings.kind !== 239); - case 247: - return childKind !== 250; + case 153: + return childKind !== 206; + case 243: + return childKind !== 244; + case 237: + return childKind !== 238 || + (child.namedBindings && child.namedBindings.kind !== 240); + case 248: + return childKind !== 251; } return indentByDefault; } @@ -63140,7 +65927,7 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var codeFixes = ts.createMap(); + var codeFixes = []; function registerCodeFix(action) { ts.forEach(action.errorCodes, function (error) { var fixes = codeFixes[error]; @@ -63213,9 +66000,9 @@ var ts; if (IndexInfoOfKind) { var writer = ts.getSingleLineStringWriter(); checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); - var result_7 = writer.string(); + var result_6 = writer.string(); ts.releaseStringWriter(writer); - return result_7; + return result_6; } } return ""; @@ -63301,7 +66088,7 @@ var ts; if (!superCall) { return undefined; } - if (superCall.expression && superCall.expression.kind == 179) { + if (superCall.expression && superCall.expression.kind == 180) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -63325,7 +66112,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 208 && ts.isSuperCall(n.expression)) { + if (n.kind === 209 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -63404,6 +66191,24 @@ var ts; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + var start = token.getStart(sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_this_to_unresolved_variable), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start: start, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var codefix; (function (codefix) { @@ -63422,41 +66227,41 @@ var ts; switch (token.kind) { case 70: switch (token.parent.kind) { - case 224: + case 225: switch (token.parent.parent.parent.kind) { - case 212: + case 213: var forStatement = token.parent.parent.parent; var forInitializer = forStatement.initializer; if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); + return createCodeFixToRemoveNode(forInitializer); } else { return removeSingleItem(forInitializer.declarations, token); } - case 214: + case 215: var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 225) { + if (forOfStatement.initializer.kind === 226) { var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); + return createCodeFix("{}", forOfInitializer.declarations[0].getStart(), forOfInitializer.declarations[0].getWidth()); } break; - case 213: + case 214: return undefined; - case 257: + case 259: var catchClause = token.parent.parent; var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); + return createCodeFixToRemoveNode(parameter); default: var variableStatement = token.parent.parent.parent; if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); + return createCodeFixToRemoveNode(variableStatement); } else { var declarations = variableStatement.declarationList.declarations; return removeSingleItem(declarations, token); } } - case 143: + case 144: var typeParameters = token.parent.parent.typeParameters; if (typeParameters.length === 1) { return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); @@ -63464,71 +66269,94 @@ var ts; else { return removeSingleItem(typeParameters, token); } - case 144: + case 145: var functionDeclaration = token.parent.parent; if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + return createCodeFixToRemoveNode(token.parent); } else { return removeSingleItem(functionDeclaration.parameters, token); } - case 235: + case 236: var importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case 240: + return createCodeFixToRemoveNode(importEquals); + case 241: var namedImports = token.parent.parent; if (namedImports.elements.length === 1) { var importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); + return createCodeFixToRemoveNode(importSpec); } else { return removeSingleItem(namedImports.elements, token); } - case 237: + case 238: var importClause = token.parent; if (!importClause.namedBindings) { var importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + return createCodeFixToRemoveNode(importDecl); } else { - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); + var start_4 = importClause.name.getStart(); + var end = findFirstNonSpaceCharPosStarting(importClause.name.end); + if (sourceFile.text.charCodeAt(end) === 44) { + end = findFirstNonSpaceCharPosStarting(end + 1); + } + return createCodeFix("", start_4, end - start_4); } - case 238: + case 239: var namespaceImport = token.parent; if (namespaceImport.name == token && !namespaceImport.parent.name) { var importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + return createCodeFixToRemoveNode(importDecl); } else { - var start_4 = namespaceImport.parent.name.end; - return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); + var start_5 = namespaceImport.parent.name.end; + return createCodeFix("", start_5, namespaceImport.parent.namedBindings.end - start_5); } } break; - case 147: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case 238: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + case 148: + case 239: + return createCodeFixToRemoveNode(token.parent); } if (ts.isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + return createCodeFixToRemoveNode(token.parent); } else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); + return createCodeFixToRemoveNode(token.parent.parent); } else { return undefined; } function findImportDeclaration(token) { var importDecl = token; - while (importDecl.kind != 236 && importDecl.parent) { + while (importDecl.kind != 237 && importDecl.parent) { importDecl = importDecl.parent; } return importDecl; } + function createCodeFixToRemoveNode(node) { + var end = node.getEnd(); + var endCharCode = sourceFile.text.charCodeAt(end); + var afterEndCharCode = sourceFile.text.charCodeAt(end + 1); + if (ts.isLineBreak(endCharCode)) { + end += 1; + } + if (ts.isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) { + end += 1; + } + var start = node.getStart(); + return createCodeFix("", start, end - start); + } + function findFirstNonSpaceCharPosStarting(start) { + while (ts.isWhiteSpace(sourceFile.text.charCodeAt(start))) { + start += 1; + } + return start; + } function createCodeFix(newText, start, length) { return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: newText, span: { start: start, length: length } }] @@ -63559,18 +66387,19 @@ var ts; })(ModuleSpecifierComparison || (ModuleSpecifierComparison = {})); var ImportCodeActionMap = (function () { function ImportCodeActionMap() { - this.symbolIdToActionMap = ts.createMap(); + this.symbolIdToActionMap = []; } ImportCodeActionMap.prototype.addAction = function (symbolId, newAction) { if (!newAction) { return; } - if (!this.symbolIdToActionMap[symbolId]) { + var actions = this.symbolIdToActionMap[symbolId]; + if (!actions) { this.symbolIdToActionMap[symbolId] = [newAction]; return; } if (newAction.kind === "CodeChange") { - this.symbolIdToActionMap[symbolId].push(newAction); + actions.push(newAction); return; } var updatedNewImports = []; @@ -63603,8 +66432,8 @@ var ts; }; ImportCodeActionMap.prototype.getAllActions = function () { var result = []; - for (var symbolId in this.symbolIdToActionMap) { - result = ts.concatenate(result, this.symbolIdToActionMap[symbolId]); + for (var key in this.symbolIdToActionMap) { + result = ts.concatenate(result, this.symbolIdToActionMap[key]); } return result; }; @@ -63635,6 +66464,7 @@ var ts; codefix.registerCodeFix({ errorCodes: [ ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics.Cannot_find_namespace_0.code, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code ], getCodeActions: function (context) { @@ -63645,7 +66475,7 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, context.span.start); var name = token.getText(); var symbolIdActionMap = new ImportCodeActionMap(); - var cachedImportDeclarations = ts.createMap(); + var cachedImportDeclarations = []; var cachedNewImportInsertPosition; var currentTokenMeaning = ts.getMeaningFromLocation(token); if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { @@ -63679,8 +66509,9 @@ var ts; return symbolIdActionMap.getAllActions(); function getImportDeclarations(moduleSymbol) { var moduleSymbolId = getUniqueSymbolId(moduleSymbol); - if (cachedImportDeclarations[moduleSymbolId]) { - return cachedImportDeclarations[moduleSymbolId]; + var cached = cachedImportDeclarations[moduleSymbolId]; + if (cached) { + return cached; } var existingDeclarations = []; for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { @@ -63695,10 +66526,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 236) { + if (node.kind === 237) { return node; } - if (node.kind === 235) { + if (node.kind === 236) { return node; } node = node.parent; @@ -63729,11 +66560,11 @@ var ts; var namespaceImportDeclaration; var namedImportDeclaration; var existingModuleSpecifier; - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; - if (declaration.kind === 236) { + for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { + var declaration = declarations_14[_i]; + if (declaration.kind === 237) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 238) { + if (namedBindings && namedBindings.kind === 239) { namespaceImportDeclaration = declaration; } else { @@ -63760,7 +66591,7 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 246) { + if (declaration.moduleReference && declaration.moduleReference.kind === 247) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); @@ -63793,7 +66624,7 @@ var ts; } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 236) { + if (declaration.kind === 237) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -63827,18 +66658,18 @@ var ts; : "" + context.newLineCharacter + importStatementText + ";"; return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], newText, { start: cachedNewImportInsertPosition, length: 0 }, sourceFile.fileName, "NewImport", moduleSpecifierWithoutQuotes); function getModuleSpecifierForNewImport() { - var fileName = sourceFile.path; - var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().path; + var fileName = sourceFile.fileName; + var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; var sourceDirectory = ts.getDirectoryPath(fileName); var options = context.program.getCompilerOptions(); return tryGetModuleNameFromAmbientModule() || - tryGetModuleNameFromBaseUrl() || - tryGetModuleNameFromRootDirs() || tryGetModuleNameFromTypeRoots() || tryGetModuleNameAsNodeModule() || + tryGetModuleNameFromBaseUrl() || + tryGetModuleNameFromRootDirs() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 262) { + if (moduleSymbol.valueDeclaration.kind !== 264) { return moduleSymbol.name; } } @@ -63846,8 +66677,7 @@ var ts; if (!options.baseUrl) { return undefined; } - var normalizedBaseUrl = ts.toPath(options.baseUrl, ts.getDirectoryPath(options.baseUrl), getCanonicalFileName); - var relativeName = tryRemoveParentDirectoryName(moduleFileName, normalizedBaseUrl); + var relativeName = getRelativePathIfInDirectory(moduleFileName, options.baseUrl); if (!relativeName) { return undefined; } @@ -63881,9 +66711,8 @@ var ts; } function tryGetModuleNameFromRootDirs() { if (options.rootDirs) { - var normalizedRootDirs = ts.map(options.rootDirs, function (rootDir) { return ts.toPath(rootDir, undefined, getCanonicalFileName); }); - var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, normalizedRootDirs); - var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, normalizedRootDirs); + var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, options.rootDirs); + var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, options.rootDirs); if (normalizedTargetPath !== undefined) { var relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath; return ts.removeFileExtension(relativePath); @@ -63945,7 +66774,7 @@ var ts; function getPathRelativeToRootDirs(path, rootDirs) { for (var _i = 0, rootDirs_2 = rootDirs; _i < rootDirs_2.length; _i++) { var rootDir = rootDirs_2[_i]; - var relativeName = tryRemoveParentDirectoryName(path, rootDir); + var relativeName = getRelativePathIfInDirectory(path, rootDir); if (relativeName !== undefined) { return relativeName; } @@ -63959,19 +66788,14 @@ var ts; } return fileName; } + function getRelativePathIfInDirectory(path, directoryPath) { + var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); + return ts.isRootedDiskPath(relativePath) || ts.startsWith(relativePath, "..") ? undefined : relativePath; + } function getRelativePath(path, directoryPath) { var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); return ts.moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath; } - function tryRemoveParentDirectoryName(path, parentDirectory) { - var index = path.indexOf(parentDirectory); - if (index === 0) { - return ts.endsWith(parentDirectory, ts.directorySeparator) - ? path.substring(parentDirectory.length) - : path.substring(parentDirectory.length + 1); - } - return undefined; - } } } function createCodeAction(description, diagnosticArgs, newText, span, fileName, kind, moduleSpecifier) { @@ -63992,7 +66816,7 @@ var ts; (function (codefix) { function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { var classMembers = classDeclaration.symbol.members; - var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !(symbol.getName() in classMembers); }); + var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !classMembers.has(symbol.getName()); }); var insertion = ""; for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { var symbol = missingMembers_1[_i]; @@ -64011,14 +66835,14 @@ var ts; var name = declaration.name ? declaration.name.getText() : undefined; var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); switch (declaration.kind) { - case 151: case 152: - case 146: + case 153: case 147: + case 148: var typeString = checker.typeToString(type, enclosingDeclaration, 0); return "" + visibility + name + ": " + typeString + ";" + newlineChar; - case 148: case 149: + case 150: var signatures = checker.getSignaturesOfType(type, 0); if (!(signatures && signatures.length > 0)) { return ""; @@ -64049,7 +66873,7 @@ var ts; } } function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { - var newSignatureDeclaration = ts.createNode(153); + var newSignatureDeclaration = ts.createNode(154); newSignatureDeclaration.parent = enclosingDeclaration; newSignatureDeclaration.name = signatures[0].getDeclaration().name; var maxNonRestArgs = -1; @@ -64080,7 +66904,7 @@ var ts; } return checker.getSignatureFromDeclaration(newSignatureDeclaration); function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { - var newParameter = ts.createNode(144); + var newParameter = ts.createNode(145); newParameter.symbol = new SymbolConstructor(1, maxArgsParameterSymbolNames[index] || "rest"); newParameter.symbol.valueDeclaration = newParameter; newParameter.symbol.declarations = [newParameter]; @@ -64110,7 +66934,7 @@ var ts; (function (ts) { ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 141 ? new NodeObject(kind, pos, end) : + var node = kind >= 142 ? new NodeObject(kind, pos, end) : kind === 70 ? new IdentifierObject(70, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; @@ -64168,7 +66992,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(293, nodes.pos, nodes.end, this); + var list = createNode(296, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -64187,11 +67011,11 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 141) { + if (this.kind >= 142) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 279 && this.kind <= 292; + var useJSDocScanner_1 = this.kind >= 282 && this.kind <= 295; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -64244,8 +67068,10 @@ var ts; if (!children.length) { return undefined; } - var child = children[0]; - return child.kind < 141 ? child : child.getFirstToken(sourceFile); + var child = ts.find(children, function (kid) { return kid.kind < 266 || kid.kind > 295; }); + return child.kind < 142 ? + child : + child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -64253,7 +67079,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 141 ? child : child.getLastToken(sourceFile); + return child.kind < 142 ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -64450,27 +67276,31 @@ var ts; return this.namedDeclarations; }; SourceFileObject.prototype.computeNamedDeclarations = function () { - var result = ts.createMap(); + var result = ts.createMultiMap(); ts.forEachChild(this, visit); return result; function addDeclaration(declaration) { var name = getDeclarationName(declaration); if (name) { - ts.multiMapAdd(result, name, declaration); + result.add(name, declaration); } } function getDeclarations(name) { - return result[name] || (result[name] = []); + var declarations = result.get(name); + if (!declarations) { + result.set(name, declarations = []); + } + return declarations; } function getDeclarationName(declaration) { if (declaration.name) { - var result_8 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_8 !== undefined) { - return result_8; + var result_7 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_7 !== undefined) { + return result_7; } - if (declaration.name.kind === 142) { + if (declaration.name.kind === 143) { var expr = declaration.name.expression; - if (expr.kind === 177) { + if (expr.kind === 178) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -64490,10 +67320,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 226: - case 184: + case 227: + case 185: + case 150: case 149: - case 148: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -64510,30 +67340,30 @@ var ts; } ts.forEachChild(node, visit); break; - case 227: - case 197: case 228: + case 198: case 229: case 230: case 231: - case 235: - case 244: - case 240: - case 235: - case 237: + case 232: + case 236: + case 245: + case 241: + case 236: case 238: - case 151: + case 239: case 152: - case 161: + case 153: + case 162: addDeclaration(node); ts.forEachChild(node, visit); break; - case 144: + case 145: if (!ts.hasModifier(node, 92)) { break; } - case 224: - case 174: { + case 225: + case 175: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -64542,24 +67372,24 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 261: + case 263: + case 148: case 147: - case 146: addDeclaration(node); break; - case 242: + case 243: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 236: + case 237: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 238) { + if (importClause.namedBindings.kind === 239) { addDeclaration(importClause.namedBindings); } else { @@ -65002,10 +67832,10 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { case 70: - case 177: - case 141: + case 178: + case 142: case 98: - case 167: + case 168: case 96: var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -65044,8 +67874,8 @@ var ts; function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); if (results) { - var sourceFile_2 = getCanonicalFileName(ts.normalizeSlashes(fileName)); - results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_2; }); + var sourceFile_1 = getCanonicalFileName(ts.normalizeSlashes(fileName)); + results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_1; }); } return results; } @@ -65079,20 +67909,20 @@ var ts; } } function findRenameLocations(fileName, position, findInStrings, findInComments) { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments, true); return ts.FindAllReferences.convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, false, false, false); return ts.FindAllReferences.convertReferences(referencedSymbols); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, false, false, false); return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); } - function findReferencedSymbols(fileName, position, findInStrings, findInComments) { + function findReferencedSymbols(fileName, position, findInStrings, findInComments, isForRename) { synchronizeHostData(); - return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments); + return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments, isForRename); } function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { synchronizeHostData(); @@ -65134,15 +67964,15 @@ var ts; return; } switch (node.kind) { - case 177: - case 141: + case 178: + case 142: case 9: case 85: case 100: case 94: case 96: case 98: - case 167: + case 168: case 70: break; default: @@ -65154,7 +67984,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 231 && + if (nodeForStartPos.parent.parent.kind === 232 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -65286,7 +68116,7 @@ var ts; var span = { start: start, length: end - start }; var newLineChar = ts.getNewLineOrDefaultFromHost(host); var allFixes = []; - ts.forEach(errorCodes, function (error) { + ts.forEach(ts.deduplicate(errorCodes), function (error) { cancellationToken.throwIfCancellationRequested(); var context = { errorCode: error, @@ -65447,15 +68277,15 @@ var ts; function walk(node) { switch (node.kind) { case 70: - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + setNameTable(node.text, node); break; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 246 || + node.parent.kind === 247 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + setNameTable(node.text, node); } break; default: @@ -65468,11 +68298,66 @@ var ts; } } } + function setNameTable(text, node) { + nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); + } } + function isObjectLiteralElement(node) { + switch (node.kind) { + case 252: + case 254: + case 260: + case 261: + case 150: + case 152: + case 153: + return true; + } + return false; + } + function getContainingObjectLiteralElement(node) { + switch (node.kind) { + case 9: + case 8: + if (node.parent.kind === 143) { + return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; + } + case 70: + return isObjectLiteralElement(node.parent) && + (node.parent.parent.kind === 177 || node.parent.parent.kind === 253) && + node.parent.name === node ? node.parent : undefined; + } + return undefined; + } + ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; + function getPropertySymbolsFromContextualType(typeChecker, node) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = ts.getTextOfPropertyName(node.name); + if (name && contextualType) { + var result_8 = []; + var symbol = contextualType.getProperty(name); + if (contextualType.flags & 65536) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_8.push(symbol); + } + }); + return result_8; + } + if (symbol) { + result_8.push(symbol); + return result_8; + } + } + return undefined; + } + ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 178 && + node.parent.kind === 179 && node.parent.argumentExpression === node; } function getDefaultLibFilePath(options) { @@ -65482,10 +68367,7 @@ var ts; throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); } ts.getDefaultLibFilePath = getDefaultLibFilePath; - function initializeServices() { - ts.objectAllocator = getServicesObjectAllocator(); - } - initializeServices(); + ts.objectAllocator = getServicesObjectAllocator(); })(ts || (ts = {})); var ts; (function (ts) { @@ -65595,14 +68477,14 @@ var ts; }; } server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; - function mergeMaps(target, source) { + function mergeMapLikes(target, source) { for (var key in source) { if (ts.hasProperty(source, key)) { target[key] = source[key]; } } } - server.mergeMaps = mergeMaps; + server.mergeMapLikes = mergeMapLikes; function removeItemFromSet(items, itemToRemove) { if (items.length === 0) { return; @@ -65633,19 +68515,19 @@ var ts; } server.asNormalizedPath = asNormalizedPath; function createNormalizedPathMap() { - var map = Object.create(null); + var map = ts.createMap(); return { get: function (path) { - return map[path]; + return map.get(path); }, set: function (path, value) { - map[path] = value; + map.set(path, value); }, contains: function (path) { - return ts.hasProperty(map, path); + return map.has(path); }, remove: function (path) { - delete map[path]; + map.delete(path); } }; } @@ -65669,13 +68551,14 @@ var ts; this.pendingTimeouts = ts.createMap(); } ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { - if (ts.hasProperty(this.pendingTimeouts, operationId)) { - this.host.clearTimeout(this.pendingTimeouts[operationId]); + var pendingTimeout = this.pendingTimeouts.get(operationId); + if (pendingTimeout) { + this.host.clearTimeout(pendingTimeout); } - this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); + this.pendingTimeouts.set(operationId, this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb)); }; ThrottledOperations.run = function (self, operationId, cb) { - delete self.pendingTimeouts[operationId]; + self.pendingTimeouts.delete(operationId); cb(); }; return ThrottledOperations; @@ -65709,6 +68592,1593 @@ var ts; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var server; + (function (server) { + server.nullCancellationToken = { + isCancellationRequested: function () { return false; }, + setRequest: function () { return void 0; }, + resetRequest: function () { return void 0; } + }; + function hrTimeToMilliseconds(time) { + var seconds = time[0]; + var nanoseconds = time[1]; + return ((1e9 * seconds) + nanoseconds) / 1000000.0; + } + function shouldSkipSematicCheck(project) { + if (project.getCompilerOptions().skipLibCheck !== undefined) { + return false; + } + if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && project.isJsOnlyProject()) { + return true; + } + return false; + } + function compareNumber(a, b) { + return a - b; + } + function compareFileStart(a, b) { + if (a.file < b.file) { + return -1; + } + else if (a.file == b.file) { + var n = compareNumber(a.start.line, b.start.line); + if (n === 0) { + return compareNumber(a.start.offset, b.start.offset); + } + else + return n; + } + else { + return 1; + } + } + function formatDiag(fileName, project, diag) { + var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); + return { + start: scriptInfo.positionToLineOffset(diag.start), + end: scriptInfo.positionToLineOffset(diag.start + diag.length), + text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), + code: diag.code + }; + } + function formatConfigFileDiag(diag) { + return { + start: undefined, + end: undefined, + text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") + }; + } + function allEditsBeforePos(edits, pos) { + for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { + var edit = edits_1[_i]; + if (ts.textSpanEnd(edit.span) >= pos) { + return false; + } + } + return true; + } + var CommandNames; + (function (CommandNames) { + CommandNames.Brace = "brace"; + CommandNames.BraceFull = "brace-full"; + CommandNames.BraceCompletion = "braceCompletion"; + CommandNames.Change = "change"; + CommandNames.Close = "close"; + CommandNames.Completions = "completions"; + CommandNames.CompletionsFull = "completions-full"; + CommandNames.CompletionDetails = "completionEntryDetails"; + CommandNames.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + CommandNames.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + CommandNames.Configure = "configure"; + CommandNames.Definition = "definition"; + CommandNames.DefinitionFull = "definition-full"; + CommandNames.Exit = "exit"; + CommandNames.Format = "format"; + CommandNames.Formatonkey = "formatonkey"; + CommandNames.FormatFull = "format-full"; + CommandNames.FormatonkeyFull = "formatonkey-full"; + CommandNames.FormatRangeFull = "formatRange-full"; + CommandNames.Geterr = "geterr"; + CommandNames.GeterrForProject = "geterrForProject"; + CommandNames.Implementation = "implementation"; + CommandNames.ImplementationFull = "implementation-full"; + CommandNames.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + CommandNames.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + CommandNames.NavBar = "navbar"; + CommandNames.NavBarFull = "navbar-full"; + CommandNames.NavTree = "navtree"; + CommandNames.NavTreeFull = "navtree-full"; + CommandNames.Navto = "navto"; + CommandNames.NavtoFull = "navto-full"; + CommandNames.Occurrences = "occurrences"; + CommandNames.DocumentHighlights = "documentHighlights"; + CommandNames.DocumentHighlightsFull = "documentHighlights-full"; + CommandNames.Open = "open"; + CommandNames.Quickinfo = "quickinfo"; + CommandNames.QuickinfoFull = "quickinfo-full"; + CommandNames.References = "references"; + CommandNames.ReferencesFull = "references-full"; + CommandNames.Reload = "reload"; + CommandNames.Rename = "rename"; + CommandNames.RenameInfoFull = "rename-full"; + CommandNames.RenameLocationsFull = "renameLocations-full"; + CommandNames.Saveto = "saveto"; + CommandNames.SignatureHelp = "signatureHelp"; + CommandNames.SignatureHelpFull = "signatureHelp-full"; + CommandNames.TypeDefinition = "typeDefinition"; + CommandNames.ProjectInfo = "projectInfo"; + CommandNames.ReloadProjects = "reloadProjects"; + CommandNames.Unknown = "unknown"; + CommandNames.OpenExternalProject = "openExternalProject"; + CommandNames.OpenExternalProjects = "openExternalProjects"; + CommandNames.CloseExternalProject = "closeExternalProject"; + CommandNames.SynchronizeProjectList = "synchronizeProjectList"; + CommandNames.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; + CommandNames.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; + CommandNames.Cleanup = "cleanup"; + CommandNames.OutliningSpans = "outliningSpans"; + CommandNames.TodoComments = "todoComments"; + CommandNames.Indentation = "indentation"; + CommandNames.DocCommentTemplate = "docCommentTemplate"; + CommandNames.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; + CommandNames.NameOrDottedNameSpan = "nameOrDottedNameSpan"; + CommandNames.BreakpointStatement = "breakpointStatement"; + CommandNames.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + CommandNames.GetCodeFixes = "getCodeFixes"; + CommandNames.GetCodeFixesFull = "getCodeFixes-full"; + CommandNames.GetSupportedCodeFixes = "getSupportedCodeFixes"; + })(CommandNames = server.CommandNames || (server.CommandNames = {})); + function formatMessage(msg, logger, byteLength, newLine) { + var verboseLogging = logger.hasLevel(server.LogLevel.verbose); + var json = JSON.stringify(msg); + if (verboseLogging) { + logger.info(msg.type + ": " + json); + } + var len = byteLength(json, "utf8"); + return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; + } + server.formatMessage = formatMessage; + var MultistepOperation = (function () { + function MultistepOperation(operationHost) { + var _this = this; + this.operationHost = operationHost; + this.completed = true; + this.next = { + immediate: function (action) { return _this.immediate(action); }, + delay: function (ms, action) { return _this.delay(ms, action); } + }; + } + MultistepOperation.prototype.startNew = function (action) { + this.complete(); + this.requestId = this.operationHost.getCurrentRequestId(); + this.completed = false; + this.executeAction(action); + }; + MultistepOperation.prototype.complete = function () { + if (!this.completed) { + if (this.requestId) { + this.operationHost.sendRequestCompletedEvent(this.requestId); + } + this.completed = true; + } + this.setTimerHandle(undefined); + this.setImmediateId(undefined); + }; + MultistepOperation.prototype.immediate = function (action) { + var _this = this; + var requestId = this.requestId; + ts.Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "immediate: incorrect request id"); + this.setImmediateId(this.operationHost.getServerHost().setImmediate(function () { + _this.immediateId = undefined; + _this.operationHost.executeWithRequestId(requestId, function () { return _this.executeAction(action); }); + })); + }; + MultistepOperation.prototype.delay = function (ms, action) { + var _this = this; + var requestId = this.requestId; + ts.Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "delay: incorrect request id"); + this.setTimerHandle(this.operationHost.getServerHost().setTimeout(function () { + _this.timerHandle = undefined; + _this.operationHost.executeWithRequestId(requestId, function () { return _this.executeAction(action); }); + }, ms)); + }; + MultistepOperation.prototype.executeAction = function (action) { + var stop = false; + try { + if (this.operationHost.isCancellationRequested()) { + stop = true; + } + else { + action(this.next); + } + } + catch (e) { + stop = true; + if (!(e instanceof ts.OperationCanceledException)) { + this.operationHost.logError(e, "delayed processing of request " + this.requestId); + } + } + if (stop || !this.hasPendingWork()) { + this.complete(); + } + }; + MultistepOperation.prototype.setTimerHandle = function (timerHandle) { + ; + if (this.timerHandle !== undefined) { + this.operationHost.getServerHost().clearTimeout(this.timerHandle); + } + this.timerHandle = timerHandle; + }; + MultistepOperation.prototype.setImmediateId = function (immediateId) { + if (this.immediateId !== undefined) { + this.operationHost.getServerHost().clearImmediate(this.immediateId); + } + this.immediateId = immediateId; + }; + MultistepOperation.prototype.hasPendingWork = function () { + return !!this.timerHandle || !!this.immediateId; + }; + return MultistepOperation; + }()); + var Session = (function () { + function Session(host, cancellationToken, useSingleInferredProject, typingsInstaller, byteLength, hrtime, logger, canUseEvents, eventHandler) { + var _this = this; + this.host = host; + this.cancellationToken = cancellationToken; + this.typingsInstaller = typingsInstaller; + this.byteLength = byteLength; + this.hrtime = hrtime; + this.logger = logger; + this.canUseEvents = canUseEvents; + this.changeSeq = 0; + this.handlers = ts.createMapFromTemplate((_a = {}, + _a[CommandNames.OpenExternalProject] = function (request) { + _this.projectService.openExternalProject(request.arguments, false); + return _this.requiredResponse(true); + }, + _a[CommandNames.OpenExternalProjects] = function (request) { + _this.projectService.openExternalProjects(request.arguments.projects); + return _this.requiredResponse(true); + }, + _a[CommandNames.CloseExternalProject] = function (request) { + _this.projectService.closeExternalProject(request.arguments.projectFileName); + return _this.requiredResponse(true); + }, + _a[CommandNames.SynchronizeProjectList] = function (request) { + var result = _this.projectService.synchronizeProjectList(request.arguments.knownProjects); + if (!result.some(function (p) { return p.projectErrors && p.projectErrors.length !== 0; })) { + return _this.requiredResponse(result); + } + var converted = ts.map(result, function (p) { + if (!p.projectErrors || p.projectErrors.length === 0) { + return p; + } + return { + info: p.info, + changes: p.changes, + files: p.files, + projectErrors: _this.convertToDiagnosticsWithLinePosition(p.projectErrors, undefined) + }; + }); + return _this.requiredResponse(converted); + }, + _a[CommandNames.ApplyChangedToOpenFiles] = function (request) { + _this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles); + _this.changeSeq++; + return _this.requiredResponse(true); + }, + _a[CommandNames.Exit] = function () { + _this.exit(); + return _this.notRequired(); + }, + _a[CommandNames.Definition] = function (request) { + return _this.requiredResponse(_this.getDefinition(request.arguments, true)); + }, + _a[CommandNames.DefinitionFull] = function (request) { + return _this.requiredResponse(_this.getDefinition(request.arguments, false)); + }, + _a[CommandNames.TypeDefinition] = function (request) { + return _this.requiredResponse(_this.getTypeDefinition(request.arguments)); + }, + _a[CommandNames.Implementation] = function (request) { + return _this.requiredResponse(_this.getImplementation(request.arguments, true)); + }, + _a[CommandNames.ImplementationFull] = function (request) { + return _this.requiredResponse(_this.getImplementation(request.arguments, false)); + }, + _a[CommandNames.References] = function (request) { + return _this.requiredResponse(_this.getReferences(request.arguments, true)); + }, + _a[CommandNames.ReferencesFull] = function (request) { + return _this.requiredResponse(_this.getReferences(request.arguments, false)); + }, + _a[CommandNames.Rename] = function (request) { + return _this.requiredResponse(_this.getRenameLocations(request.arguments, true)); + }, + _a[CommandNames.RenameLocationsFull] = function (request) { + return _this.requiredResponse(_this.getRenameLocations(request.arguments, false)); + }, + _a[CommandNames.RenameInfoFull] = function (request) { + return _this.requiredResponse(_this.getRenameInfo(request.arguments)); + }, + _a[CommandNames.Open] = function (request) { + _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName)); + return _this.notRequired(); + }, + _a[CommandNames.Quickinfo] = function (request) { + return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, true)); + }, + _a[CommandNames.QuickinfoFull] = function (request) { + return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, false)); + }, + _a[CommandNames.OutliningSpans] = function (request) { + return _this.requiredResponse(_this.getOutliningSpans(request.arguments)); + }, + _a[CommandNames.TodoComments] = function (request) { + return _this.requiredResponse(_this.getTodoComments(request.arguments)); + }, + _a[CommandNames.Indentation] = function (request) { + return _this.requiredResponse(_this.getIndentation(request.arguments)); + }, + _a[CommandNames.NameOrDottedNameSpan] = function (request) { + return _this.requiredResponse(_this.getNameOrDottedNameSpan(request.arguments)); + }, + _a[CommandNames.BreakpointStatement] = function (request) { + return _this.requiredResponse(_this.getBreakpointStatement(request.arguments)); + }, + _a[CommandNames.BraceCompletion] = function (request) { + return _this.requiredResponse(_this.isValidBraceCompletion(request.arguments)); + }, + _a[CommandNames.DocCommentTemplate] = function (request) { + return _this.requiredResponse(_this.getDocCommentTemplate(request.arguments)); + }, + _a[CommandNames.Format] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsForRange(request.arguments)); + }, + _a[CommandNames.Formatonkey] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsAfterKeystroke(request.arguments)); + }, + _a[CommandNames.FormatFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsForDocumentFull(request.arguments)); + }, + _a[CommandNames.FormatonkeyFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsAfterKeystrokeFull(request.arguments)); + }, + _a[CommandNames.FormatRangeFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsForRangeFull(request.arguments)); + }, + _a[CommandNames.Completions] = function (request) { + return _this.requiredResponse(_this.getCompletions(request.arguments, true)); + }, + _a[CommandNames.CompletionsFull] = function (request) { + return _this.requiredResponse(_this.getCompletions(request.arguments, false)); + }, + _a[CommandNames.CompletionDetails] = function (request) { + return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments)); + }, + _a[CommandNames.CompileOnSaveAffectedFileList] = function (request) { + return _this.requiredResponse(_this.getCompileOnSaveAffectedFileList(request.arguments)); + }, + _a[CommandNames.CompileOnSaveEmitFile] = function (request) { + return _this.requiredResponse(_this.emitFile(request.arguments)); + }, + _a[CommandNames.SignatureHelp] = function (request) { + return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, true)); + }, + _a[CommandNames.SignatureHelpFull] = function (request) { + return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, false)); + }, + _a[CommandNames.CompilerOptionsDiagnosticsFull] = function (request) { + return _this.requiredResponse(_this.getCompilerOptionsDiagnostics(request.arguments)); + }, + _a[CommandNames.EncodedSemanticClassificationsFull] = function (request) { + return _this.requiredResponse(_this.getEncodedSemanticClassifications(request.arguments)); + }, + _a[CommandNames.Cleanup] = function () { + _this.cleanup(); + return _this.requiredResponse(true); + }, + _a[CommandNames.SemanticDiagnosticsSync] = function (request) { + return _this.requiredResponse(_this.getSemanticDiagnosticsSync(request.arguments)); + }, + _a[CommandNames.SyntacticDiagnosticsSync] = function (request) { + return _this.requiredResponse(_this.getSyntacticDiagnosticsSync(request.arguments)); + }, + _a[CommandNames.Geterr] = function (request) { + _this.errorCheck.startNew(function (next) { return _this.getDiagnostics(next, request.arguments.delay, request.arguments.files); }); + return _this.notRequired(); + }, + _a[CommandNames.GeterrForProject] = function (request) { + _this.errorCheck.startNew(function (next) { return _this.getDiagnosticsForProject(next, request.arguments.delay, request.arguments.file); }); + return _this.notRequired(); + }, + _a[CommandNames.Change] = function (request) { + _this.change(request.arguments); + return _this.notRequired(); + }, + _a[CommandNames.Configure] = function (request) { + _this.projectService.setHostConfiguration(request.arguments); + _this.output(undefined, CommandNames.Configure, request.seq); + return _this.notRequired(); + }, + _a[CommandNames.Reload] = function (request) { + _this.reload(request.arguments, request.seq); + return _this.requiredResponse({ reloadFinished: true }); + }, + _a[CommandNames.Saveto] = function (request) { + var savetoArgs = request.arguments; + _this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); + return _this.notRequired(); + }, + _a[CommandNames.Close] = function (request) { + var closeArgs = request.arguments; + _this.closeClientFile(closeArgs.file); + return _this.notRequired(); + }, + _a[CommandNames.Navto] = function (request) { + return _this.requiredResponse(_this.getNavigateToItems(request.arguments, true)); + }, + _a[CommandNames.NavtoFull] = function (request) { + return _this.requiredResponse(_this.getNavigateToItems(request.arguments, false)); + }, + _a[CommandNames.Brace] = function (request) { + return _this.requiredResponse(_this.getBraceMatching(request.arguments, true)); + }, + _a[CommandNames.BraceFull] = function (request) { + return _this.requiredResponse(_this.getBraceMatching(request.arguments, false)); + }, + _a[CommandNames.NavBar] = function (request) { + return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, true)); + }, + _a[CommandNames.NavBarFull] = function (request) { + return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, false)); + }, + _a[CommandNames.NavTree] = function (request) { + return _this.requiredResponse(_this.getNavigationTree(request.arguments, true)); + }, + _a[CommandNames.NavTreeFull] = function (request) { + return _this.requiredResponse(_this.getNavigationTree(request.arguments, false)); + }, + _a[CommandNames.Occurrences] = function (request) { + return _this.requiredResponse(_this.getOccurrences(request.arguments)); + }, + _a[CommandNames.DocumentHighlights] = function (request) { + return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, true)); + }, + _a[CommandNames.DocumentHighlightsFull] = function (request) { + return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, false)); + }, + _a[CommandNames.CompilerOptionsForInferredProjects] = function (request) { + _this.setCompilerOptionsForInferredProjects(request.arguments); + return _this.requiredResponse(true); + }, + _a[CommandNames.ProjectInfo] = function (request) { + return _this.requiredResponse(_this.getProjectInfo(request.arguments)); + }, + _a[CommandNames.ReloadProjects] = function () { + _this.projectService.reloadProjects(); + return _this.notRequired(); + }, + _a[CommandNames.GetCodeFixes] = function (request) { + return _this.requiredResponse(_this.getCodeFixes(request.arguments, true)); + }, + _a[CommandNames.GetCodeFixesFull] = function (request) { + return _this.requiredResponse(_this.getCodeFixes(request.arguments, false)); + }, + _a[CommandNames.GetSupportedCodeFixes] = function () { + return _this.requiredResponse(_this.getSupportedCodeFixes()); + }, + _a)); + this.eventHander = canUseEvents + ? eventHandler || (function (event) { return _this.defaultEventHandler(event); }) + : undefined; + var multistepOperationHost = { + executeWithRequestId: function (requestId, action) { return _this.executeWithRequestId(requestId, action); }, + getCurrentRequestId: function () { return _this.currentRequestId; }, + getServerHost: function () { return _this.host; }, + logError: function (err, cmd) { return _this.logError(err, cmd); }, + sendRequestCompletedEvent: function (requestId) { return _this.sendRequestCompletedEvent(requestId); }, + isCancellationRequested: function () { return cancellationToken.isCancellationRequested(); } + }; + this.errorCheck = new MultistepOperation(multistepOperationHost); + this.projectService = new server.ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); + this.gcTimer = new server.GcTimer(host, 7000, logger); + var _a; + } + Session.prototype.sendRequestCompletedEvent = function (requestId) { + var event = { + seq: 0, + type: "event", + event: "requestCompleted", + body: { request_seq: requestId } + }; + this.send(event); + }; + Session.prototype.defaultEventHandler = function (event) { + var _this = this; + switch (event.eventName) { + case server.ContextEvent: + var _a = event.data, project_1 = _a.project, fileName_1 = _a.fileName; + this.projectService.logger.info("got context event, updating diagnostics for " + fileName_1); + this.errorCheck.startNew(function (next) { return _this.updateErrorCheck(next, [{ fileName: fileName_1, project: project_1 }], _this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); }); + break; + case server.ConfigFileDiagEvent: + var _b = event.data, triggerFile = _b.triggerFile, configFileName = _b.configFileName, diagnostics = _b.diagnostics; + this.configFileDiagnosticEvent(triggerFile, configFileName, diagnostics); + break; + case server.ProjectLanguageServiceStateEvent: + var eventName = "projectLanguageServiceState"; + this.event({ + projectName: event.data.project.getProjectName(), + languageServiceEnabled: event.data.languageServiceEnabled + }, eventName); + break; + } + }; + Session.prototype.logError = function (err, cmd) { + var msg = "Exception on executing command " + cmd; + if (err.message) { + msg += ":\n" + err.message; + if (err.stack) { + msg += "\n" + err.stack; + } + } + this.logger.msg(msg, server.Msg.Err); + }; + Session.prototype.send = function (msg) { + if (msg.type === "event" && !this.canUseEvents) { + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("Session does not support events: ignored event: " + JSON.stringify(msg)); + } + return; + } + this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine)); + }; + Session.prototype.configFileDiagnosticEvent = function (triggerFile, configFile, diagnostics) { + var bakedDiags = ts.map(diagnostics, formatConfigFileDiag); + var ev = { + seq: 0, + type: "event", + event: "configFileDiag", + body: { + triggerFile: triggerFile, + configFile: configFile, + diagnostics: bakedDiags + } + }; + this.send(ev); + }; + Session.prototype.event = function (info, eventName) { + var ev = { + seq: 0, + type: "event", + event: eventName, + body: info + }; + this.send(ev); + }; + Session.prototype.output = function (info, cmdName, reqSeq, errorMsg) { + if (reqSeq === void 0) { reqSeq = 0; } + var res = { + seq: 0, + type: "response", + command: cmdName, + request_seq: reqSeq, + success: !errorMsg, + }; + if (!errorMsg) { + res.body = info; + } + else { + res.message = errorMsg; + } + this.send(res); + }; + Session.prototype.semanticCheck = function (file, project) { + try { + var diags = []; + if (!shouldSkipSematicCheck(project)) { + diags = project.getLanguageService().getSemanticDiagnostics(file); + } + var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); + this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); + } + catch (err) { + this.logError(err, "semantic check"); + } + }; + Session.prototype.syntacticCheck = function (file, project) { + try { + var diags = project.getLanguageService().getSyntacticDiagnostics(file); + if (diags) { + var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); + this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag"); + } + } + catch (err) { + this.logError(err, "syntactic check"); + } + }; + Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { + var _this = this; + if (ms === void 0) { ms = 1500; } + this.host.setTimeout(function () { + if (matchSeq(seq)) { + _this.projectService.refreshInferredProjects(); + } + }, ms); + }; + Session.prototype.updateErrorCheck = function (next, checkList, seq, matchSeq, ms, followMs, requireOpen) { + var _this = this; + if (ms === void 0) { ms = 1500; } + if (followMs === void 0) { followMs = 200; } + if (requireOpen === void 0) { requireOpen = true; } + if (followMs > ms) { + followMs = ms; + } + var index = 0; + var checkOne = function () { + if (matchSeq(seq)) { + var checkSpec_1 = checkList[index]; + index++; + if (checkSpec_1.project.containsFile(checkSpec_1.fileName, requireOpen)) { + _this.syntacticCheck(checkSpec_1.fileName, checkSpec_1.project); + next.immediate(function () { + _this.semanticCheck(checkSpec_1.fileName, checkSpec_1.project); + if (checkList.length > index) { + next.delay(followMs, checkOne); + } + }); + } + } + }; + if ((checkList.length > index) && (matchSeq(seq))) { + next.delay(ms, checkOne); + } + }; + Session.prototype.cleanProjects = function (caption, projects) { + if (!projects) { + return; + } + this.logger.info("cleaning " + caption); + for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) { + var p = projects_1[_i]; + p.getLanguageService(false).cleanupSemanticCache(); + } + }; + Session.prototype.cleanup = function () { + this.cleanProjects("inferred projects", this.projectService.inferredProjects); + this.cleanProjects("configured projects", this.projectService.configuredProjects); + this.cleanProjects("external projects", this.projectService.externalProjects); + if (this.host.gc) { + this.logger.info("host.gc()"); + this.host.gc(); + } + }; + Session.prototype.getEncodedSemanticClassifications = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + return project.getLanguageService().getEncodedSemanticClassifications(file, args); + }; + Session.prototype.getProject = function (projectFileName) { + return projectFileName && this.projectService.findProject(projectFileName); + }; + Session.prototype.getCompilerOptionsDiagnostics = function (args) { + var project = this.getProject(args.projectFileName); + return this.convertToDiagnosticsWithLinePosition(project.getLanguageService().getCompilerOptionsDiagnostics(), undefined); + }; + Session.prototype.convertToDiagnosticsWithLinePosition = function (diagnostics, scriptInfo) { + var _this = this; + return diagnostics.map(function (d) { return ({ + message: ts.flattenDiagnosticMessageText(d.messageText, _this.host.newLine), + start: d.start, + length: d.length, + category: ts.DiagnosticCategory[d.category].toLowerCase(), + code: d.code, + startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start), + endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length) + }); }); + }; + Session.prototype.getDiagnosticsWorker = function (args, isSemantic, selector, includeLinePosition) { + var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; + if (isSemantic && shouldSkipSematicCheck(project)) { + return []; + } + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var diagnostics = selector(project, file); + return includeLinePosition + ? this.convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo) + : diagnostics.map(function (d) { return formatDiag(file, project, d); }); + }; + Session.prototype.getDefinition = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var definitions = project.getLanguageService().getDefinitionAtPosition(file, position); + if (!definitions) { + return undefined; + } + if (simplifiedResult) { + return definitions.map(function (def) { + var defScriptInfo = project.getScriptInfo(def.fileName); + return { + file: def.fileName, + start: defScriptInfo.positionToLineOffset(def.textSpan.start), + end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) + }; + }); + } + else { + return definitions; + } + }; + Session.prototype.getTypeDefinition = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var definitions = project.getLanguageService().getTypeDefinitionAtPosition(file, position); + if (!definitions) { + return undefined; + } + return definitions.map(function (def) { + var defScriptInfo = project.getScriptInfo(def.fileName); + return { + file: def.fileName, + start: defScriptInfo.positionToLineOffset(def.textSpan.start), + end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) + }; + }); + }; + Session.prototype.getImplementation = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + var implementations = project.getLanguageService().getImplementationAtPosition(file, position); + if (!implementations) { + return []; + } + if (simplifiedResult) { + return implementations.map(function (_a) { + var fileName = _a.fileName, textSpan = _a.textSpan; + var scriptInfo = project.getScriptInfo(fileName); + return { + file: fileName, + start: scriptInfo.positionToLineOffset(textSpan.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)) + }; + }); + } + else { + return implementations; + } + }; + Session.prototype.getOccurrences = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position); + if (!occurrences) { + return undefined; + } + return occurrences.map(function (occurrence) { + var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan; + var scriptInfo = project.getScriptInfo(fileName); + var start = scriptInfo.positionToLineOffset(textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); + return { + start: start, + end: end, + file: fileName, + isWriteAccess: isWriteAccess, + }; + }); + }; + Session.prototype.getSyntacticDiagnosticsSync = function (args) { + return this.getDiagnosticsWorker(args, false, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); + }; + Session.prototype.getSemanticDiagnosticsSync = function (args) { + return this.getDiagnosticsWorker(args, true, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, args.includeLinePosition); + }; + Session.prototype.getDocumentHighlights = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var documentHighlights = project.getLanguageService().getDocumentHighlights(file, position, args.filesToSearch); + if (!documentHighlights) { + return undefined; + } + if (simplifiedResult) { + return documentHighlights.map(convertToDocumentHighlightsItem); + } + else { + return documentHighlights; + } + function convertToDocumentHighlightsItem(documentHighlights) { + var fileName = documentHighlights.fileName, highlightSpans = documentHighlights.highlightSpans; + var scriptInfo = project.getScriptInfo(fileName); + return { + file: fileName, + highlightSpans: highlightSpans.map(convertHighlightSpan) + }; + function convertHighlightSpan(highlightSpan) { + var textSpan = highlightSpan.textSpan, kind = highlightSpan.kind; + var start = scriptInfo.positionToLineOffset(textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); + return { start: start, end: end, kind: kind }; + } + } + }; + Session.prototype.setCompilerOptionsForInferredProjects = function (args) { + this.projectService.setCompilerOptionsForInferredProjects(args.options); + }; + Session.prototype.getProjectInfo = function (args) { + return this.getProjectInfoWorker(args.file, args.projectFileName, args.needFileNameList); + }; + Session.prototype.getProjectInfoWorker = function (uncheckedFileName, projectFileName, needFileNameList) { + var project = this.getFileAndProjectWorker(uncheckedFileName, projectFileName, true, true).project; + var projectInfo = { + configFileName: project.getProjectName(), + languageServiceDisabled: !project.languageServiceEnabled, + fileNames: needFileNameList ? project.getFileNames() : undefined + }; + return projectInfo; + }; + Session.prototype.getRenameInfo = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + return project.getLanguageService().getRenameInfo(file, position); + }; + Session.prototype.getProjects = function (args) { + var projects; + if (args.projectFileName) { + var project = this.getProject(args.projectFileName); + if (project) { + projects = [project]; + } + } + else { + var scriptInfo = this.projectService.getScriptInfo(args.file); + projects = scriptInfo.containingProjects; + } + projects = ts.filter(projects, function (p) { return p.languageServiceEnabled; }); + if (!projects || !projects.length) { + return server.Errors.ThrowNoProject(); + } + return projects; + }; + Session.prototype.getRenameLocations = function (args, simplifiedResult) { + var file = server.toNormalizedPath(args.file); + var info = this.projectService.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, info); + var projects = this.getProjects(args); + if (simplifiedResult) { + var defaultProject = projects[0]; + var renameInfo = defaultProject.getLanguageService().getRenameInfo(file, position); + if (!renameInfo) { + return undefined; + } + if (!renameInfo.canRename) { + return { + info: renameInfo, + locs: [] + }; + } + var fileSpans = server.combineProjectOutput(projects, function (project) { + var renameLocations = project.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); + if (!renameLocations) { + return []; + } + return renameLocations.map(function (location) { + var locationScriptInfo = project.getScriptInfo(location.fileName); + return { + file: location.fileName, + start: locationScriptInfo.positionToLineOffset(location.textSpan.start), + end: locationScriptInfo.positionToLineOffset(ts.textSpanEnd(location.textSpan)), + }; + }); + }, compareRenameLocation, function (a, b) { return a.file === b.file && a.start.line === b.start.line && a.start.offset === b.start.offset; }); + var locs = fileSpans.reduce(function (accum, cur) { + var curFileAccum; + if (accum.length > 0) { + curFileAccum = accum[accum.length - 1]; + if (curFileAccum.file !== cur.file) { + curFileAccum = undefined; + } + } + if (!curFileAccum) { + curFileAccum = { file: cur.file, locs: [] }; + accum.push(curFileAccum); + } + curFileAccum.locs.push({ start: cur.start, end: cur.end }); + return accum; + }, []); + return { info: renameInfo, locs: locs }; + } + else { + return server.combineProjectOutput(projects, function (p) { return p.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); }, undefined, renameLocationIsEqualTo); + } + function renameLocationIsEqualTo(a, b) { + if (a === b) { + return true; + } + if (!a || !b) { + return false; + } + return a.fileName === b.fileName && + a.textSpan.start === b.textSpan.start && + a.textSpan.length === b.textSpan.length; + } + function compareRenameLocation(a, b) { + if (a.file < b.file) { + return -1; + } + else if (a.file > b.file) { + return 1; + } + else { + if (a.start.line < b.start.line) { + return 1; + } + else if (a.start.line > b.start.line) { + return -1; + } + else { + return b.start.offset - a.start.offset; + } + } + } + }; + Session.prototype.getReferences = function (args, simplifiedResult) { + var file = server.toNormalizedPath(args.file); + var projects = this.getProjects(args); + var defaultProject = projects[0]; + var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + if (simplifiedResult) { + var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); + if (!nameInfo) { + return undefined; + } + var displayString = ts.displayPartsToString(nameInfo.displayParts); + var nameSpan = nameInfo.textSpan; + var nameColStart = scriptInfo.positionToLineOffset(nameSpan.start).offset; + var nameText = scriptInfo.getSnapshot().getText(nameSpan.start, ts.textSpanEnd(nameSpan)); + var refs = server.combineProjectOutput(projects, function (project) { + var references = project.getLanguageService().getReferencesAtPosition(file, position); + if (!references) { + return []; + } + return references.map(function (ref) { + var refScriptInfo = project.getScriptInfo(ref.fileName); + var start = refScriptInfo.positionToLineOffset(ref.textSpan.start); + var refLineSpan = refScriptInfo.lineToTextSpan(start.line - 1); + var lineText = refScriptInfo.getSnapshot().getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); + return { + file: ref.fileName, + start: start, + lineText: lineText, + end: refScriptInfo.positionToLineOffset(ts.textSpanEnd(ref.textSpan)), + isWriteAccess: ref.isWriteAccess, + isDefinition: ref.isDefinition + }; + }); + }, compareFileStart, areReferencesResponseItemsForTheSameLocation); + return { + refs: refs, + symbolName: nameText, + symbolStartOffset: nameColStart, + symbolDisplayString: displayString + }; + } + else { + return server.combineProjectOutput(projects, function (project) { return project.getLanguageService().findReferences(file, position); }, undefined, undefined); + } + function areReferencesResponseItemsForTheSameLocation(a, b) { + if (a && b) { + return a.file === b.file && + a.start === b.start && + a.end === b.end; + } + return false; + } + }; + Session.prototype.openClientFile = function (fileName, fileContent, scriptKind) { + var _a = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; + if (this.eventHander) { + this.eventHander({ + eventName: "configFileDiag", + data: { triggerFile: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } + }); + } + }; + Session.prototype.getPosition = function (args, scriptInfo) { + return args.position !== undefined ? args.position : scriptInfo.lineOffsetToPosition(args.line, args.offset); + }; + Session.prototype.getFileAndProject = function (args, errorOnMissingProject) { + if (errorOnMissingProject === void 0) { errorOnMissingProject = true; } + return this.getFileAndProjectWorker(args.file, args.projectFileName, true, errorOnMissingProject); + }; + Session.prototype.getFileAndProjectWithoutRefreshingInferredProjects = function (args, errorOnMissingProject) { + if (errorOnMissingProject === void 0) { errorOnMissingProject = true; } + return this.getFileAndProjectWorker(args.file, args.projectFileName, false, errorOnMissingProject); + }; + Session.prototype.getFileAndProjectWorker = function (uncheckedFileName, projectFileName, refreshInferredProjects, errorOnMissingProject) { + var file = server.toNormalizedPath(uncheckedFileName); + var project = this.getProject(projectFileName) || this.projectService.getDefaultProjectForFile(file, refreshInferredProjects); + if (!project && errorOnMissingProject) { + return server.Errors.ThrowNoProject(); + } + return { file: file, project: project }; + }; + Session.prototype.getOutliningSpans = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + return project.getLanguageService(false).getOutliningSpans(file); + }; + Session.prototype.getTodoComments = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + return project.getLanguageService().getTodoComments(file, args.descriptors); + }; + Session.prototype.getDocCommentTemplate = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + return project.getLanguageService(false).getDocCommentTemplateAtPosition(file, position); + }; + Session.prototype.getIndentation = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); + var indentation = project.getLanguageService(false).getIndentationAtPosition(file, position, options); + return { position: position, indentation: indentation }; + }; + Session.prototype.getBreakpointStatement = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + return project.getLanguageService(false).getBreakpointStatementAtPosition(file, position); + }; + Session.prototype.getNameOrDottedNameSpan = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + return project.getLanguageService(false).getNameOrDottedNameSpan(file, position, position); + }; + Session.prototype.isValidBraceCompletion = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + return project.getLanguageService(false).isValidBraceCompletionAtPosition(file, position, args.openingBrace.charCodeAt(0)); + }; + Session.prototype.getQuickInfoWorker = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var quickInfo = project.getLanguageService().getQuickInfoAtPosition(file, this.getPosition(args, scriptInfo)); + if (!quickInfo) { + return undefined; + } + if (simplifiedResult) { + var displayString = ts.displayPartsToString(quickInfo.displayParts); + var docString = ts.displayPartsToString(quickInfo.documentation); + return { + kind: quickInfo.kind, + kindModifiers: quickInfo.kindModifiers, + start: scriptInfo.positionToLineOffset(quickInfo.textSpan.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), + displayString: displayString, + documentation: docString, + }; + } + else { + return quickInfo; + } + }; + Session.prototype.getFormattingEditsForRange = function (args) { + var _this = this; + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var startPosition = scriptInfo.lineOffsetToPosition(args.line, args.offset); + var endPosition = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); + var edits = project.getLanguageService(false).getFormattingEditsForRange(file, startPosition, endPosition, this.projectService.getFormatCodeOptions(file)); + if (!edits) { + return undefined; + } + return edits.map(function (edit) { return _this.convertTextChangeToCodeEdit(edit, scriptInfo); }); + }; + Session.prototype.getFormattingEditsForRangeFull = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); + return project.getLanguageService(false).getFormattingEditsForRange(file, args.position, args.endPosition, options); + }; + Session.prototype.getFormattingEditsForDocumentFull = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); + return project.getLanguageService(false).getFormattingEditsForDocument(file, options); + }; + Session.prototype.getFormattingEditsAfterKeystrokeFull = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); + return project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, args.position, args.key, options); + }; + Session.prototype.getFormattingEditsAfterKeystroke = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = scriptInfo.lineOffsetToPosition(args.line, args.offset); + var formatOptions = this.projectService.getFormatCodeOptions(file); + var edits = project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, position, args.key, formatOptions); + if ((args.key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { + var lineInfo = scriptInfo.getLineInfo(args.line); + if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { + var lineText = lineInfo.leaf.text; + if (lineText.search("\\S") < 0) { + var preferredIndent = project.getLanguageService(false).getIndentationAtPosition(file, position, formatOptions); + var hasIndent = 0; + var i = void 0, len = void 0; + for (i = 0, len = lineText.length; i < len; i++) { + if (lineText.charAt(i) == " ") { + hasIndent++; + } + else if (lineText.charAt(i) == "\t") { + hasIndent += formatOptions.tabSize; + } + else { + break; + } + } + if (preferredIndent !== hasIndent) { + var firstNoWhiteSpacePosition = lineInfo.offset + i; + edits.push({ + span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition), + newText: ts.formatting.getIndentationString(preferredIndent, formatOptions) + }); + } + } + } + } + if (!edits) { + return undefined; + } + return edits.map(function (edit) { + return { + start: scriptInfo.positionToLineOffset(edit.span.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(edit.span)), + newText: edit.newText ? edit.newText : "" + }; + }); + }; + Session.prototype.getCompletions = function (args, simplifiedResult) { + var _this = this; + var prefix = args.prefix || ""; + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var completions = project.getLanguageService().getCompletionsAtPosition(file, position); + if (!completions) { + return undefined; + } + if (simplifiedResult) { + return completions.entries.reduce(function (result, entry) { + if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { + var name = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; + var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; + result.push({ name: name, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); + } + return result; + }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); + } + else { + return completions; + } + }; + Session.prototype.getCompletionEntryDetails = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + return args.entryNames.reduce(function (accum, entryName) { + var details = project.getLanguageService().getCompletionEntryDetails(file, position, entryName); + if (details) { + accum.push(details); + } + return accum; + }, []); + }; + Session.prototype.getCompileOnSaveAffectedFileList = function (args) { + var info = this.projectService.getScriptInfo(args.file); + var result = []; + if (!info) { + return []; + } + var projectsToSearch = args.projectFileName ? [this.projectService.findProject(args.projectFileName)] : info.containingProjects; + for (var _i = 0, projectsToSearch_1 = projectsToSearch; _i < projectsToSearch_1.length; _i++) { + var project = projectsToSearch_1[_i]; + if (project.compileOnSaveEnabled && project.languageServiceEnabled) { + result.push({ + projectFileName: project.getProjectName(), + fileNames: project.getCompileOnSaveAffectedFileList(info), + projectUsesOutFile: !!project.getCompilerOptions().outFile || !!project.getCompilerOptions().out + }); + } + } + return result; + }; + Session.prototype.emitFile = function (args) { + var _this = this; + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + if (!project) { + server.Errors.ThrowNoProject(); + } + if (!project.languageServiceEnabled) { + return false; + } + var scriptInfo = project.getScriptInfo(file); + return project.builder.emitFile(scriptInfo, function (path, data, writeByteOrderMark) { return _this.host.writeFile(path, data, writeByteOrderMark); }); + }; + Session.prototype.getSignatureHelpItems = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var helpItems = project.getLanguageService().getSignatureHelpItems(file, position); + if (!helpItems) { + return undefined; + } + if (simplifiedResult) { + var span_16 = helpItems.applicableSpan; + return { + items: helpItems.items, + applicableSpan: { + start: scriptInfo.positionToLineOffset(span_16.start), + end: scriptInfo.positionToLineOffset(span_16.start + span_16.length) + }, + selectedItemIndex: helpItems.selectedItemIndex, + argumentIndex: helpItems.argumentIndex, + argumentCount: helpItems.argumentCount, + }; + } + else { + return helpItems; + } + }; + Session.prototype.getDiagnostics = function (next, delay, fileNames) { + var _this = this; + var checkList = fileNames.reduce(function (accum, uncheckedFileName) { + var fileName = server.toNormalizedPath(uncheckedFileName); + var project = _this.projectService.getDefaultProjectForFile(fileName, true); + if (project) { + accum.push({ fileName: fileName, project: project }); + } + return accum; + }, []); + if (checkList.length > 0) { + this.updateErrorCheck(next, checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); + } + }; + Session.prototype.change = function (args) { + var _this = this; + var _a = this.getFileAndProject(args, false), file = _a.file, project = _a.project; + if (project) { + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var start = scriptInfo.lineOffsetToPosition(args.line, args.offset); + var end = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); + if (start >= 0) { + scriptInfo.editContent(start, end, args.insertString); + this.changeSeq++; + } + this.updateProjectStructure(this.changeSeq, function (n) { return n === _this.changeSeq; }); + } + }; + Session.prototype.reload = function (args, reqSeq) { + var file = server.toNormalizedPath(args.file); + var tempFileName = args.tmpfile && server.toNormalizedPath(args.tmpfile); + var project = this.projectService.getDefaultProjectForFile(file, true); + if (project) { + this.changeSeq++; + if (project.reloadScript(file, tempFileName)) { + this.output(undefined, CommandNames.Reload, reqSeq); + } + } + }; + Session.prototype.saveToTmp = function (fileName, tempFileName) { + var scriptInfo = this.projectService.getScriptInfo(fileName); + if (scriptInfo) { + scriptInfo.saveTo(tempFileName); + } + }; + Session.prototype.closeClientFile = function (fileName) { + if (!fileName) { + return; + } + var file = ts.normalizePath(fileName); + this.projectService.closeClientFile(file); + }; + Session.prototype.decorateNavigationBarItems = function (items, scriptInfo) { + var _this = this; + return ts.map(items, function (item) { return ({ + text: item.text, + kind: item.kind, + kindModifiers: item.kindModifiers, + spans: item.spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }), + childItems: _this.decorateNavigationBarItems(item.childItems, scriptInfo), + indent: item.indent + }); }); + }; + Session.prototype.getNavigationBarItems = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var items = project.getLanguageService(false).getNavigationBarItems(file); + return !items + ? undefined + : simplifiedResult + ? this.decorateNavigationBarItems(items, project.getScriptInfoForNormalizedPath(file)) + : items; + }; + Session.prototype.decorateNavigationTree = function (tree, scriptInfo) { + var _this = this; + return { + text: tree.text, + kind: tree.kind, + kindModifiers: tree.kindModifiers, + spans: tree.spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }), + childItems: ts.map(tree.childItems, function (item) { return _this.decorateNavigationTree(item, scriptInfo); }) + }; + }; + Session.prototype.decorateSpan = function (span, scriptInfo) { + return { + start: scriptInfo.positionToLineOffset(span.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(span)) + }; + }; + Session.prototype.getNavigationTree = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var tree = project.getLanguageService(false).getNavigationTree(file); + return !tree + ? undefined + : simplifiedResult + ? this.decorateNavigationTree(tree, project.getScriptInfoForNormalizedPath(file)) + : tree; + }; + Session.prototype.getNavigateToItems = function (args, simplifiedResult) { + var projects = this.getProjects(args); + var fileName = args.currentFileOnly ? args.file && ts.normalizeSlashes(args.file) : undefined; + if (simplifiedResult) { + return server.combineProjectOutput(projects, function (project) { + var navItems = project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); + if (!navItems) { + return []; + } + return navItems.map(function (navItem) { + var scriptInfo = project.getScriptInfo(navItem.fileName); + var start = scriptInfo.positionToLineOffset(navItem.textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(navItem.textSpan)); + var bakedItem = { + name: navItem.name, + kind: navItem.kind, + file: navItem.fileName, + start: start, + end: end, + }; + if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { + bakedItem.kindModifiers = navItem.kindModifiers; + } + if (navItem.matchKind !== "none") { + bakedItem.matchKind = navItem.matchKind; + } + if (navItem.containerName && (navItem.containerName.length > 0)) { + bakedItem.containerName = navItem.containerName; + } + if (navItem.containerKind && (navItem.containerKind.length > 0)) { + bakedItem.containerKind = navItem.containerKind; + } + return bakedItem; + }); + }, undefined, areNavToItemsForTheSameLocation); + } + else { + return server.combineProjectOutput(projects, function (project) { return project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); }, undefined, navigateToItemIsEqualTo); + } + function navigateToItemIsEqualTo(a, b) { + if (a === b) { + return true; + } + if (!a || !b) { + return false; + } + return a.containerKind === b.containerKind && + a.containerName === b.containerName && + a.fileName === b.fileName && + a.isCaseSensitive === b.isCaseSensitive && + a.kind === b.kind && + a.kindModifiers === b.containerName && + a.matchKind === b.matchKind && + a.name === b.name && + a.textSpan.start === b.textSpan.start && + a.textSpan.length === b.textSpan.length; + } + function areNavToItemsForTheSameLocation(a, b) { + if (a && b) { + return a.file === b.file && + a.start === b.start && + a.end === b.end; + } + return false; + } + }; + Session.prototype.getSupportedCodeFixes = function () { + return ts.getSupportedCodeFixes(); + }; + Session.prototype.getCodeFixes = function (args, simplifiedResult) { + var _this = this; + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var startPosition = getStartPosition(); + var endPosition = getEndPosition(); + var codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes); + if (!codeActions) { + return undefined; + } + if (simplifiedResult) { + return codeActions.map(function (codeAction) { return _this.mapCodeAction(codeAction, scriptInfo); }); + } + else { + return codeActions; + } + function getStartPosition() { + return args.startPosition !== undefined ? args.startPosition : scriptInfo.lineOffsetToPosition(args.startLine, args.startOffset); + } + function getEndPosition() { + return args.endPosition !== undefined ? args.endPosition : scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); + } + }; + Session.prototype.mapCodeAction = function (codeAction, scriptInfo) { + var _this = this; + return { + description: codeAction.description, + changes: codeAction.changes.map(function (change) { return ({ + fileName: change.fileName, + textChanges: change.textChanges.map(function (textChange) { return _this.convertTextChangeToCodeEdit(textChange, scriptInfo); }) + }); }) + }; + }; + Session.prototype.convertTextChangeToCodeEdit = function (change, scriptInfo) { + return { + start: scriptInfo.positionToLineOffset(change.span.start), + end: scriptInfo.positionToLineOffset(change.span.start + change.span.length), + newText: change.newText ? change.newText : "" + }; + }; + Session.prototype.getBraceMatching = function (args, simplifiedResult) { + var _this = this; + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var spans = project.getLanguageService(false).getBraceMatchingAtPosition(file, position); + return !spans + ? undefined + : simplifiedResult + ? spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }) + : spans; + }; + Session.prototype.getDiagnosticsForProject = function (next, delay, fileName) { + var _this = this; + var _a = this.getProjectInfoWorker(fileName, undefined, true), fileNames = _a.fileNames, languageServiceDisabled = _a.languageServiceDisabled; + if (languageServiceDisabled) { + return; + } + var fileNamesInProject = fileNames.filter(function (value) { return value.indexOf("lib.d.ts") < 0; }); + var highPriorityFiles = []; + var mediumPriorityFiles = []; + var lowPriorityFiles = []; + var veryLowPriorityFiles = []; + var normalizedFileName = server.toNormalizedPath(fileName); + var project = this.projectService.getDefaultProjectForFile(normalizedFileName, true); + for (var _i = 0, fileNamesInProject_1 = fileNamesInProject; _i < fileNamesInProject_1.length; _i++) { + var fileNameInProject = fileNamesInProject_1[_i]; + if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) + highPriorityFiles.push(fileNameInProject); + else { + var info = this.projectService.getScriptInfo(fileNameInProject); + if (!info.isScriptOpen()) { + if (fileNameInProject.indexOf(".d.ts") > 0) + veryLowPriorityFiles.push(fileNameInProject); + else + lowPriorityFiles.push(fileNameInProject); + } + else + mediumPriorityFiles.push(fileNameInProject); + } + } + fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); + if (fileNamesInProject.length > 0) { + var checkList = fileNamesInProject.map(function (fileName) { return ({ fileName: fileName, project: project }); }); + this.updateErrorCheck(next, checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); + } + }; + Session.prototype.getCanonicalFileName = function (fileName) { + var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return ts.normalizePath(name); + }; + Session.prototype.exit = function () { + }; + Session.prototype.notRequired = function () { + return { responseRequired: false }; + }; + Session.prototype.requiredResponse = function (response) { + return { response: response, responseRequired: true }; + }; + Session.prototype.addProtocolHandler = function (command, handler) { + if (this.handlers.has(command)) { + throw new Error("Protocol handler already exists for command \"" + command + "\""); + } + this.handlers.set(command, handler); + }; + Session.prototype.setCurrentRequest = function (requestId) { + ts.Debug.assert(this.currentRequestId === undefined); + this.currentRequestId = requestId; + this.cancellationToken.setRequest(requestId); + }; + Session.prototype.resetCurrentRequest = function (requestId) { + ts.Debug.assert(this.currentRequestId === requestId); + this.currentRequestId = undefined; + this.cancellationToken.resetRequest(requestId); + }; + Session.prototype.executeWithRequestId = function (requestId, f) { + try { + this.setCurrentRequest(requestId); + return f(); + } + finally { + this.resetCurrentRequest(requestId); + } + }; + Session.prototype.executeCommand = function (request) { + var handler = this.handlers.get(request.command); + if (handler) { + return this.executeWithRequestId(request.seq, function () { return handler(request); }); + } + else { + this.logger.msg("Unrecognized JSON command: " + JSON.stringify(request), server.Msg.Err); + this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); + return { responseRequired: false }; + } + }; + Session.prototype.onMessage = function (message) { + this.gcTimer.scheduleCollect(); + var start; + if (this.logger.hasLevel(server.LogLevel.requestTime)) { + start = this.hrtime(); + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("request: " + message); + } + } + var request; + try { + request = JSON.parse(message); + var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; + if (this.logger.hasLevel(server.LogLevel.requestTime)) { + var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4); + if (responseRequired) { + this.logger.perftrc(request.seq + "::" + request.command + ": elapsed time (in milliseconds) " + elapsedTime); + } + else { + this.logger.perftrc(request.seq + "::" + request.command + ": async elapsed time (in milliseconds) " + elapsedTime); + } + } + if (response) { + this.output(response, request.command, request.seq); + } + else if (responseRequired) { + this.output(undefined, request.command, request.seq, "No content available."); + } + } + catch (err) { + if (err instanceof ts.OperationCanceledException) { + this.output({ canceled: true }, request.command, request.seq); + return; + } + this.logError(err, message); + this.output(undefined, request ? request.command : CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message + "\n" + err.stack); + } + }; + return Session; + }()); + server.Session = Session; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var server; (function (server) { @@ -66777,7 +71247,7 @@ var ts; if (!this.formatCodeSettings) { this.formatCodeSettings = server.getDefaultFormatCodeSettings(this.host); } - server.mergeMaps(this.formatCodeSettings, formatSettings); + server.mergeMapLikes(this.formatCodeSettings, formatSettings); } }; ScriptInfo.prototype.setWatcher = function (watcher) { @@ -66832,6 +71302,9 @@ var ts; ScriptInfo.prototype.positionToLineOffset = function (position) { return this.textStorage.positionToLineOffset(position); }; + ScriptInfo.prototype.isJavaScript = function () { + return this.scriptKind === 1 || this.scriptKind === 2; + }; return ScriptInfo; }()); server.ScriptInfo = ScriptInfo; @@ -66858,7 +71331,7 @@ var ts; ? _this.project.projectService.typingsInstaller.globalTypingsCacheLocation : undefined; var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host); - if (!(primaryResult.resolvedModule && ts.extensionIsTypeScript(primaryResult.resolvedModule.extension)) && globalCache !== undefined) { + if (ts.moduleHasNonRelativeName(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTypeScript(primaryResult.resolvedModule.extension)) && globalCache !== undefined) { var _a = ts.loadModuleFromGlobalCache(moduleName, _this.project.getProjectName(), compilerOptions, host, globalCache), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (resolvedModule) { return { resolvedModule: resolvedModule, failedLookupLocations: primaryResult.failedLookupLocations.concat(failedLookupLocations) }; @@ -66886,15 +71359,16 @@ var ts; var compilerOptions = this.getCompilationSettings(); var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_51 = names_2[_i]; - var resolution = newResolutions[name_51]; + var name = names_2[_i]; + var resolution = newResolutions.get(name); if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_51]; + var existingResolution = currentResolutionsInFile && currentResolutionsInFile.get(name); if (moduleResolutionIsValid(existingResolution)) { resolution = existingResolution; } else { - newResolutions[name_51] = resolution = loader(name_51, containingFile, compilerOptions, this); + resolution = loader(name, containingFile, compilerOptions, this); + newResolutions.set(name, resolution); } if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { this.filesWithChangedSetOfUnresolvedImports.push(path); @@ -67042,18 +71516,19 @@ var ts; var unique = 0; for (var _i = 0, arr1_1 = arr1; _i < arr1_1.length; _i++) { var v = arr1_1[_i]; - if (set[v] !== true) { - set[v] = true; + if (set.get(v) !== true) { + set.set(v, true); unique++; } } for (var _a = 0, arr2_1 = arr2; _a < arr2_1.length; _a++) { var v = arr2_1[_a]; - if (!ts.hasProperty(set, v)) { + var isSet = set.get(v); + if (isSet === undefined) { return false; } - if (set[v] === true) { - set[v] = false; + if (isSet === true) { + set.set(v, false); unique--; } } @@ -67083,38 +71558,38 @@ var ts; if (!typeAcquisition || !typeAcquisition.enable) { return server.emptyArray; } - var entry = this.perProjectCache[project.getProjectName()]; + var entry = this.perProjectCache.get(project.getProjectName()); var result = entry ? entry.typings : server.emptyArray; if (forceRefresh || !entry || typeAcquisitionChanged(typeAcquisition, entry.typeAcquisition) || compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions) || unresolvedImportsChanged(unresolvedImports, entry.unresolvedImports)) { - this.perProjectCache[project.getProjectName()] = { + this.perProjectCache.set(project.getProjectName(), { compilerOptions: project.getCompilerOptions(), typeAcquisition: typeAcquisition, typings: result, unresolvedImports: unresolvedImports, poisoned: true - }; + }); this.installer.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports); } return result; }; TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typeAcquisition, unresolvedImports, newTypings) { - this.perProjectCache[projectName] = { + this.perProjectCache.set(projectName, { compilerOptions: compilerOptions, typeAcquisition: typeAcquisition, typings: server.toSortedReadonlyArray(newTypings), unresolvedImports: unresolvedImports, poisoned: false - }; + }); }; TypingsCache.prototype.deleteTypingsForProject = function (projectName) { - delete this.perProjectCache[projectName]; + this.perProjectCache.delete(projectName); }; TypingsCache.prototype.onProjectClosed = function (project) { - delete this.perProjectCache[project.getProjectName()]; + this.perProjectCache.delete(project.getProjectName()); this.installer.onProjectClosed(project); }; return TypingsCache; @@ -67123,6 +71598,314 @@ var ts; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var server; + (function (server) { + function shouldEmitFile(scriptInfo) { + return !scriptInfo.hasMixedContent; + } + server.shouldEmitFile = shouldEmitFile; + var BuilderFileInfo = (function () { + function BuilderFileInfo(scriptInfo, project) { + this.scriptInfo = scriptInfo; + this.project = project; + } + BuilderFileInfo.prototype.isExternalModuleOrHasOnlyAmbientExternalModules = function () { + var sourceFile = this.getSourceFile(); + return ts.isExternalModule(sourceFile) || this.containsOnlyAmbientModules(sourceFile); + }; + BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (statement.kind !== 232 || statement.name.kind !== 9) { + return false; + } + } + return true; + }; + BuilderFileInfo.prototype.computeHash = function (text) { + return this.project.projectService.host.createHash(text); + }; + BuilderFileInfo.prototype.getSourceFile = function () { + return this.project.getSourceFile(this.scriptInfo.path); + }; + BuilderFileInfo.prototype.updateShapeSignature = function () { + var sourceFile = this.getSourceFile(); + if (!sourceFile) { + return true; + } + var lastSignature = this.lastCheckedShapeSignature; + if (sourceFile.isDeclarationFile) { + this.lastCheckedShapeSignature = this.computeHash(sourceFile.text); + } + else { + var emitOutput = this.project.getFileEmitOutput(this.scriptInfo, true); + if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { + this.lastCheckedShapeSignature = this.computeHash(emitOutput.outputFiles[0].text); + } + } + return !lastSignature || this.lastCheckedShapeSignature !== lastSignature; + }; + return BuilderFileInfo; + }()); + server.BuilderFileInfo = BuilderFileInfo; + var AbstractBuilder = (function () { + function AbstractBuilder(project, ctor) { + this.project = project; + this.ctor = ctor; + } + AbstractBuilder.prototype.getFileInfos = function () { + return this.fileInfos_doNotAccessDirectly || (this.fileInfos_doNotAccessDirectly = ts.createFileMap()); + }; + AbstractBuilder.prototype.clear = function () { + this.fileInfos_doNotAccessDirectly = undefined; + }; + AbstractBuilder.prototype.getFileInfo = function (path) { + return this.getFileInfos().get(path); + }; + AbstractBuilder.prototype.getOrCreateFileInfo = function (path) { + var fileInfo = this.getFileInfo(path); + if (!fileInfo) { + var scriptInfo = this.project.getScriptInfo(path); + fileInfo = new this.ctor(scriptInfo, this.project); + this.setFileInfo(path, fileInfo); + } + return fileInfo; + }; + AbstractBuilder.prototype.getFileInfoPaths = function () { + return this.getFileInfos().getKeys(); + }; + AbstractBuilder.prototype.setFileInfo = function (path, info) { + this.getFileInfos().set(path, info); + }; + AbstractBuilder.prototype.removeFileInfo = function (path) { + this.getFileInfos().remove(path); + }; + AbstractBuilder.prototype.forEachFileInfo = function (action) { + this.getFileInfos().forEachValue(function (_path, value) { return action(value); }); + }; + AbstractBuilder.prototype.emitFile = function (scriptInfo, writeFile) { + var fileInfo = this.getFileInfo(scriptInfo.path); + if (!fileInfo) { + return false; + } + var _a = this.project.getFileEmitOutput(fileInfo.scriptInfo, false), emitSkipped = _a.emitSkipped, outputFiles = _a.outputFiles; + if (!emitSkipped) { + var projectRootPath = this.project.getProjectRootPath(); + for (var _i = 0, outputFiles_1 = outputFiles; _i < outputFiles_1.length; _i++) { + var outputFile = outputFiles_1[_i]; + var outputFileAbsoluteFileName = ts.getNormalizedAbsolutePath(outputFile.name, projectRootPath ? projectRootPath : ts.getDirectoryPath(scriptInfo.fileName)); + writeFile(outputFileAbsoluteFileName, outputFile.text, outputFile.writeByteOrderMark); + } + } + return !emitSkipped; + }; + return AbstractBuilder; + }()); + var NonModuleBuilder = (function (_super) { + __extends(NonModuleBuilder, _super); + function NonModuleBuilder(project) { + var _this = _super.call(this, project, BuilderFileInfo) || this; + _this.project = project; + return _this; + } + NonModuleBuilder.prototype.onProjectUpdateGraph = function () { + }; + NonModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { + var info = this.getOrCreateFileInfo(scriptInfo.path); + var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + if (info.updateShapeSignature()) { + var options = this.project.getCompilerOptions(); + if (options && (options.out || options.outFile)) { + return singleFileResult; + } + return this.project.getAllEmittableFiles(); + } + return singleFileResult; + }; + return NonModuleBuilder; + }(AbstractBuilder)); + var ModuleBuilderFileInfo = (function (_super) { + __extends(ModuleBuilderFileInfo, _super); + function ModuleBuilderFileInfo() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.references = []; + _this.referencedBy = []; + return _this; + } + ModuleBuilderFileInfo.compareFileInfos = function (lf, rf) { + var l = lf.scriptInfo.fileName; + var r = rf.scriptInfo.fileName; + return (l < r ? -1 : (l > r ? 1 : 0)); + }; + ; + ModuleBuilderFileInfo.addToReferenceList = function (array, fileInfo) { + if (array.length === 0) { + array.push(fileInfo); + return; + } + var insertIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); + if (insertIndex < 0) { + array.splice(~insertIndex, 0, fileInfo); + } + }; + ModuleBuilderFileInfo.removeFromReferenceList = function (array, fileInfo) { + if (!array || array.length === 0) { + return; + } + if (array[0] === fileInfo) { + array.splice(0, 1); + return; + } + var removeIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); + if (removeIndex >= 0) { + array.splice(removeIndex, 1); + } + }; + ModuleBuilderFileInfo.prototype.addReferencedBy = function (fileInfo) { + ModuleBuilderFileInfo.addToReferenceList(this.referencedBy, fileInfo); + }; + ModuleBuilderFileInfo.prototype.removeReferencedBy = function (fileInfo) { + ModuleBuilderFileInfo.removeFromReferenceList(this.referencedBy, fileInfo); + }; + ModuleBuilderFileInfo.prototype.removeFileReferences = function () { + for (var _i = 0, _a = this.references; _i < _a.length; _i++) { + var reference = _a[_i]; + reference.removeReferencedBy(this); + } + this.references = []; + }; + return ModuleBuilderFileInfo; + }(BuilderFileInfo)); + var ModuleBuilder = (function (_super) { + __extends(ModuleBuilder, _super); + function ModuleBuilder(project) { + var _this = _super.call(this, project, ModuleBuilderFileInfo) || this; + _this.project = project; + return _this; + } + ModuleBuilder.prototype.clear = function () { + this.projectVersionForDependencyGraph = undefined; + _super.prototype.clear.call(this); + }; + ModuleBuilder.prototype.getReferencedFileInfos = function (fileInfo) { + var _this = this; + if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { + return []; + } + var referencedFilePaths = this.project.getReferencedFiles(fileInfo.scriptInfo.path); + if (referencedFilePaths.length > 0) { + return ts.map(referencedFilePaths, function (f) { return _this.getOrCreateFileInfo(f); }).sort(ModuleBuilderFileInfo.compareFileInfos); + } + return []; + }; + ModuleBuilder.prototype.onProjectUpdateGraph = function () { + this.ensureProjectDependencyGraphUpToDate(); + }; + ModuleBuilder.prototype.ensureProjectDependencyGraphUpToDate = function () { + var _this = this; + if (!this.projectVersionForDependencyGraph || this.project.getProjectVersion() !== this.projectVersionForDependencyGraph) { + var currentScriptInfos = this.project.getScriptInfos(); + for (var _i = 0, currentScriptInfos_1 = currentScriptInfos; _i < currentScriptInfos_1.length; _i++) { + var scriptInfo = currentScriptInfos_1[_i]; + var fileInfo = this.getOrCreateFileInfo(scriptInfo.path); + this.updateFileReferences(fileInfo); + } + this.forEachFileInfo(function (fileInfo) { + if (!_this.project.containsScriptInfo(fileInfo.scriptInfo)) { + fileInfo.removeFileReferences(); + _this.removeFileInfo(fileInfo.scriptInfo.path); + } + }); + this.projectVersionForDependencyGraph = this.project.getProjectVersion(); + } + }; + ModuleBuilder.prototype.updateFileReferences = function (fileInfo) { + if (fileInfo.scriptVersionForReferences === fileInfo.scriptInfo.getLatestVersion()) { + return; + } + var newReferences = this.getReferencedFileInfos(fileInfo); + var oldReferences = fileInfo.references; + var oldIndex = 0; + var newIndex = 0; + while (oldIndex < oldReferences.length && newIndex < newReferences.length) { + var oldReference = oldReferences[oldIndex]; + var newReference = newReferences[newIndex]; + var compare = ModuleBuilderFileInfo.compareFileInfos(oldReference, newReference); + if (compare < 0) { + oldReference.removeReferencedBy(fileInfo); + oldIndex++; + } + else if (compare > 0) { + newReference.addReferencedBy(fileInfo); + newIndex++; + } + else { + oldIndex++; + newIndex++; + } + } + for (var i = oldIndex; i < oldReferences.length; i++) { + oldReferences[i].removeReferencedBy(fileInfo); + } + for (var i = newIndex; i < newReferences.length; i++) { + newReferences[i].addReferencedBy(fileInfo); + } + fileInfo.references = newReferences; + fileInfo.scriptVersionForReferences = fileInfo.scriptInfo.getLatestVersion(); + }; + ModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { + this.ensureProjectDependencyGraphUpToDate(); + var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + var fileInfo = this.getFileInfo(scriptInfo.path); + if (!fileInfo || !fileInfo.updateShapeSignature()) { + return singleFileResult; + } + if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { + return this.project.getAllEmittableFiles(); + } + var options = this.project.getCompilerOptions(); + if (options && (options.isolatedModules || options.out || options.outFile)) { + return singleFileResult; + } + var queue = fileInfo.referencedBy.slice(0); + var fileNameSet = ts.createMap(); + fileNameSet.set(scriptInfo.fileName, scriptInfo); + while (queue.length > 0) { + var processingFileInfo = queue.pop(); + if (processingFileInfo.updateShapeSignature() && processingFileInfo.referencedBy.length > 0) { + for (var _i = 0, _a = processingFileInfo.referencedBy; _i < _a.length; _i++) { + var potentialFileInfo = _a[_i]; + if (!fileNameSet.has(potentialFileInfo.scriptInfo.fileName)) { + queue.push(potentialFileInfo); + } + } + } + fileNameSet.set(processingFileInfo.scriptInfo.fileName, processingFileInfo.scriptInfo); + } + var result = []; + fileNameSet.forEach(function (scriptInfo, fileName) { + if (shouldEmitFile(scriptInfo)) { + result.push(fileName); + } + }); + return result; + }; + return ModuleBuilder; + }(AbstractBuilder)); + function createBuilder(project) { + var moduleKind = project.getCompilerOptions().module; + switch (moduleKind) { + case ts.ModuleKind.None: + return new NonModuleBuilder(project); + default: + return new ModuleBuilder(project); + } + } + server.createBuilder = createBuilder; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var server; (function (server) { @@ -67222,7 +72005,7 @@ var ts; this.compilerOptions.allowNonTsExtensions = true; this.compilerOptions.allowJs = true; } - else if (hasExplicitListOfFiles) { + else if (hasExplicitListOfFiles || this.compilerOptions.allowJs) { this.compilerOptions.allowNonTsExtensions = true; } this.setInternalCompilerOptionsForEmittingJsFiles(); @@ -67246,6 +72029,16 @@ var ts; Project.prototype.getCachedUnresolvedImportsPerFile_TestOnly = function () { return this.cachedUnresolvedImportsPerFile; }; + Project.resolveModule = function (moduleName, initialDir, host, log) { + var resolvedPath = ts.normalizeSlashes(host.resolvePath(ts.combinePaths(initialDir, "node_modules"))); + log("Loading " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")"); + var result = host.require(resolvedPath, moduleName); + if (result.error) { + log("Failed to load module: " + JSON.stringify(result.error)); + return undefined; + } + return result.module; + }; Project.prototype.setInternalCompilerOptionsForEmittingJsFiles = function () { if (this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) { this.compilerOptions.noEmitForJsFiles = true; @@ -67289,6 +72082,9 @@ var ts; Project.prototype.getProjectName = function () { return this.projectName; }; + Project.prototype.getExternalFiles = function () { + return []; + }; Project.prototype.getSourceFile = function (path) { if (!this.program) { return undefined; @@ -67429,7 +72225,9 @@ var ts; }; Project.prototype.removeFile = function (info, detachFromProject) { if (detachFromProject === void 0) { detachFromProject = true; } - this.removeRootFileIfNecessary(info); + if (this.isRoot(info)) { + this.removeRoot(info); + } this.lsHost.notifyFileRemoved(info); this.cachedUnresolvedImportsPerFile.remove(info.path); if (detachFromProject) { @@ -67438,7 +72236,7 @@ var ts; this.markAsDirty(); }; Project.prototype.registerFileUpdate = function (fileName) { - (this.updatedFileNames || (this.updatedFileNames = ts.createMap()))[fileName] = fileName; + (this.updatedFileNames || (this.updatedFileNames = ts.createMap())).set(fileName, fileName); }; Project.prototype.markAsDirty = function () { this.projectStateVersion++; @@ -67446,17 +72244,17 @@ var ts; Project.prototype.extractUnresolvedImportsFromSourceFile = function (file, result) { var cached = this.cachedUnresolvedImportsPerFile.get(file.path); if (cached) { - for (var _i = 0, cached_1 = cached; _i < cached_1.length; _i++) { - var f = cached_1[_i]; + for (var _i = 0, cached_2 = cached; _i < cached_2.length; _i++) { + var f = cached_2[_i]; result.push(f); } return; } var unresolvedImports; if (file.resolvedModules) { - for (var name_52 in file.resolvedModules) { - if (!file.resolvedModules[name_52] && !ts.isExternalModuleNameRelative(name_52)) { - var trimmed = name_52.trim(); + file.resolvedModules.forEach(function (resolvedModule, name) { + if (!resolvedModule && !ts.isExternalModuleNameRelative(name)) { + var trimmed = name.trim(); var i = trimmed.indexOf("/"); if (i !== -1 && trimmed.charCodeAt(0) === 64) { i = trimmed.indexOf("/", i + 1); @@ -67467,7 +72265,7 @@ var ts; (unresolvedImports || (unresolvedImports = [])).push(trimmed); result.push(trimmed); } - } + }); } this.cachedUnresolvedImportsPerFile.set(file.path, unresolvedImports || server.emptyArray); }; @@ -67563,9 +72361,6 @@ var ts; }; Project.prototype.setCompilerOptions = function (compilerOptions) { if (compilerOptions) { - if (this.projectKind === ProjectKind.Inferred) { - compilerOptions.allowJs = true; - } compilerOptions.allowNonTsExtensions = true; if (ts.changesAffectModuleResolution(this.compilerOptions, compilerOptions)) { this.cachedUnresolvedImportsPerFile.clear(); @@ -67601,24 +72396,24 @@ var ts; if (this.projectStructureVersion == this.lastReportedVersion && !updatedFileNames) { return { info: info, projectErrors: this.projectErrors }; } - var lastReportedFileNames = this.lastReportedFileNames; - var currentFiles = ts.arrayToMap(this.getFileNames(), function (x) { return x; }); - var added = []; - var removed = []; - var updated = ts.getOwnKeys(updatedFileNames); - for (var id in currentFiles) { - if (!ts.hasProperty(lastReportedFileNames, id)) { - added.push(id); + var lastReportedFileNames_1 = this.lastReportedFileNames; + var currentFiles_1 = ts.arrayToMap(this.getFileNames(), function (x) { return x; }); + var added_1 = []; + var removed_1 = []; + var updated = ts.arrayFrom(updatedFileNames.keys()); + ts.forEachKey(currentFiles_1, function (id) { + if (!lastReportedFileNames_1.has(id)) { + added_1.push(id); } - } - for (var id in lastReportedFileNames) { - if (!ts.hasProperty(currentFiles, id)) { - removed.push(id); + }); + ts.forEachKey(lastReportedFileNames_1, function (id) { + if (!currentFiles_1.has(id)) { + removed_1.push(id); } - } - this.lastReportedFileNames = currentFiles; + }); + this.lastReportedFileNames = currentFiles_1; this.lastReportedVersion = this.projectStructureVersion; - return { info: info, changes: { added: added, removed: removed, updated: updated }, projectErrors: this.projectErrors }; + return { info: info, changes: { added: added_1, removed: removed_1, updated: updated }, projectErrors: this.projectErrors }; } else { var projectFileNames = this.getFileNames(); @@ -67645,7 +72440,7 @@ var ts; if (symbol && symbol.declarations && symbol.declarations[0]) { var declarationSourceFile = symbol.declarations[0].getSourceFile(); if (declarationSourceFile) { - referencedFiles[declarationSourceFile.path] = true; + referencedFiles.set(declarationSourceFile.path, true); } } } @@ -67656,28 +72451,25 @@ var ts; for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) { var referencedFile = _c[_b]; var referencedPath = ts.toPath(referencedFile.fileName, currentDirectory, getCanonicalFileName); - referencedFiles[referencedPath] = true; + referencedFiles.set(referencedPath, true); } } if (sourceFile.resolvedTypeReferenceDirectiveNames) { - for (var typeName in sourceFile.resolvedTypeReferenceDirectiveNames) { - var resolvedTypeReferenceDirective = sourceFile.resolvedTypeReferenceDirectiveNames[typeName]; + sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) { if (!resolvedTypeReferenceDirective) { - continue; + return; } var fileName = resolvedTypeReferenceDirective.resolvedFileName; var typeFilePath = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - referencedFiles[typeFilePath] = true; - } + referencedFiles.set(typeFilePath, true); + }); } - var allFileNames = ts.map(Object.keys(referencedFiles), function (key) { return key; }); + var allFileNames = ts.arrayFrom(referencedFiles.keys()); return ts.filter(allFileNames, function (file) { return _this.projectService.host.fileExists(file); }); }; - Project.prototype.removeRootFileIfNecessary = function (info) { - if (this.isRoot(info)) { - remove(this.rootFiles, info); - this.rootFilesMap.remove(info.path); - } + Project.prototype.removeRoot = function (info) { + remove(this.rootFiles, info); + this.rootFilesMap.remove(info.path); }; return Project; }()); @@ -67686,9 +72478,44 @@ var ts; __extends(InferredProject, _super); function InferredProject(projectService, documentRegistry, compilerOptions) { var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, undefined, true, compilerOptions, false) || this; + _this._isJsInferredProject = false; _this.directoriesWatchedForTsconfig = []; return _this; } + InferredProject.prototype.toggleJsInferredProject = function (isJsInferredProject) { + if (isJsInferredProject !== this._isJsInferredProject) { + this._isJsInferredProject = isJsInferredProject; + this.setCompilerOptions(); + } + }; + InferredProject.prototype.setCompilerOptions = function (options) { + var newOptions = options ? ts.clone(options) : this.getCompilerOptions(); + if (!newOptions) { + return; + } + if (this._isJsInferredProject && typeof newOptions.maxNodeModuleJsDepth !== "number") { + newOptions.maxNodeModuleJsDepth = 2; + } + else if (!this._isJsInferredProject) { + newOptions.maxNodeModuleJsDepth = undefined; + } + newOptions.allowJs = true; + _super.prototype.setCompilerOptions.call(this, newOptions); + }; + InferredProject.prototype.addRoot = function (info) { + if (!this._isJsInferredProject && info.isJavaScript()) { + this.toggleJsInferredProject(true); + } + _super.prototype.addRoot.call(this, info); + }; + InferredProject.prototype.removeRoot = function (info) { + if (this._isJsInferredProject && info.isJavaScript()) { + if (ts.filter(this.getRootScriptInfos(), function (info) { return info.isJavaScript(); }).length === 0) { + this.toggleJsInferredProject(false); + } + } + _super.prototype.removeRoot.call(this, info); + }; InferredProject.prototype.getProjectRootPath = function () { if (this.projectService.useSingleInferredProject) { return undefined; @@ -67725,15 +72552,63 @@ var ts; __extends(ConfiguredProject, _super); function ConfiguredProject(configFileName, projectService, documentRegistry, hasExplicitListOfFiles, compilerOptions, wildcardDirectories, languageServiceEnabled, compileOnSaveEnabled) { var _this = _super.call(this, configFileName, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.configFileName = configFileName; _this.wildcardDirectories = wildcardDirectories; _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.plugins = []; _this.openRefCount = 0; _this.canonicalConfigFilePath = server.asNormalizedPath(projectService.toCanonicalFileName(configFileName)); + _this.enablePlugins(); return _this; } ConfiguredProject.prototype.getConfigFilePath = function () { return this.getProjectName(); }; + ConfiguredProject.prototype.enablePlugins = function () { + var _this = this; + var host = this.projectService.host; + var options = this.getCompilerOptions(); + var log = function (message) { + _this.projectService.logger.info(message); + }; + if (!(options.plugins && options.plugins.length)) { + this.projectService.logger.info("No plugins exist"); + return; + } + if (!host.require) { + this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); + return; + } + for (var _i = 0, _a = options.plugins; _i < _a.length; _i++) { + var pluginConfigEntry = _a[_i]; + var searchPath = ts.getDirectoryPath(this.configFileName); + var resolvedModule = Project.resolveModule(pluginConfigEntry.name, searchPath, host, log); + if (resolvedModule) { + this.enableProxy(resolvedModule, pluginConfigEntry); + } + } + }; + ConfiguredProject.prototype.enableProxy = function (pluginModuleFactory, configEntry) { + try { + if (typeof pluginModuleFactory !== "function") { + this.projectService.logger.info("Skipped loading plugin " + configEntry.name + " because it did expose a proper factory function"); + return; + } + var info = { + config: configEntry, + project: this, + languageService: this.languageService, + languageServiceHost: this.lsHost, + serverHost: this.projectService.host + }; + var pluginModule = pluginModuleFactory({ typescript: ts }); + this.languageService = pluginModule.create(info); + this.plugins.push(pluginModule); + } + catch (e) { + this.projectService.logger.info("Plugin activation failed: " + e); + } + }; ConfiguredProject.prototype.getProjectRootPath = function () { return ts.getDirectoryPath(this.getConfigFilePath()); }; @@ -67746,6 +72621,21 @@ var ts; ConfiguredProject.prototype.getTypeAcquisition = function () { return this.typeAcquisition; }; + ConfiguredProject.prototype.getExternalFiles = function () { + var items = []; + for (var _i = 0, _a = this.plugins; _i < _a.length; _i++) { + var plugin = _a[_i]; + if (typeof plugin.getExternalFiles === "function") { + try { + items.push.apply(items, plugin.getExternalFiles(this)); + } + catch (e) { + this.projectService.logger.info("A plugin threw an exception in getExternalFiles: " + e); + } + } + } + return items; + }; ConfiguredProject.prototype.watchConfigFile = function (callback) { var _this = this; this.projectFileWatcher = this.projectService.host.watchFile(this.getConfigFilePath(), function (_) { return callback(_this); }); @@ -67776,14 +72666,14 @@ var ts; return; } var configDirectoryPath = ts.getDirectoryPath(this.getConfigFilePath()); - this.directoriesWatchedForWildcards = ts.reduceProperties(this.wildcardDirectories, function (watchers, flag, directory) { + this.directoriesWatchedForWildcards = ts.createMap(); + this.wildcardDirectories.forEach(function (flag, directory) { if (ts.comparePaths(configDirectoryPath, directory, ".", !_this.projectService.host.useCaseSensitiveFileNames) !== 0) { var recursive = (flag & 1) !== 0; _this.projectService.logger.info("Add " + (recursive ? "recursive " : "") + "watcher for: " + directory); - watchers[directory] = _this.projectService.host.watchDirectory(directory, function (path) { return callback(_this, path); }, recursive); + _this.directoriesWatchedForWildcards.set(directory, _this.projectService.host.watchDirectory(directory, function (path) { return callback(_this, path); }, recursive)); } - return watchers; - }, {}); + }); }; ConfiguredProject.prototype.stopWatchingDirectory = function () { if (this.directoryWatcher) { @@ -67803,9 +72693,9 @@ var ts; } this.typeRootsWatchers = undefined; } - for (var id in this.directoriesWatchedForWildcards) { - this.directoriesWatchedForWildcards[id].close(); - } + this.directoriesWatchedForWildcards.forEach(function (watcher) { + watcher.close(); + }); this.directoriesWatchedForWildcards = undefined; this.stopWatchingDirectory(); }; @@ -67882,36 +72772,35 @@ var ts; var option = commandLineOptions_1[_i]; if (typeof option.type === "object") { var optionMap = option.type; - for (var id in optionMap) { - ts.Debug.assert(typeof optionMap[id] === "number"); - } - map[option.name] = optionMap; + optionMap.forEach(function (value) { + ts.Debug.assert(typeof value === "number"); + }); + map.set(option.name, optionMap); } } return map; } var compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(ts.optionDeclarations); - var indentStyle = ts.createMap({ + var indentStyle = ts.createMapFromTemplate({ "none": ts.IndentStyle.None, "block": ts.IndentStyle.Block, "smart": ts.IndentStyle.Smart }); function convertFormatOptions(protocolOptions) { if (typeof protocolOptions.indentStyle === "string") { - protocolOptions.indentStyle = indentStyle[protocolOptions.indentStyle.toLowerCase()]; + protocolOptions.indentStyle = indentStyle.get(protocolOptions.indentStyle.toLowerCase()); ts.Debug.assert(protocolOptions.indentStyle !== undefined); } return protocolOptions; } server.convertFormatOptions = convertFormatOptions; function convertCompilerOptions(protocolOptions) { - for (var id in compilerOptionConverters) { + compilerOptionConverters.forEach(function (mappedValues, id) { var propertyValue = protocolOptions[id]; if (typeof propertyValue === "string") { - var mappedValues = compilerOptionConverters[id]; - protocolOptions[id] = mappedValues[propertyValue.toLowerCase()]; + protocolOptions[id] = mappedValues.get(propertyValue.toLowerCase()); } - } + }); return protocolOptions; } server.convertCompilerOptions = convertCompilerOptions; @@ -67955,8 +72844,8 @@ var ts; hasMixedContent: function (x) { return x.hasMixedContent; } }; function findProjectByName(projectName, projects) { - for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) { - var proj = projects_1[_i]; + for (var _i = 0, projects_2 = projects; _i < projects_2.length; _i++) { + var proj = projects_2[_i]; if (proj.getProjectName() === projectName) { return proj; } @@ -67978,24 +72867,25 @@ var ts; this.directoryWatchersRefCount = ts.createMap(); } DirectoryWatchers.prototype.stopWatchingDirectory = function (directory) { - this.directoryWatchersRefCount[directory]--; - if (this.directoryWatchersRefCount[directory] === 0) { + var refCount = this.directoryWatchersRefCount.get(directory) - 1; + this.directoryWatchersRefCount.set(directory, refCount); + if (refCount === 0) { this.projectService.logger.info("Close directory watcher for: " + directory); - this.directoryWatchersForTsconfig[directory].close(); - delete this.directoryWatchersForTsconfig[directory]; + this.directoryWatchersForTsconfig.get(directory).close(); + this.directoryWatchersForTsconfig.delete(directory); } }; DirectoryWatchers.prototype.startWatchingContainingDirectoriesForFile = function (fileName, project, callback) { var currentPath = ts.getDirectoryPath(fileName); var parentPath = ts.getDirectoryPath(currentPath); while (currentPath != parentPath) { - if (!this.directoryWatchersForTsconfig[currentPath]) { + if (!this.directoryWatchersForTsconfig.has(currentPath)) { this.projectService.logger.info("Add watcher for: " + currentPath); - this.directoryWatchersForTsconfig[currentPath] = this.projectService.host.watchDirectory(currentPath, callback); - this.directoryWatchersRefCount[currentPath] = 1; + this.directoryWatchersForTsconfig.set(currentPath, this.projectService.host.watchDirectory(currentPath, callback)); + this.directoryWatchersRefCount.set(currentPath, 1); } else { - this.directoryWatchersRefCount[currentPath] += 1; + this.directoryWatchersRefCount.set(currentPath, this.directoryWatchersRefCount.get(currentPath) + 1); } project.directoriesWatchedForTsconfig.push(currentPath); currentPath = parentPath; @@ -68134,8 +73024,8 @@ var ts; }; ProjectService.prototype.updateProjectGraphs = function (projects) { var shouldRefreshInferredProjects = false; - for (var _i = 0, projects_2 = projects; _i < projects_2.length; _i++) { - var p = projects_2[_i]; + for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { + var p = projects_3[_i]; if (!p.updateGraph()) { shouldRefreshInferredProjects = true; } @@ -68395,8 +73285,8 @@ var ts; } this.logger.endGroup(); function printProjects(logger, projects, counter) { - for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { - var project = projects_3[_i]; + for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { + var project = projects_4[_i]; project.updateGraph(); logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); logger.info(project.filesToString()); @@ -68442,7 +73332,7 @@ var ts; files: parsedCommandLine.fileNames, compilerOptions: parsedCommandLine.options, configHasFilesProperty: config["files"] !== undefined, - wildcardDirectories: ts.createMap(parsedCommandLine.wildcardDirectories), + wildcardDirectories: ts.createMapFromTemplate(parsedCommandLine.wildcardDirectories), typeAcquisition: parsedCommandLine.typeAcquisition, compileOnSave: parsedCommandLine.compileOnSave }; @@ -68700,7 +73590,7 @@ var ts; this.logger.info("Host information " + args.hostInfo); } if (args.formatOptions) { - server.mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); + server.mergeMapLikes(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); this.logger.info("Format host information updated"); } if (args.extraFileExtensions) { @@ -68780,13 +73670,13 @@ var ts; this.printProjects(); }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_4 = function (proj) { + var _loop_6 = function (proj) { var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); }; for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { var proj = currentProjects_1[_i]; - _loop_4(proj); + _loop_6(proj); } }; ProjectService.prototype.synchronizeProjectList = function (knownProjects) { @@ -68845,7 +73735,7 @@ var ts; ProjectService.prototype.closeExternalProject = function (uncheckedFileName, suppressRefresh) { if (suppressRefresh === void 0) { suppressRefresh = false; } var fileName = server.toNormalizedPath(uncheckedFileName); - var configFiles = this.externalProjectToConfiguredProjectMap[fileName]; + var configFiles = this.externalProjectToConfiguredProjectMap.get(fileName); if (configFiles) { var shouldRefreshInferredProjects = false; for (var _i = 0, configFiles_1 = configFiles; _i < configFiles_1.length; _i++) { @@ -68854,7 +73744,7 @@ var ts; shouldRefreshInferredProjects = true; } } - delete this.externalProjectToConfiguredProjectMap[fileName]; + this.externalProjectToConfiguredProjectMap.delete(fileName); if (shouldRefreshInferredProjects && !suppressRefresh) { this.refreshInferredProjects(); } @@ -68870,18 +73760,19 @@ var ts; } }; ProjectService.prototype.openExternalProjects = function (projects) { + var _this = this; var projectsToClose = ts.arrayToMap(this.externalProjects, function (p) { return p.getProjectName(); }, function (_) { return true; }); - for (var externalProjectName in this.externalProjectToConfiguredProjectMap) { - projectsToClose[externalProjectName] = true; - } - for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { - var externalProject = projects_4[_i]; + ts.forEachKey(this.externalProjectToConfiguredProjectMap, function (externalProjectName) { + projectsToClose.set(externalProjectName, true); + }); + for (var _i = 0, projects_5 = projects; _i < projects_5.length; _i++) { + var externalProject = projects_5[_i]; this.openExternalProject(externalProject, true); - delete projectsToClose[externalProject.projectFileName]; - } - for (var externalProjectName in projectsToClose) { - this.closeExternalProject(externalProjectName, true); + projectsToClose.delete(externalProject.projectFileName); } + ts.forEachKey(projectsToClose, function (externalProjectName) { + _this.closeExternalProject(externalProjectName, true); + }); this.refreshInferredProjects(); }; ProjectService.prototype.openExternalProject = function (proj, suppressRefreshOfInferredProjects) { @@ -68923,12 +73814,12 @@ var ts; } this.closeExternalProject(proj.projectFileName, true); } - else if (this.externalProjectToConfiguredProjectMap[proj.projectFileName]) { + else if (this.externalProjectToConfiguredProjectMap.get(proj.projectFileName)) { if (!tsConfigFiles) { this.closeExternalProject(proj.projectFileName, true); } else { - var oldConfigFiles = this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + var oldConfigFiles = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName); var iNew = 0; var iOld = 0; while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { @@ -68953,7 +73844,7 @@ var ts; } } if (tsConfigFiles) { - this.externalProjectToConfiguredProjectMap[proj.projectFileName] = tsConfigFiles; + this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, tsConfigFiles); for (var _b = 0, tsConfigFiles_1 = tsConfigFiles; _b < tsConfigFiles_1.length; _b++) { var tsconfigFile = tsConfigFiles_1[_b]; var project = this.findConfiguredProjectByProjectName(tsconfigFile); @@ -68967,7 +73858,7 @@ var ts; } } else { - delete this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName); this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); } if (!suppressRefreshOfInferredProjects) { @@ -68979,1783 +73870,6 @@ var ts; server.ProjectService = ProjectService; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - function hrTimeToMilliseconds(time) { - var seconds = time[0]; - var nanoseconds = time[1]; - return ((1e9 * seconds) + nanoseconds) / 1000000.0; - } - function shouldSkipSematicCheck(project) { - if (project.getCompilerOptions().skipLibCheck !== undefined) { - return false; - } - if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && project.isJsOnlyProject()) { - return true; - } - return false; - } - function compareNumber(a, b) { - return a - b; - } - function compareFileStart(a, b) { - if (a.file < b.file) { - return -1; - } - else if (a.file == b.file) { - var n = compareNumber(a.start.line, b.start.line); - if (n === 0) { - return compareNumber(a.start.offset, b.start.offset); - } - else - return n; - } - else { - return 1; - } - } - function formatDiag(fileName, project, diag) { - var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); - return { - start: scriptInfo.positionToLineOffset(diag.start), - end: scriptInfo.positionToLineOffset(diag.start + diag.length), - text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), - code: diag.code - }; - } - function formatConfigFileDiag(diag) { - return { - start: undefined, - end: undefined, - text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") - }; - } - function allEditsBeforePos(edits, pos) { - for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { - var edit = edits_1[_i]; - if (ts.textSpanEnd(edit.span) >= pos) { - return false; - } - } - return true; - } - var CommandNames; - (function (CommandNames) { - CommandNames.Brace = "brace"; - CommandNames.BraceFull = "brace-full"; - CommandNames.BraceCompletion = "braceCompletion"; - CommandNames.Change = "change"; - CommandNames.Close = "close"; - CommandNames.Completions = "completions"; - CommandNames.CompletionsFull = "completions-full"; - CommandNames.CompletionDetails = "completionEntryDetails"; - CommandNames.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; - CommandNames.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; - CommandNames.Configure = "configure"; - CommandNames.Definition = "definition"; - CommandNames.DefinitionFull = "definition-full"; - CommandNames.Exit = "exit"; - CommandNames.Format = "format"; - CommandNames.Formatonkey = "formatonkey"; - CommandNames.FormatFull = "format-full"; - CommandNames.FormatonkeyFull = "formatonkey-full"; - CommandNames.FormatRangeFull = "formatRange-full"; - CommandNames.Geterr = "geterr"; - CommandNames.GeterrForProject = "geterrForProject"; - CommandNames.Implementation = "implementation"; - CommandNames.ImplementationFull = "implementation-full"; - CommandNames.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; - CommandNames.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; - CommandNames.NavBar = "navbar"; - CommandNames.NavBarFull = "navbar-full"; - CommandNames.NavTree = "navtree"; - CommandNames.NavTreeFull = "navtree-full"; - CommandNames.Navto = "navto"; - CommandNames.NavtoFull = "navto-full"; - CommandNames.Occurrences = "occurrences"; - CommandNames.DocumentHighlights = "documentHighlights"; - CommandNames.DocumentHighlightsFull = "documentHighlights-full"; - CommandNames.Open = "open"; - CommandNames.Quickinfo = "quickinfo"; - CommandNames.QuickinfoFull = "quickinfo-full"; - CommandNames.References = "references"; - CommandNames.ReferencesFull = "references-full"; - CommandNames.Reload = "reload"; - CommandNames.Rename = "rename"; - CommandNames.RenameInfoFull = "rename-full"; - CommandNames.RenameLocationsFull = "renameLocations-full"; - CommandNames.Saveto = "saveto"; - CommandNames.SignatureHelp = "signatureHelp"; - CommandNames.SignatureHelpFull = "signatureHelp-full"; - CommandNames.TypeDefinition = "typeDefinition"; - CommandNames.ProjectInfo = "projectInfo"; - CommandNames.ReloadProjects = "reloadProjects"; - CommandNames.Unknown = "unknown"; - CommandNames.OpenExternalProject = "openExternalProject"; - CommandNames.OpenExternalProjects = "openExternalProjects"; - CommandNames.CloseExternalProject = "closeExternalProject"; - CommandNames.SynchronizeProjectList = "synchronizeProjectList"; - CommandNames.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; - CommandNames.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; - CommandNames.Cleanup = "cleanup"; - CommandNames.OutliningSpans = "outliningSpans"; - CommandNames.TodoComments = "todoComments"; - CommandNames.Indentation = "indentation"; - CommandNames.DocCommentTemplate = "docCommentTemplate"; - CommandNames.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; - CommandNames.NameOrDottedNameSpan = "nameOrDottedNameSpan"; - CommandNames.BreakpointStatement = "breakpointStatement"; - CommandNames.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; - CommandNames.GetCodeFixes = "getCodeFixes"; - CommandNames.GetCodeFixesFull = "getCodeFixes-full"; - CommandNames.GetSupportedCodeFixes = "getSupportedCodeFixes"; - })(CommandNames = server.CommandNames || (server.CommandNames = {})); - function formatMessage(msg, logger, byteLength, newLine) { - var verboseLogging = logger.hasLevel(server.LogLevel.verbose); - var json = JSON.stringify(msg); - if (verboseLogging) { - logger.info(msg.type + ": " + json); - } - var len = byteLength(json, "utf8"); - return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; - } - server.formatMessage = formatMessage; - var Session = (function () { - function Session(host, cancellationToken, useSingleInferredProject, typingsInstaller, byteLength, hrtime, logger, canUseEvents, eventHandler) { - var _this = this; - this.host = host; - this.typingsInstaller = typingsInstaller; - this.byteLength = byteLength; - this.hrtime = hrtime; - this.logger = logger; - this.canUseEvents = canUseEvents; - this.changeSeq = 0; - this.handlers = ts.createMap((_a = {}, - _a[CommandNames.OpenExternalProject] = function (request) { - _this.projectService.openExternalProject(request.arguments, false); - return _this.requiredResponse(true); - }, - _a[CommandNames.OpenExternalProjects] = function (request) { - _this.projectService.openExternalProjects(request.arguments.projects); - return _this.requiredResponse(true); - }, - _a[CommandNames.CloseExternalProject] = function (request) { - _this.projectService.closeExternalProject(request.arguments.projectFileName); - return _this.requiredResponse(true); - }, - _a[CommandNames.SynchronizeProjectList] = function (request) { - var result = _this.projectService.synchronizeProjectList(request.arguments.knownProjects); - if (!result.some(function (p) { return p.projectErrors && p.projectErrors.length !== 0; })) { - return _this.requiredResponse(result); - } - var converted = ts.map(result, function (p) { - if (!p.projectErrors || p.projectErrors.length === 0) { - return p; - } - return { - info: p.info, - changes: p.changes, - files: p.files, - projectErrors: _this.convertToDiagnosticsWithLinePosition(p.projectErrors, undefined) - }; - }); - return _this.requiredResponse(converted); - }, - _a[CommandNames.ApplyChangedToOpenFiles] = function (request) { - _this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles); - _this.changeSeq++; - return _this.requiredResponse(true); - }, - _a[CommandNames.Exit] = function () { - _this.exit(); - return _this.notRequired(); - }, - _a[CommandNames.Definition] = function (request) { - return _this.requiredResponse(_this.getDefinition(request.arguments, true)); - }, - _a[CommandNames.DefinitionFull] = function (request) { - return _this.requiredResponse(_this.getDefinition(request.arguments, false)); - }, - _a[CommandNames.TypeDefinition] = function (request) { - return _this.requiredResponse(_this.getTypeDefinition(request.arguments)); - }, - _a[CommandNames.Implementation] = function (request) { - return _this.requiredResponse(_this.getImplementation(request.arguments, true)); - }, - _a[CommandNames.ImplementationFull] = function (request) { - return _this.requiredResponse(_this.getImplementation(request.arguments, false)); - }, - _a[CommandNames.References] = function (request) { - return _this.requiredResponse(_this.getReferences(request.arguments, true)); - }, - _a[CommandNames.ReferencesFull] = function (request) { - return _this.requiredResponse(_this.getReferences(request.arguments, false)); - }, - _a[CommandNames.Rename] = function (request) { - return _this.requiredResponse(_this.getRenameLocations(request.arguments, true)); - }, - _a[CommandNames.RenameLocationsFull] = function (request) { - return _this.requiredResponse(_this.getRenameLocations(request.arguments, false)); - }, - _a[CommandNames.RenameInfoFull] = function (request) { - return _this.requiredResponse(_this.getRenameInfo(request.arguments)); - }, - _a[CommandNames.Open] = function (request) { - _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName)); - return _this.notRequired(); - }, - _a[CommandNames.Quickinfo] = function (request) { - return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, true)); - }, - _a[CommandNames.QuickinfoFull] = function (request) { - return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, false)); - }, - _a[CommandNames.OutliningSpans] = function (request) { - return _this.requiredResponse(_this.getOutliningSpans(request.arguments)); - }, - _a[CommandNames.TodoComments] = function (request) { - return _this.requiredResponse(_this.getTodoComments(request.arguments)); - }, - _a[CommandNames.Indentation] = function (request) { - return _this.requiredResponse(_this.getIndentation(request.arguments)); - }, - _a[CommandNames.NameOrDottedNameSpan] = function (request) { - return _this.requiredResponse(_this.getNameOrDottedNameSpan(request.arguments)); - }, - _a[CommandNames.BreakpointStatement] = function (request) { - return _this.requiredResponse(_this.getBreakpointStatement(request.arguments)); - }, - _a[CommandNames.BraceCompletion] = function (request) { - return _this.requiredResponse(_this.isValidBraceCompletion(request.arguments)); - }, - _a[CommandNames.DocCommentTemplate] = function (request) { - return _this.requiredResponse(_this.getDocCommentTemplate(request.arguments)); - }, - _a[CommandNames.Format] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsForRange(request.arguments)); - }, - _a[CommandNames.Formatonkey] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsAfterKeystroke(request.arguments)); - }, - _a[CommandNames.FormatFull] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsForDocumentFull(request.arguments)); - }, - _a[CommandNames.FormatonkeyFull] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsAfterKeystrokeFull(request.arguments)); - }, - _a[CommandNames.FormatRangeFull] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsForRangeFull(request.arguments)); - }, - _a[CommandNames.Completions] = function (request) { - return _this.requiredResponse(_this.getCompletions(request.arguments, true)); - }, - _a[CommandNames.CompletionsFull] = function (request) { - return _this.requiredResponse(_this.getCompletions(request.arguments, false)); - }, - _a[CommandNames.CompletionDetails] = function (request) { - return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments)); - }, - _a[CommandNames.CompileOnSaveAffectedFileList] = function (request) { - return _this.requiredResponse(_this.getCompileOnSaveAffectedFileList(request.arguments)); - }, - _a[CommandNames.CompileOnSaveEmitFile] = function (request) { - return _this.requiredResponse(_this.emitFile(request.arguments)); - }, - _a[CommandNames.SignatureHelp] = function (request) { - return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, true)); - }, - _a[CommandNames.SignatureHelpFull] = function (request) { - return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, false)); - }, - _a[CommandNames.CompilerOptionsDiagnosticsFull] = function (request) { - return _this.requiredResponse(_this.getCompilerOptionsDiagnostics(request.arguments)); - }, - _a[CommandNames.EncodedSemanticClassificationsFull] = function (request) { - return _this.requiredResponse(_this.getEncodedSemanticClassifications(request.arguments)); - }, - _a[CommandNames.Cleanup] = function () { - _this.cleanup(); - return _this.requiredResponse(true); - }, - _a[CommandNames.SemanticDiagnosticsSync] = function (request) { - return _this.requiredResponse(_this.getSemanticDiagnosticsSync(request.arguments)); - }, - _a[CommandNames.SyntacticDiagnosticsSync] = function (request) { - return _this.requiredResponse(_this.getSyntacticDiagnosticsSync(request.arguments)); - }, - _a[CommandNames.Geterr] = function (request) { - var geterrArgs = request.arguments; - return { response: _this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; - }, - _a[CommandNames.GeterrForProject] = function (request) { - var _a = request.arguments, file = _a.file, delay = _a.delay; - return { response: _this.getDiagnosticsForProject(delay, file), responseRequired: false }; - }, - _a[CommandNames.Change] = function (request) { - _this.change(request.arguments); - return _this.notRequired(); - }, - _a[CommandNames.Configure] = function (request) { - _this.projectService.setHostConfiguration(request.arguments); - _this.output(undefined, CommandNames.Configure, request.seq); - return _this.notRequired(); - }, - _a[CommandNames.Reload] = function (request) { - _this.reload(request.arguments, request.seq); - return _this.requiredResponse({ reloadFinished: true }); - }, - _a[CommandNames.Saveto] = function (request) { - var savetoArgs = request.arguments; - _this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); - return _this.notRequired(); - }, - _a[CommandNames.Close] = function (request) { - var closeArgs = request.arguments; - _this.closeClientFile(closeArgs.file); - return _this.notRequired(); - }, - _a[CommandNames.Navto] = function (request) { - return _this.requiredResponse(_this.getNavigateToItems(request.arguments, true)); - }, - _a[CommandNames.NavtoFull] = function (request) { - return _this.requiredResponse(_this.getNavigateToItems(request.arguments, false)); - }, - _a[CommandNames.Brace] = function (request) { - return _this.requiredResponse(_this.getBraceMatching(request.arguments, true)); - }, - _a[CommandNames.BraceFull] = function (request) { - return _this.requiredResponse(_this.getBraceMatching(request.arguments, false)); - }, - _a[CommandNames.NavBar] = function (request) { - return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, true)); - }, - _a[CommandNames.NavBarFull] = function (request) { - return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, false)); - }, - _a[CommandNames.NavTree] = function (request) { - return _this.requiredResponse(_this.getNavigationTree(request.arguments, true)); - }, - _a[CommandNames.NavTreeFull] = function (request) { - return _this.requiredResponse(_this.getNavigationTree(request.arguments, false)); - }, - _a[CommandNames.Occurrences] = function (request) { - return _this.requiredResponse(_this.getOccurrences(request.arguments)); - }, - _a[CommandNames.DocumentHighlights] = function (request) { - return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, true)); - }, - _a[CommandNames.DocumentHighlightsFull] = function (request) { - return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, false)); - }, - _a[CommandNames.CompilerOptionsForInferredProjects] = function (request) { - _this.setCompilerOptionsForInferredProjects(request.arguments); - return _this.requiredResponse(true); - }, - _a[CommandNames.ProjectInfo] = function (request) { - return _this.requiredResponse(_this.getProjectInfo(request.arguments)); - }, - _a[CommandNames.ReloadProjects] = function () { - _this.projectService.reloadProjects(); - return _this.notRequired(); - }, - _a[CommandNames.GetCodeFixes] = function (request) { - return _this.requiredResponse(_this.getCodeFixes(request.arguments, true)); - }, - _a[CommandNames.GetCodeFixesFull] = function (request) { - return _this.requiredResponse(_this.getCodeFixes(request.arguments, false)); - }, - _a[CommandNames.GetSupportedCodeFixes] = function () { - return _this.requiredResponse(_this.getSupportedCodeFixes()); - }, - _a)); - this.eventHander = canUseEvents - ? eventHandler || (function (event) { return _this.defaultEventHandler(event); }) - : undefined; - this.projectService = new server.ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); - this.gcTimer = new server.GcTimer(host, 7000, logger); - var _a; - } - Session.prototype.defaultEventHandler = function (event) { - var _this = this; - switch (event.eventName) { - case server.ContextEvent: - var _a = event.data, project = _a.project, fileName = _a.fileName; - this.projectService.logger.info("got context event, updating diagnostics for " + fileName); - this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); - break; - case server.ConfigFileDiagEvent: - var _b = event.data, triggerFile = _b.triggerFile, configFileName = _b.configFileName, diagnostics = _b.diagnostics; - this.configFileDiagnosticEvent(triggerFile, configFileName, diagnostics); - break; - case server.ProjectLanguageServiceStateEvent: - var eventName = "projectLanguageServiceState"; - this.event({ - projectName: event.data.project.getProjectName(), - languageServiceEnabled: event.data.languageServiceEnabled - }, eventName); - break; - } - }; - Session.prototype.logError = function (err, cmd) { - var msg = "Exception on executing command " + cmd; - if (err.message) { - msg += ":\n" + err.message; - if (err.stack) { - msg += "\n" + err.stack; - } - } - this.logger.msg(msg, server.Msg.Err); - }; - Session.prototype.send = function (msg) { - if (msg.type === "event" && !this.canUseEvents) { - if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Session does not support events: ignored event: " + JSON.stringify(msg)); - } - return; - } - this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine)); - }; - Session.prototype.configFileDiagnosticEvent = function (triggerFile, configFile, diagnostics) { - var bakedDiags = ts.map(diagnostics, formatConfigFileDiag); - var ev = { - seq: 0, - type: "event", - event: "configFileDiag", - body: { - triggerFile: triggerFile, - configFile: configFile, - diagnostics: bakedDiags - } - }; - this.send(ev); - }; - Session.prototype.event = function (info, eventName) { - var ev = { - seq: 0, - type: "event", - event: eventName, - body: info, - }; - this.send(ev); - }; - Session.prototype.output = function (info, cmdName, reqSeq, errorMsg) { - if (reqSeq === void 0) { reqSeq = 0; } - var res = { - seq: 0, - type: "response", - command: cmdName, - request_seq: reqSeq, - success: !errorMsg, - }; - if (!errorMsg) { - res.body = info; - } - else { - res.message = errorMsg; - } - this.send(res); - }; - Session.prototype.semanticCheck = function (file, project) { - try { - var diags = []; - if (!shouldSkipSematicCheck(project)) { - diags = project.getLanguageService().getSemanticDiagnostics(file); - } - var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); - this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); - } - catch (err) { - this.logError(err, "semantic check"); - } - }; - Session.prototype.syntacticCheck = function (file, project) { - try { - var diags = project.getLanguageService().getSyntacticDiagnostics(file); - if (diags) { - var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); - this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag"); - } - } - catch (err) { - this.logError(err, "syntactic check"); - } - }; - Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { - var _this = this; - if (ms === void 0) { ms = 1500; } - this.host.setTimeout(function () { - if (matchSeq(seq)) { - _this.projectService.refreshInferredProjects(); - } - }, ms); - }; - Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs, requireOpen) { - var _this = this; - if (ms === void 0) { ms = 1500; } - if (followMs === void 0) { followMs = 200; } - if (requireOpen === void 0) { requireOpen = true; } - if (followMs > ms) { - followMs = ms; - } - if (this.errorTimer) { - this.host.clearTimeout(this.errorTimer); - } - if (this.immediateId) { - this.host.clearImmediate(this.immediateId); - this.immediateId = undefined; - } - var index = 0; - var checkOne = function () { - if (matchSeq(seq)) { - var checkSpec_1 = checkList[index]; - index++; - if (checkSpec_1.project.containsFile(checkSpec_1.fileName, requireOpen)) { - _this.syntacticCheck(checkSpec_1.fileName, checkSpec_1.project); - _this.immediateId = _this.host.setImmediate(function () { - _this.semanticCheck(checkSpec_1.fileName, checkSpec_1.project); - _this.immediateId = undefined; - if (checkList.length > index) { - _this.errorTimer = _this.host.setTimeout(checkOne, followMs); - } - else { - _this.errorTimer = undefined; - } - }); - } - } - }; - if ((checkList.length > index) && (matchSeq(seq))) { - this.errorTimer = this.host.setTimeout(checkOne, ms); - } - }; - Session.prototype.cleanProjects = function (caption, projects) { - if (!projects) { - return; - } - this.logger.info("cleaning " + caption); - for (var _i = 0, projects_5 = projects; _i < projects_5.length; _i++) { - var p = projects_5[_i]; - p.getLanguageService(false).cleanupSemanticCache(); - } - }; - Session.prototype.cleanup = function () { - this.cleanProjects("inferred projects", this.projectService.inferredProjects); - this.cleanProjects("configured projects", this.projectService.configuredProjects); - this.cleanProjects("external projects", this.projectService.externalProjects); - if (this.host.gc) { - this.logger.info("host.gc()"); - this.host.gc(); - } - }; - Session.prototype.getEncodedSemanticClassifications = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - return project.getLanguageService().getEncodedSemanticClassifications(file, args); - }; - Session.prototype.getProject = function (projectFileName) { - return projectFileName && this.projectService.findProject(projectFileName); - }; - Session.prototype.getCompilerOptionsDiagnostics = function (args) { - var project = this.getProject(args.projectFileName); - return this.convertToDiagnosticsWithLinePosition(project.getLanguageService().getCompilerOptionsDiagnostics(), undefined); - }; - Session.prototype.convertToDiagnosticsWithLinePosition = function (diagnostics, scriptInfo) { - var _this = this; - return diagnostics.map(function (d) { return ({ - message: ts.flattenDiagnosticMessageText(d.messageText, _this.host.newLine), - start: d.start, - length: d.length, - category: ts.DiagnosticCategory[d.category].toLowerCase(), - code: d.code, - startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start), - endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length) - }); }); - }; - Session.prototype.getDiagnosticsWorker = function (args, isSemantic, selector, includeLinePosition) { - var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; - if (isSemantic && shouldSkipSematicCheck(project)) { - return []; - } - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var diagnostics = selector(project, file); - return includeLinePosition - ? this.convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo) - : diagnostics.map(function (d) { return formatDiag(file, project, d); }); - }; - Session.prototype.getDefinition = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var definitions = project.getLanguageService().getDefinitionAtPosition(file, position); - if (!definitions) { - return undefined; - } - if (simplifiedResult) { - return definitions.map(function (def) { - var defScriptInfo = project.getScriptInfo(def.fileName); - return { - file: def.fileName, - start: defScriptInfo.positionToLineOffset(def.textSpan.start), - end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) - }; - }); - } - else { - return definitions; - } - }; - Session.prototype.getTypeDefinition = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var definitions = project.getLanguageService().getTypeDefinitionAtPosition(file, position); - if (!definitions) { - return undefined; - } - return definitions.map(function (def) { - var defScriptInfo = project.getScriptInfo(def.fileName); - return { - file: def.fileName, - start: defScriptInfo.positionToLineOffset(def.textSpan.start), - end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) - }; - }); - }; - Session.prototype.getImplementation = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var implementations = project.getLanguageService().getImplementationAtPosition(file, position); - if (!implementations) { - return []; - } - if (simplifiedResult) { - return implementations.map(function (impl) { return ({ - file: impl.fileName, - start: scriptInfo.positionToLineOffset(impl.textSpan.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(impl.textSpan)) - }); }); - } - else { - return implementations; - } - }; - Session.prototype.getOccurrences = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position); - if (!occurrences) { - return undefined; - } - return occurrences.map(function (occurrence) { - var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan; - var scriptInfo = project.getScriptInfo(fileName); - var start = scriptInfo.positionToLineOffset(textSpan.start); - var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); - return { - start: start, - end: end, - file: fileName, - isWriteAccess: isWriteAccess, - }; - }); - }; - Session.prototype.getSyntacticDiagnosticsSync = function (args) { - return this.getDiagnosticsWorker(args, false, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); - }; - Session.prototype.getSemanticDiagnosticsSync = function (args) { - return this.getDiagnosticsWorker(args, true, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, args.includeLinePosition); - }; - Session.prototype.getDocumentHighlights = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var documentHighlights = project.getLanguageService().getDocumentHighlights(file, position, args.filesToSearch); - if (!documentHighlights) { - return undefined; - } - if (simplifiedResult) { - return documentHighlights.map(convertToDocumentHighlightsItem); - } - else { - return documentHighlights; - } - function convertToDocumentHighlightsItem(documentHighlights) { - var fileName = documentHighlights.fileName, highlightSpans = documentHighlights.highlightSpans; - var scriptInfo = project.getScriptInfo(fileName); - return { - file: fileName, - highlightSpans: highlightSpans.map(convertHighlightSpan) - }; - function convertHighlightSpan(highlightSpan) { - var textSpan = highlightSpan.textSpan, kind = highlightSpan.kind; - var start = scriptInfo.positionToLineOffset(textSpan.start); - var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); - return { start: start, end: end, kind: kind }; - } - } - }; - Session.prototype.setCompilerOptionsForInferredProjects = function (args) { - this.projectService.setCompilerOptionsForInferredProjects(args.options); - }; - Session.prototype.getProjectInfo = function (args) { - return this.getProjectInfoWorker(args.file, args.projectFileName, args.needFileNameList); - }; - Session.prototype.getProjectInfoWorker = function (uncheckedFileName, projectFileName, needFileNameList) { - var project = this.getFileAndProjectWorker(uncheckedFileName, projectFileName, true, true).project; - var projectInfo = { - configFileName: project.getProjectName(), - languageServiceDisabled: !project.languageServiceEnabled, - fileNames: needFileNameList ? project.getFileNames() : undefined - }; - return projectInfo; - }; - Session.prototype.getRenameInfo = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - return project.getLanguageService().getRenameInfo(file, position); - }; - Session.prototype.getProjects = function (args) { - var projects; - if (args.projectFileName) { - var project = this.getProject(args.projectFileName); - if (project) { - projects = [project]; - } - } - else { - var scriptInfo = this.projectService.getScriptInfo(args.file); - projects = scriptInfo.containingProjects; - } - projects = ts.filter(projects, function (p) { return p.languageServiceEnabled; }); - if (!projects || !projects.length) { - return server.Errors.ThrowNoProject(); - } - return projects; - }; - Session.prototype.getRenameLocations = function (args, simplifiedResult) { - var file = server.toNormalizedPath(args.file); - var info = this.projectService.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, info); - var projects = this.getProjects(args); - if (simplifiedResult) { - var defaultProject = projects[0]; - var renameInfo = defaultProject.getLanguageService().getRenameInfo(file, position); - if (!renameInfo) { - return undefined; - } - if (!renameInfo.canRename) { - return { - info: renameInfo, - locs: [] - }; - } - var fileSpans = server.combineProjectOutput(projects, function (project) { - var renameLocations = project.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); - if (!renameLocations) { - return []; - } - return renameLocations.map(function (location) { - var locationScriptInfo = project.getScriptInfo(location.fileName); - return { - file: location.fileName, - start: locationScriptInfo.positionToLineOffset(location.textSpan.start), - end: locationScriptInfo.positionToLineOffset(ts.textSpanEnd(location.textSpan)), - }; - }); - }, compareRenameLocation, function (a, b) { return a.file === b.file && a.start.line === b.start.line && a.start.offset === b.start.offset; }); - var locs = fileSpans.reduce(function (accum, cur) { - var curFileAccum; - if (accum.length > 0) { - curFileAccum = accum[accum.length - 1]; - if (curFileAccum.file !== cur.file) { - curFileAccum = undefined; - } - } - if (!curFileAccum) { - curFileAccum = { file: cur.file, locs: [] }; - accum.push(curFileAccum); - } - curFileAccum.locs.push({ start: cur.start, end: cur.end }); - return accum; - }, []); - return { info: renameInfo, locs: locs }; - } - else { - return server.combineProjectOutput(projects, function (p) { return p.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); }, undefined, renameLocationIsEqualTo); - } - function renameLocationIsEqualTo(a, b) { - if (a === b) { - return true; - } - if (!a || !b) { - return false; - } - return a.fileName === b.fileName && - a.textSpan.start === b.textSpan.start && - a.textSpan.length === b.textSpan.length; - } - function compareRenameLocation(a, b) { - if (a.file < b.file) { - return -1; - } - else if (a.file > b.file) { - return 1; - } - else { - if (a.start.line < b.start.line) { - return 1; - } - else if (a.start.line > b.start.line) { - return -1; - } - else { - return b.start.offset - a.start.offset; - } - } - } - }; - Session.prototype.getReferences = function (args, simplifiedResult) { - var file = server.toNormalizedPath(args.file); - var projects = this.getProjects(args); - var defaultProject = projects[0]; - var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - if (simplifiedResult) { - var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); - if (!nameInfo) { - return undefined; - } - var displayString = ts.displayPartsToString(nameInfo.displayParts); - var nameSpan = nameInfo.textSpan; - var nameColStart = scriptInfo.positionToLineOffset(nameSpan.start).offset; - var nameText = scriptInfo.getSnapshot().getText(nameSpan.start, ts.textSpanEnd(nameSpan)); - var refs = server.combineProjectOutput(projects, function (project) { - var references = project.getLanguageService().getReferencesAtPosition(file, position); - if (!references) { - return []; - } - return references.map(function (ref) { - var refScriptInfo = project.getScriptInfo(ref.fileName); - var start = refScriptInfo.positionToLineOffset(ref.textSpan.start); - var refLineSpan = refScriptInfo.lineToTextSpan(start.line - 1); - var lineText = refScriptInfo.getSnapshot().getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); - return { - file: ref.fileName, - start: start, - lineText: lineText, - end: refScriptInfo.positionToLineOffset(ts.textSpanEnd(ref.textSpan)), - isWriteAccess: ref.isWriteAccess, - isDefinition: ref.isDefinition - }; - }); - }, compareFileStart, areReferencesResponseItemsForTheSameLocation); - return { - refs: refs, - symbolName: nameText, - symbolStartOffset: nameColStart, - symbolDisplayString: displayString - }; - } - else { - return server.combineProjectOutput(projects, function (project) { return project.getLanguageService().findReferences(file, position); }, undefined, undefined); - } - function areReferencesResponseItemsForTheSameLocation(a, b) { - if (a && b) { - return a.file === b.file && - a.start === b.start && - a.end === b.end; - } - return false; - } - }; - Session.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - var _a = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; - if (this.eventHander) { - this.eventHander({ - eventName: "configFileDiag", - data: { triggerFile: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } - }); - } - }; - Session.prototype.getPosition = function (args, scriptInfo) { - return args.position !== undefined ? args.position : scriptInfo.lineOffsetToPosition(args.line, args.offset); - }; - Session.prototype.getFileAndProject = function (args, errorOnMissingProject) { - if (errorOnMissingProject === void 0) { errorOnMissingProject = true; } - return this.getFileAndProjectWorker(args.file, args.projectFileName, true, errorOnMissingProject); - }; - Session.prototype.getFileAndProjectWithoutRefreshingInferredProjects = function (args, errorOnMissingProject) { - if (errorOnMissingProject === void 0) { errorOnMissingProject = true; } - return this.getFileAndProjectWorker(args.file, args.projectFileName, false, errorOnMissingProject); - }; - Session.prototype.getFileAndProjectWorker = function (uncheckedFileName, projectFileName, refreshInferredProjects, errorOnMissingProject) { - var file = server.toNormalizedPath(uncheckedFileName); - var project = this.getProject(projectFileName) || this.projectService.getDefaultProjectForFile(file, refreshInferredProjects); - if (!project && errorOnMissingProject) { - return server.Errors.ThrowNoProject(); - } - return { file: file, project: project }; - }; - Session.prototype.getOutliningSpans = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - return project.getLanguageService(false).getOutliningSpans(file); - }; - Session.prototype.getTodoComments = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - return project.getLanguageService().getTodoComments(file, args.descriptors); - }; - Session.prototype.getDocCommentTemplate = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - return project.getLanguageService(false).getDocCommentTemplateAtPosition(file, position); - }; - Session.prototype.getIndentation = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); - var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); - var indentation = project.getLanguageService(false).getIndentationAtPosition(file, position, options); - return { position: position, indentation: indentation }; - }; - Session.prototype.getBreakpointStatement = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); - return project.getLanguageService(false).getBreakpointStatementAtPosition(file, position); - }; - Session.prototype.getNameOrDottedNameSpan = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); - return project.getLanguageService(false).getNameOrDottedNameSpan(file, position, position); - }; - Session.prototype.isValidBraceCompletion = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); - return project.getLanguageService(false).isValidBraceCompletionAtPosition(file, position, args.openingBrace.charCodeAt(0)); - }; - Session.prototype.getQuickInfoWorker = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var quickInfo = project.getLanguageService().getQuickInfoAtPosition(file, this.getPosition(args, scriptInfo)); - if (!quickInfo) { - return undefined; - } - if (simplifiedResult) { - var displayString = ts.displayPartsToString(quickInfo.displayParts); - var docString = ts.displayPartsToString(quickInfo.documentation); - return { - kind: quickInfo.kind, - kindModifiers: quickInfo.kindModifiers, - start: scriptInfo.positionToLineOffset(quickInfo.textSpan.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), - displayString: displayString, - documentation: docString, - }; - } - else { - return quickInfo; - } - }; - Session.prototype.getFormattingEditsForRange = function (args) { - var _this = this; - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var startPosition = scriptInfo.lineOffsetToPosition(args.line, args.offset); - var endPosition = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); - var edits = project.getLanguageService(false).getFormattingEditsForRange(file, startPosition, endPosition, this.projectService.getFormatCodeOptions(file)); - if (!edits) { - return undefined; - } - return edits.map(function (edit) { return _this.convertTextChangeToCodeEdit(edit, scriptInfo); }); - }; - Session.prototype.getFormattingEditsForRangeFull = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); - return project.getLanguageService(false).getFormattingEditsForRange(file, args.position, args.endPosition, options); - }; - Session.prototype.getFormattingEditsForDocumentFull = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); - return project.getLanguageService(false).getFormattingEditsForDocument(file, options); - }; - Session.prototype.getFormattingEditsAfterKeystrokeFull = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); - return project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, args.position, args.key, options); - }; - Session.prototype.getFormattingEditsAfterKeystroke = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = scriptInfo.lineOffsetToPosition(args.line, args.offset); - var formatOptions = this.projectService.getFormatCodeOptions(file); - var edits = project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, position, args.key, formatOptions); - if ((args.key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { - var lineInfo = scriptInfo.getLineInfo(args.line); - if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { - var lineText = lineInfo.leaf.text; - if (lineText.search("\\S") < 0) { - var preferredIndent = project.getLanguageService(false).getIndentationAtPosition(file, position, formatOptions); - var hasIndent = 0; - var i = void 0, len = void 0; - for (i = 0, len = lineText.length; i < len; i++) { - if (lineText.charAt(i) == " ") { - hasIndent++; - } - else if (lineText.charAt(i) == "\t") { - hasIndent += formatOptions.tabSize; - } - else { - break; - } - } - if (preferredIndent !== hasIndent) { - var firstNoWhiteSpacePosition = lineInfo.offset + i; - edits.push({ - span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition), - newText: ts.formatting.getIndentationString(preferredIndent, formatOptions) - }); - } - } - } - } - if (!edits) { - return undefined; - } - return edits.map(function (edit) { - return { - start: scriptInfo.positionToLineOffset(edit.span.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(edit.span)), - newText: edit.newText ? edit.newText : "" - }; - }); - }; - Session.prototype.getCompletions = function (args, simplifiedResult) { - var _this = this; - var prefix = args.prefix || ""; - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var completions = project.getLanguageService().getCompletionsAtPosition(file, position); - if (!completions) { - return undefined; - } - if (simplifiedResult) { - return completions.entries.reduce(function (result, entry) { - if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_53 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; - var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; - result.push({ name: name_53, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); - } - return result; - }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); - } - else { - return completions; - } - }; - Session.prototype.getCompletionEntryDetails = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - return args.entryNames.reduce(function (accum, entryName) { - var details = project.getLanguageService().getCompletionEntryDetails(file, position, entryName); - if (details) { - accum.push(details); - } - return accum; - }, []); - }; - Session.prototype.getCompileOnSaveAffectedFileList = function (args) { - var info = this.projectService.getScriptInfo(args.file); - var result = []; - if (!info) { - return []; - } - var projectsToSearch = args.projectFileName ? [this.projectService.findProject(args.projectFileName)] : info.containingProjects; - for (var _i = 0, projectsToSearch_1 = projectsToSearch; _i < projectsToSearch_1.length; _i++) { - var project = projectsToSearch_1[_i]; - if (project.compileOnSaveEnabled && project.languageServiceEnabled) { - result.push({ - projectFileName: project.getProjectName(), - fileNames: project.getCompileOnSaveAffectedFileList(info) - }); - } - } - return result; - }; - Session.prototype.emitFile = function (args) { - var _this = this; - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - if (!project) { - server.Errors.ThrowNoProject(); - } - if (!project.languageServiceEnabled) { - return false; - } - var scriptInfo = project.getScriptInfo(file); - return project.builder.emitFile(scriptInfo, function (path, data, writeByteOrderMark) { return _this.host.writeFile(path, data, writeByteOrderMark); }); - }; - Session.prototype.getSignatureHelpItems = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var helpItems = project.getLanguageService().getSignatureHelpItems(file, position); - if (!helpItems) { - return undefined; - } - if (simplifiedResult) { - var span_16 = helpItems.applicableSpan; - return { - items: helpItems.items, - applicableSpan: { - start: scriptInfo.positionToLineOffset(span_16.start), - end: scriptInfo.positionToLineOffset(span_16.start + span_16.length) - }, - selectedItemIndex: helpItems.selectedItemIndex, - argumentIndex: helpItems.argumentIndex, - argumentCount: helpItems.argumentCount, - }; - } - else { - return helpItems; - } - }; - Session.prototype.getDiagnostics = function (delay, fileNames) { - var _this = this; - var checkList = fileNames.reduce(function (accum, uncheckedFileName) { - var fileName = server.toNormalizedPath(uncheckedFileName); - var project = _this.projectService.getDefaultProjectForFile(fileName, true); - if (project) { - accum.push({ fileName: fileName, project: project }); - } - return accum; - }, []); - if (checkList.length > 0) { - this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); - } - }; - Session.prototype.change = function (args) { - var _this = this; - var _a = this.getFileAndProject(args, false), file = _a.file, project = _a.project; - if (project) { - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var start = scriptInfo.lineOffsetToPosition(args.line, args.offset); - var end = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); - if (start >= 0) { - scriptInfo.editContent(start, end, args.insertString); - this.changeSeq++; - } - this.updateProjectStructure(this.changeSeq, function (n) { return n === _this.changeSeq; }); - } - }; - Session.prototype.reload = function (args, reqSeq) { - var file = server.toNormalizedPath(args.file); - var tempFileName = args.tmpfile && server.toNormalizedPath(args.tmpfile); - var project = this.projectService.getDefaultProjectForFile(file, true); - if (project) { - this.changeSeq++; - if (project.reloadScript(file, tempFileName)) { - this.output(undefined, CommandNames.Reload, reqSeq); - } - } - }; - Session.prototype.saveToTmp = function (fileName, tempFileName) { - var scriptInfo = this.projectService.getScriptInfo(fileName); - if (scriptInfo) { - scriptInfo.saveTo(tempFileName); - } - }; - Session.prototype.closeClientFile = function (fileName) { - if (!fileName) { - return; - } - var file = ts.normalizePath(fileName); - this.projectService.closeClientFile(file); - }; - Session.prototype.decorateNavigationBarItems = function (items, scriptInfo) { - var _this = this; - return ts.map(items, function (item) { return ({ - text: item.text, - kind: item.kind, - kindModifiers: item.kindModifiers, - spans: item.spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }), - childItems: _this.decorateNavigationBarItems(item.childItems, scriptInfo), - indent: item.indent - }); }); - }; - Session.prototype.getNavigationBarItems = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var items = project.getLanguageService(false).getNavigationBarItems(file); - return !items - ? undefined - : simplifiedResult - ? this.decorateNavigationBarItems(items, project.getScriptInfoForNormalizedPath(file)) - : items; - }; - Session.prototype.decorateNavigationTree = function (tree, scriptInfo) { - var _this = this; - return { - text: tree.text, - kind: tree.kind, - kindModifiers: tree.kindModifiers, - spans: tree.spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }), - childItems: ts.map(tree.childItems, function (item) { return _this.decorateNavigationTree(item, scriptInfo); }) - }; - }; - Session.prototype.decorateSpan = function (span, scriptInfo) { - return { - start: scriptInfo.positionToLineOffset(span.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(span)) - }; - }; - Session.prototype.getNavigationTree = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var tree = project.getLanguageService(false).getNavigationTree(file); - return !tree - ? undefined - : simplifiedResult - ? this.decorateNavigationTree(tree, project.getScriptInfoForNormalizedPath(file)) - : tree; - }; - Session.prototype.getNavigateToItems = function (args, simplifiedResult) { - var projects = this.getProjects(args); - var fileName = args.currentFileOnly ? args.file && ts.normalizeSlashes(args.file) : undefined; - if (simplifiedResult) { - return server.combineProjectOutput(projects, function (project) { - var navItems = project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); - if (!navItems) { - return []; - } - return navItems.map(function (navItem) { - var scriptInfo = project.getScriptInfo(navItem.fileName); - var start = scriptInfo.positionToLineOffset(navItem.textSpan.start); - var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(navItem.textSpan)); - var bakedItem = { - name: navItem.name, - kind: navItem.kind, - file: navItem.fileName, - start: start, - end: end, - }; - if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { - bakedItem.kindModifiers = navItem.kindModifiers; - } - if (navItem.matchKind !== "none") { - bakedItem.matchKind = navItem.matchKind; - } - if (navItem.containerName && (navItem.containerName.length > 0)) { - bakedItem.containerName = navItem.containerName; - } - if (navItem.containerKind && (navItem.containerKind.length > 0)) { - bakedItem.containerKind = navItem.containerKind; - } - return bakedItem; - }); - }, undefined, areNavToItemsForTheSameLocation); - } - else { - return server.combineProjectOutput(projects, function (project) { return project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); }, undefined, navigateToItemIsEqualTo); - } - function navigateToItemIsEqualTo(a, b) { - if (a === b) { - return true; - } - if (!a || !b) { - return false; - } - return a.containerKind === b.containerKind && - a.containerName === b.containerName && - a.fileName === b.fileName && - a.isCaseSensitive === b.isCaseSensitive && - a.kind === b.kind && - a.kindModifiers === b.containerName && - a.matchKind === b.matchKind && - a.name === b.name && - a.textSpan.start === b.textSpan.start && - a.textSpan.length === b.textSpan.length; - } - function areNavToItemsForTheSameLocation(a, b) { - if (a && b) { - return a.file === b.file && - a.start === b.start && - a.end === b.end; - } - return false; - } - }; - Session.prototype.getSupportedCodeFixes = function () { - return ts.getSupportedCodeFixes(); - }; - Session.prototype.getCodeFixes = function (args, simplifiedResult) { - var _this = this; - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var startPosition = getStartPosition(); - var endPosition = getEndPosition(); - var codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes); - if (!codeActions) { - return undefined; - } - if (simplifiedResult) { - return codeActions.map(function (codeAction) { return _this.mapCodeAction(codeAction, scriptInfo); }); - } - else { - return codeActions; - } - function getStartPosition() { - return args.startPosition !== undefined ? args.startPosition : scriptInfo.lineOffsetToPosition(args.startLine, args.startOffset); - } - function getEndPosition() { - return args.endPosition !== undefined ? args.endPosition : scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); - } - }; - Session.prototype.mapCodeAction = function (codeAction, scriptInfo) { - var _this = this; - return { - description: codeAction.description, - changes: codeAction.changes.map(function (change) { return ({ - fileName: change.fileName, - textChanges: change.textChanges.map(function (textChange) { return _this.convertTextChangeToCodeEdit(textChange, scriptInfo); }) - }); }) - }; - }; - Session.prototype.convertTextChangeToCodeEdit = function (change, scriptInfo) { - return { - start: scriptInfo.positionToLineOffset(change.span.start), - end: scriptInfo.positionToLineOffset(change.span.start + change.span.length), - newText: change.newText ? change.newText : "" - }; - }; - Session.prototype.getBraceMatching = function (args, simplifiedResult) { - var _this = this; - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var spans = project.getLanguageService(false).getBraceMatchingAtPosition(file, position); - return !spans - ? undefined - : simplifiedResult - ? spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }) - : spans; - }; - Session.prototype.getDiagnosticsForProject = function (delay, fileName) { - var _this = this; - var _a = this.getProjectInfoWorker(fileName, undefined, true), fileNames = _a.fileNames, languageServiceDisabled = _a.languageServiceDisabled; - if (languageServiceDisabled) { - return; - } - var fileNamesInProject = fileNames.filter(function (value) { return value.indexOf("lib.d.ts") < 0; }); - var highPriorityFiles = []; - var mediumPriorityFiles = []; - var lowPriorityFiles = []; - var veryLowPriorityFiles = []; - var normalizedFileName = server.toNormalizedPath(fileName); - var project = this.projectService.getDefaultProjectForFile(normalizedFileName, true); - for (var _i = 0, fileNamesInProject_1 = fileNamesInProject; _i < fileNamesInProject_1.length; _i++) { - var fileNameInProject = fileNamesInProject_1[_i]; - if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) - highPriorityFiles.push(fileNameInProject); - else { - var info = this.projectService.getScriptInfo(fileNameInProject); - if (!info.isScriptOpen()) { - if (fileNameInProject.indexOf(".d.ts") > 0) - veryLowPriorityFiles.push(fileNameInProject); - else - lowPriorityFiles.push(fileNameInProject); - } - else - mediumPriorityFiles.push(fileNameInProject); - } - } - fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); - if (fileNamesInProject.length > 0) { - var checkList = fileNamesInProject.map(function (fileName) { return ({ fileName: fileName, project: project }); }); - this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); - } - }; - Session.prototype.getCanonicalFileName = function (fileName) { - var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - return ts.normalizePath(name); - }; - Session.prototype.exit = function () { - }; - Session.prototype.notRequired = function () { - return { responseRequired: false }; - }; - Session.prototype.requiredResponse = function (response) { - return { response: response, responseRequired: true }; - }; - Session.prototype.addProtocolHandler = function (command, handler) { - if (command in this.handlers) { - throw new Error("Protocol handler already exists for command \"" + command + "\""); - } - this.handlers[command] = handler; - }; - Session.prototype.executeCommand = function (request) { - var handler = this.handlers[request.command]; - if (handler) { - return handler(request); - } - else { - this.logger.msg("Unrecognized JSON command: " + JSON.stringify(request), server.Msg.Err); - this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); - return { responseRequired: false }; - } - }; - Session.prototype.onMessage = function (message) { - this.gcTimer.scheduleCollect(); - var start; - if (this.logger.hasLevel(server.LogLevel.requestTime)) { - start = this.hrtime(); - if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("request: " + message); - } - } - var request; - try { - request = JSON.parse(message); - var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; - if (this.logger.hasLevel(server.LogLevel.requestTime)) { - var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4); - if (responseRequired) { - this.logger.perftrc(request.seq + "::" + request.command + ": elapsed time (in milliseconds) " + elapsedTime); - } - else { - this.logger.perftrc(request.seq + "::" + request.command + ": async elapsed time (in milliseconds) " + elapsedTime); - } - } - if (response) { - this.output(response, request.command, request.seq); - } - else if (responseRequired) { - this.output(undefined, request.command, request.seq, "No content available."); - } - } - catch (err) { - if (err instanceof ts.OperationCanceledException) { - this.output({ canceled: true }, request.command, request.seq); - return; - } - this.logError(err, message); - this.output(undefined, request ? request.command : CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message + "\n" + err.stack); - } - }; - return Session; - }()); - server.Session = Session; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - function shouldEmitFile(scriptInfo) { - return !scriptInfo.hasMixedContent; - } - server.shouldEmitFile = shouldEmitFile; - var BuilderFileInfo = (function () { - function BuilderFileInfo(scriptInfo, project) { - this.scriptInfo = scriptInfo; - this.project = project; - } - BuilderFileInfo.prototype.isExternalModuleOrHasOnlyAmbientExternalModules = function () { - var sourceFile = this.getSourceFile(); - return ts.isExternalModule(sourceFile) || this.containsOnlyAmbientModules(sourceFile); - }; - BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (statement.kind !== 231 || statement.name.kind !== 9) { - return false; - } - } - return true; - }; - BuilderFileInfo.prototype.computeHash = function (text) { - return this.project.projectService.host.createHash(text); - }; - BuilderFileInfo.prototype.getSourceFile = function () { - return this.project.getSourceFile(this.scriptInfo.path); - }; - BuilderFileInfo.prototype.updateShapeSignature = function () { - var sourceFile = this.getSourceFile(); - if (!sourceFile) { - return true; - } - var lastSignature = this.lastCheckedShapeSignature; - if (sourceFile.isDeclarationFile) { - this.lastCheckedShapeSignature = this.computeHash(sourceFile.text); - } - else { - var emitOutput = this.project.getFileEmitOutput(this.scriptInfo, true); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - this.lastCheckedShapeSignature = this.computeHash(emitOutput.outputFiles[0].text); - } - } - return !lastSignature || this.lastCheckedShapeSignature !== lastSignature; - }; - return BuilderFileInfo; - }()); - server.BuilderFileInfo = BuilderFileInfo; - var AbstractBuilder = (function () { - function AbstractBuilder(project, ctor) { - this.project = project; - this.ctor = ctor; - } - AbstractBuilder.prototype.getFileInfos = function () { - return this.fileInfos_doNotAccessDirectly || (this.fileInfos_doNotAccessDirectly = ts.createFileMap()); - }; - AbstractBuilder.prototype.clear = function () { - this.fileInfos_doNotAccessDirectly = undefined; - }; - AbstractBuilder.prototype.getFileInfo = function (path) { - return this.getFileInfos().get(path); - }; - AbstractBuilder.prototype.getOrCreateFileInfo = function (path) { - var fileInfo = this.getFileInfo(path); - if (!fileInfo) { - var scriptInfo = this.project.getScriptInfo(path); - fileInfo = new this.ctor(scriptInfo, this.project); - this.setFileInfo(path, fileInfo); - } - return fileInfo; - }; - AbstractBuilder.prototype.getFileInfoPaths = function () { - return this.getFileInfos().getKeys(); - }; - AbstractBuilder.prototype.setFileInfo = function (path, info) { - this.getFileInfos().set(path, info); - }; - AbstractBuilder.prototype.removeFileInfo = function (path) { - this.getFileInfos().remove(path); - }; - AbstractBuilder.prototype.forEachFileInfo = function (action) { - this.getFileInfos().forEachValue(function (_path, value) { return action(value); }); - }; - AbstractBuilder.prototype.emitFile = function (scriptInfo, writeFile) { - var fileInfo = this.getFileInfo(scriptInfo.path); - if (!fileInfo) { - return false; - } - var _a = this.project.getFileEmitOutput(fileInfo.scriptInfo, false), emitSkipped = _a.emitSkipped, outputFiles = _a.outputFiles; - if (!emitSkipped) { - var projectRootPath = this.project.getProjectRootPath(); - for (var _i = 0, outputFiles_1 = outputFiles; _i < outputFiles_1.length; _i++) { - var outputFile = outputFiles_1[_i]; - var outputFileAbsoluteFileName = ts.getNormalizedAbsolutePath(outputFile.name, projectRootPath ? projectRootPath : ts.getDirectoryPath(scriptInfo.fileName)); - writeFile(outputFileAbsoluteFileName, outputFile.text, outputFile.writeByteOrderMark); - } - } - return !emitSkipped; - }; - return AbstractBuilder; - }()); - var NonModuleBuilder = (function (_super) { - __extends(NonModuleBuilder, _super); - function NonModuleBuilder(project) { - var _this = _super.call(this, project, BuilderFileInfo) || this; - _this.project = project; - return _this; - } - NonModuleBuilder.prototype.onProjectUpdateGraph = function () { - }; - NonModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { - var info = this.getOrCreateFileInfo(scriptInfo.path); - var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; - if (info.updateShapeSignature()) { - var options = this.project.getCompilerOptions(); - if (options && (options.out || options.outFile)) { - return singleFileResult; - } - return this.project.getAllEmittableFiles(); - } - return singleFileResult; - }; - return NonModuleBuilder; - }(AbstractBuilder)); - var ModuleBuilderFileInfo = (function (_super) { - __extends(ModuleBuilderFileInfo, _super); - function ModuleBuilderFileInfo() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.references = []; - _this.referencedBy = []; - return _this; - } - ModuleBuilderFileInfo.compareFileInfos = function (lf, rf) { - var l = lf.scriptInfo.fileName; - var r = rf.scriptInfo.fileName; - return (l < r ? -1 : (l > r ? 1 : 0)); - }; - ; - ModuleBuilderFileInfo.addToReferenceList = function (array, fileInfo) { - if (array.length === 0) { - array.push(fileInfo); - return; - } - var insertIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); - if (insertIndex < 0) { - array.splice(~insertIndex, 0, fileInfo); - } - }; - ModuleBuilderFileInfo.removeFromReferenceList = function (array, fileInfo) { - if (!array || array.length === 0) { - return; - } - if (array[0] === fileInfo) { - array.splice(0, 1); - return; - } - var removeIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); - if (removeIndex >= 0) { - array.splice(removeIndex, 1); - } - }; - ModuleBuilderFileInfo.prototype.addReferencedBy = function (fileInfo) { - ModuleBuilderFileInfo.addToReferenceList(this.referencedBy, fileInfo); - }; - ModuleBuilderFileInfo.prototype.removeReferencedBy = function (fileInfo) { - ModuleBuilderFileInfo.removeFromReferenceList(this.referencedBy, fileInfo); - }; - ModuleBuilderFileInfo.prototype.removeFileReferences = function () { - for (var _i = 0, _a = this.references; _i < _a.length; _i++) { - var reference = _a[_i]; - reference.removeReferencedBy(this); - } - this.references = []; - }; - return ModuleBuilderFileInfo; - }(BuilderFileInfo)); - var ModuleBuilder = (function (_super) { - __extends(ModuleBuilder, _super); - function ModuleBuilder(project) { - var _this = _super.call(this, project, ModuleBuilderFileInfo) || this; - _this.project = project; - return _this; - } - ModuleBuilder.prototype.clear = function () { - this.projectVersionForDependencyGraph = undefined; - _super.prototype.clear.call(this); - }; - ModuleBuilder.prototype.getReferencedFileInfos = function (fileInfo) { - var _this = this; - if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { - return []; - } - var referencedFilePaths = this.project.getReferencedFiles(fileInfo.scriptInfo.path); - if (referencedFilePaths.length > 0) { - return ts.map(referencedFilePaths, function (f) { return _this.getOrCreateFileInfo(f); }).sort(ModuleBuilderFileInfo.compareFileInfos); - } - return []; - }; - ModuleBuilder.prototype.onProjectUpdateGraph = function () { - this.ensureProjectDependencyGraphUpToDate(); - }; - ModuleBuilder.prototype.ensureProjectDependencyGraphUpToDate = function () { - var _this = this; - if (!this.projectVersionForDependencyGraph || this.project.getProjectVersion() !== this.projectVersionForDependencyGraph) { - var currentScriptInfos = this.project.getScriptInfos(); - for (var _i = 0, currentScriptInfos_1 = currentScriptInfos; _i < currentScriptInfos_1.length; _i++) { - var scriptInfo = currentScriptInfos_1[_i]; - var fileInfo = this.getOrCreateFileInfo(scriptInfo.path); - this.updateFileReferences(fileInfo); - } - this.forEachFileInfo(function (fileInfo) { - if (!_this.project.containsScriptInfo(fileInfo.scriptInfo)) { - fileInfo.removeFileReferences(); - _this.removeFileInfo(fileInfo.scriptInfo.path); - } - }); - this.projectVersionForDependencyGraph = this.project.getProjectVersion(); - } - }; - ModuleBuilder.prototype.updateFileReferences = function (fileInfo) { - if (fileInfo.scriptVersionForReferences === fileInfo.scriptInfo.getLatestVersion()) { - return; - } - var newReferences = this.getReferencedFileInfos(fileInfo); - var oldReferences = fileInfo.references; - var oldIndex = 0; - var newIndex = 0; - while (oldIndex < oldReferences.length && newIndex < newReferences.length) { - var oldReference = oldReferences[oldIndex]; - var newReference = newReferences[newIndex]; - var compare = ModuleBuilderFileInfo.compareFileInfos(oldReference, newReference); - if (compare < 0) { - oldReference.removeReferencedBy(fileInfo); - oldIndex++; - } - else if (compare > 0) { - newReference.addReferencedBy(fileInfo); - newIndex++; - } - else { - oldIndex++; - newIndex++; - } - } - for (var i = oldIndex; i < oldReferences.length; i++) { - oldReferences[i].removeReferencedBy(fileInfo); - } - for (var i = newIndex; i < newReferences.length; i++) { - newReferences[i].addReferencedBy(fileInfo); - } - fileInfo.references = newReferences; - fileInfo.scriptVersionForReferences = fileInfo.scriptInfo.getLatestVersion(); - }; - ModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { - this.ensureProjectDependencyGraphUpToDate(); - var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; - var fileInfo = this.getFileInfo(scriptInfo.path); - if (!fileInfo || !fileInfo.updateShapeSignature()) { - return singleFileResult; - } - if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { - return this.project.getAllEmittableFiles(); - } - var options = this.project.getCompilerOptions(); - if (options && (options.isolatedModules || options.out || options.outFile)) { - return singleFileResult; - } - var queue = fileInfo.referencedBy.slice(0); - var fileNameSet = ts.createMap(); - fileNameSet[scriptInfo.fileName] = scriptInfo; - while (queue.length > 0) { - var processingFileInfo = queue.pop(); - if (processingFileInfo.updateShapeSignature() && processingFileInfo.referencedBy.length > 0) { - for (var _i = 0, _a = processingFileInfo.referencedBy; _i < _a.length; _i++) { - var potentialFileInfo = _a[_i]; - if (!fileNameSet[potentialFileInfo.scriptInfo.fileName]) { - queue.push(potentialFileInfo); - } - } - } - fileNameSet[processingFileInfo.scriptInfo.fileName] = processingFileInfo.scriptInfo; - } - var result = []; - for (var fileName in fileNameSet) { - if (shouldEmitFile(fileNameSet[fileName])) { - result.push(fileName); - } - } - return result; - }; - return ModuleBuilder; - }(AbstractBuilder)); - function createBuilder(project) { - var moduleKind = project.getCompilerOptions().module; - switch (moduleKind) { - case ts.ModuleKind.None: - return new NonModuleBuilder(project); - default: - return new ModuleBuilder(project); - } - } - server.createBuilder = createBuilder; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); var debugObjectHost = (function () { return this; })(); var ts; (function (ts) { @@ -70848,7 +73962,9 @@ var ts; if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } - return JSON.parse(settingsJson); + var compilerOptions = JSON.parse(settingsJson); + compilerOptions.allowNonTsExtensions = true; + return compilerOptions; }; LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { var encoded = this.shimHost.getScriptFileNames(); @@ -71286,12 +74402,6 @@ var ts; var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (resolvedFileName && !compilerOptions.allowJs && ts.fileExtensionIs(resolvedFileName, ".js")) { - return { - resolvedFileName: undefined, - failedLookupLocations: [] - }; - } return { resolvedFileName: resolvedFileName, failedLookupLocations: result.failedLookupLocations @@ -71453,4 +74563,4 @@ var TypeScript; Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); -var toolsVersion = "2.2"; +var toolsVersion = "2.3"; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 65a33f28c33..05f02b45233 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -14,11 +14,36 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { + /** + * Type of objects whose values are all of the same type. + * The `in` and `for-in` operators can *not* be safely used, + * since `Object.prototype` may be modified by outside code. + */ interface MapLike { [index: string]: T; } - interface Map extends MapLike { - __mapBrand: any; + /** ES6 Map interface. */ + interface Map { + get(key: string): T; + has(key: string): boolean; + set(key: string, value: T): this; + delete(key: string): boolean; + clear(): void; + forEach(action: (value: T, key: string) => void): void; + readonly size: number; + keys(): Iterator; + values(): Iterator; + entries(): Iterator<[string, T]>; + } + /** ES6 Iterator type. */ + interface Iterator { + next(): { + value: T; + done: false; + } | { + value: never; + done: true; + }; } type Path = string & { __pathBrand: any; @@ -170,172 +195,175 @@ declare namespace ts { ReadonlyKeyword = 130, RequireKeyword = 131, NumberKeyword = 132, - SetKeyword = 133, - StringKeyword = 134, - SymbolKeyword = 135, - TypeKeyword = 136, - UndefinedKeyword = 137, - FromKeyword = 138, - GlobalKeyword = 139, - OfKeyword = 140, - QualifiedName = 141, - ComputedPropertyName = 142, - TypeParameter = 143, - Parameter = 144, - Decorator = 145, - PropertySignature = 146, - PropertyDeclaration = 147, - MethodSignature = 148, - MethodDeclaration = 149, - Constructor = 150, - GetAccessor = 151, - SetAccessor = 152, - CallSignature = 153, - ConstructSignature = 154, - IndexSignature = 155, - TypePredicate = 156, - TypeReference = 157, - FunctionType = 158, - ConstructorType = 159, - TypeQuery = 160, - TypeLiteral = 161, - ArrayType = 162, - TupleType = 163, - UnionType = 164, - IntersectionType = 165, - ParenthesizedType = 166, - ThisType = 167, - TypeOperator = 168, - IndexedAccessType = 169, - MappedType = 170, - LiteralType = 171, - ObjectBindingPattern = 172, - ArrayBindingPattern = 173, - BindingElement = 174, - ArrayLiteralExpression = 175, - ObjectLiteralExpression = 176, - PropertyAccessExpression = 177, - ElementAccessExpression = 178, - CallExpression = 179, - NewExpression = 180, - TaggedTemplateExpression = 181, - TypeAssertionExpression = 182, - ParenthesizedExpression = 183, - FunctionExpression = 184, - ArrowFunction = 185, - DeleteExpression = 186, - TypeOfExpression = 187, - VoidExpression = 188, - AwaitExpression = 189, - PrefixUnaryExpression = 190, - PostfixUnaryExpression = 191, - BinaryExpression = 192, - ConditionalExpression = 193, - TemplateExpression = 194, - YieldExpression = 195, - SpreadElement = 196, - ClassExpression = 197, - OmittedExpression = 198, - ExpressionWithTypeArguments = 199, - AsExpression = 200, - NonNullExpression = 201, - MetaProperty = 202, - TemplateSpan = 203, - SemicolonClassElement = 204, - Block = 205, - VariableStatement = 206, - EmptyStatement = 207, - ExpressionStatement = 208, - IfStatement = 209, - DoStatement = 210, - WhileStatement = 211, - ForStatement = 212, - ForInStatement = 213, - ForOfStatement = 214, - ContinueStatement = 215, - BreakStatement = 216, - ReturnStatement = 217, - WithStatement = 218, - SwitchStatement = 219, - LabeledStatement = 220, - ThrowStatement = 221, - TryStatement = 222, - DebuggerStatement = 223, - VariableDeclaration = 224, - VariableDeclarationList = 225, - FunctionDeclaration = 226, - ClassDeclaration = 227, - InterfaceDeclaration = 228, - TypeAliasDeclaration = 229, - EnumDeclaration = 230, - ModuleDeclaration = 231, - ModuleBlock = 232, - CaseBlock = 233, - NamespaceExportDeclaration = 234, - ImportEqualsDeclaration = 235, - ImportDeclaration = 236, - ImportClause = 237, - NamespaceImport = 238, - NamedImports = 239, - ImportSpecifier = 240, - ExportAssignment = 241, - ExportDeclaration = 242, - NamedExports = 243, - ExportSpecifier = 244, - MissingDeclaration = 245, - ExternalModuleReference = 246, - JsxElement = 247, - JsxSelfClosingElement = 248, - JsxOpeningElement = 249, - JsxClosingElement = 250, - JsxAttribute = 251, - JsxSpreadAttribute = 252, - JsxExpression = 253, - CaseClause = 254, - DefaultClause = 255, - HeritageClause = 256, - CatchClause = 257, - PropertyAssignment = 258, - ShorthandPropertyAssignment = 259, - SpreadAssignment = 260, - EnumMember = 261, - SourceFile = 262, - JSDocTypeExpression = 263, - JSDocAllType = 264, - JSDocUnknownType = 265, - JSDocArrayType = 266, - JSDocUnionType = 267, - JSDocTupleType = 268, - JSDocNullableType = 269, - JSDocNonNullableType = 270, - JSDocRecordType = 271, - JSDocRecordMember = 272, - JSDocTypeReference = 273, - JSDocOptionalType = 274, - JSDocFunctionType = 275, - JSDocVariadicType = 276, - JSDocConstructorType = 277, - JSDocThisType = 278, - JSDocComment = 279, - JSDocTag = 280, - JSDocAugmentsTag = 281, - JSDocParameterTag = 282, - JSDocReturnTag = 283, - JSDocTypeTag = 284, - JSDocTemplateTag = 285, - JSDocTypedefTag = 286, - JSDocPropertyTag = 287, - JSDocTypeLiteral = 288, - JSDocLiteralType = 289, - JSDocNullKeyword = 290, - JSDocUndefinedKeyword = 291, - JSDocNeverKeyword = 292, - SyntaxList = 293, - NotEmittedStatement = 294, - PartiallyEmittedExpression = 295, - MergeDeclarationMarker = 296, - EndOfDeclarationMarker = 297, - Count = 298, + ObjectKeyword = 133, + SetKeyword = 134, + StringKeyword = 135, + SymbolKeyword = 136, + TypeKeyword = 137, + UndefinedKeyword = 138, + FromKeyword = 139, + GlobalKeyword = 140, + OfKeyword = 141, + QualifiedName = 142, + ComputedPropertyName = 143, + TypeParameter = 144, + Parameter = 145, + Decorator = 146, + PropertySignature = 147, + PropertyDeclaration = 148, + MethodSignature = 149, + MethodDeclaration = 150, + Constructor = 151, + GetAccessor = 152, + SetAccessor = 153, + CallSignature = 154, + ConstructSignature = 155, + IndexSignature = 156, + TypePredicate = 157, + TypeReference = 158, + FunctionType = 159, + ConstructorType = 160, + TypeQuery = 161, + TypeLiteral = 162, + ArrayType = 163, + TupleType = 164, + UnionType = 165, + IntersectionType = 166, + ParenthesizedType = 167, + ThisType = 168, + TypeOperator = 169, + IndexedAccessType = 170, + MappedType = 171, + LiteralType = 172, + ObjectBindingPattern = 173, + ArrayBindingPattern = 174, + BindingElement = 175, + ArrayLiteralExpression = 176, + ObjectLiteralExpression = 177, + PropertyAccessExpression = 178, + ElementAccessExpression = 179, + CallExpression = 180, + NewExpression = 181, + TaggedTemplateExpression = 182, + TypeAssertionExpression = 183, + ParenthesizedExpression = 184, + FunctionExpression = 185, + ArrowFunction = 186, + DeleteExpression = 187, + TypeOfExpression = 188, + VoidExpression = 189, + AwaitExpression = 190, + PrefixUnaryExpression = 191, + PostfixUnaryExpression = 192, + BinaryExpression = 193, + ConditionalExpression = 194, + TemplateExpression = 195, + YieldExpression = 196, + SpreadElement = 197, + ClassExpression = 198, + OmittedExpression = 199, + ExpressionWithTypeArguments = 200, + AsExpression = 201, + NonNullExpression = 202, + MetaProperty = 203, + TemplateSpan = 204, + SemicolonClassElement = 205, + Block = 206, + VariableStatement = 207, + EmptyStatement = 208, + ExpressionStatement = 209, + IfStatement = 210, + DoStatement = 211, + WhileStatement = 212, + ForStatement = 213, + ForInStatement = 214, + ForOfStatement = 215, + ContinueStatement = 216, + BreakStatement = 217, + ReturnStatement = 218, + WithStatement = 219, + SwitchStatement = 220, + LabeledStatement = 221, + ThrowStatement = 222, + TryStatement = 223, + DebuggerStatement = 224, + VariableDeclaration = 225, + VariableDeclarationList = 226, + FunctionDeclaration = 227, + ClassDeclaration = 228, + InterfaceDeclaration = 229, + TypeAliasDeclaration = 230, + EnumDeclaration = 231, + ModuleDeclaration = 232, + ModuleBlock = 233, + CaseBlock = 234, + NamespaceExportDeclaration = 235, + ImportEqualsDeclaration = 236, + ImportDeclaration = 237, + ImportClause = 238, + NamespaceImport = 239, + NamedImports = 240, + ImportSpecifier = 241, + ExportAssignment = 242, + ExportDeclaration = 243, + NamedExports = 244, + ExportSpecifier = 245, + MissingDeclaration = 246, + ExternalModuleReference = 247, + JsxElement = 248, + JsxSelfClosingElement = 249, + JsxOpeningElement = 250, + JsxClosingElement = 251, + JsxAttribute = 252, + JsxAttributes = 253, + JsxSpreadAttribute = 254, + JsxExpression = 255, + CaseClause = 256, + DefaultClause = 257, + HeritageClause = 258, + CatchClause = 259, + PropertyAssignment = 260, + ShorthandPropertyAssignment = 261, + SpreadAssignment = 262, + EnumMember = 263, + SourceFile = 264, + Bundle = 265, + JSDocTypeExpression = 266, + JSDocAllType = 267, + JSDocUnknownType = 268, + JSDocArrayType = 269, + JSDocUnionType = 270, + JSDocTupleType = 271, + JSDocNullableType = 272, + JSDocNonNullableType = 273, + JSDocRecordType = 274, + JSDocRecordMember = 275, + JSDocTypeReference = 276, + JSDocOptionalType = 277, + JSDocFunctionType = 278, + JSDocVariadicType = 279, + JSDocConstructorType = 280, + JSDocThisType = 281, + JSDocComment = 282, + JSDocTag = 283, + JSDocAugmentsTag = 284, + JSDocParameterTag = 285, + JSDocReturnTag = 286, + JSDocTypeTag = 287, + JSDocTemplateTag = 288, + JSDocTypedefTag = 289, + JSDocPropertyTag = 290, + JSDocTypeLiteral = 291, + JSDocLiteralType = 292, + JSDocNullKeyword = 293, + JSDocUndefinedKeyword = 294, + JSDocNeverKeyword = 295, + SyntaxList = 296, + NotEmittedStatement = 297, + PartiallyEmittedExpression = 298, + MergeDeclarationMarker = 299, + EndOfDeclarationMarker = 300, + Count = 301, FirstAssignment = 57, LastAssignment = 69, FirstCompoundAssignment = 58, @@ -343,15 +371,15 @@ declare namespace ts { FirstReservedWord = 71, LastReservedWord = 106, FirstKeyword = 71, - LastKeyword = 140, + LastKeyword = 141, FirstFutureReservedWord = 107, LastFutureReservedWord = 115, - FirstTypeNode = 156, - LastTypeNode = 171, + FirstTypeNode = 157, + LastTypeNode = 172, FirstPunctuation = 16, LastPunctuation = 69, FirstToken = 0, - LastToken = 140, + LastToken = 141, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -360,11 +388,11 @@ declare namespace ts { LastTemplateToken = 15, FirstBinaryOperator = 26, LastBinaryOperator = 69, - FirstNode = 141, - FirstJSDocNode = 263, - LastJSDocNode = 289, - FirstJSDocTagNode = 279, - LastJSDocTagNode = 292, + FirstNode = 142, + FirstJSDocNode = 266, + LastJSDocNode = 295, + FirstJSDocTagNode = 282, + LastJSDocTagNode = 295, } enum NodeFlags { None = 0, @@ -481,6 +509,7 @@ declare namespace ts { kind: SyntaxKind.TypeParameter; name: Identifier; constraint?: TypeNode; + default?: TypeNode; expression?: Expression; } interface SignatureDeclaration extends Declaration { @@ -632,7 +661,7 @@ declare namespace ts { _typeNodeBrand: any; } interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; + kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; } interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; @@ -717,6 +746,10 @@ declare namespace ts { interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } + interface PartiallyEmittedExpression extends LeftHandSideExpression { + kind: SyntaxKind.PartiallyEmittedExpression; + expression: Expression; + } interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } @@ -953,7 +986,7 @@ declare namespace ts { tag: LeftHandSideExpression; template: TemplateLiteral; } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; + type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; interface AsExpression extends Expression { kind: SyntaxKind.AsExpression; expression: Expression; @@ -980,25 +1013,27 @@ declare namespace ts { children: NodeArray; closingElement: JsxClosingElement; } + type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + interface JsxAttributes extends ObjectLiteralExpressionBase { + } interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; tagName: JsxTagNameExpression; - attributes: NodeArray; + attributes: JsxAttributes; } interface JsxSelfClosingElement extends PrimaryExpression { kind: SyntaxKind.JsxSelfClosingElement; tagName: JsxTagNameExpression; - attributes: NodeArray; + attributes: JsxAttributes; } - type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; - type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - interface JsxAttribute extends Node { + interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; name: Identifier; initializer?: StringLiteral | JsxExpression; } - interface JsxSpreadAttribute extends Node { + interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; expression: Expression; } @@ -1018,6 +1053,9 @@ declare namespace ts { interface Statement extends Node { _statementBrand: any; } + interface NotEmittedStatement extends Statement { + kind: SyntaxKind.NotEmittedStatement; + } interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } @@ -1184,20 +1222,22 @@ declare namespace ts { name: Identifier; members: NodeArray; } - type ModuleBody = ModuleBlock | ModuleDeclaration; type ModuleName = Identifier | StringLiteral; + type ModuleBody = NamespaceBody | JSDocNamespaceBody; interface ModuleDeclaration extends DeclarationStatement { kind: SyntaxKind.ModuleDeclaration; name: Identifier | StringLiteral; - body?: ModuleBlock | NamespaceDeclaration | JSDocNamespaceDeclaration | Identifier; + body?: ModuleBody | JSDocNamespaceDeclaration | Identifier; } + type NamespaceBody = ModuleBlock | NamespaceDeclaration; interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: ModuleBlock | NamespaceDeclaration; + body: NamespaceBody; } + type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: JSDocNamespaceDeclaration | Identifier; + body: JSDocNamespaceBody; } interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; @@ -1412,9 +1452,21 @@ declare namespace ts { ArrayMutation = 256, Referenced = 512, Shared = 1024, + PreFinally = 2048, + AfterFinally = 4096, Label = 12, Condition = 96, } + interface FlowLock { + locked?: boolean; + } + interface AfterFinallyFlow extends FlowNode, FlowLock { + antecedent: FlowNode; + } + interface PreFinallyFlow extends FlowNode { + antecedent: FlowNode; + lock: FlowLock; + } interface FlowNode { flags: FlowFlags; id?: number; @@ -1476,6 +1528,10 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; } + interface Bundle extends Node { + kind: SyntaxKind.Bundle; + sourceFiles: SourceFile[]; + } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; getSourceFile(fileName: string): SourceFile; @@ -1578,7 +1634,7 @@ declare namespace ts { getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; - getBaseTypes(type: InterfaceType): ObjectType[]; + getBaseTypes(type: InterfaceType): BaseType[]; getReturnTypeOfSignature(signature: Signature): Type; getNonNullableType(type: Type): Type; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; @@ -1607,7 +1663,7 @@ declare namespace ts { isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; - getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; + getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; @@ -1642,6 +1698,7 @@ declare namespace ts { clear(): void; trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError(): void; + reportIllegalExtends(): void; } enum TypeFormatFlags { None = 0, @@ -1657,6 +1714,7 @@ declare namespace ts { InTypeAlias = 512, UseTypeAliasValue = 1024, SuppressAnyReturnType = 2048, + AddUndefined = 4096, } enum SymbolFormatFlags { None = 0, @@ -1706,13 +1764,10 @@ declare namespace ts { ExportType = 2097152, ExportNamespace = 4194304, Alias = 8388608, - Instantiated = 16777216, - Merged = 33554432, - Transient = 67108864, - Prototype = 134217728, - SyntheticProperty = 268435456, - Optional = 536870912, - ExportStar = 1073741824, + Prototype = 16777216, + ExportStar = 33554432, + Optional = 67108864, + Transient = 134217728, Enum = 384, Variable = 3, Value = 107455, @@ -1778,6 +1833,7 @@ declare namespace ts { Intersection = 131072, Index = 262144, IndexedAccess = 524288, + NonPrimitive = 16777216, Literal = 480, StringOrNumberLiteral = 96, PossiblyFalsy = 7406, @@ -1787,10 +1843,10 @@ declare namespace ts { EnumLike = 272, UnionOrIntersection = 196608, StructuredType = 229376, - StructuredOrTypeParameter = 507904, + StructuredOrTypeVariable = 1032192, TypeVariable = 540672, - Narrowable = 1033215, - NotUnionOrUnit = 33281, + Narrowable = 17810431, + NotUnionOrUnit = 16810497, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -1806,7 +1862,7 @@ declare namespace ts { regularType?: LiteralType; } interface EnumType extends Type { - memberTypes: Map; + memberTypes: EnumLiteralType[]; } interface EnumLiteralType extends LiteralType { baseType: EnumType & UnionType; @@ -1822,6 +1878,7 @@ declare namespace ts { ObjectLiteral = 128, EvolvingArray = 256, ObjectLiteralPatternWithComputedProperties = 512, + NonPrimitive = 1024, ClassOrInterface = 3, } interface ObjectType extends Type { @@ -1834,6 +1891,7 @@ declare namespace ts { localTypeParameters: TypeParameter[]; thisType: TypeParameter; } + type BaseType = ObjectType | IntersectionType; interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; @@ -1873,6 +1931,7 @@ declare namespace ts { } interface TypeParameter extends TypeVariable { constraint: Type; + default?: Type; } interface IndexedAccessType extends TypeVariable { objectType: Type; @@ -1900,9 +1959,8 @@ declare namespace ts { isReadonly: boolean; declaration?: SignatureDeclaration; } - interface FileExtensionInfo { + interface JsFileExtensionInfo { extension: string; - scriptKind: ScriptKind; isMixedContent: boolean; } interface DiagnosticMessage { @@ -1940,7 +1998,10 @@ declare namespace ts { Classic = 1, NodeJs = 2, } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; + interface PluginImport { + name: string; + } + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; interface CompilerOptions { allowJs?: boolean; allowSyntheticDefaultImports?: boolean; @@ -2034,6 +2095,7 @@ declare namespace ts { None = 0, Preserve = 1, React = 2, + ReactNative = 3, } enum NewLineKind { CarriageReturnLineFeed = 0, @@ -2049,6 +2111,7 @@ declare namespace ts { JSX = 2, TS = 3, TSX = 4, + External = 5, } enum ScriptTarget { ES3 = 0, @@ -2157,6 +2220,120 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getEnvironmentVariable?(name: string): string; } + enum EmitFlags { + SingleLine = 1, + AdviseOnEmitNode = 2, + NoSubstitution = 4, + CapturesThis = 8, + NoLeadingSourceMap = 16, + NoTrailingSourceMap = 32, + NoSourceMap = 48, + NoNestedSourceMaps = 64, + NoTokenLeadingSourceMaps = 128, + NoTokenTrailingSourceMaps = 256, + NoTokenSourceMaps = 384, + NoLeadingComments = 512, + NoTrailingComments = 1024, + NoComments = 1536, + NoNestedComments = 2048, + HelperName = 4096, + ExportName = 8192, + LocalName = 16384, + Indented = 32768, + NoIndentation = 65536, + AsyncFunctionBody = 131072, + ReuseTempVariableScope = 262144, + CustomPrologue = 524288, + NoHoisting = 1048576, + HasEndOfDeclarationMarker = 2097152, + } + interface EmitHelper { + readonly name: string; + readonly scoped: boolean; + readonly text: string; + readonly priority?: number; + } + enum EmitHint { + SourceFile = 0, + Expression = 1, + IdentifierName = 2, + Unspecified = 3, + } + interface Printer { + /** + * Print a node and its subtree as-is, without any emit transformations. + * @param hint A value indicating the purpose of a node. This is primarily used to + * distinguish between an `Identifier` used in an expression position, versus an + * `Identifier` used as an `IdentifierName` as part of a declaration. For most nodes you + * should just pass `Unspecified`. + * @param node The node to print. The node and its subtree are printed as-is, without any + * emit transformations. + * @param sourceFile A source file that provides context for the node. The source text of + * the file is used to emit the original source content for literals and identifiers, while + * the identifiers of the source file are used when generating unique names to avoid + * collisions. + */ + printNode(hint: EmitHint, node: Node, sourceFile: SourceFile): string; + /** + * Prints a source file as-is, without any emit transformations. + */ + printFile(sourceFile: SourceFile): string; + /** + * Prints a bundle of source files as-is, without any emit transformations. + */ + printBundle(bundle: Bundle): string; + } + interface PrintHandlers { + /** + * A hook used by the Printer when generating unique names to avoid collisions with + * globally defined names that exist outside of the current source file. + */ + hasGlobalName?(name: string): boolean; + /** + * A hook used by the Printer to provide notifications prior to emitting a node. A + * compatible implementation **must** invoke `emitCallback` with the provided `hint` and + * `node` values. + * @param hint A hint indicating the intended purpose of the node. + * @param node The node to emit. + * @param emitCallback A callback that, when invoked, will emit the node. + * @example + * ```ts + * var printer = createPrinter(printerOptions, { + * onEmitNode(hint, node, emitCallback) { + * // set up or track state prior to emitting the node... + * emitCallback(hint, node); + * // restore state after emitting the node... + * } + * }); + * ``` + */ + onEmitNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + /** + * A hook used by the Printer to perform just-in-time substitution of a node. This is + * primarily used by node transformations that need to substitute one node for another, + * such as replacing `myExportedVar` with `exports.myExportedVar`. A compatible + * implementation **must** invoke `emitCallback` eith the provided `hint` and either + * the provided `node`, or its substitute. + * @param hint A hint indicating the intended purpose of the node. + * @param node The node to emit. + * @param emitCallback A callback that, when invoked, will emit the node. + * @example + * ```ts + * var printer = createPrinter(printerOptions, { + * onSubstituteNode(hint, node, emitCallback) { + * // perform substitution if necessary... + * emitCallback(hint, node); + * } + * }); + * ``` + */ + onSubstituteNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + } + interface PrinterOptions { + target?: ScriptTarget; + removeComments?: boolean; + newLine?: NewLineKind; + } interface TextSpan { start: number; length: number; @@ -2171,8 +2348,10 @@ declare namespace ts { } declare namespace ts { /** The version of the TypeScript compiler release */ - const version = "2.2.0"; + const version = "2.3.0"; } +declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; +declare function clearTimeout(handle: any): void; declare namespace ts { type FileWatcherCallback = (fileName: string, removed?: boolean) => void; type DirectoryWatcherCallback = (fileName: string) => void; @@ -2267,8 +2446,8 @@ declare namespace ts { function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; - function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; - function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined; + function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; /** Optionally, get the shebang */ function getShebang(text: string): string; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; @@ -2317,6 +2496,356 @@ declare namespace ts { fileExists(fileName: string): boolean; readFile(fileName: string): string; }, errors?: Diagnostic[]): void; + function getOriginalNode(node: Node): Node; + function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; + /** + * Gets a value indicating whether a node originated in the parse tree. + * + * @param node The node to test. + */ + function isParseTreeNode(node: Node): boolean; + /** + * Gets the original parse tree node for a node. + * + * @param node The original node. + * @returns The original parse tree node if found; otherwise, undefined. + */ + function getParseTreeNode(node: Node): Node; + /** + * Gets the original parse tree node for a node. + * + * @param node The original node. + * @param nodeTest A callback used to ensure the correct type of parse tree node is returned. + * @returns The original parse tree node if found; otherwise, undefined. + */ + function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; + /** + * Remove extra underscore from escaped identifier text content. + * + * @param identifier The escaped identifier text. + * @returns The unescaped identifier text. + */ + function unescapeIdentifier(identifier: string): string; +} +declare namespace ts { + /** + * Make `elements` into a `NodeArray`. If `elements` is `undefined`, returns an empty `NodeArray`. + */ + function createNodeArray(elements?: T[], hasTrailingComma?: boolean): NodeArray; + function createLiteral(value: string): StringLiteral; + function createLiteral(value: number): NumericLiteral; + function createLiteral(value: boolean): BooleanLiteral; + /** Create a string literal whose source text is read from a source node during emit. */ + function createLiteral(sourceNode: StringLiteral | NumericLiteral | Identifier): StringLiteral; + function createLiteral(value: string | number | boolean): PrimaryExpression; + function createNumericLiteral(value: string): NumericLiteral; + function createIdentifier(text: string): Identifier; + /** Create a unique temporary variable. */ + function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier; + /** Create a unique temporary variable for use in a loop. */ + function createLoopVariable(): Identifier; + /** Create a unique name based on the supplied text. */ + function createUniqueName(text: string): Identifier; + /** Create a unique name generated for a node. */ + function getGeneratedNameForNode(node: Node): Identifier; + function createToken(token: TKind): Token; + function createSuper(): PrimaryExpression; + function createThis(): PrimaryExpression; + function createNull(): PrimaryExpression; + function createTrue(): BooleanLiteral; + function createFalse(): BooleanLiteral; + function createQualifiedName(left: EntityName, right: string | Identifier): QualifiedName; + function updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName; + function createComputedPropertyName(expression: Expression): ComputedPropertyName; + function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; + function createParameter(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: BindingName, type: TypeNode, initializer: Expression): ParameterDeclaration; + function createDecorator(expression: Expression): Decorator; + function updateDecorator(node: Decorator, expression: Expression): Decorator; + function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, type: TypeNode, initializer: Expression): PropertyDeclaration; + function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; + function createConstructor(decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; + function createGetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; + function createSetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; + function createObjectBindingPattern(elements: BindingElement[]): ObjectBindingPattern; + function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern; + function createArrayBindingPattern(elements: ArrayBindingElement[]): ArrayBindingPattern; + function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ArrayBindingElement[]): ArrayBindingPattern; + function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression): BindingElement; + function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken, propertyName: PropertyName, name: BindingName, initializer: Expression): BindingElement; + function createArrayLiteral(elements?: Expression[], multiLine?: boolean): ArrayLiteralExpression; + function updateArrayLiteral(node: ArrayLiteralExpression, elements: Expression[]): ArrayLiteralExpression; + function createObjectLiteral(properties?: ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; + function updateObjectLiteral(node: ObjectLiteralExpression, properties: ObjectLiteralElementLike[]): ObjectLiteralExpression; + function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; + function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; + function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; + function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; + function createCall(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; + function createNew(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; + function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; + function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; + function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; + function createParen(expression: Expression): ParenthesizedExpression; + function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; + function createFunctionExpression(modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; + function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: ConciseBody): ArrowFunction; + function createDelete(expression: Expression): DeleteExpression; + function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; + function createTypeOf(expression: Expression): TypeOfExpression; + function updateTypeOf(node: TypeOfExpression, expression: Expression): TypeOfExpression; + function createVoid(expression: Expression): VoidExpression; + function updateVoid(node: VoidExpression, expression: Expression): VoidExpression; + function createAwait(expression: Expression): AwaitExpression; + function updateAwait(node: AwaitExpression, expression: Expression): AwaitExpression; + function createPrefix(operator: PrefixUnaryOperator, operand: Expression): PrefixUnaryExpression; + function updatePrefix(node: PrefixUnaryExpression, operand: Expression): PrefixUnaryExpression; + function createPostfix(operand: Expression, operator: PostfixUnaryOperator): PostfixUnaryExpression; + function updatePostfix(node: PostfixUnaryExpression, operand: Expression): PostfixUnaryExpression; + function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression): BinaryExpression; + function updateBinary(node: BinaryExpression, left: Expression, right: Expression): BinaryExpression; + function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; + function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + function createTemplateExpression(head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; + function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; + function createYield(expression?: Expression): YieldExpression; + function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; + function updateYield(node: YieldExpression, expression: Expression): YieldExpression; + function createSpread(expression: Expression): SpreadElement; + function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; + function createClassExpression(modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; + function createOmittedExpression(): OmittedExpression; + function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; + function createAsExpression(expression: Expression, type: TypeNode): AsExpression; + function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; + function createNonNullExpression(expression: Expression): NonNullExpression; + function updateNonNullExpression(node: NonNullExpression, expression: Expression): NonNullExpression; + function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; + function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; + function createBlock(statements: Statement[], multiLine?: boolean): Block; + function updateBlock(node: Block, statements: Statement[]): Block; + function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList | VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: Modifier[], declarationList: VariableDeclarationList): VariableStatement; + function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; + function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList; + function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; + function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode, initializer: Expression): VariableDeclaration; + function createEmptyStatement(): EmptyStatement; + function createStatement(expression: Expression): ExpressionStatement; + function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; + function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement): IfStatement; + function createDo(statement: Statement, expression: Expression): DoStatement; + function updateDo(node: DoStatement, statement: Statement, expression: Expression): DoStatement; + function createWhile(expression: Expression, statement: Statement): WhileStatement; + function updateWhile(node: WhileStatement, expression: Expression, statement: Statement): WhileStatement; + function createFor(initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; + function updateFor(node: ForStatement, initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; + function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; + function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; + function createForOf(initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function createContinue(label?: string | Identifier): ContinueStatement; + function updateContinue(node: ContinueStatement, label: Identifier): ContinueStatement; + function createBreak(label?: string | Identifier): BreakStatement; + function updateBreak(node: BreakStatement, label: Identifier): BreakStatement; + function createReturn(expression?: Expression): ReturnStatement; + function updateReturn(node: ReturnStatement, expression: Expression): ReturnStatement; + function createWith(expression: Expression, statement: Statement): WithStatement; + function updateWith(node: WithStatement, expression: Expression, statement: Statement): WithStatement; + function createSwitch(expression: Expression, caseBlock: CaseBlock): SwitchStatement; + function updateSwitch(node: SwitchStatement, expression: Expression, caseBlock: CaseBlock): SwitchStatement; + function createLabel(label: string | Identifier, statement: Statement): LabeledStatement; + function updateLabel(node: LabeledStatement, label: Identifier, statement: Statement): LabeledStatement; + function createThrow(expression: Expression): ThrowStatement; + function updateThrow(node: ThrowStatement, expression: Expression): ThrowStatement; + function createTry(tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; + function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; + function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; + function createClassDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function createEnumDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, members: EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, members: EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody): ModuleDeclaration; + function createModuleBlock(statements: Statement[]): ModuleBlock; + function updateModuleBlock(node: ModuleBlock, statements: Statement[]): ModuleBlock; + function createCaseBlock(clauses: CaseOrDefaultClause[]): CaseBlock; + function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock; + function createImportEqualsDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier?: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier: Expression): ImportDeclaration; + function createImportClause(name: Identifier, namedBindings: NamedImportBindings): ImportClause; + function updateImportClause(node: ImportClause, name: Identifier, namedBindings: NamedImportBindings): ImportClause; + function createNamespaceImport(name: Identifier): NamespaceImport; + function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; + function createNamedImports(elements: ImportSpecifier[]): NamedImports; + function updateNamedImports(node: NamedImports, elements: ImportSpecifier[]): NamedImports; + function createImportSpecifier(propertyName: Identifier, name: Identifier): ImportSpecifier; + function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier, name: Identifier): ImportSpecifier; + function createExportAssignment(decorators: Decorator[], modifiers: Modifier[], isExportEquals: boolean, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: Decorator[], modifiers: Modifier[], expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier: Expression): ExportDeclaration; + function createNamedExports(elements: ExportSpecifier[]): NamedExports; + function updateNamedExports(node: NamedExports, elements: ExportSpecifier[]): NamedExports; + function createExportSpecifier(name: string | Identifier, propertyName?: string | Identifier): ExportSpecifier; + function updateExportSpecifier(node: ExportSpecifier, name: Identifier, propertyName: Identifier): ExportSpecifier; + function createExternalModuleReference(expression: Expression): ExternalModuleReference; + function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; + function createJsxElement(openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; + function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; + function createJsxSelfClosingElement(tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxSelfClosingElement; + function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxSelfClosingElement; + function createJsxOpeningElement(tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxOpeningElement; + function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxOpeningElement; + function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement; + function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; + function createJsxAttributes(properties: JsxAttributeLike[]): JsxAttributes; + function updateJsxAttributes(jsxAttributes: JsxAttributes, properties: JsxAttributeLike[]): JsxAttributes; + function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; + function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; + function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; + function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; + function createJsxExpression(expression: Expression, dotDotDotToken: DotDotDotToken): JsxExpression; + function updateJsxExpression(node: JsxExpression, expression: Expression): JsxExpression; + function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[]): HeritageClause; + function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause; + function createCaseClause(expression: Expression, statements: Statement[]): CaseClause; + function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]): CaseClause; + function createDefaultClause(statements: Statement[]): DefaultClause; + function updateDefaultClause(node: DefaultClause, statements: Statement[]): DefaultClause; + function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block): CatchClause; + function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause; + function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; + function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; + function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; + function createSpreadAssignment(expression: Expression): SpreadAssignment; + function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; + function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; + function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; + function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; + function updateSourceFileNode(node: SourceFile, statements: Statement[]): SourceFile; + /** + * Creates a shallow, memberwise clone of a node for mutation. + */ + function getMutableClone(node: T): T; + /** + * Creates a synthetic statement to act as a placeholder for a not-emitted statement in + * order to preserve comments. + * + * @param original The original statement. + */ + function createNotEmittedStatement(original: Node): NotEmittedStatement; + /** + * Creates a synthetic expression to act as a placeholder for a not-emitted expression in + * order to preserve comments or sourcemap positions. + * + * @param expression The inner expression to emit. + * @param original The original outer expression. + * @param location The location for the expression. Defaults to the positions from "original" if provided. + */ + function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression; + function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; + function createBundle(sourceFiles: SourceFile[]): Bundle; + function updateBundle(node: Bundle, sourceFiles: SourceFile[]): Bundle; + function createComma(left: Expression, right: Expression): Expression; + function createLessThan(left: Expression, right: Expression): Expression; + function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; + function createAssignment(left: Expression, right: Expression): BinaryExpression; + function createStrictEquality(left: Expression, right: Expression): BinaryExpression; + function createStrictInequality(left: Expression, right: Expression): BinaryExpression; + function createAdd(left: Expression, right: Expression): BinaryExpression; + function createSubtract(left: Expression, right: Expression): BinaryExpression; + function createPostfixIncrement(operand: Expression): PostfixUnaryExpression; + function createLogicalAnd(left: Expression, right: Expression): BinaryExpression; + function createLogicalOr(left: Expression, right: Expression): BinaryExpression; + function createLogicalNot(operand: Expression): PrefixUnaryExpression; + function createVoidZero(): VoidExpression; + function createExportDefault(expression: Expression): ExportAssignment; + function createExternalModuleExport(exportName: Identifier): ExportDeclaration; + /** + * Clears any EmitNode entries from parse-tree nodes. + * @param sourceFile A source file. + */ + function disposeEmitNodes(sourceFile: SourceFile): void; + function setTextRange(range: T, location: TextRange | undefined): T; + /** + * Gets flags that control emit behavior of a node. + */ + function getEmitFlags(node: Node): EmitFlags; + /** + * Sets flags that control emit behavior of a node. + */ + function setEmitFlags(node: T, emitFlags: EmitFlags): T; + /** + * Gets a custom text range to use when emitting source maps. + */ + function getSourceMapRange(node: Node): TextRange; + /** + * Sets a custom text range to use when emitting source maps. + */ + function setSourceMapRange(node: T, range: TextRange): T; + /** + * Gets the TextRange to use for source maps for a token of a node. + */ + function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange; + /** + * Sets the TextRange to use for source maps for a token of a node. + */ + function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange): T; + /** + * Gets a custom text range to use when emitting comments. + */ + function getCommentRange(node: Node): TextRange; + /** + * Sets a custom text range to use when emitting comments. + */ + function setCommentRange(node: T, range: TextRange): T; + /** + * Gets the constant value to emit for an expression. + */ + function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; + /** + * Sets the constant value to emit for an expression. + */ + function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number): PropertyAccessExpression | ElementAccessExpression; + /** + * Adds an EmitHelper to a node. + */ + function addEmitHelper(node: T, helper: EmitHelper): T; + /** + * Add EmitHelpers to a node. + */ + function addEmitHelpers(node: T, helpers: EmitHelper[] | undefined): T; + /** + * Removes an EmitHelper from a node. + */ + function removeEmitHelper(node: Node, helper: EmitHelper): boolean; + /** + * Gets the EmitHelpers of a node. + */ + function getEmitHelpers(node: Node): EmitHelper[] | undefined; + /** + * Moves matching emit helpers from a source node to a target node. + */ + function moveEmitHelpers(source: Node, target: Node, predicate: (helper: EmitHelper) => boolean): void; + function setOriginalNode(node: T, original: Node): T; } declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; @@ -2327,6 +2856,10 @@ declare namespace ts { function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } declare namespace ts { + /** Array that is only intended to be pushed to, never read. */ + interface Push { + push(value: T): void; + } function moduleHasNonRelativeName(moduleName: string): boolean; function getEffectiveTypeRoots(options: CompilerOptions, host: { directoryExists?: (directoryName: string) => boolean; @@ -2370,6 +2903,9 @@ declare namespace ts { function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; } +declare namespace ts { + function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; +} declare namespace ts { function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; function resolveTripleslashReference(moduleName: string, containingFile: string): string; @@ -2410,7 +2946,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: FileExtensionInfo[]): ParsedCommandLine; + function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: JsFileExtensionInfo[]): ParsedCommandLine; function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; @@ -2454,7 +2990,7 @@ declare namespace ts { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; - getBaseTypes(): ObjectType[]; + getBaseTypes(): BaseType[]; getNonNullableType(): Type; } interface Signature { @@ -3004,6 +3540,10 @@ declare namespace ts { const letElement = "let"; const directory = "directory"; const externalModuleName = "external module name"; + /** + * + **/ + const jsxAttribute = "JSX attribute"; } namespace ScriptElementKindModifier { const none = ""; diff --git a/lib/typescript.js b/lib/typescript.js index bae2811e4de..a8db5a7997f 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -173,193 +173,196 @@ var ts; SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 130] = "ReadonlyKeyword"; SyntaxKind[SyntaxKind["RequireKeyword"] = 131] = "RequireKeyword"; SyntaxKind[SyntaxKind["NumberKeyword"] = 132] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 133] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 134] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 135] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 136] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 137] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 138] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 139] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 140] = "OfKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 133] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 134] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 135] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 136] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 137] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 138] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 139] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 140] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 141] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 141] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 142] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 142] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 143] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 143] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 144] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 145] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 144] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 145] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 146] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 146] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 147] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 148] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 149] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 150] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 151] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 152] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 153] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 154] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 155] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 147] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 148] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 149] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 150] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 151] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 152] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 153] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 154] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 155] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 156] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 156] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 157] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 158] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 159] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 160] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 161] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 162] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 163] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 164] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 165] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 166] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 167] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 168] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 169] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 170] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 171] = "LiteralType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 157] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 158] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 159] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 160] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 161] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 162] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 163] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 164] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 165] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 166] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 167] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 168] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 169] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 170] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 171] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 172] = "LiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 172] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 173] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 174] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 173] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 174] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 175] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 175] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 176] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 177] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 178] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 179] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 180] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 181] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 182] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 183] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 184] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 185] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 186] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 187] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 188] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 189] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 190] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 191] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 192] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 193] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 194] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 195] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 196] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 197] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 198] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 199] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 200] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 201] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 202] = "MetaProperty"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 176] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 177] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 178] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 179] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 180] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 181] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 182] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 183] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 184] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 185] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 186] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 187] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 188] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 189] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 190] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 191] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 192] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 193] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 194] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 195] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 196] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 197] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 198] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 199] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 200] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 201] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 202] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 203] = "MetaProperty"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 203] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 204] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 204] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 205] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 205] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 206] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 207] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 208] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 209] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 210] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 211] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 212] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 213] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 214] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 215] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 216] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 217] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 218] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 219] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 220] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 221] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 222] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 223] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 225] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 226] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 227] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 228] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 229] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 230] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 231] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 232] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 233] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 234] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 235] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 236] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 237] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 238] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 239] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 240] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 241] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 242] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 243] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 244] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 245] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 206] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 207] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 208] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 209] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 210] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 211] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 212] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 213] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 214] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 215] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 216] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 217] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 218] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 219] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 220] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 221] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 222] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 223] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 224] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 225] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 226] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 227] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 228] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 229] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 230] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 231] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 232] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 233] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 234] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 235] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 236] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 237] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 238] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 239] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 240] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 241] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 242] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 243] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 244] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 245] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 246] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 246] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 247] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 247] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 248] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 249] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 250] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 251] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 252] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 253] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 248] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 249] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 250] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 251] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 252] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 253] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 254] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 255] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 254] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 255] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 256] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 257] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 256] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 257] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 258] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 259] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 258] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 259] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 260] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 260] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 261] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 262] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 261] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 263] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 262] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 264] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 265] = "Bundle"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 263] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 266] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 264] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 267] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 265] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 266] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 267] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 268] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 269] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 270] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 271] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 272] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 273] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 274] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 275] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 276] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 277] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 278] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 279] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 280] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 281] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 282] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 283] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 284] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 285] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 286] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 287] = "JSDocPropertyTag"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 288] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocLiteralType"] = 289] = "JSDocLiteralType"; - SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 290] = "JSDocNullKeyword"; - SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 291] = "JSDocUndefinedKeyword"; - SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 292] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 268] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 269] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 270] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 271] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 272] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 273] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 274] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 275] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 276] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 277] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 278] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 279] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 280] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 281] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 282] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 283] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 284] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 285] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 286] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 287] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 288] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 289] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 290] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 291] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 292] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 293] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 294] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 295] = "JSDocNeverKeyword"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 293] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 296] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 294] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 295] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 296] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 297] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 297] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 298] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 299] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 300] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 298] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 301] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; @@ -368,15 +371,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 140] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 141] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 156] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 171] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 157] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 172] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 140] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 141] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -385,11 +388,11 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 141] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 263] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 289] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 279] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 292] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 142] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 266] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 295] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 282] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 295] = "LastJSDocTagNode"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -481,6 +484,8 @@ var ts; FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); @@ -517,6 +522,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 2048] = "SuppressAnyReturnType"; + TypeFormatFlags[TypeFormatFlags["AddUndefined"] = 4096] = "AddUndefined"; })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -598,13 +604,10 @@ var ts; SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; - SymbolFlags[SymbolFlags["Instantiated"] = 16777216] = "Instantiated"; - SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; - SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; - SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; - SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; - SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; - SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; + SymbolFlags[SymbolFlags["Prototype"] = 16777216] = "Prototype"; + SymbolFlags[SymbolFlags["ExportStar"] = 33554432] = "ExportStar"; + SymbolFlags[SymbolFlags["Optional"] = 67108864] = "Optional"; + SymbolFlags[SymbolFlags["Transient"] = 134217728] = "Transient"; SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; @@ -648,6 +651,19 @@ var ts; SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); /* @internal */ + var CheckFlags; + (function (CheckFlags) { + CheckFlags[CheckFlags["Instantiated"] = 1] = "Instantiated"; + CheckFlags[CheckFlags["SyntheticProperty"] = 2] = "SyntheticProperty"; + CheckFlags[CheckFlags["Readonly"] = 4] = "Readonly"; + CheckFlags[CheckFlags["Partial"] = 8] = "Partial"; + CheckFlags[CheckFlags["HasNonUniformType"] = 16] = "HasNonUniformType"; + CheckFlags[CheckFlags["ContainsPublic"] = 32] = "ContainsPublic"; + CheckFlags[CheckFlags["ContainsProtected"] = 64] = "ContainsProtected"; + CheckFlags[CheckFlags["ContainsPrivate"] = 128] = "ContainsPrivate"; + CheckFlags[CheckFlags["ContainsStatic"] = 256] = "ContainsStatic"; + })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); + /* @internal */ var NodeCheckFlags; (function (NodeCheckFlags) { NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; @@ -702,6 +718,9 @@ var ts; TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; /* @internal */ TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; + /* @internal */ + TypeFlags[TypeFlags["JsxAttributes"] = 33554432] = "JsxAttributes"; /* @internal */ TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; @@ -710,7 +729,7 @@ var ts; TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 16015] = "Intrinsic"; + TypeFlags[TypeFlags["Intrinsic"] = 16793231] = "Intrinsic"; /* @internal */ TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; TypeFlags[TypeFlags["StringLike"] = 262178] = "StringLike"; @@ -719,12 +738,12 @@ var ts; TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; TypeFlags[TypeFlags["UnionOrIntersection"] = 196608] = "UnionOrIntersection"; TypeFlags[TypeFlags["StructuredType"] = 229376] = "StructuredType"; - TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 507904] = "StructuredOrTypeParameter"; + TypeFlags[TypeFlags["StructuredOrTypeVariable"] = 1032192] = "StructuredOrTypeVariable"; TypeFlags[TypeFlags["TypeVariable"] = 540672] = "TypeVariable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 1033215] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 33281] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["Narrowable"] = 17810431] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 16810497] = "NotUnionOrUnit"; /* @internal */ TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; /* @internal */ @@ -742,6 +761,7 @@ var ts; ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; + ObjectFlags[ObjectFlags["NonPrimitive"] = 1024] = "NonPrimitive"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); var SignatureKind; @@ -792,6 +812,7 @@ var ts; JsxEmit[JsxEmit["None"] = 0] = "None"; JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; JsxEmit[JsxEmit["React"] = 2] = "React"; + JsxEmit[JsxEmit["ReactNative"] = 3] = "ReactNative"; })(JsxEmit = ts.JsxEmit || (ts.JsxEmit = {})); var NewLineKind; (function (NewLineKind) { @@ -805,6 +826,7 @@ var ts; ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; ScriptKind[ScriptKind["TS"] = 3] = "TS"; ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + ScriptKind[ScriptKind["External"] = 5] = "External"; })(ScriptKind = ts.ScriptKind || (ts.ScriptKind = {})); var ScriptTarget; (function (ScriptTarget) { @@ -1039,7 +1061,6 @@ var ts; TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 274432] = "TypeScriptClassSyntaxMask"; TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 163840] = "ES2015FunctionSyntaxMask"; })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); - /* @internal */ var EmitFlags; (function (EmitFlags) { EmitFlags[EmitFlags["SingleLine"] = 1] = "SingleLine"; @@ -1086,14 +1107,13 @@ var ts; ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 128] = "LastEmitHelper"; })(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {})); - /* @internal */ - var EmitContext; - (function (EmitContext) { - EmitContext[EmitContext["SourceFile"] = 0] = "SourceFile"; - EmitContext[EmitContext["Expression"] = 1] = "Expression"; - EmitContext[EmitContext["IdentifierName"] = 2] = "IdentifierName"; - EmitContext[EmitContext["Unspecified"] = 3] = "Unspecified"; - })(EmitContext = ts.EmitContext || (ts.EmitContext = {})); + var EmitHint; + (function (EmitHint) { + EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile"; + EmitHint[EmitHint["Expression"] = 1] = "Expression"; + EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; + EmitHint[EmitHint["Unspecified"] = 3] = "Unspecified"; + })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); })(ts || (ts = {})); /*@internal*/ var ts; @@ -1121,8 +1141,8 @@ var ts; */ function mark(markName) { if (enabled) { - marks[markName] = ts.timestamp(); - counts[markName] = (counts[markName] || 0) + 1; + marks.set(markName, ts.timestamp()); + counts.set(markName, (counts.get(markName) || 0) + 1); profilerEvent(markName); } } @@ -1138,9 +1158,9 @@ var ts; */ function measure(measureName, startMarkName, endMarkName) { if (enabled) { - var end = endMarkName && marks[endMarkName] || ts.timestamp(); - var start = startMarkName && marks[startMarkName] || profilerStart; - measures[measureName] = (measures[measureName] || 0) + (end - start); + var end = endMarkName && marks.get(endMarkName) || ts.timestamp(); + var start = startMarkName && marks.get(startMarkName) || profilerStart; + measures.set(measureName, (measures.get(measureName) || 0) + (end - start)); } } performance.measure = measure; @@ -1150,7 +1170,7 @@ var ts; * @param markName The name of the mark. */ function getCount(markName) { - return counts && counts[markName] || 0; + return counts && counts.get(markName) || 0; } performance.getCount = getCount; /** @@ -1159,7 +1179,7 @@ var ts; * @param measureName The name of the measure whose durations should be accumulated. */ function getDuration(measureName) { - return measures && measures[measureName] || 0; + return measures && measures.get(measureName) || 0; } performance.getDuration = getDuration; /** @@ -1168,9 +1188,9 @@ var ts; * @param cb The action to perform for each measure */ function forEachMeasure(cb) { - for (var key in measures) { - cb(key, measures[key]); - } + measures.forEach(function (measure, key) { + cb(key, measure); + }); } performance.forEachMeasure = forEachMeasure; /** Enables (and resets) performance measurements for the compiler. */ @@ -1194,7 +1214,7 @@ var ts; var ts; (function (ts) { /** The version of the TypeScript compiler release */ - ts.version = "2.2.0"; + ts.version = "2.3.0"; })(ts || (ts = {})); /* @internal */ (function (ts) { @@ -1213,25 +1233,106 @@ var ts; Ternary[Ternary["Maybe"] = 1] = "Maybe"; Ternary[Ternary["True"] = -1] = "True"; })(Ternary = ts.Ternary || (ts.Ternary = {})); - var createObject = Object.create; // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. - ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - function createMap(template) { - var map = createObject(null); // tslint:disable-line:no-null-keyword + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(/*locales*/ undefined, { usage: "sort", sensitivity: "accent" }) : undefined; + // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". + ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + /** Create a MapLike with good performance. */ + function createDictionaryObject() { + var map = Object.create(null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is // constantly changing shape. map["__"] = undefined; delete map["__"]; + return map; + } + /** Create a new map. If a template object is provided, the map will copy entries from it. */ + function createMap() { + return new MapCtr(); + } + ts.createMap = createMap; + function createMapFromTemplate(template) { + var map = new MapCtr(); // Copies keys/values from template. Note that for..in will not throw if // template is undefined, and instead will just exit the loop. for (var key in template) if (hasOwnProperty.call(template, key)) { - map[key] = template[key]; + map.set(key, template[key]); } return map; } - ts.createMap = createMap; + ts.createMapFromTemplate = createMapFromTemplate; + // Internet Explorer's Map doesn't support iteration, so don't use it. + // tslint:disable-next-line:no-in-operator + var MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); + // Keep the class inside a function so it doesn't get compiled if it's not used. + function shimMap() { + var MapIterator = (function () { + function MapIterator(data, selector) { + this.index = 0; + this.data = data; + this.selector = selector; + this.keys = Object.keys(data); + } + MapIterator.prototype.next = function () { + var index = this.index; + if (index < this.keys.length) { + this.index++; + return { value: this.selector(this.data, this.keys[index]), done: false }; + } + return { value: undefined, done: true }; + }; + return MapIterator; + }()); + return (function () { + function class_1() { + this.data = createDictionaryObject(); + this.size = 0; + } + class_1.prototype.get = function (key) { + return this.data[key]; + }; + class_1.prototype.set = function (key, value) { + if (!this.has(key)) { + this.size++; + } + this.data[key] = value; + return this; + }; + class_1.prototype.has = function (key) { + // tslint:disable-next-line:no-in-operator + return key in this.data; + }; + class_1.prototype.delete = function (key) { + if (this.has(key)) { + this.size--; + delete this.data[key]; + return true; + } + return false; + }; + class_1.prototype.clear = function () { + this.data = createDictionaryObject(); + this.size = 0; + }; + class_1.prototype.keys = function () { + return new MapIterator(this.data, function (_data, key) { return key; }); + }; + class_1.prototype.values = function () { + return new MapIterator(this.data, function (data, key) { return data[key]; }); + }; + class_1.prototype.entries = function () { + return new MapIterator(this.data, function (data, key) { return [key, data[key]]; }); + }; + class_1.prototype.forEach = function (action) { + for (var key in this.data) { + action(this.data[key], key); + } + }; + return class_1; + }()); + } function createFileMap(keyMapper) { var files = createMap(); return { @@ -1244,33 +1345,28 @@ var ts; clear: clear, }; function forEachValueInMap(f) { - for (var key in files) { - f(key, files[key]); - } + files.forEach(function (file, key) { + f(key, file); + }); } function getKeys() { - var keys = []; - for (var key in files) { - keys.push(key); - } - return keys; + return arrayFrom(files.keys()); } // path should already be well-formed so it does not need to be normalized function get(path) { - return files[toKey(path)]; + return files.get(toKey(path)); } function set(path, value) { - files[toKey(path)] = value; + files.set(toKey(path), value); } function contains(path) { - return toKey(path) in files; + return files.has(toKey(path)); } function remove(path) { - var key = toKey(path); - delete files[key]; + files.delete(toKey(path)); } function clear() { - files = createMap(); + files.clear(); } function toKey(path) { return keyMapper ? keyMapper(path) : path; @@ -1290,6 +1386,10 @@ var ts; Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; })(Comparison = ts.Comparison || (ts.Comparison = {})); + function length(array) { + return array ? array.length : 0; + } + ts.length = length; /** * 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. @@ -1341,6 +1441,16 @@ var ts; return undefined; } ts.find = find; + /** Works like Array.prototype.findIndex, returning `-1` if no element satisfying the predicate is found. */ + function findIndex(array, predicate) { + for (var i = 0; i < array.length; i++) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; + } + ts.findIndex = findIndex; /** * Returns the first truthy result of `callback`, or else fails. * This is like `forEach`, but never returns undefined. @@ -1589,21 +1699,18 @@ var ts; return result; } ts.spanMap = spanMap; - function mapObject(object, f) { - var result; - if (object) { - result = {}; - for (var _i = 0, _a = getOwnKeys(object); _i < _a.length; _i++) { - var v = _a[_i]; - var _b = f(v, object[v]) || [undefined, undefined], key = _b[0], value = _b[1]; - if (key !== undefined) { - result[key] = value; - } - } + function mapEntries(map, f) { + if (!map) { + return undefined; } + var result = createMap(); + map.forEach(function (value, key) { + var _a = f(key, value), newKey = _a[0], newValue = _a[1]; + result.set(newKey, newValue); + }); return result; } - ts.mapObject = mapObject; + ts.mapEntries = mapEntries; function some(array, predicate) { if (array) { if (predicate) { @@ -1921,9 +2028,6 @@ var ts; /** * Indicates whether a map-like contains an own property with the specified key. * - * NOTE: This is intended for use only with MapLike objects. For Map objects, use - * the 'in' operator. - * * @param map A map-like. * @param key A property key. */ @@ -1934,9 +2038,6 @@ var ts; /** * Gets the value of an owned property in a map-like. * - * NOTE: This is intended for use only with MapLike objects. For Map objects, use - * an indexer. - * * @param map A map-like. * @param key A property key. */ @@ -1961,56 +2062,62 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - /** - * Enumerates the properties of a Map, invoking a callback and returning the first truthy result. - * - * @param map A map for which properties should be enumerated. - * @param callback A callback to invoke for each property. - */ - function forEachProperty(map, callback) { - var result; - for (var key in map) { - if (result = callback(map[key], key)) - break; + /** Shims `Array.from`. */ + function arrayFrom(iterator) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(value); } return result; + var _b; } - ts.forEachProperty = forEachProperty; - /** - * Returns true if a Map has some matching property. - * - * @param map A map whose properties should be tested. - * @param predicate An optional callback used to test each property. - */ - function someProperties(map, predicate) { - for (var key in map) { - if (!predicate || predicate(map[key], key)) - return true; + ts.arrayFrom = arrayFrom; + function convertToArray(iterator, f) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(f(value)); } - return false; + return result; + var _b; } - ts.someProperties = someProperties; + ts.convertToArray = convertToArray; /** - * Performs a shallow copy of the properties from a source Map to a target MapLike - * - * @param source A map from which properties should be copied. - * @param target A map to which properties should be copied. + * Calls `callback` for each entry in the map, returning the first truthy result. + * Use `map.forEach` instead for normal iteration. */ - function copyProperties(source, target) { - for (var key in source) { - target[key] = source[key]; + function forEachEntry(map, callback) { + var iterator = map.entries(); + for (var _a = iterator.next(), pair = _a.value, done = _a.done; !done; _b = iterator.next(), pair = _b.value, done = _b.done, _b) { + var key = pair[0], value = pair[1]; + var result = callback(value, key); + if (result) { + return result; + } } + return undefined; + var _b; } - ts.copyProperties = copyProperties; - function appendProperty(map, key, value) { - if (key === undefined || value === undefined) - return map; - if (map === undefined) - map = createMap(); - map[key] = value; - return map; + ts.forEachEntry = forEachEntry; + /** `forEachEntry` for just keys. */ + function forEachKey(map, callback) { + var iterator = map.keys(); + for (var _a = iterator.next(), key = _a.value, done = _a.done; !done; _b = iterator.next(), key = _b.value, done = _b.done, _b) { + var result = callback(key); + if (result) { + return result; + } + } + return undefined; + var _b; } - ts.appendProperty = appendProperty; + ts.forEachKey = forEachKey; + /** Copy entries from `source` to `target`. */ + function copyEntries(source, target) { + source.forEach(function (value, key) { + target.set(key, value); + }); + } + ts.copyEntries = copyEntries; function assign(t) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -2026,24 +2133,6 @@ var ts; return t; } ts.assign = assign; - /** - * Reduce the properties of a map. - * - * NOTE: This is intended for use with Map objects. For MapLike objects, use - * reduceOwnProperties instead as it offers better runtime safety. - * - * @param map The map to reduce - * @param callback An aggregation function that is called for each entry in the map - * @param initial The initial value for the reduction. - */ - function reduceProperties(map, callback, initial) { - var result = initial; - for (var key in map) { - result = callback(result, map[key], String(key)); - } - return result; - } - ts.reduceProperties = reduceProperties; /** * Performs a shallow equality comparison of the contents of two map-likes. * @@ -2074,23 +2163,14 @@ var ts; var result = createMap(); for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { var value = array_8[_i]; - result[makeKey(value)] = makeValue ? makeValue(value) : value; + result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; } ts.arrayToMap = arrayToMap; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; function cloneMap(map) { var clone = createMap(); - copyProperties(map, clone); + copyEntries(map, clone); return clone; } ts.cloneMap = cloneMap; @@ -2117,36 +2197,32 @@ var ts; return result; } ts.extend = extend; - /** - * Adds the value to an array of values associated with the key, and returns the array. - * Creates the array if it does not already exist. - */ - function multiMapAdd(map, key, value) { - var values = map[key]; + function createMultiMap() { + var map = createMap(); + map.add = multiMapAdd; + map.remove = multiMapRemove; + return map; + } + ts.createMultiMap = createMultiMap; + function multiMapAdd(key, value) { + var values = this.get(key); if (values) { values.push(value); - return values; } else { - return map[key] = [value]; + this.set(key, values = [value]); } + return values; } - ts.multiMapAdd = multiMapAdd; - /** - * Removes a value from an array of values associated with the key. - * Does not preserve the order of those values. - * Does nothing if `key` is not in `map`, or `value` is not in `map[key]`. - */ - function multiMapRemove(map, key, value) { - var values = map[key]; + function multiMapRemove(key, value) { + var values = this.get(key); if (values) { unorderedRemoveItem(values, value); if (!values.length) { - delete map[key]; + this.delete(key); } } } - ts.multiMapRemove = multiMapRemove; /** * Tests whether a value is an array. */ @@ -2330,9 +2406,12 @@ var ts; if (b === undefined) return 1 /* GreaterThan */; if (ignoreCase) { - if (ts.collator && String.prototype.localeCompare) { - // accent means a ≠ b, a ≠ á, a = A - var result = a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); + // Checking if "collator exists indicates that Intl is available. + // We still have to check if "collator.compare" is correct. If it is not, use "String.localeComapre" + if (ts.collator) { + var result = ts.localeCompareIsCorrect ? + ts.collator.compare(a, b) : + a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); // accent means a ≠ b, a ≠ á, a = A return result < 0 ? -1 /* LessThan */ : result > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; } a = a.toUpperCase(); @@ -2777,6 +2856,17 @@ var ts; var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; var singleAsteriskRegexFragmentOther = "[^/]*"; function getRegularExpressionForWildcard(specs, basePath, usage) { + var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); + if (!patterns || !patterns.length) { + return undefined; + } + var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + // If excluding, match "foo/bar/baz...", but if including, only allow "foo". + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; + } + ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + function getRegularExpressionsForWildcards(specs, basePath, usage) { if (specs === undefined || specs.length === 0) { return undefined; } @@ -2787,31 +2877,10 @@ var ts; * files or directories, does not match subdirectories that start with a . character */ var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; - var pattern = ""; - var hasWrittenSubpattern = false; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!spec) { - continue; - } - var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); - if (subPattern === undefined) { - continue; - } - if (hasWrittenSubpattern) { - pattern += "|"; - } - pattern += "(" + subPattern + ")"; - hasWrittenSubpattern = true; - } - if (!pattern) { - return undefined; - } - // If excluding, match "foo/bar/baz...", but if including, only allow "foo". - var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return flatMap(specs, function (spec) { + return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + }); } - ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; /** * An "includes" path "foo" is implicitly a glob "foo/** /*" (without the space) if its last component has no extension, * and does not contain any glob characters itself. @@ -2890,6 +2959,7 @@ var ts; currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); return { + includeFilePatterns: map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -2902,34 +2972,50 @@ var ts; currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); - var result = []; + // Associate an array of results with each include regex. This keeps results in order of the "include" order. + // If there are no "includes", then just put everything in results[0]. + var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; + var comparer = useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive; for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; visitDirectory(basePath, combinePaths(currentDirectory, basePath)); } - return result; + return flatten(results); function visitDirectory(path, absolutePath) { var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; + files = files.slice().sort(comparer); + directories = directories.slice().sort(comparer); + var _loop_1 = function (current) { + var name = combinePaths(path, current); + var absoluteName = combinePaths(absolutePath, current); + if (extensions && !fileExtensionIsAny(name, extensions)) + return "continue"; + if (excludeRegex && excludeRegex.test(absoluteName)) + return "continue"; + if (!includeFileRegexes) { + results[0].push(name); + } + else { + var includeIndex = findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); }); + if (includeIndex !== -1) { + results[includeIndex].push(name); + } + } + }; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var current = files_1[_i]; - var name_1 = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); - if ((!extensions || fileExtensionIsAny(name_1, extensions)) && - (!includeFileRegex || includeFileRegex.test(absoluteName)) && - (!excludeRegex || !excludeRegex.test(absoluteName))) { - result.push(name_1); - } + _loop_1(current); } for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var current = directories_1[_b]; - var name_2 = combinePaths(path, current); + var name = combinePaths(path, current); var absoluteName = combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { - visitDirectory(name_2, absoluteName); + visitDirectory(name, absoluteName); } } } @@ -2954,7 +3040,7 @@ var ts; } // Sort the offsets array using either the literal or canonical path representations. includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); - var _loop_1 = function (includeBasePath) { + var _loop_2 = function (includeBasePath) { if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } @@ -2963,7 +3049,7 @@ var ts; // subpath of an existing base path for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { var includeBasePath = includeBasePaths_1[_a]; - _loop_1(includeBasePath); + _loop_2(includeBasePath); } } return basePaths; @@ -3014,13 +3100,13 @@ var ts; var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions); function getSupportedExtensions(options, extraFileExtensions) { var needAllExtensions = options && options.allowJs; - if (!extraFileExtensions || extraFileExtensions.length === 0) { + if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = (needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions).slice(0); + var extensions = allSupportedExtensions.slice(0); for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { var extInfo = extraFileExtensions_1[_i]; - if (needAllExtensions || extInfo.scriptKind === 3 /* TS */) { + if (extensions.indexOf(extInfo.extension) === -1) { extensions.push(extInfo.extension); } } @@ -3057,14 +3143,13 @@ var ts; (function (ExtensionPriority) { ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; - ExtensionPriority[ExtensionPriority["Limit"] = 5] = "Limit"; ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; })(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {})); function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { - return adjustExtensionPriority(i); + return adjustExtensionPriority(i, supportedExtensions); } } // If its not in the list of supported extensions, this is likely a @@ -3075,27 +3160,27 @@ var ts; /** * Adjusts an extension priority to be the highest priority within the same range. */ - function adjustExtensionPriority(extensionPriority) { + function adjustExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) { return 0 /* TypeScriptFiles */; } - else if (extensionPriority < 5 /* Limit */) { + else if (extensionPriority < supportedExtensions.length) { return 2 /* DeclarationAndJavaScriptFiles */; } else { - return 5 /* Limit */; + return supportedExtensions.length; } } ts.adjustExtensionPriority = adjustExtensionPriority; /** * Gets the next lowest extension priority for a given priority. */ - function getNextLowestExtensionPriority(extensionPriority) { + function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) { return 2 /* DeclarationAndJavaScriptFiles */; } else { - return 5 /* Limit */; + return supportedExtensions.length; } } ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority; @@ -3489,32 +3574,32 @@ var ts; function createWatchedFileSet() { var dirWatchers = ts.createMap(); // One file can have multiple watchers - var fileWatcherCallbacks = ts.createMap(); + var fileWatcherCallbacks = ts.createMultiMap(); return { addFile: addFile, removeFile: removeFile }; function reduceDirWatcherRefCountForFile(fileName) { var dirName = ts.getDirectoryPath(fileName); - var watcher = dirWatchers[dirName]; + var watcher = dirWatchers.get(dirName); if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); - delete dirWatchers[dirName]; + dirWatchers.delete(dirName); } } } function addDirWatcher(dirPath) { - var watcher = dirWatchers[dirPath]; + var watcher = dirWatchers.get(dirPath); if (watcher) { watcher.referenceCount += 1; return; } watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; - dirWatchers[dirPath] = watcher; + dirWatchers.set(dirPath, watcher); return; } function addFileWatcherCallback(filePath, callback) { - ts.multiMapAdd(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.add(filePath, callback); } function addFile(fileName, callback) { addFileWatcherCallback(fileName, callback); @@ -3526,7 +3611,7 @@ var ts; reduceDirWatcherRefCountForFile(watchedFile.fileName); } function removeFileWatcherCallback(filePath, callback) { - ts.multiMapRemove(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.remove(filePath, callback); } function fileEventHandler(eventName, relativeFileName, baseDirPath) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" @@ -3534,10 +3619,13 @@ var ts; ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); // Some applications save a working file via rename operations - if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { - for (var _i = 0, _a = fileWatcherCallbacks[fileName]; _i < _a.length; _i++) { - var fileCallback = _a[_i]; - fileCallback(fileName); + if ((eventName === "change" || eventName === "rename")) { + var callbacks = fileWatcherCallbacks.get(fileName); + if (callbacks) { + for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) { + var fileCallback = callbacks_1[_i]; + fileCallback(fileName); + } } } } @@ -3613,10 +3701,10 @@ var ts; if (entry === "." || entry === "..") { continue; } - var name_3 = ts.combinePaths(path, entry); + var name = ts.combinePaths(path, entry); var stat = void 0; try { - stat = _fs.statSync(name_3); + stat = _fs.statSync(name); } catch (e) { continue; @@ -3697,7 +3785,10 @@ var ts; // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) var options; - if (!directoryExists(directoryName)) { + if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { + // do nothing if either + // - target folder does not exist + // - this is UNC path on Windows (https://github.com/Microsoft/TypeScript/issues/13874) return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { @@ -3716,6 +3807,9 @@ var ts; } ; }); + function isUNCPath(s) { + return s.length > 2 && s.charCodeAt(0) === 47 /* slash */ && s.charCodeAt(1) === 47 /* slash */; + } }, resolvePath: function (path) { return _path.resolve(path); @@ -3778,6 +3872,7 @@ var ts; require("source-map-support").install(); } catch (e) { + // Could not enable source maps. } }, setTimeout: setTimeout, @@ -4034,6 +4129,7 @@ var ts; Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", message: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", message: "Invalid use of '{0}'. Modules are automatically in strict mode." }, + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", message: "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export_assignment_is_not_supported_when_module_flag_is_system_1218", message: "Export assignment is not supported when '--module' flag is 'system'." }, Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", message: "Generators are only available when targeting ECMAScript 2015 or higher." }, @@ -4312,6 +4408,8 @@ var ts; Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, + A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, + Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union 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_2601", message: "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_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -4322,6 +4420,7 @@ var ts; 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_2607", message: "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_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, + Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -4370,11 +4469,15 @@ var ts; The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: { code: 2699, category: ts.DiagnosticCategory.Error, key: "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", message: "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'." }, Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, + Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, + Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "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_4002", message: "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_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -4385,8 +4488,8 @@ var ts; Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4014", message: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_function_has_or_is_using_private_name_1_4016", message: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019", message: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "'extends' clause of exported class '{0}' has or is using private name '{1}'." }, + extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "'extends' clause of exported interface '{0}' has or is using private name '{1}'." }, Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023", message: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024", message: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_private_name_1_4025", message: "Exported variable '{0}' has or is using private name '{1}'." }, @@ -4449,6 +4552,7 @@ var ts; Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced: { code: 4093, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced_4093", message: "'extends' clause of exported class '{0}' refers to a type whose name cannot be referenced." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -4494,7 +4598,7 @@ var ts; Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, - Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_in_the_given_directory_6020", message: "Compile the project in the given directory." }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, @@ -4509,6 +4613,7 @@ var ts; LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, STRATEGY: { code: 6039, category: ts.DiagnosticCategory.Message, key: "STRATEGY_6039", message: "STRATEGY" }, + FILE_OR_DIRECTORY: { code: 6040, category: ts.DiagnosticCategory.Message, key: "FILE_OR_DIRECTORY_6040", message: "FILE OR DIRECTORY" }, Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation_complete_Watching_for_file_changes_6042", message: "Compilation complete. Watching for file changes." }, Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_map_file_6043", message: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_expects_an_argument_6044", message: "Compiler option '{0}' expects an argument." }, @@ -4542,7 +4647,7 @@ var ts; Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, @@ -4562,7 +4667,7 @@ var ts; File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, + package_json_does_not_have_a_0_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_0_field_6100", message: "'package.json' does not have a '{0}' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -4599,7 +4704,6 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, @@ -4652,7 +4756,7 @@ var ts; parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: ts.DiagnosticCategory.Error, key: "parameter_modifiers_can_only_be_used_in_a_ts_file_8012", message: "'parameter modifiers' 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_8015", message: "'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_8016", message: "'type assertion expressions' 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_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause." }, class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "class_expressions_are_not_currently_supported_9003", message: "'class' expressions are not currently supported." }, Language_service_is_disabled: { code: 9004, category: ts.DiagnosticCategory.Error, key: "Language_service_is_disabled_9004", message: "Language service is disabled." }, 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_17000", message: "JSX attributes must only be assigned a non-empty 'expression'." }, @@ -4676,9 +4780,10 @@ var ts; Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, + Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, @@ -4697,7 +4802,7 @@ var ts; return token >= 70 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = ts.createMap({ + var textToToken = ts.createMapFromTemplate({ "abstract": 116 /* AbstractKeyword */, "any": 118 /* AnyKeyword */, "as": 117 /* AsKeyword */, @@ -4721,7 +4826,7 @@ var ts; "false": 85 /* FalseKeyword */, "finally": 86 /* FinallyKeyword */, "for": 87 /* ForKeyword */, - "from": 138 /* FromKeyword */, + "from": 139 /* FromKeyword */, "function": 88 /* FunctionKeyword */, "get": 124 /* GetKeyword */, "if": 89 /* IfKeyword */, @@ -4739,27 +4844,28 @@ var ts; "new": 93 /* NewKeyword */, "null": 94 /* NullKeyword */, "number": 132 /* NumberKeyword */, + "object": 133 /* ObjectKeyword */, "package": 110 /* PackageKeyword */, "private": 111 /* PrivateKeyword */, "protected": 112 /* ProtectedKeyword */, "public": 113 /* PublicKeyword */, "readonly": 130 /* ReadonlyKeyword */, "require": 131 /* RequireKeyword */, - "global": 139 /* GlobalKeyword */, + "global": 140 /* GlobalKeyword */, "return": 95 /* ReturnKeyword */, - "set": 133 /* SetKeyword */, + "set": 134 /* SetKeyword */, "static": 114 /* StaticKeyword */, - "string": 134 /* StringKeyword */, + "string": 135 /* StringKeyword */, "super": 96 /* SuperKeyword */, "switch": 97 /* SwitchKeyword */, - "symbol": 135 /* SymbolKeyword */, + "symbol": 136 /* SymbolKeyword */, "this": 98 /* ThisKeyword */, "throw": 99 /* ThrowKeyword */, "true": 100 /* TrueKeyword */, "try": 101 /* TryKeyword */, - "type": 136 /* TypeKeyword */, + "type": 137 /* TypeKeyword */, "typeof": 102 /* TypeOfKeyword */, - "undefined": 137 /* UndefinedKeyword */, + "undefined": 138 /* UndefinedKeyword */, "var": 103 /* VarKeyword */, "void": 104 /* VoidKeyword */, "while": 105 /* WhileKeyword */, @@ -4767,7 +4873,7 @@ var ts; "yield": 115 /* YieldKeyword */, "async": 119 /* AsyncKeyword */, "await": 120 /* AwaitKeyword */, - "of": 140 /* OfKeyword */, + "of": 141 /* OfKeyword */, "{": 16 /* OpenBraceToken */, "}": 17 /* CloseBraceToken */, "(": 18 /* OpenParenToken */, @@ -4907,9 +5013,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_4 in source) { - result[source[name_4]] = name_4; - } + source.forEach(function (value, name) { + result[value] = name; + }); return result; } var tokenStrings = makeReverseMap(textToToken); @@ -4919,7 +5025,7 @@ var ts; ts.tokenToString = tokenToString; /* @internal */ function stringToToken(s) { - return textToToken[s]; + return textToToken.get(s); } ts.stringToToken = stringToToken; /* @internal */ @@ -4993,7 +5099,6 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - var hasOwnProperty = Object.prototype.hasOwnProperty; function isWhiteSpace(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } @@ -5736,8 +5841,11 @@ var ts; var len = tokenValue.length; if (len >= 2 && len <= 11) { var ch = tokenValue.charCodeAt(0); - if (ch >= 97 /* a */ && ch <= 122 /* z */ && hasOwnProperty.call(textToToken, tokenValue)) { - return token = textToToken[tokenValue]; + if (ch >= 97 /* a */ && ch <= 122 /* z */) { + token = textToToken.get(tokenValue); + if (token !== undefined) { + return token; + } } } return token = 70 /* Identifier */; @@ -6430,6 +6538,19 @@ var ts; return undefined; } ts.getDeclarationOfKind = getDeclarationOfKind; + function findDeclaration(symbol, predicate) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; + if (predicate(declaration)) { + return declaration; + } + } + } + return undefined; + } + ts.findDeclaration = findDeclaration; // Pool writers to avoid needing to allocate them for every symbol we write. var stringWriters = []; function getSingleLineStringWriter() { @@ -6453,7 +6574,8 @@ var ts; decreaseIndent: ts.noop, clear: function () { return str_1 = ""; }, trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop }; } return stringWriters.pop(); @@ -6469,25 +6591,25 @@ var ts; } ts.getFullWidth = getFullWidth; function hasResolvedModule(sourceFile, moduleNameText) { - return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText)); } ts.hasResolvedModule = hasResolvedModule; function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules.get(moduleNameText) : undefined; } ts.getResolvedModule = getResolvedModule; function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { if (!sourceFile.resolvedModules) { sourceFile.resolvedModules = ts.createMap(); } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; + sourceFile.resolvedModules.set(moduleNameText, resolvedModule); } ts.setResolvedModule = setResolvedModule; function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { if (!sourceFile.resolvedTypeReferenceDirectiveNames) { sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; + sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective); } ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; /* @internal */ @@ -6509,7 +6631,7 @@ var ts; } for (var i = 0; i < names.length; i++) { var newResolution = newResolutions[i]; - var oldResolution = oldResolutions && oldResolutions[names[i]]; + var oldResolution = oldResolutions && oldResolutions.get(names[i]); var changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) : newResolution; @@ -6544,7 +6666,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 262 /* SourceFile */) { + while (node && node.kind !== 264 /* SourceFile */) { node = node.parent; } return node; @@ -6552,11 +6674,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 205 /* Block */: - case 233 /* CaseBlock */: - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: + case 206 /* Block */: + case 234 /* CaseBlock */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: return true; } return false; @@ -6647,18 +6769,18 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 293 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 296 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 263 /* FirstJSDocNode */ && node.kind <= 289 /* LastJSDocNode */; + return node.kind >= 266 /* FirstJSDocNode */ && node.kind <= 295 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 279 /* FirstJSDocTagNode */ && node.kind <= 292 /* LastJSDocTagNode */; + return node.kind >= 282 /* FirstJSDocTagNode */ && node.kind <= 295 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6724,18 +6846,52 @@ var ts; } ts.getLiteralText = getLiteralText; function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { + return node.kind === 8 /* NumericLiteral */ + && (getNumericLiteralFlags(text, /*hint*/ 6 /* BinaryOrOctal */) & 6 /* BinaryOrOctal */) !== 0; + } + ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + var NumericLiteralFlags; + (function (NumericLiteralFlags) { + NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; + NumericLiteralFlags[NumericLiteralFlags["Hexadecimal"] = 1] = "Hexadecimal"; + NumericLiteralFlags[NumericLiteralFlags["Binary"] = 2] = "Binary"; + NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; + NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 8] = "Scientific"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctal"] = 6] = "BinaryOrOctal"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalOrHexadecimal"] = 7] = "BinaryOrOctalOrHexadecimal"; + NumericLiteralFlags[NumericLiteralFlags["All"] = 15] = "All"; + })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); + /** + * Scans a numeric literal string to determine the form of the number. + * @param text Numeric literal text + * @param hint If `Scientific` or `All` is specified, performs a more expensive check to scan for scientific notation. + */ + function getNumericLiteralFlags(text, hint) { + if (text.length > 1) { switch (text.charCodeAt(1)) { case 98 /* b */: case 66 /* B */: + return 2 /* Binary */; case 111 /* o */: case 79 /* O */: - return true; + return 4 /* Octal */; + case 120 /* x */: + case 88 /* X */: + return 1 /* Hexadecimal */; + } + if (hint & 8 /* Scientific */) { + for (var i = text.length - 1; i >= 0; i--) { + switch (text.charCodeAt(i)) { + case 101 /* e */: + case 69 /* E */: + return 8 /* Scientific */; + } + } } } - return false; + return 0 /* None */; } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + ts.getNumericLiteralFlags = getNumericLiteralFlags; function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; } @@ -6744,11 +6900,6 @@ var ts; return identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier; } ts.escapeIdentifier = escapeIdentifier; - // Remove extra underscore from escaped identifier - function unescapeIdentifier(identifier) { - return identifier.length >= 3 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ && identifier.charCodeAt(2) === 95 /* _ */ ? identifier.substr(1) : identifier; - } - ts.unescapeIdentifier = unescapeIdentifier; // Make an identifier from an external module name by extracting the string after the last "/" and replacing // all non-alphanumeric characters with underscores function makeIdentifierFromModuleName(moduleName) { @@ -6762,11 +6913,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 224 /* VariableDeclaration */ && node.parent.kind === 257 /* CatchClause */; + return node.kind === 225 /* VariableDeclaration */ && node.parent.kind === 259 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 231 /* ModuleDeclaration */ && + return node && node.kind === 232 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6777,11 +6928,11 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node.kind === 231 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 232 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 262 /* SourceFile */ || - node.kind === 231 /* ModuleDeclaration */ || + return node.kind === 264 /* SourceFile */ || + node.kind === 232 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6797,9 +6948,9 @@ var ts; return false; } switch (node.parent.kind) { - case 262 /* SourceFile */: + case 264 /* SourceFile */: return ts.isExternalModule(node.parent); - case 232 /* ModuleBlock */: + case 233 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6811,22 +6962,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 262 /* SourceFile */: - case 233 /* CaseBlock */: - case 257 /* CatchClause */: - case 231 /* ModuleDeclaration */: - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 150 /* Constructor */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 264 /* SourceFile */: + case 234 /* CaseBlock */: + case 259 /* CatchClause */: + case 232 /* ModuleDeclaration */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 151 /* Constructor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return true; - case 205 /* Block */: + case 206 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -6860,7 +7011,7 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: if (isStringOrNumericLiteral(name.expression)) { return name.expression.text; } @@ -6871,10 +7022,10 @@ var ts; function entityNameToString(name) { switch (name.kind) { case 70 /* Identifier */: - return getFullWidth(name) === 0 ? unescapeIdentifier(name.text) : getTextOfNode(name); - case 141 /* QualifiedName */: + return getFullWidth(name) === 0 ? ts.unescapeIdentifier(name.text) : getTextOfNode(name); + case 142 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); } } @@ -6911,7 +7062,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 205 /* Block */) { + if (node.body && node.body.kind === 206 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6925,7 +7076,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 262 /* SourceFile */: + case 264 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -6934,23 +7085,23 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 224 /* VariableDeclaration */: - case 174 /* BindingElement */: - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 228 /* InterfaceDeclaration */: - case 231 /* ModuleDeclaration */: - case 230 /* EnumDeclaration */: - case 261 /* EnumMember */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 229 /* TypeAliasDeclaration */: + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 232 /* ModuleDeclaration */: + case 231 /* EnumDeclaration */: + case 263 /* EnumMember */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 230 /* TypeAliasDeclaration */: errorNode = node.name; break; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -6973,7 +7124,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 230 /* EnumDeclaration */ && isConst(node); + return node.kind === 231 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -6986,11 +7137,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 179 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; + return n.kind === 180 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 208 /* ExpressionStatement */ + return node.kind === 209 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -7003,10 +7154,10 @@ var ts; } ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 144 /* Parameter */ || - node.kind === 143 /* TypeParameter */ || - node.kind === 184 /* FunctionExpression */ || - node.kind === 185 /* ArrowFunction */) ? + var commentRanges = (node.kind === 145 /* Parameter */ || + node.kind === 144 /* TypeParameter */ || + node.kind === 185 /* FunctionExpression */ || + node.kind === 186 /* ArrowFunction */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); // True if the comment starts with '/**' but not if it is '/**/' @@ -7021,39 +7172,39 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (156 /* FirstTypeNode */ <= node.kind && node.kind <= 171 /* LastTypeNode */) { + if (157 /* FirstTypeNode */ <= node.kind && node.kind <= 172 /* LastTypeNode */) { return true; } switch (node.kind) { case 118 /* AnyKeyword */: case 132 /* NumberKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: - case 137 /* UndefinedKeyword */: + case 136 /* SymbolKeyword */: + case 138 /* UndefinedKeyword */: case 129 /* NeverKeyword */: return true; case 104 /* VoidKeyword */: - return node.parent.kind !== 188 /* VoidExpression */; - case 199 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 189 /* VoidExpression */; + case 200 /* 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 70 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 177 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */ || node.kind === 177 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 141 /* QualifiedName */: - case 177 /* PropertyAccessExpression */: + ts.Debug.assert(node.kind === 70 /* Identifier */ || node.kind === 142 /* QualifiedName */ || node.kind === 178 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 142 /* QualifiedName */: + case 178 /* PropertyAccessExpression */: case 98 /* ThisKeyword */: - var parent_1 = node.parent; - if (parent_1.kind === 160 /* TypeQuery */) { + var parent = node.parent; + if (parent.kind === 161 /* TypeQuery */) { return false; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -7062,38 +7213,38 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (156 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 171 /* LastTypeNode */) { + if (157 /* FirstTypeNode */ <= parent.kind && parent.kind <= 172 /* LastTypeNode */) { return true; } - switch (parent_1.kind) { - case 199 /* ExpressionWithTypeArguments */: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 143 /* TypeParameter */: - return node === parent_1.constraint; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 144 /* Parameter */: - case 224 /* VariableDeclaration */: - return node === parent_1.type; - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 150 /* Constructor */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - return node === parent_1.type; - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - return node === parent_1.type; - case 182 /* TypeAssertionExpression */: - return node === parent_1.type; - case 179 /* CallExpression */: - case 180 /* NewExpression */: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 181 /* TaggedTemplateExpression */: + switch (parent.kind) { + case 200 /* ExpressionWithTypeArguments */: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); + case 144 /* TypeParameter */: + return node === parent.constraint; + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 145 /* Parameter */: + case 225 /* VariableDeclaration */: + return node === parent.type; + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 151 /* Constructor */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + return node === parent.type; + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + return node === parent.type; + case 183 /* TypeAssertionExpression */: + return node === parent.type; + case 180 /* CallExpression */: + case 181 /* NewExpression */: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 182 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -7112,7 +7263,7 @@ var ts; } ts.isChildOfNodeWithKind = isChildOfNodeWithKind; function isPrefixUnaryExpression(node) { - return node.kind === 190 /* PrefixUnaryExpression */; + return node.kind === 191 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; // Warning: This has the same semantics as the forEach family of functions, @@ -7121,23 +7272,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: return visitor(node); - case 233 /* CaseBlock */: - case 205 /* Block */: - case 209 /* IfStatement */: - case 210 /* DoStatement */: - case 211 /* WhileStatement */: - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 218 /* WithStatement */: - case 219 /* SwitchStatement */: - case 254 /* CaseClause */: - case 255 /* DefaultClause */: - case 220 /* LabeledStatement */: - case 222 /* TryStatement */: - case 257 /* CatchClause */: + case 234 /* CaseBlock */: + case 206 /* Block */: + case 210 /* IfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 219 /* WithStatement */: + case 220 /* SwitchStatement */: + case 256 /* CaseClause */: + case 257 /* DefaultClause */: + case 221 /* LabeledStatement */: + case 223 /* TryStatement */: + case 259 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -7147,29 +7298,29 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 230 /* EnumDeclaration */: - case 228 /* InterfaceDeclaration */: - case 231 /* ModuleDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 231 /* EnumDeclaration */: + case 229 /* InterfaceDeclaration */: + case 232 /* ModuleDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* 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_5 = node.name; - if (name_5 && name_5.kind === 142 /* ComputedPropertyName */) { + var name = node.name; + if (name && name.kind === 143 /* 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_5.expression); + traverse(name.expression); return; } } @@ -7189,10 +7340,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 162 /* ArrayType */) { + if (node && node.kind === 163 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 157 /* TypeReference */) { + else if (node && node.kind === 158 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -7203,14 +7354,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 174 /* BindingElement */: - case 261 /* EnumMember */: - case 144 /* Parameter */: - case 258 /* PropertyAssignment */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 259 /* ShorthandPropertyAssignment */: - case 224 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 263 /* EnumMember */: + case 145 /* Parameter */: + case 260 /* PropertyAssignment */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 261 /* ShorthandPropertyAssignment */: + case 225 /* VariableDeclaration */: return true; } } @@ -7218,11 +7369,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 151 /* GetAccessor */ || node.kind === 152 /* SetAccessor */); + return node && (node.kind === 152 /* GetAccessor */ || node.kind === 153 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 227 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */); + return node && (node.kind === 228 /* ClassDeclaration */ || node.kind === 198 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7231,19 +7382,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 150 /* Constructor */: - case 184 /* FunctionExpression */: - case 226 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 151 /* Constructor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return true; } return false; @@ -7251,13 +7402,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: return true; } return false; @@ -7265,13 +7416,13 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 210 /* DoStatement */: - case 211 /* WhileStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: return true; - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -7282,7 +7433,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 220 /* LabeledStatement */) { + if (node.statement.kind !== 221 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -7290,17 +7441,17 @@ var ts; } ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 205 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 206 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 149 /* MethodDeclaration */ && node.parent.kind === 176 /* ObjectLiteralExpression */; + return node && node.kind === 150 /* MethodDeclaration */ && node.parent.kind === 177 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 149 /* MethodDeclaration */ && - (node.parent.kind === 176 /* ObjectLiteralExpression */ || - node.parent.kind === 197 /* ClassExpression */); + return node.kind === 150 /* MethodDeclaration */ && + (node.parent.kind === 177 /* ObjectLiteralExpression */ || + node.parent.kind === 198 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -7336,7 +7487,7 @@ var ts; return undefined; } switch (node.kind) { - case 142 /* ComputedPropertyName */: + case 143 /* 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 @@ -7351,9 +7502,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 145 /* Decorator */: + case 146 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 144 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 145 /* 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; @@ -7364,26 +7515,26 @@ var ts; node = node.parent; } break; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 231 /* ModuleDeclaration */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 230 /* EnumDeclaration */: - case 262 /* SourceFile */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 232 /* ModuleDeclaration */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 231 /* EnumDeclaration */: + case 264 /* SourceFile */: return node; } } @@ -7393,9 +7544,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 150 /* Constructor */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 151 /* Constructor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: return container; } } @@ -7417,26 +7568,26 @@ var ts; return node; } switch (node.kind) { - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: node = node.parent; break; - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: if (!stopOnFunctions) { continue; } - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return node; - case 145 /* Decorator */: + case 146 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 144 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 145 /* 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; @@ -7452,15 +7603,15 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 184 /* FunctionExpression */ || func.kind === 185 /* ArrowFunction */) { + if (func.kind === 185 /* FunctionExpression */ || func.kind === 186 /* ArrowFunction */) { var prev = func; - var parent_2 = func.parent; - while (parent_2.kind === 183 /* ParenthesizedExpression */) { - prev = parent_2; - parent_2 = parent_2.parent; + var parent = func.parent; + while (parent.kind === 184 /* ParenthesizedExpression */) { + prev = parent; + parent = parent.parent; } - if (parent_2.kind === 179 /* CallExpression */ && parent_2.expression === prev) { - return parent_2; + if (parent.kind === 180 /* CallExpression */ && parent.expression === prev) { + return parent; } } } @@ -7470,21 +7621,21 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 177 /* PropertyAccessExpression */ || kind === 178 /* ElementAccessExpression */) + return (kind === 178 /* PropertyAccessExpression */ || kind === 179 /* ElementAccessExpression */) && node.expression.kind === 96 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 157 /* TypeReference */: - case 273 /* JSDocTypeReference */: + case 158 /* TypeReference */: + case 276 /* JSDocTypeReference */: return node.typeName; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 70 /* Identifier */: - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: return node; } return undefined; @@ -7492,10 +7643,12 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 181 /* TaggedTemplateExpression */: - case 145 /* Decorator */: + case 250 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 182 /* TaggedTemplateExpression */: + case 146 /* Decorator */: return true; default: return false; @@ -7503,34 +7656,37 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 181 /* TaggedTemplateExpression */) { + if (node.kind === 182 /* TaggedTemplateExpression */) { return node.tag; } + else if (isJsxOpeningLikeElement(node)) { + return node.tagName; + } // Will either be a CallExpression, NewExpression, or Decorator. return node.expression; } ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: // classes are valid targets return true; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 227 /* ClassDeclaration */; - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 149 /* MethodDeclaration */: + return node.parent.kind === 228 /* ClassDeclaration */; + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 150 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && node.parent.kind === 227 /* ClassDeclaration */; - case 144 /* Parameter */: + && node.parent.kind === 228 /* ClassDeclaration */; + case 145 /* 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 !== undefined - && (node.parent.kind === 150 /* Constructor */ - || node.parent.kind === 149 /* MethodDeclaration */ - || node.parent.kind === 152 /* SetAccessor */) - && node.parent.parent.kind === 227 /* ClassDeclaration */; + && (node.parent.kind === 151 /* Constructor */ + || node.parent.kind === 150 /* MethodDeclaration */ + || node.parent.kind === 153 /* SetAccessor */) + && node.parent.parent.kind === 228 /* ClassDeclaration */; } return false; } @@ -7546,19 +7702,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 149 /* MethodDeclaration */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 153 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 249 /* JsxOpeningElement */ || - parent.kind === 248 /* JsxSelfClosingElement */ || - parent.kind === 250 /* JsxClosingElement */) { + if (parent.kind === 250 /* JsxOpeningElement */ || + parent.kind === 249 /* JsxSelfClosingElement */ || + parent.kind === 251 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -7572,97 +7728,97 @@ var ts; case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: case 11 /* RegularExpressionLiteral */: - case 175 /* ArrayLiteralExpression */: - case 176 /* ObjectLiteralExpression */: - case 177 /* PropertyAccessExpression */: - case 178 /* ElementAccessExpression */: - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 181 /* TaggedTemplateExpression */: - case 200 /* AsExpression */: - case 182 /* TypeAssertionExpression */: - case 201 /* NonNullExpression */: - case 183 /* ParenthesizedExpression */: - case 184 /* FunctionExpression */: - case 197 /* ClassExpression */: - case 185 /* ArrowFunction */: - case 188 /* VoidExpression */: - case 186 /* DeleteExpression */: - case 187 /* TypeOfExpression */: - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: - case 192 /* BinaryExpression */: - case 193 /* ConditionalExpression */: - case 196 /* SpreadElement */: - case 194 /* TemplateExpression */: + case 176 /* ArrayLiteralExpression */: + case 177 /* ObjectLiteralExpression */: + case 178 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 182 /* TaggedTemplateExpression */: + case 201 /* AsExpression */: + case 183 /* TypeAssertionExpression */: + case 202 /* NonNullExpression */: + case 184 /* ParenthesizedExpression */: + case 185 /* FunctionExpression */: + case 198 /* ClassExpression */: + case 186 /* ArrowFunction */: + case 189 /* VoidExpression */: + case 187 /* DeleteExpression */: + case 188 /* TypeOfExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: + case 193 /* BinaryExpression */: + case 194 /* ConditionalExpression */: + case 197 /* SpreadElement */: + case 195 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: - case 198 /* OmittedExpression */: - case 247 /* JsxElement */: - case 248 /* JsxSelfClosingElement */: - case 195 /* YieldExpression */: - case 189 /* AwaitExpression */: - case 202 /* MetaProperty */: + case 199 /* OmittedExpression */: + case 248 /* JsxElement */: + case 249 /* JsxSelfClosingElement */: + case 196 /* YieldExpression */: + case 190 /* AwaitExpression */: + case 203 /* MetaProperty */: return true; - case 141 /* QualifiedName */: - while (node.parent.kind === 141 /* QualifiedName */) { + case 142 /* QualifiedName */: + while (node.parent.kind === 142 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 160 /* TypeQuery */ || isJSXTagName(node); + return node.parent.kind === 161 /* TypeQuery */ || isJSXTagName(node); case 70 /* Identifier */: - if (node.parent.kind === 160 /* TypeQuery */ || isJSXTagName(node)) { + if (node.parent.kind === 161 /* TypeQuery */ || isJSXTagName(node)) { return true; } // fall through case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 98 /* ThisKeyword */: - var parent_3 = node.parent; - switch (parent_3.kind) { - case 224 /* VariableDeclaration */: - case 144 /* Parameter */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 261 /* EnumMember */: - case 258 /* PropertyAssignment */: - case 174 /* BindingElement */: - return parent_3.initializer === node; - case 208 /* ExpressionStatement */: - case 209 /* IfStatement */: - case 210 /* DoStatement */: - case 211 /* WhileStatement */: - case 217 /* ReturnStatement */: - case 218 /* WithStatement */: - case 219 /* SwitchStatement */: - case 254 /* CaseClause */: - case 221 /* ThrowStatement */: - case 219 /* SwitchStatement */: - return parent_3.expression === node; - case 212 /* ForStatement */: - var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 225 /* VariableDeclarationList */) || + var parent = node.parent; + switch (parent.kind) { + case 225 /* VariableDeclaration */: + case 145 /* Parameter */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 263 /* EnumMember */: + case 260 /* PropertyAssignment */: + case 175 /* BindingElement */: + return parent.initializer === node; + case 209 /* ExpressionStatement */: + case 210 /* IfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 218 /* ReturnStatement */: + case 219 /* WithStatement */: + case 220 /* SwitchStatement */: + case 256 /* CaseClause */: + case 222 /* ThrowStatement */: + case 220 /* SwitchStatement */: + return parent.expression === node; + case 213 /* ForStatement */: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 226 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 225 /* VariableDeclarationList */) || + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + var forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 226 /* VariableDeclarationList */) || forInStatement.expression === node; - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: - return node === parent_3.expression; - case 203 /* TemplateSpan */: - return node === parent_3.expression; - case 142 /* ComputedPropertyName */: - return node === parent_3.expression; - case 145 /* Decorator */: - case 253 /* JsxExpression */: - case 252 /* JsxSpreadAttribute */: - case 260 /* SpreadAssignment */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: + return node === parent.expression; + case 204 /* TemplateSpan */: + return node === parent.expression; + case 143 /* ComputedPropertyName */: + return node === parent.expression; + case 146 /* Decorator */: + case 255 /* JsxExpression */: + case 254 /* JsxSpreadAttribute */: + case 262 /* SpreadAssignment */: return true; - case 199 /* ExpressionWithTypeArguments */: - return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); + case 200 /* ExpressionWithTypeArguments */: + return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: - if (isPartOfExpression(parent_3)) { + if (isPartOfExpression(parent)) { return true; } } @@ -7677,7 +7833,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 246 /* ExternalModuleReference */; + return node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 247 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7686,7 +7842,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 246 /* ExternalModuleReference */; + return node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 247 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7704,7 +7860,7 @@ var ts; */ function isRequireCall(expression, checkArgumentIsStringLiteral) { // of the form 'require("name")' - var isRequire = expression.kind === 179 /* CallExpression */ && + var isRequire = expression.kind === 180 /* CallExpression */ && expression.expression.kind === 70 /* Identifier */ && expression.expression.text === "require" && expression.arguments.length === 1; @@ -7720,9 +7876,9 @@ var ts; * This function does not test if the node is in a JavaScript file or not. */ function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 224 /* VariableDeclaration */) { + if (s.valueDeclaration && s.valueDeclaration.kind === 225 /* VariableDeclaration */) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 184 /* FunctionExpression */; + return declaration.initializer && declaration.initializer.kind === 185 /* FunctionExpression */; } return false; } @@ -7733,11 +7889,11 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0 /* None */; } - if (expression.kind !== 192 /* BinaryExpression */) { + if (expression.kind !== 193 /* BinaryExpression */) { return 0 /* None */; } var expr = expression; - if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 177 /* PropertyAccessExpression */) { + if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 178 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; @@ -7755,7 +7911,7 @@ var ts; else if (lhs.expression.kind === 98 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (lhs.expression.kind === 177 /* PropertyAccessExpression */) { + else if (lhs.expression.kind === 178 /* PropertyAccessExpression */) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 70 /* Identifier */) { @@ -7773,35 +7929,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 236 /* ImportDeclaration */) { + if (node.kind === 237 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 235 /* ImportEqualsDeclaration */) { + if (node.kind === 236 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 246 /* ExternalModuleReference */) { + if (reference.kind === 247 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 242 /* ExportDeclaration */) { + if (node.kind === 243 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 231 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 232 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 235 /* ImportEqualsDeclaration */) { + if (node.kind === 236 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 238 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 239 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 236 /* ImportDeclaration */ + return node.kind === 237 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7809,13 +7965,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 144 /* Parameter */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 259 /* ShorthandPropertyAssignment */: - case 258 /* PropertyAssignment */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 145 /* Parameter */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 261 /* ShorthandPropertyAssignment */: + case 260 /* PropertyAssignment */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -7823,22 +7979,27 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 275 /* JSDocFunctionType */ && + return node.kind === 278 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 277 /* JSDocConstructorType */; + node.parameters[0].type.kind === 280 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { return ts.map(getJSDocs(node), function (doc) { return doc.comment; }); } ts.getCommentsFromJSDoc = getCommentsFromJSDoc; + function hasJSDocParameterTags(node) { + var parameterTags = getJSDocTags(node, 285 /* JSDocParameterTag */); + return parameterTags && parameterTags.length > 0; + } + ts.hasJSDocParameterTags = hasJSDocParameterTags; function getJSDocTags(node, kind) { var docs = getJSDocs(node); if (docs) { var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 282 /* JSDocParameterTag */) { + if (doc.kind === 285 /* JSDocParameterTag */) { if (doc.kind === kind) { result.push(doc); } @@ -7870,9 +8031,9 @@ var ts; // var x = function(name) { return name.length; } var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 206 /* VariableStatement */; + parent.parent.parent.kind === 207 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 206 /* VariableStatement */; + parent.parent.kind === 207 /* VariableStatement */; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -7881,20 +8042,20 @@ var ts; } // Also recognize when the node is the RHS of an assignment expression var isSourceOfAssignmentExpressionStatement = parent && parent.parent && - parent.kind === 192 /* BinaryExpression */ && + parent.kind === 193 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && - parent.parent.kind === 208 /* ExpressionStatement */; + parent.parent.kind === 209 /* ExpressionStatement */; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 231 /* ModuleDeclaration */ && - parent && parent.kind === 231 /* ModuleDeclaration */; - var isPropertyAssignmentExpression = parent && parent.kind === 258 /* PropertyAssignment */; + var isModuleDeclaration = node.kind === 232 /* ModuleDeclaration */ && + parent && parent.kind === 232 /* ModuleDeclaration */; + var isPropertyAssignmentExpression = parent && parent.kind === 260 /* PropertyAssignment */; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } // Pull parameter comments from declaring function as well - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { cache = ts.concatenate(cache, getJSDocParameterTags(node)); } if (isVariableLike(node) && node.initializer) { @@ -7908,18 +8069,18 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 282 /* JSDocParameterTag */); + var tags = getJSDocTags(func, 285 /* JSDocParameterTag */); if (!param.name) { // this is an anonymous jsdoc param from a `function(type1, type2): type3` specification var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 282 /* JSDocParameterTag */; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 285 /* JSDocParameterTag */; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70 /* Identifier */) { - var name_6 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 282 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); + var name_1 = param.name.text; + return ts.filter(tags, function (tag) { return tag.kind === 285 /* JSDocParameterTag */ && tag.parameterName.text === name_1; }); } else { // TODO: it's a destructured parameter, so it should look up an "object type" series of multiple lines @@ -7929,8 +8090,8 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 284 /* JSDocTypeTag */); - if (!tag && node.kind === 144 /* Parameter */) { + var tag = getFirstJSDocTag(node, 287 /* JSDocTypeTag */); + if (!tag && node.kind === 145 /* Parameter */) { var paramTags = getJSDocParameterTags(node); if (paramTags) { tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); @@ -7940,15 +8101,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 281 /* JSDocAugmentsTag */); + return getFirstJSDocTag(node, 284 /* JSDocAugmentsTag */); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 283 /* JSDocReturnTag */); + return getFirstJSDocTag(node, 286 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 285 /* JSDocTemplateTag */); + return getFirstJSDocTag(node, 288 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -7961,8 +8122,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536 /* JavaScriptFile */)) { - if (node.type && node.type.kind === 276 /* JSDocVariadicType */ || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 276 /* JSDocVariadicType */; })) { + if (node.type && node.type.kind === 279 /* JSDocVariadicType */ || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 279 /* JSDocVariadicType */; })) { return true; } } @@ -7983,29 +8144,33 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 57 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 42 /* PlusPlusToken */ || unaryOperator === 43 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 183 /* ParenthesizedExpression */: - case 175 /* ArrayLiteralExpression */: - case 196 /* SpreadElement */: + case 184 /* ParenthesizedExpression */: + case 176 /* ArrayLiteralExpression */: + case 197 /* SpreadElement */: node = parent; break; - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } - // Fall through - case 258 /* PropertyAssignment */: + node = parent.parent; + break; + case 260 /* PropertyAssignment */: + if (parent.name === node) { + return 0 /* None */; + } node = parent.parent; break; default: @@ -8017,21 +8182,22 @@ var ts; ts.getAssignmentTargetKind = getAssignmentTargetKind; // A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property // assignment in an object literal that is an assignment target, or if it is parented by an array literal that is - // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. + // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'. + // (Note that `p` is not a target in the above examples, only `a`.) function isAssignmentTarget(node) { return getAssignmentTargetKind(node) !== 0 /* None */; } ts.isAssignmentTarget = isAssignmentTarget; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 177 /* PropertyAccessExpression */ && node.kind !== 178 /* ElementAccessExpression */) { + if (node.kind !== 178 /* PropertyAccessExpression */ && node.kind !== 179 /* ElementAccessExpression */) { return false; } node = node.parent; - while (node && node.kind === 183 /* ParenthesizedExpression */) { + while (node && node.kind === 184 /* ParenthesizedExpression */) { node = node.parent; } - return node && node.kind === 186 /* DeleteExpression */; + return node && node.kind === 187 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -8045,7 +8211,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2 /* Ambient */) || (node.kind === 262 /* SourceFile */ && node.isDeclarationFile)) { + if (hasModifier(node, 2 /* Ambient */) || (node.kind === 264 /* SourceFile */ && node.isDeclarationFile)) { return true; } node = node.parent; @@ -8059,7 +8225,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 240 /* ImportSpecifier */ || parent.kind === 244 /* ExportSpecifier */) { + if (parent.kind === 241 /* ImportSpecifier */ || parent.kind === 245 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -8072,7 +8238,7 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 142 /* ComputedPropertyName */ && + node.parent.kind === 143 /* ComputedPropertyName */ && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -8080,31 +8246,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 261 /* EnumMember */: - case 258 /* PropertyAssignment */: - case 177 /* PropertyAccessExpression */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 263 /* EnumMember */: + case 260 /* PropertyAssignment */: + case 178 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 141 /* QualifiedName */) { + while (parent.kind === 142 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 160 /* TypeQuery */; + return parent.kind === 161 /* TypeQuery */; } return false; - case 174 /* BindingElement */: - case 240 /* ImportSpecifier */: + case 175 /* BindingElement */: + case 241 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 244 /* ExportSpecifier */: + case 245 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -8120,13 +8286,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 235 /* ImportEqualsDeclaration */ || - node.kind === 234 /* NamespaceExportDeclaration */ || - node.kind === 237 /* ImportClause */ && !!node.name || - node.kind === 238 /* NamespaceImport */ || - node.kind === 240 /* ImportSpecifier */ || - node.kind === 244 /* ExportSpecifier */ || - node.kind === 241 /* ExportAssignment */ && exportAssignmentIsAlias(node); + return node.kind === 236 /* ImportEqualsDeclaration */ || + node.kind === 235 /* NamespaceExportDeclaration */ || + node.kind === 238 /* ImportClause */ && !!node.name || + node.kind === 239 /* NamespaceImport */ || + node.kind === 241 /* ImportSpecifier */ || + node.kind === 245 /* ExportSpecifier */ || + node.kind === 242 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8212,7 +8378,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 /* FirstKeyword */ <= token && token <= 140 /* LastKeyword */; + return 71 /* FirstKeyword */ <= token && token <= 141 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -8241,7 +8407,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 142 /* ComputedPropertyName */ && + return name.kind === 143 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -8256,10 +8422,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 144 /* Parameter */) { + if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 145 /* Parameter */) { return name.text; } - if (name.kind === 142 /* ComputedPropertyName */) { + if (name.kind === 143 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -8307,11 +8473,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 144 /* Parameter */; + return root.kind === 145 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 174 /* BindingElement */) { + while (node.kind === 175 /* BindingElement */) { node = node.parent.parent; } return node; @@ -8319,15 +8485,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 150 /* Constructor */ - || kind === 184 /* FunctionExpression */ - || kind === 226 /* FunctionDeclaration */ - || kind === 185 /* ArrowFunction */ - || kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */ - || kind === 231 /* ModuleDeclaration */ - || kind === 262 /* SourceFile */; + return kind === 151 /* Constructor */ + || kind === 185 /* FunctionExpression */ + || kind === 227 /* FunctionDeclaration */ + || kind === 186 /* ArrowFunction */ + || kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */ + || kind === 232 /* ModuleDeclaration */ + || kind === 264 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8335,49 +8501,22 @@ var ts; || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node, nodeTest) { - if (node) { - while (node.original !== undefined) { - node = node.original; - } + function getOriginalSourceFileOrBundle(sourceFileOrBundle) { + if (sourceFileOrBundle.kind === 265 /* Bundle */) { + return ts.updateBundle(sourceFileOrBundle, ts.sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile)); } - return !nodeTest || nodeTest(node) ? node : undefined; + return getOriginalSourceFile(sourceFileOrBundle); } - ts.getOriginalNode = getOriginalNode; - /** - * Gets a value indicating whether a node originated in the parse tree. - * - * @param node The node to test. - */ - function isParseTreeNode(node) { - return (node.flags & 8 /* Synthesized */) === 0; + ts.getOriginalSourceFileOrBundle = getOriginalSourceFileOrBundle; + function getOriginalSourceFile(sourceFile) { + return ts.getParseTreeNode(sourceFile, isSourceFile) || sourceFile; } - ts.isParseTreeNode = isParseTreeNode; - function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { - return node; - } - node = getOriginalNode(node); - if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { - return node; - } - return undefined; - } - ts.getParseTreeNode = getParseTreeNode; function getOriginalSourceFiles(sourceFiles) { - var originalSourceFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); - if (originalSourceFile) { - originalSourceFiles.push(originalSourceFile); - } - } - return originalSourceFiles; + return ts.sameMap(sourceFiles, getOriginalSourceFile); } ts.getOriginalSourceFiles = getOriginalSourceFiles; function getOriginalNodeId(node) { - node = getOriginalNode(node); + node = ts.getOriginalNode(node); return node ? ts.getNodeId(node) : 0; } ts.getOriginalNodeId = getOriginalNodeId; @@ -8388,23 +8527,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 180 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 181 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 180 /* NewExpression */: + case 181 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 190 /* PrefixUnaryExpression */: - case 187 /* TypeOfExpression */: - case 188 /* VoidExpression */: - case 186 /* DeleteExpression */: - case 189 /* AwaitExpression */: - case 193 /* ConditionalExpression */: - case 195 /* YieldExpression */: + case 191 /* PrefixUnaryExpression */: + case 188 /* TypeOfExpression */: + case 189 /* VoidExpression */: + case 187 /* DeleteExpression */: + case 190 /* AwaitExpression */: + case 194 /* ConditionalExpression */: + case 196 /* YieldExpression */: return 1 /* Right */; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (operator) { case 39 /* AsteriskAsteriskToken */: case 57 /* EqualsToken */: @@ -8428,15 +8567,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 180 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 181 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 192 /* BinaryExpression */) { + if (expression.kind === 193 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 190 /* PrefixUnaryExpression */ || expression.kind === 191 /* PostfixUnaryExpression */) { + else if (expression.kind === 191 /* PrefixUnaryExpression */ || expression.kind === 192 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -8454,36 +8593,36 @@ var ts; case 85 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 175 /* ArrayLiteralExpression */: - case 176 /* ObjectLiteralExpression */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 197 /* ClassExpression */: - case 247 /* JsxElement */: - case 248 /* JsxSelfClosingElement */: + case 176 /* ArrayLiteralExpression */: + case 177 /* ObjectLiteralExpression */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 198 /* ClassExpression */: + case 248 /* JsxElement */: + case 249 /* JsxSelfClosingElement */: case 11 /* RegularExpressionLiteral */: case 12 /* NoSubstitutionTemplateLiteral */: - case 194 /* TemplateExpression */: - case 183 /* ParenthesizedExpression */: - case 198 /* OmittedExpression */: + case 195 /* TemplateExpression */: + case 184 /* ParenthesizedExpression */: + case 199 /* OmittedExpression */: return 19; - case 181 /* TaggedTemplateExpression */: - case 177 /* PropertyAccessExpression */: - case 178 /* ElementAccessExpression */: + case 182 /* TaggedTemplateExpression */: + case 178 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: return 18; - case 180 /* NewExpression */: + case 181 /* NewExpression */: return hasArguments ? 18 : 17; - case 179 /* CallExpression */: + case 180 /* CallExpression */: return 17; - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return 16; - case 190 /* PrefixUnaryExpression */: - case 187 /* TypeOfExpression */: - case 188 /* VoidExpression */: - case 186 /* DeleteExpression */: - case 189 /* AwaitExpression */: + case 191 /* PrefixUnaryExpression */: + case 188 /* TypeOfExpression */: + case 189 /* VoidExpression */: + case 187 /* DeleteExpression */: + case 190 /* AwaitExpression */: return 15; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (operatorKind) { case 50 /* ExclamationToken */: case 51 /* TildeToken */: @@ -8541,11 +8680,11 @@ var ts; default: return -1; } - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return 4; - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return 2; - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return 1; default: return -1; @@ -8568,21 +8707,15 @@ var ts; return modificationCount; } function reattachFileDiagnostics(newFile) { - if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { - var diagnostic = _a[_i]; - diagnostic.file = newFile; - } + ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } function add(diagnostic) { var diagnostics; if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); if (!diagnostics) { diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; + fileDiagnostics.set(diagnostic.file.fileName, diagnostics); } } else { @@ -8599,16 +8732,16 @@ var ts; function getDiagnostics(fileName) { sortAndDeduplicate(); if (fileName) { - return fileDiagnostics[fileName] || []; + return fileDiagnostics.get(fileName) || []; } var allDiagnostics = []; function pushDiagnostic(d) { allDiagnostics.push(d); } ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } + fileDiagnostics.forEach(function (diagnostics) { + ts.forEach(diagnostics, pushDiagnostic); + }); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function sortAndDeduplicate() { @@ -8617,9 +8750,9 @@ var ts; } diagnosticsModified = false; nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } + fileDiagnostics.forEach(function (diagnostics, key) { + fileDiagnostics.set(key, ts.sortAndDeduplicateDiagnostics(diagnostics)); + }); } } ts.createDiagnosticCollection = createDiagnosticCollection; @@ -8629,7 +8762,7 @@ var ts; // the map below must be updated. Note that this regexp *does not* include the 'delete' character. // There is no reason for this other than that JSON.stringify does not handle it either. var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = ts.createMap({ + var escapedCharsMap = ts.createMapFromTemplate({ "\0": "\\0", "\t": "\\t", "\v": "\\v", @@ -8653,7 +8786,7 @@ var ts; } ts.escapeString = escapeString; function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); @@ -8811,168 +8944,77 @@ var ts; */ function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); + var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); }; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); - var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = getAllEmittableSourceFiles(); + var moduleEmitEnabled_1 = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified - return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); + return ts.filter(host.getSourceFiles(), function (sourceFile) { + return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); + }); } else { - var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; - return filterSourceFilesInDirectory(sourceFiles, function (file) { return host.isSourceFileFromExternalLibrary(file); }); - } - function getAllEmittableSourceFiles() { - return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); + var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); }); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; - /** Don't call this for `--outFile`, just for `--outDir` or plain emit. */ - function filterSourceFilesInDirectory(sourceFiles, isSourceFileFromExternalLibrary) { - return ts.filter(sourceFiles, function (file) { return shouldEmitInDirectory(file, isSourceFileFromExternalLibrary); }); - } - ts.filterSourceFilesInDirectory = filterSourceFilesInDirectory; - function isNonDeclarationFile(sourceFile) { - return !isDeclarationFile(sourceFile); + /** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */ + function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) { + return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !isDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); } + ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; /** - * Whether a file should be emitted in a non-`--outFile` case. - * Don't emit if source file is a declaration file, or was located under node_modules - */ - function shouldEmitInDirectory(sourceFile, isSourceFileFromExternalLibrary) { - return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); - } - function isBundleEmitNonExternalModule(sourceFile) { - return isNonDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); - } - /** - * Iterates over each source file to emit. The source files are expected to have been - * transformed for use by the pretty printer. - * - * Originally part of `forEachExpectedEmitFile`, this functionality was extracted to support - * transformations. + * Iterates over the source files that are expected to have an emit output. * * @param host An EmitHost. - * @param sourceFiles The transformed source files to emit. * @param action The action to execute. + * @param sourceFilesOrTargetSourceFile + * If an array, the full list of source files to emit. + * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); - // Emit on each source file if (options.outFile || options.out) { - onBundledEmit(sourceFiles); - } - else { - for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { - var sourceFile = sourceFiles_2[_i]; - // Don't emit if source file is a declaration file, or was located under node_modules - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } - } - function onSingleFileEmit(host, sourceFile) { - // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. - // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. - // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve - var extension = ".js"; - if (options.jsx === 1 /* Preserve */) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1 /* JSX */) { - // TypeScript source file preserving JSX syntax - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], /*isBundledEmit*/ false); - } - function onBundledEmit(sourceFiles) { if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, /*isBundledEmit*/ true); + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); + } + } + else { + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, sourceFile, emitOnlyDtsFiles); } } } - ts.forEachTransformedEmitFile = forEachTransformedEmitFile; + ts.forEachEmittedFile = forEachEmittedFile; function getSourceMapFilePath(jsFilePath, options) { return options.sourceMap ? jsFilePath + ".map" : undefined; } - /** - * Iterates over the source files that are expected to have an emit output. This function - * is used by the legacy emitter and the declaration emitter and should not be used by - * the tree transforming emitter. - * - * @param host An EmitHost. - * @param action The action to execute. - * @param targetSourceFile An optional target source file to emit. - */ - function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - // Emit on each source file - if (options.outFile || options.out) { - onBundledEmit(host); - } - else { - var sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; - if (shouldEmitInDirectory(sourceFile, function (file) { return host.isSourceFileFromExternalLibrary(file); })) { - onSingleFileEmit(host, sourceFile); + // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. + // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. + // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve + function getOutputExtension(sourceFile, options) { + if (options.jsx === 1 /* Preserve */) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + return ".jsx"; } } - } - function onSingleFileEmit(host, sourceFile) { - // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. - // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. - // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve - var extension = ".js"; - if (options.jsx === 1 /* Preserve */) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1 /* JSX */) { - // TypeScript source file preserving JSX syntax - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: declarationFilePath - }; - action(emitFileNames, [sourceFile], /*isBundledEmit*/ false, emitOnlyDtsFiles); - } - function onBundledEmit(host) { - // Can emit only sources that are not declaration file and are either non module code or module with - // --module or --target es6 specified. Files included by searching under node_modules are also not emitted. - var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (!ts.isExternalModule(sourceFile) || - !!ts.getEmitModuleKind(options)); }); - if (bundledSources.length) { - var jsFilePath = options.outFile || options.out; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined - }; - action(emitFileNames, bundledSources, /*isBundledEmit*/ true, emitOnlyDtsFiles); + else if (sourceFile.languageVariant === 1 /* JSX */) { + // TypeScript source file preserving JSX syntax + return ".jsx"; } } + return ".js"; } - ts.forEachExpectedEmitFile = forEachExpectedEmitFile; function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); var commonSourceDirectory = host.getCommonSourceDirectory(); @@ -8997,7 +9039,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 150 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 151 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -9039,10 +9081,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 151 /* GetAccessor */) { + if (accessor.kind === 152 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 152 /* SetAccessor */) { + else if (accessor.kind === 153 /* SetAccessor */) { setAccessor = accessor; } else { @@ -9051,7 +9093,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 151 /* GetAccessor */ || member.kind === 152 /* SetAccessor */) + if ((member.kind === 152 /* GetAccessor */ || member.kind === 153 /* SetAccessor */) && hasModifier(member, 32 /* Static */) === hasModifier(accessor, 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -9062,10 +9104,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 151 /* GetAccessor */ && !getAccessor) { + if (member.kind === 152 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 152 /* SetAccessor */ && !setAccessor) { + if (member.kind === 153 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -9328,7 +9370,7 @@ var ts; ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 199 /* ExpressionWithTypeArguments */ && + if (node.kind === 200 /* ExpressionWithTypeArguments */ && node.parent.token === 84 /* ExtendsKeyword */ && isClassLike(node.parent.parent)) { return node.parent.parent; @@ -9346,8 +9388,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 176 /* ObjectLiteralExpression */ - || kind === 175 /* ArrayLiteralExpression */; + return kind === 177 /* ObjectLiteralExpression */ + || kind === 176 /* ArrayLiteralExpression */; } return false; } @@ -9375,29 +9417,33 @@ var ts; ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { return node.kind === 70 /* Identifier */ || - node.kind === 177 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); + node.kind === 178 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 177 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 176 /* ObjectLiteralExpression */) { + if (kind === 177 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 175 /* ArrayLiteralExpression */) { + if (kind === 176 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; } ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; + return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function isExportDefaultSymbol(symbol) { + return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512 /* Default */); + } + ts.isExportDefaultSymbol = isExportDefaultSymbol; /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -9509,39 +9555,39 @@ var ts; || kind === 94 /* NullKeyword */) { return true; } - else if (kind === 177 /* PropertyAccessExpression */) { + else if (kind === 178 /* PropertyAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 178 /* ElementAccessExpression */) { + else if (kind === 179 /* ElementAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 190 /* PrefixUnaryExpression */ - || kind === 191 /* PostfixUnaryExpression */) { + else if (kind === 191 /* PrefixUnaryExpression */ + || kind === 192 /* PostfixUnaryExpression */) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 192 /* BinaryExpression */) { + else if (kind === 193 /* BinaryExpression */) { return node.operatorToken.kind !== 39 /* AsteriskAsteriskToken */ && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 193 /* ConditionalExpression */) { + else if (kind === 194 /* ConditionalExpression */) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 188 /* VoidExpression */ - || kind === 187 /* TypeOfExpression */ - || kind === 186 /* DeleteExpression */) { + else if (kind === 189 /* VoidExpression */ + || kind === 188 /* TypeOfExpression */ + || kind === 187 /* DeleteExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 175 /* ArrayLiteralExpression */) { + else if (kind === 176 /* ArrayLiteralExpression */) { return node.elements.length === 0; } - else if (kind === 176 /* ObjectLiteralExpression */) { + else if (kind === 177 /* ObjectLiteralExpression */) { return node.properties.length === 0; } - else if (kind === 179 /* CallExpression */) { + else if (kind === 180 /* CallExpression */) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9556,16 +9602,19 @@ var ts; } return false; } - var syntaxKindCache = ts.createMap(); + var syntaxKindCache = []; function formatSyntaxKind(kind) { var syntaxKindEnum = ts.SyntaxKind; if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; + var cached = syntaxKindCache[kind]; + if (cached !== undefined) { + return cached; } - for (var name_7 in syntaxKindEnum) { - if (syntaxKindEnum[name_7] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_7 + ")"; + for (var name in syntaxKindEnum) { + if (syntaxKindEnum[name] === kind) { + var result = kind + " (" + name + ")"; + syntaxKindCache[kind] = result; + return result; } } } @@ -9574,6 +9623,14 @@ var ts; } } ts.formatSyntaxKind = formatSyntaxKind; + function getRangePos(range) { + return range ? range.pos : -1; + } + ts.getRangePos = getRangePos; + function getRangeEnd(range) { + return range ? range.end : -1; + } + ts.getRangeEnd = getRangeEnd; /** * Increases (or decreases) a position by the provided amount. * @@ -9705,11 +9762,11 @@ var ts; * declaration. */ function isDeclarationNameOfEnumOrNamespace(node) { - var parseNode = getParseTreeNode(node); + var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 230 /* EnumDeclaration */: - case 231 /* ModuleDeclaration */: + case 231 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -9730,7 +9787,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 /* ClassDeclaration */ && declaration !== node) { + if (declaration.kind === 228 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9796,7 +9853,7 @@ var ts; } ts.isIdentifier = isIdentifier; function isVoidExpression(node) { - return node.kind === 188 /* VoidExpression */; + return node.kind === 189 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { @@ -9811,16 +9868,16 @@ var ts; ts.isModifier = isModifier; // Names function isQualifiedName(node) { - return node.kind === 141 /* QualifiedName */; + return node.kind === 142 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 142 /* ComputedPropertyName */; + return node.kind === 143 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 141 /* QualifiedName */ + return kind === 142 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isEntityName = isEntityName; @@ -9829,7 +9886,7 @@ var ts; return kind === 70 /* Identifier */ || kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 142 /* ComputedPropertyName */; + || kind === 143 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isModuleName(node) { @@ -9841,61 +9898,61 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 70 /* Identifier */ - || kind === 172 /* ObjectBindingPattern */ - || kind === 173 /* ArrayBindingPattern */; + || kind === 173 /* ObjectBindingPattern */ + || kind === 174 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Signature elements function isTypeParameter(node) { - return node.kind === 143 /* TypeParameter */; + return node.kind === 144 /* TypeParameter */; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 144 /* Parameter */; + return node.kind === 145 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 145 /* Decorator */; + return node.kind === 146 /* Decorator */; } ts.isDecorator = isDecorator; // Type members function isMethodDeclaration(node) { - return node.kind === 149 /* MethodDeclaration */; + return node.kind === 150 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 150 /* Constructor */ - || kind === 147 /* PropertyDeclaration */ - || kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */ - || kind === 155 /* IndexSignature */ - || kind === 204 /* SemicolonClassElement */; + return kind === 151 /* Constructor */ + || kind === 148 /* PropertyDeclaration */ + || kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */ + || kind === 156 /* IndexSignature */ + || kind === 205 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 258 /* PropertyAssignment */ - || kind === 259 /* ShorthandPropertyAssignment */ - || kind === 260 /* SpreadAssignment */ - || kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */ - || kind === 245 /* MissingDeclaration */; + return kind === 260 /* PropertyAssignment */ + || kind === 261 /* ShorthandPropertyAssignment */ + || kind === 262 /* SpreadAssignment */ + || kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */ + || kind === 246 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 156 /* FirstTypeNode */ && kind <= 171 /* LastTypeNode */) + return (kind >= 157 /* FirstTypeNode */ && kind <= 172 /* LastTypeNode */) || kind === 118 /* AnyKeyword */ || kind === 132 /* NumberKeyword */ || kind === 121 /* BooleanKeyword */ - || kind === 134 /* StringKeyword */ - || kind === 135 /* SymbolKeyword */ + || kind === 135 /* StringKeyword */ + || kind === 136 /* SymbolKeyword */ || kind === 104 /* VoidKeyword */ || kind === 129 /* NeverKeyword */ - || kind === 199 /* ExpressionWithTypeArguments */; + || kind === 200 /* ExpressionWithTypeArguments */; } /** * Node test that determines whether a node is a valid type node. @@ -9908,36 +9965,36 @@ var ts; ts.isTypeNode = isTypeNode; // Binding patterns function isArrayBindingPattern(node) { - return node.kind === 173 /* ArrayBindingPattern */; + return node.kind === 174 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isObjectBindingPattern(node) { - return node.kind === 172 /* ObjectBindingPattern */; + return node.kind === 173 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 173 /* ArrayBindingPattern */ - || kind === 172 /* ObjectBindingPattern */; + return kind === 174 /* ArrayBindingPattern */ + || kind === 173 /* ObjectBindingPattern */; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 175 /* ArrayLiteralExpression */ - || kind === 176 /* ObjectLiteralExpression */; + return kind === 176 /* ArrayLiteralExpression */ + || kind === 177 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; function isBindingElement(node) { - return node.kind === 174 /* BindingElement */; + return node.kind === 175 /* BindingElement */; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 174 /* BindingElement */ - || kind === 198 /* OmittedExpression */; + return kind === 175 /* BindingElement */ + || kind === 199 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -9945,9 +10002,9 @@ var ts; */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 224 /* VariableDeclaration */: - case 144 /* Parameter */: - case 174 /* BindingElement */: + case 225 /* VariableDeclaration */: + case 145 /* Parameter */: + case 175 /* BindingElement */: return true; } return false; @@ -9966,8 +10023,8 @@ var ts; */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 172 /* ObjectBindingPattern */: - case 176 /* ObjectLiteralExpression */: + case 173 /* ObjectBindingPattern */: + case 177 /* ObjectLiteralExpression */: return true; } return false; @@ -9978,8 +10035,8 @@ var ts; */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 173 /* ArrayBindingPattern */: - case 175 /* ArrayLiteralExpression */: + case 174 /* ArrayBindingPattern */: + case 176 /* ArrayLiteralExpression */: return true; } return false; @@ -9987,86 +10044,86 @@ var ts; ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; // Expression function isArrayLiteralExpression(node) { - return node.kind === 175 /* ArrayLiteralExpression */; + return node.kind === 176 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 176 /* ObjectLiteralExpression */; + return node.kind === 177 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 177 /* PropertyAccessExpression */; + return node.kind === 178 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 178 /* ElementAccessExpression */; + return node.kind === 179 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 192 /* BinaryExpression */; + return node.kind === 193 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 193 /* ConditionalExpression */; + return node.kind === 194 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 179 /* CallExpression */; + return node.kind === 180 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 194 /* TemplateExpression */ + return kind === 195 /* TemplateExpression */ || kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadExpression(node) { - return node.kind === 196 /* SpreadElement */; + return node.kind === 197 /* SpreadElement */; } ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 199 /* ExpressionWithTypeArguments */; + return node.kind === 200 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 177 /* PropertyAccessExpression */ - || kind === 178 /* ElementAccessExpression */ - || kind === 180 /* NewExpression */ - || kind === 179 /* CallExpression */ - || kind === 247 /* JsxElement */ - || kind === 248 /* JsxSelfClosingElement */ - || kind === 181 /* TaggedTemplateExpression */ - || kind === 175 /* ArrayLiteralExpression */ - || kind === 183 /* ParenthesizedExpression */ - || kind === 176 /* ObjectLiteralExpression */ - || kind === 197 /* ClassExpression */ - || kind === 184 /* FunctionExpression */ + return kind === 178 /* PropertyAccessExpression */ + || kind === 179 /* ElementAccessExpression */ + || kind === 181 /* NewExpression */ + || kind === 180 /* CallExpression */ + || kind === 248 /* JsxElement */ + || kind === 249 /* JsxSelfClosingElement */ + || kind === 182 /* TaggedTemplateExpression */ + || kind === 176 /* ArrayLiteralExpression */ + || kind === 184 /* ParenthesizedExpression */ + || kind === 177 /* ObjectLiteralExpression */ + || kind === 198 /* ClassExpression */ + || kind === 185 /* FunctionExpression */ || kind === 70 /* Identifier */ || kind === 11 /* RegularExpressionLiteral */ || kind === 8 /* NumericLiteral */ || kind === 9 /* StringLiteral */ || kind === 12 /* NoSubstitutionTemplateLiteral */ - || kind === 194 /* TemplateExpression */ + || kind === 195 /* TemplateExpression */ || kind === 85 /* FalseKeyword */ || kind === 94 /* NullKeyword */ || kind === 98 /* ThisKeyword */ || kind === 100 /* TrueKeyword */ || kind === 96 /* SuperKeyword */ - || kind === 201 /* NonNullExpression */ - || kind === 202 /* MetaProperty */; + || kind === 202 /* NonNullExpression */ + || kind === 203 /* MetaProperty */; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 190 /* PrefixUnaryExpression */ - || kind === 191 /* PostfixUnaryExpression */ - || kind === 186 /* DeleteExpression */ - || kind === 187 /* TypeOfExpression */ - || kind === 188 /* VoidExpression */ - || kind === 189 /* AwaitExpression */ - || kind === 182 /* TypeAssertionExpression */ + return kind === 191 /* PrefixUnaryExpression */ + || kind === 192 /* PostfixUnaryExpression */ + || kind === 187 /* DeleteExpression */ + || kind === 188 /* TypeOfExpression */ + || kind === 189 /* VoidExpression */ + || kind === 190 /* AwaitExpression */ + || kind === 183 /* TypeAssertionExpression */ || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -10074,13 +10131,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 193 /* ConditionalExpression */ - || kind === 195 /* YieldExpression */ - || kind === 185 /* ArrowFunction */ - || kind === 192 /* BinaryExpression */ - || kind === 196 /* SpreadElement */ - || kind === 200 /* AsExpression */ - || kind === 198 /* OmittedExpression */ + return kind === 194 /* ConditionalExpression */ + || kind === 196 /* YieldExpression */ + || kind === 186 /* ArrowFunction */ + || kind === 193 /* BinaryExpression */ + || kind === 197 /* SpreadElement */ + || kind === 201 /* AsExpression */ + || kind === 199 /* OmittedExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10089,16 +10146,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 182 /* TypeAssertionExpression */ - || kind === 200 /* AsExpression */; + return kind === 183 /* TypeAssertionExpression */ + || kind === 201 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 295 /* PartiallyEmittedExpression */; + return node.kind === 298 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 294 /* NotEmittedStatement */; + return node.kind === 297 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10107,17 +10164,17 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 198 /* OmittedExpression */; + return node.kind === 199 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 203 /* TemplateSpan */; + return node.kind === 204 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 205 /* Block */; + return node.kind === 206 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -10135,121 +10192,135 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 224 /* VariableDeclaration */; + return node.kind === 225 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 225 /* VariableDeclarationList */; + return node.kind === 226 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 233 /* CaseBlock */; + return node.kind === 234 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 232 /* ModuleBlock */ - || kind === 231 /* ModuleDeclaration */; + return kind === 233 /* ModuleBlock */ + || kind === 232 /* ModuleDeclaration */ + || kind === 70 /* Identifier */; } ts.isModuleBody = isModuleBody; + function isNamespaceBody(node) { + var kind = node.kind; + return kind === 233 /* ModuleBlock */ + || kind === 232 /* ModuleDeclaration */; + } + ts.isNamespaceBody = isNamespaceBody; + function isJSDocNamespaceBody(node) { + var kind = node.kind; + return kind === 70 /* Identifier */ + || kind === 232 /* ModuleDeclaration */; + } + ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isImportEqualsDeclaration(node) { - return node.kind === 235 /* ImportEqualsDeclaration */; + return node.kind === 236 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 237 /* ImportClause */; + return node.kind === 238 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 239 /* NamedImports */ - || kind === 238 /* NamespaceImport */; + return kind === 240 /* NamedImports */ + || kind === 239 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 240 /* ImportSpecifier */; + return node.kind === 241 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 243 /* NamedExports */; + return node.kind === 244 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 244 /* ExportSpecifier */; + return node.kind === 245 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 231 /* ModuleDeclaration */ || node.kind === 230 /* EnumDeclaration */; + return node.kind === 232 /* ModuleDeclaration */ || node.kind === 231 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 185 /* ArrowFunction */ - || kind === 174 /* BindingElement */ - || kind === 227 /* ClassDeclaration */ - || kind === 197 /* ClassExpression */ - || kind === 150 /* Constructor */ - || kind === 230 /* EnumDeclaration */ - || kind === 261 /* EnumMember */ - || kind === 244 /* ExportSpecifier */ - || kind === 226 /* FunctionDeclaration */ - || kind === 184 /* FunctionExpression */ - || kind === 151 /* GetAccessor */ - || kind === 237 /* ImportClause */ - || kind === 235 /* ImportEqualsDeclaration */ - || kind === 240 /* ImportSpecifier */ - || kind === 228 /* InterfaceDeclaration */ - || kind === 149 /* MethodDeclaration */ - || kind === 148 /* MethodSignature */ - || kind === 231 /* ModuleDeclaration */ - || kind === 234 /* NamespaceExportDeclaration */ - || kind === 238 /* NamespaceImport */ - || kind === 144 /* Parameter */ - || kind === 258 /* PropertyAssignment */ - || kind === 147 /* PropertyDeclaration */ - || kind === 146 /* PropertySignature */ - || kind === 152 /* SetAccessor */ - || kind === 259 /* ShorthandPropertyAssignment */ - || kind === 229 /* TypeAliasDeclaration */ - || kind === 143 /* TypeParameter */ - || kind === 224 /* VariableDeclaration */ - || kind === 286 /* JSDocTypedefTag */; + return kind === 186 /* ArrowFunction */ + || kind === 175 /* BindingElement */ + || kind === 228 /* ClassDeclaration */ + || kind === 198 /* ClassExpression */ + || kind === 151 /* Constructor */ + || kind === 231 /* EnumDeclaration */ + || kind === 263 /* EnumMember */ + || kind === 245 /* ExportSpecifier */ + || kind === 227 /* FunctionDeclaration */ + || kind === 185 /* FunctionExpression */ + || kind === 152 /* GetAccessor */ + || kind === 238 /* ImportClause */ + || kind === 236 /* ImportEqualsDeclaration */ + || kind === 241 /* ImportSpecifier */ + || kind === 229 /* InterfaceDeclaration */ + || kind === 252 /* JsxAttribute */ + || kind === 150 /* MethodDeclaration */ + || kind === 149 /* MethodSignature */ + || kind === 232 /* ModuleDeclaration */ + || kind === 235 /* NamespaceExportDeclaration */ + || kind === 239 /* NamespaceImport */ + || kind === 145 /* Parameter */ + || kind === 260 /* PropertyAssignment */ + || kind === 148 /* PropertyDeclaration */ + || kind === 147 /* PropertySignature */ + || kind === 153 /* SetAccessor */ + || kind === 261 /* ShorthandPropertyAssignment */ + || kind === 230 /* TypeAliasDeclaration */ + || kind === 144 /* TypeParameter */ + || kind === 225 /* VariableDeclaration */ + || kind === 289 /* JSDocTypedefTag */; } function isDeclarationStatementKind(kind) { - return kind === 226 /* FunctionDeclaration */ - || kind === 245 /* MissingDeclaration */ - || kind === 227 /* ClassDeclaration */ - || kind === 228 /* InterfaceDeclaration */ - || kind === 229 /* TypeAliasDeclaration */ - || kind === 230 /* EnumDeclaration */ - || kind === 231 /* ModuleDeclaration */ - || kind === 236 /* ImportDeclaration */ - || kind === 235 /* ImportEqualsDeclaration */ - || kind === 242 /* ExportDeclaration */ - || kind === 241 /* ExportAssignment */ - || kind === 234 /* NamespaceExportDeclaration */; + return kind === 227 /* FunctionDeclaration */ + || kind === 246 /* MissingDeclaration */ + || kind === 228 /* ClassDeclaration */ + || kind === 229 /* InterfaceDeclaration */ + || kind === 230 /* TypeAliasDeclaration */ + || kind === 231 /* EnumDeclaration */ + || kind === 232 /* ModuleDeclaration */ + || kind === 237 /* ImportDeclaration */ + || kind === 236 /* ImportEqualsDeclaration */ + || kind === 243 /* ExportDeclaration */ + || kind === 242 /* ExportAssignment */ + || kind === 235 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 216 /* BreakStatement */ - || kind === 215 /* ContinueStatement */ - || kind === 223 /* DebuggerStatement */ - || kind === 210 /* DoStatement */ - || kind === 208 /* ExpressionStatement */ - || kind === 207 /* EmptyStatement */ - || kind === 213 /* ForInStatement */ - || kind === 214 /* ForOfStatement */ - || kind === 212 /* ForStatement */ - || kind === 209 /* IfStatement */ - || kind === 220 /* LabeledStatement */ - || kind === 217 /* ReturnStatement */ - || kind === 219 /* SwitchStatement */ - || kind === 221 /* ThrowStatement */ - || kind === 222 /* TryStatement */ - || kind === 206 /* VariableStatement */ - || kind === 211 /* WhileStatement */ - || kind === 218 /* WithStatement */ - || kind === 294 /* NotEmittedStatement */ - || kind === 297 /* EndOfDeclarationMarker */ - || kind === 296 /* MergeDeclarationMarker */; + return kind === 217 /* BreakStatement */ + || kind === 216 /* ContinueStatement */ + || kind === 224 /* DebuggerStatement */ + || kind === 211 /* DoStatement */ + || kind === 209 /* ExpressionStatement */ + || kind === 208 /* EmptyStatement */ + || kind === 214 /* ForInStatement */ + || kind === 215 /* ForOfStatement */ + || kind === 213 /* ForStatement */ + || kind === 210 /* IfStatement */ + || kind === 221 /* LabeledStatement */ + || kind === 218 /* ReturnStatement */ + || kind === 220 /* SwitchStatement */ + || kind === 222 /* ThrowStatement */ + || kind === 223 /* TryStatement */ + || kind === 207 /* VariableStatement */ + || kind === 212 /* WhileStatement */ + || kind === 219 /* WithStatement */ + || kind === 297 /* NotEmittedStatement */ + || kind === 300 /* EndOfDeclarationMarker */ + || kind === 299 /* MergeDeclarationMarker */; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10270,93 +10341,102 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 205 /* Block */; + || kind === 206 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 246 /* ExternalModuleReference */ - || kind === 141 /* QualifiedName */ + return kind === 247 /* ExternalModuleReference */ + || kind === 142 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 249 /* JsxOpeningElement */; + return node.kind === 250 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 250 /* JsxClosingElement */; + return node.kind === 251 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; return kind === 98 /* ThisKeyword */ || kind === 70 /* Identifier */ - || kind === 177 /* PropertyAccessExpression */; + || kind === 178 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 247 /* JsxElement */ - || kind === 253 /* JsxExpression */ - || kind === 248 /* JsxSelfClosingElement */ + return kind === 248 /* JsxElement */ + || kind === 255 /* JsxExpression */ + || kind === 249 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; + function isJsxAttributes(node) { + var kind = node.kind; + return kind === 253 /* JsxAttributes */; + } + ts.isJsxAttributes = isJsxAttributes; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 251 /* JsxAttribute */ - || kind === 252 /* JsxSpreadAttribute */; + return kind === 252 /* JsxAttribute */ + || kind === 254 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 252 /* JsxSpreadAttribute */; + return node.kind === 254 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 251 /* JsxAttribute */; + return node.kind === 252 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; + function isJsxOpeningLikeElement(node) { + return node.kind === 250 /* JsxOpeningElement */ || node.kind === 249 /* JsxSelfClosingElement */; + } + ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 253 /* JsxExpression */; + || kind === 255 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 254 /* CaseClause */ - || kind === 255 /* DefaultClause */; + return kind === 256 /* CaseClause */ + || kind === 257 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 256 /* HeritageClause */; + return node.kind === 258 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 257 /* CatchClause */; + return node.kind === 259 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 258 /* PropertyAssignment */; + return node.kind === 260 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 259 /* ShorthandPropertyAssignment */; + return node.kind === 261 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; // Enum function isEnumMember(node) { - return node.kind === 261 /* EnumMember */; + return node.kind === 263 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 262 /* SourceFile */; + return node.kind === 264 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10586,9 +10666,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 143 /* TypeParameter */) { + if (d && d.kind === 144 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 228 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 229 /* InterfaceDeclaration */) { return current; } } @@ -10596,11 +10676,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 150 /* Constructor */ && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 151 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 174 /* BindingElement */ || ts.isBindingPattern(node))) { + while (node && (node.kind === 175 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10608,14 +10688,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 224 /* VariableDeclaration */) { + if (node.kind === 225 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 225 /* VariableDeclarationList */) { + if (node && node.kind === 226 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 206 /* VariableStatement */) { + if (node && node.kind === 207 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10631,14 +10711,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 224 /* VariableDeclaration */) { + if (node.kind === 225 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 225 /* VariableDeclarationList */) { + if (node && node.kind === 226 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 206 /* VariableStatement */) { + if (node && node.kind === 207 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -10698,27 +10778,60 @@ var ts; } } ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage; + function getOriginalNode(node, nodeTest) { + if (node) { + while (node.original !== undefined) { + node = node.original; + } + } + return !nodeTest || nodeTest(node) ? node : undefined; + } + ts.getOriginalNode = getOriginalNode; + /** + * Gets a value indicating whether a node originated in the parse tree. + * + * @param node The node to test. + */ + function isParseTreeNode(node) { + return (node.flags & 8 /* Synthesized */) === 0; + } + ts.isParseTreeNode = isParseTreeNode; + function getParseTreeNode(node, nodeTest) { + if (isParseTreeNode(node)) { + return node; + } + node = getOriginalNode(node); + if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { + return node; + } + return undefined; + } + ts.getParseTreeNode = getParseTreeNode; + /** + * Remove extra underscore from escaped identifier text content. + * + * @param identifier The escaped identifier text. + * @returns The unescaped identifier text. + */ + function unescapeIdentifier(identifier) { + return identifier.length >= 3 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ && identifier.charCodeAt(2) === 95 /* _ */ ? identifier.substr(1) : identifier; + } + ts.unescapeIdentifier = unescapeIdentifier; })(ts || (ts = {})); /// /// -/* @internal */ var ts; (function (ts) { - var NodeConstructor; - var SourceFileConstructor; - function createNode(kind, location, flags) { - var ConstructorForKind = kind === 262 /* SourceFile */ - ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) - : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); - var node = location - ? new ConstructorForKind(kind, location.pos, location.end) - : new ConstructorForKind(kind, /*pos*/ -1, /*end*/ -1); - node.flags = flags | 8 /* Synthesized */; + function createSynthesizedNode(kind) { + var node = ts.createNode(kind, -1, -1); + node.flags |= 8 /* Synthesized */; return node; } + /* @internal */ function updateNode(updated, original) { if (updated !== original) { setOriginalNode(updated, original); + setTextRange(updated, original); if (original.startsOnNewLine) { updated.startsOnNewLine = true; } @@ -10727,7 +10840,10 @@ var ts; return updated; } ts.updateNode = updateNode; - function createNodeArray(elements, location, hasTrailingComma) { + /** + * Make `elements` into a `NodeArray`. If `elements` is `undefined`, returns an empty `NodeArray`. + */ + function createNodeArray(elements, hasTrailingComma) { if (elements) { if (ts.isNodeArray(elements)) { return elements; @@ -10737,38 +10853,22 @@ var ts; elements = []; } var array = elements; - if (location) { - array.pos = location.pos; - array.end = location.end; - } - else { - array.pos = -1; - array.end = -1; - } - if (hasTrailingComma) { - array.hasTrailingComma = true; - } + array.pos = -1; + array.end = -1; + array.hasTrailingComma = hasTrailingComma; return array; } ts.createNodeArray = createNodeArray; - function createSynthesizedNode(kind, startsOnNewLine) { - var node = createNode(kind, /*location*/ undefined); - node.startsOnNewLine = startsOnNewLine; - return node; - } - ts.createSynthesizedNode = createSynthesizedNode; - function createSynthesizedNodeArray(elements) { - return createNodeArray(elements, /*location*/ undefined); - } - ts.createSynthesizedNodeArray = createSynthesizedNodeArray; /** * Creates a shallow, memberwise clone of a node with no source map location. */ + /* @internal */ function getSynthesizedClone(node) { // We don't use "clone" from core.ts here, as we need to preserve the prototype chain of // the original node. We also need to exclude specific properties and only include own- // properties (to skip members already defined on the shared prototype). - var clone = createNode(node.kind, /*location*/ undefined, node.flags); + var clone = createSynthesizedNode(node.kind); + clone.flags |= node.flags; setOriginalNode(clone, node); for (var key in node) { if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { @@ -10779,54 +10879,49 @@ var ts; return clone; } ts.getSynthesizedClone = getSynthesizedClone; - /** - * Creates a shallow, memberwise clone of a node for mutation. - */ - function getMutableClone(node) { - var clone = getSynthesizedClone(node); - clone.pos = node.pos; - clone.end = node.end; - clone.parent = node.parent; - return clone; - } - ts.getMutableClone = getMutableClone; - function createLiteral(value, location) { + function createLiteral(value) { if (typeof value === "number") { - var node = createNode(8 /* NumericLiteral */, location, /*flags*/ undefined); - node.text = value.toString(); - return node; + return createNumericLiteral(value + ""); } - else if (typeof value === "boolean") { - return createNode(value ? 100 /* TrueKeyword */ : 85 /* FalseKeyword */, location, /*flags*/ undefined); + if (typeof value === "boolean") { + return value ? createTrue() : createFalse(); } - else if (typeof value === "string") { - var node = createNode(9 /* StringLiteral */, location, /*flags*/ undefined); - node.text = value; - return node; - } - else if (value) { - var node = createNode(9 /* StringLiteral */, location, /*flags*/ undefined); - node.textSourceNode = value; - node.text = value.text; - return node; + if (typeof value === "string") { + return createStringLiteral(value); } + return createLiteralFromNode(value); } ts.createLiteral = createLiteral; + function createNumericLiteral(value) { + var node = createSynthesizedNode(8 /* NumericLiteral */); + node.text = value; + return node; + } + ts.createNumericLiteral = createNumericLiteral; + function createStringLiteral(text) { + var node = createSynthesizedNode(9 /* StringLiteral */); + node.text = text; + return node; + } + function createLiteralFromNode(sourceNode) { + var node = createStringLiteral(sourceNode.text); + node.textSourceNode = sourceNode; + return node; + } // Identifiers - var nextAutoGenerateId = 0; - function createIdentifier(text, location) { - var node = createNode(70 /* Identifier */, location); + function createIdentifier(text) { + var node = createSynthesizedNode(70 /* Identifier */); node.text = ts.escapeIdentifier(text); - node.originalKeywordKind = ts.stringToToken(text); + node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateKind = 0 /* None */; node.autoGenerateId = 0; return node; } ts.createIdentifier = createIdentifier; - function createTempVariable(recordTempVariable, location) { - var name = createNode(70 /* Identifier */, location); - name.text = ""; - name.originalKeywordKind = 0 /* Unknown */; + var nextAutoGenerateId = 0; + /** Create a unique temporary variable. */ + function createTempVariable(recordTempVariable) { + var name = createIdentifier(""); name.autoGenerateKind = 1 /* Auto */; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; @@ -10836,98 +10931,129 @@ var ts; return name; } ts.createTempVariable = createTempVariable; - function createLoopVariable(location) { - var name = createNode(70 /* Identifier */, location); - name.text = ""; - name.originalKeywordKind = 0 /* Unknown */; + /** Create a unique temporary variable for use in a loop. */ + function createLoopVariable() { + var name = createIdentifier(""); name.autoGenerateKind = 2 /* Loop */; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createLoopVariable = createLoopVariable; - function createUniqueName(text, location) { - var name = createNode(70 /* Identifier */, location); - name.text = text; - name.originalKeywordKind = 0 /* Unknown */; + /** Create a unique name based on the supplied text. */ + function createUniqueName(text) { + var name = createIdentifier(text); name.autoGenerateKind = 3 /* Unique */; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createUniqueName = createUniqueName; - function getGeneratedNameForNode(node, location) { - var name = createNode(70 /* Identifier */, location); - name.original = node; - name.text = ""; - name.originalKeywordKind = 0 /* Unknown */; + /** Create a unique name generated for a node. */ + function getGeneratedNameForNode(node) { + var name = createIdentifier(""); name.autoGenerateKind = 4 /* Node */; name.autoGenerateId = nextAutoGenerateId; + name.original = node; nextAutoGenerateId++; return name; } ts.getGeneratedNameForNode = getGeneratedNameForNode; // Punctuation function createToken(token) { - return createNode(token); + return createSynthesizedNode(token); } ts.createToken = createToken; // Reserved words function createSuper() { - var node = createNode(96 /* SuperKeyword */); - return node; + return createSynthesizedNode(96 /* SuperKeyword */); } ts.createSuper = createSuper; - function createThis(location) { - var node = createNode(98 /* ThisKeyword */, location); - return node; + function createThis() { + return createSynthesizedNode(98 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - var node = createNode(94 /* NullKeyword */); - return node; + return createSynthesizedNode(94 /* NullKeyword */); } ts.createNull = createNull; + function createTrue() { + return createSynthesizedNode(100 /* TrueKeyword */); + } + ts.createTrue = createTrue; + function createFalse() { + return createSynthesizedNode(85 /* FalseKeyword */); + } + ts.createFalse = createFalse; // Names - function createComputedPropertyName(expression, location) { - var node = createNode(142 /* ComputedPropertyName */, location); + function createQualifiedName(left, right) { + var node = createSynthesizedNode(142 /* QualifiedName */); + node.left = left; + node.right = asName(right); + return node; + } + ts.createQualifiedName = createQualifiedName; + function updateQualifiedName(node, left, right) { + return node.left !== left + || node.right !== right + ? updateNode(createQualifiedName(left, right), node) + : node; + } + ts.updateQualifiedName = updateQualifiedName; + function createComputedPropertyName(expression) { + var node = createSynthesizedNode(143 /* ComputedPropertyName */); node.expression = expression; return node; } ts.createComputedPropertyName = createComputedPropertyName; function updateComputedPropertyName(node, expression) { - if (node.expression !== expression) { - return updateNode(createComputedPropertyName(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createComputedPropertyName(expression), node) + : node; } ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements - function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(144 /* Parameter */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { + var node = createSynthesizedNode(145 /* Parameter */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.questionToken = questionToken; node.type = type; - node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createParameter = createParameter; function updateParameter(node, decorators, modifiers, dotDotDotToken, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer, /*location*/ node, /*flags*/ node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + : node; } ts.updateParameter = updateParameter; + function createDecorator(expression) { + var node = createSynthesizedNode(146 /* Decorator */); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createDecorator = createDecorator; + function updateDecorator(node, expression) { + return node.expression !== expression + ? updateNode(createDecorator(expression), node) + : node; + } + ts.updateDecorator = updateDecorator; // Type members - function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(147 /* PropertyDeclaration */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createProperty(decorators, modifiers, name, questionToken, type, initializer) { + var node = createSynthesizedNode(148 /* PropertyDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.questionToken = questionToken; node.type = type; node.initializer = initializer; @@ -10935,19 +11061,22 @@ var ts; } ts.createProperty = createProperty; function updateProperty(node, decorators, modifiers, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer), node) + : node; } ts.updateProperty = updateProperty; - function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(149 /* MethodDeclaration */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(150 /* MethodDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -10955,16 +11084,21 @@ var ts; } ts.createMethod = createMethod; function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateMethod = updateMethod; - function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(150 /* Constructor */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createConstructor(decorators, modifiers, parameters, body) { + var node = createSynthesizedNode(151 /* Constructor */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = undefined; @@ -10973,17 +11107,19 @@ var ts; } ts.createConstructor = createConstructor; function updateConstructor(node, decorators, modifiers, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.parameters !== parameters || node.body !== body) { - return updateNode(createConstructor(decorators, modifiers, parameters, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.parameters !== parameters + || node.body !== body + ? updateNode(createConstructor(decorators, modifiers, parameters, body), node) + : node; } ts.updateConstructor = updateConstructor; - function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(151 /* GetAccessor */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createGetAccessor(decorators, modifiers, name, parameters, type, body) { + var node = createSynthesizedNode(152 /* GetAccessor */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = type; @@ -10992,17 +11128,21 @@ var ts; } ts.createGetAccessor = createGetAccessor; function updateGetAccessor(node, decorators, modifiers, name, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body), node) + : node; } ts.updateGetAccessor = updateGetAccessor; - function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(152 /* SetAccessor */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createSetAccessor(decorators, modifiers, name, parameters, body) { + var node = createSynthesizedNode(153 /* SetAccessor */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.body = body; @@ -11010,59 +11150,62 @@ var ts; } ts.createSetAccessor = createSetAccessor; function updateSetAccessor(node, decorators, modifiers, name, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.body !== body) { - return updateNode(createSetAccessor(decorators, modifiers, name, parameters, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.body !== body + ? updateNode(createSetAccessor(decorators, modifiers, name, parameters, body), node) + : node; } ts.updateSetAccessor = updateSetAccessor; // Binding Patterns - function createObjectBindingPattern(elements, location) { - var node = createNode(172 /* ObjectBindingPattern */, location); + function createObjectBindingPattern(elements) { + var node = createSynthesizedNode(173 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } ts.createObjectBindingPattern = createObjectBindingPattern; function updateObjectBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createObjectBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createObjectBindingPattern(elements), node) + : node; } ts.updateObjectBindingPattern = updateObjectBindingPattern; - function createArrayBindingPattern(elements, location) { - var node = createNode(173 /* ArrayBindingPattern */, location); + function createArrayBindingPattern(elements) { + var node = createSynthesizedNode(174 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } ts.createArrayBindingPattern = createArrayBindingPattern; function updateArrayBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayBindingPattern(elements), node) + : node; } ts.updateArrayBindingPattern = updateArrayBindingPattern; - function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(174 /* BindingElement */, location); - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createBindingElement(propertyName, dotDotDotToken, name, initializer) { + var node = createSynthesizedNode(175 /* BindingElement */); + node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.initializer = initializer; return node; } ts.createBindingElement = createBindingElement; function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) { - if (node.propertyName !== propertyName || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer) { - return updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer, node), node); - } - return node; + return node.propertyName !== propertyName + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.initializer !== initializer + ? updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer), node) + : node; } ts.updateBindingElement = updateBindingElement; // Expression - function createArrayLiteral(elements, location, multiLine) { - var node = createNode(175 /* ArrayLiteralExpression */, location); - node.elements = parenthesizeListElements(createNodeArray(elements)); + function createArrayLiteral(elements, multiLine) { + var node = createSynthesizedNode(176 /* ArrayLiteralExpression */); + node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; } @@ -11070,14 +11213,13 @@ var ts; } ts.createArrayLiteral = createArrayLiteral; function updateArrayLiteral(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayLiteral(elements, node, node.multiLine), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayLiteral(elements, node.multiLine), node) + : node; } ts.updateArrayLiteral = updateArrayLiteral; - function createObjectLiteral(properties, location, multiLine) { - var node = createNode(176 /* ObjectLiteralExpression */, location); + function createObjectLiteral(properties, multiLine) { + var node = createSynthesizedNode(177 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -11086,109 +11228,120 @@ var ts; } ts.createObjectLiteral = createObjectLiteral; function updateObjectLiteral(node, properties) { - if (node.properties !== properties) { - return updateNode(createObjectLiteral(properties, node, node.multiLine), node); - } - return node; + return node.properties !== properties + ? updateNode(createObjectLiteral(properties, node.multiLine), node) + : node; } ts.updateObjectLiteral = updateObjectLiteral; - function createPropertyAccess(expression, name, location, flags) { - var node = createNode(177 /* PropertyAccessExpression */, location, flags); - node.expression = parenthesizeForAccess(expression); - (node.emitNode || (node.emitNode = {})).flags |= 65536 /* NoIndentation */; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAccess(expression, name) { + var node = createSynthesizedNode(178 /* PropertyAccessExpression */); + node.expression = ts.parenthesizeForAccess(expression); + node.name = asName(name); + setEmitFlags(node, 65536 /* NoIndentation */); return node; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { - if (node.expression !== expression || node.name !== name) { - var propertyAccess = createPropertyAccess(expression, name, /*location*/ node, node.flags); - // Because we are updating existed propertyAccess we want to inherit its emitFlags instead of using default from createPropertyAccess - (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); - return updateNode(propertyAccess, node); - } - return node; + // Because we are updating existed propertyAccess we want to inherit its emitFlags + // instead of using the default from createPropertyAccess + return node.expression !== expression + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccess(expression, name), getEmitFlags(node)), node) + : node; } ts.updatePropertyAccess = updatePropertyAccess; - function createElementAccess(expression, index, location) { - var node = createNode(178 /* ElementAccessExpression */, location); - node.expression = parenthesizeForAccess(expression); - node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; + function createElementAccess(expression, index) { + var node = createSynthesizedNode(179 /* ElementAccessExpression */); + node.expression = ts.parenthesizeForAccess(expression); + node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { - if (node.expression !== expression || node.argumentExpression !== argumentExpression) { - return updateNode(createElementAccess(expression, argumentExpression, node), node); - } - return node; + return node.expression !== expression + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccess(expression, argumentExpression), node) + : node; } ts.updateElementAccess = updateElementAccess; - function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(179 /* CallExpression */, location, flags); - node.expression = parenthesizeForAccess(expression); - if (typeArguments) { - node.typeArguments = createNodeArray(typeArguments); - } - node.arguments = parenthesizeListElements(createNodeArray(argumentsArray)); + function createCall(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(180 /* CallExpression */); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); return node; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { - if (expression !== node.expression || typeArguments !== node.typeArguments || argumentsArray !== node.arguments) { - return updateNode(createCall(expression, typeArguments, argumentsArray, /*location*/ node, node.flags), node); - } - return node; + return expression !== node.expression + || typeArguments !== node.typeArguments + || argumentsArray !== node.arguments + ? updateNode(createCall(expression, typeArguments, argumentsArray), node) + : node; } ts.updateCall = updateCall; - function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(180 /* NewExpression */, location, flags); - node.expression = parenthesizeForNew(expression); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; + function createNew(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(181 /* NewExpression */); + node.expression = ts.parenthesizeForNew(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; return node; } ts.createNew = createNew; function updateNew(node, expression, typeArguments, argumentsArray) { - if (node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray) { - return updateNode(createNew(expression, typeArguments, argumentsArray, /*location*/ node, node.flags), node); - } - return node; + return node.expression !== expression + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createNew(expression, typeArguments, argumentsArray), node) + : node; } ts.updateNew = updateNew; - function createTaggedTemplate(tag, template, location) { - var node = createNode(181 /* TaggedTemplateExpression */, location); - node.tag = parenthesizeForAccess(tag); + function createTaggedTemplate(tag, template) { + var node = createSynthesizedNode(182 /* TaggedTemplateExpression */); + node.tag = ts.parenthesizeForAccess(tag); node.template = template; return node; } ts.createTaggedTemplate = createTaggedTemplate; function updateTaggedTemplate(node, tag, template) { - if (node.tag !== tag || node.template !== template) { - return updateNode(createTaggedTemplate(tag, template, node), node); - } - return node; + return node.tag !== tag + || node.template !== template + ? updateNode(createTaggedTemplate(tag, template), node) + : node; } ts.updateTaggedTemplate = updateTaggedTemplate; - function createParen(expression, location) { - var node = createNode(183 /* ParenthesizedExpression */, location); + function createTypeAssertion(type, expression) { + var node = createSynthesizedNode(183 /* TypeAssertionExpression */); + node.type = type; + node.expression = ts.parenthesizePrefixOperand(expression); + return node; + } + ts.createTypeAssertion = createTypeAssertion; + function updateTypeAssertion(node, type, expression) { + return node.type !== type + || node.expression !== expression + ? updateNode(createTypeAssertion(type, expression), node) + : node; + } + ts.updateTypeAssertion = updateTypeAssertion; + function createParen(expression) { + var node = createSynthesizedNode(184 /* ParenthesizedExpression */); node.expression = expression; return node; } ts.createParen = createParen; function updateParen(node, expression) { - if (node.expression !== expression) { - return updateNode(createParen(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createParen(expression), node) + : node; } ts.updateParen = updateParen; - function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(184 /* FunctionExpression */, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(185 /* FunctionExpression */); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -11196,326 +11349,342 @@ var ts; } ts.createFunctionExpression = createFunctionExpression; function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + return node.name !== name + || node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionExpression = updateFunctionExpression; - function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(185 /* ArrowFunction */, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { + var node = createSynthesizedNode(186 /* ArrowFunction */); + node.modifiers = asNodeArray(modifiers); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35 /* EqualsGreaterThanToken */); - node.body = parenthesizeConciseBody(body); + node.body = ts.parenthesizeConciseBody(body); return node; } ts.createArrowFunction = createArrowFunction; function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { - if (node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body, /*location*/ node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + : node; } ts.updateArrowFunction = updateArrowFunction; - function createDelete(expression, location) { - var node = createNode(186 /* DeleteExpression */, location); - node.expression = parenthesizePrefixOperand(expression); + function createDelete(expression) { + var node = createSynthesizedNode(187 /* DeleteExpression */); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createDelete = createDelete; function updateDelete(node, expression) { - if (node.expression !== expression) { - return updateNode(createDelete(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createDelete(expression), node) + : node; } ts.updateDelete = updateDelete; - function createTypeOf(expression, location) { - var node = createNode(187 /* TypeOfExpression */, location); - node.expression = parenthesizePrefixOperand(expression); + function createTypeOf(expression) { + var node = createSynthesizedNode(188 /* TypeOfExpression */); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createTypeOf = createTypeOf; function updateTypeOf(node, expression) { - if (node.expression !== expression) { - return updateNode(createTypeOf(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createTypeOf(expression), node) + : node; } ts.updateTypeOf = updateTypeOf; - function createVoid(expression, location) { - var node = createNode(188 /* VoidExpression */, location); - node.expression = parenthesizePrefixOperand(expression); + function createVoid(expression) { + var node = createSynthesizedNode(189 /* VoidExpression */); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createVoid = createVoid; function updateVoid(node, expression) { - if (node.expression !== expression) { - return updateNode(createVoid(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createVoid(expression), node) + : node; } ts.updateVoid = updateVoid; - function createAwait(expression, location) { - var node = createNode(189 /* AwaitExpression */, location); - node.expression = parenthesizePrefixOperand(expression); + function createAwait(expression) { + var node = createSynthesizedNode(190 /* AwaitExpression */); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createAwait = createAwait; function updateAwait(node, expression) { - if (node.expression !== expression) { - return updateNode(createAwait(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createAwait(expression), node) + : node; } ts.updateAwait = updateAwait; - function createPrefix(operator, operand, location) { - var node = createNode(190 /* PrefixUnaryExpression */, location); + function createPrefix(operator, operand) { + var node = createSynthesizedNode(191 /* PrefixUnaryExpression */); node.operator = operator; - node.operand = parenthesizePrefixOperand(operand); + node.operand = ts.parenthesizePrefixOperand(operand); return node; } ts.createPrefix = createPrefix; function updatePrefix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPrefix(node.operator, operand, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPrefix(node.operator, operand), node) + : node; } ts.updatePrefix = updatePrefix; - function createPostfix(operand, operator, location) { - var node = createNode(191 /* PostfixUnaryExpression */, location); - node.operand = parenthesizePostfixOperand(operand); + function createPostfix(operand, operator) { + var node = createSynthesizedNode(192 /* PostfixUnaryExpression */); + node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; } ts.createPostfix = createPostfix; function updatePostfix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPostfix(operand, node.operator, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPostfix(operand, node.operator), node) + : node; } ts.updatePostfix = updatePostfix; - function createBinary(left, operator, right, location) { - var operatorToken = typeof operator === "number" ? createToken(operator) : operator; + function createBinary(left, operator, right) { + var node = createSynthesizedNode(193 /* BinaryExpression */); + var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; - var node = createNode(192 /* BinaryExpression */, location); - node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); + node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); node.operatorToken = operatorToken; - node.right = parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); + node.right = ts.parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); return node; } ts.createBinary = createBinary; function updateBinary(node, left, right) { - if (node.left !== left || node.right !== right) { - return updateNode(createBinary(left, node.operatorToken, right, /*location*/ node), node); - } - return node; + return node.left !== left + || node.right !== right + ? updateNode(createBinary(left, node.operatorToken, right), node) + : node; } ts.updateBinary = updateBinary; - function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonTokenOrLocation, whenFalse, location) { - var node = createNode(193 /* ConditionalExpression */, whenFalse ? location : colonTokenOrLocation); - node.condition = parenthesizeForConditionalHead(condition); - if (whenFalse) { - // second overload - node.questionToken = questionTokenOrWhenTrue; - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - node.colonToken = colonTokenOrLocation; - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenFalse); - } - else { - // first overload - node.questionToken = createToken(54 /* QuestionToken */); - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(questionTokenOrWhenTrue); - node.colonToken = createToken(55 /* ColonToken */); - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - } + function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { + var node = createSynthesizedNode(194 /* ConditionalExpression */); + node.condition = ts.parenthesizeForConditionalHead(condition); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(54 /* QuestionToken */); + node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); + node.colonToken = whenFalse ? colonToken : createToken(55 /* ColonToken */); + node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } ts.createConditional = createConditional; function updateConditional(node, condition, whenTrue, whenFalse) { - if (node.condition !== condition || node.whenTrue !== whenTrue || node.whenFalse !== whenFalse) { - return updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse, node), node); - } - return node; + return node.condition !== condition + || node.whenTrue !== whenTrue + || node.whenFalse !== whenFalse + ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + : node; } ts.updateConditional = updateConditional; - function createTemplateExpression(head, templateSpans, location) { - var node = createNode(194 /* TemplateExpression */, location); + function createTemplateExpression(head, templateSpans) { + var node = createSynthesizedNode(195 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; } ts.createTemplateExpression = createTemplateExpression; function updateTemplateExpression(node, head, templateSpans) { - if (node.head !== head || node.templateSpans !== templateSpans) { - return updateNode(createTemplateExpression(head, templateSpans, node), node); - } - return node; + return node.head !== head + || node.templateSpans !== templateSpans + ? updateNode(createTemplateExpression(head, templateSpans), node) + : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createYield(asteriskToken, expression, location) { - var node = createNode(195 /* YieldExpression */, location); - node.asteriskToken = asteriskToken; - node.expression = expression; + function createYield(asteriskTokenOrExpression, expression) { + var node = createSynthesizedNode(196 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 38 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 38 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; function updateYield(node, expression) { - if (node.expression !== expression) { - return updateNode(createYield(node.asteriskToken, expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createYield(node.asteriskToken, expression), node) + : node; } ts.updateYield = updateYield; - function createSpread(expression, location) { - var node = createNode(196 /* SpreadElement */, location); - node.expression = parenthesizeExpressionForList(expression); + function createSpread(expression) { + var node = createSynthesizedNode(197 /* SpreadElement */); + node.expression = ts.parenthesizeExpressionForList(expression); return node; } ts.createSpread = createSpread; function updateSpread(node, expression) { - if (node.expression !== expression) { - return updateNode(createSpread(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createSpread(expression), node) + : node; } ts.updateSpread = updateSpread; - function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(197 /* ClassExpression */, location); + function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(198 /* ClassExpression */); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassExpression = createClassExpression; function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) { - if (node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassExpression = updateClassExpression; - function createOmittedExpression(location) { - var node = createNode(198 /* OmittedExpression */, location); - return node; + function createOmittedExpression() { + return createSynthesizedNode(199 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; - function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(199 /* ExpressionWithTypeArguments */, location); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.expression = parenthesizeForAccess(expression); + function createExpressionWithTypeArguments(typeArguments, expression) { + var node = createSynthesizedNode(200 /* ExpressionWithTypeArguments */); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); return node; } ts.createExpressionWithTypeArguments = createExpressionWithTypeArguments; function updateExpressionWithTypeArguments(node, typeArguments, expression) { - if (node.typeArguments !== typeArguments || node.expression !== expression) { - return updateNode(createExpressionWithTypeArguments(typeArguments, expression, node), node); - } - return node; + return node.typeArguments !== typeArguments + || node.expression !== expression + ? updateNode(createExpressionWithTypeArguments(typeArguments, expression), node) + : node; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; + function createAsExpression(expression, type) { + var node = createSynthesizedNode(201 /* AsExpression */); + node.expression = expression; + node.type = type; + return node; + } + ts.createAsExpression = createAsExpression; + function updateAsExpression(node, expression, type) { + return node.expression !== expression + || node.type !== type + ? updateNode(createAsExpression(expression, type), node) + : node; + } + ts.updateAsExpression = updateAsExpression; + function createNonNullExpression(expression) { + var node = createSynthesizedNode(202 /* NonNullExpression */); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createNonNullExpression = createNonNullExpression; + function updateNonNullExpression(node, expression) { + return node.expression !== expression + ? updateNode(createNonNullExpression(expression), node) + : node; + } + ts.updateNonNullExpression = updateNonNullExpression; // Misc - function createTemplateSpan(expression, literal, location) { - var node = createNode(203 /* TemplateSpan */, location); + function createTemplateSpan(expression, literal) { + var node = createSynthesizedNode(204 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; } ts.createTemplateSpan = createTemplateSpan; function updateTemplateSpan(node, expression, literal) { - if (node.expression !== expression || node.literal !== literal) { - return updateNode(createTemplateSpan(expression, literal, node), node); - } - return node; + return node.expression !== expression + || node.literal !== literal + ? updateNode(createTemplateSpan(expression, literal), node) + : node; } ts.updateTemplateSpan = updateTemplateSpan; // Element - function createBlock(statements, location, multiLine, flags) { - var block = createNode(205 /* Block */, location, flags); + function createBlock(statements, multiLine) { + var block = createSynthesizedNode(206 /* Block */); block.statements = createNodeArray(statements); - if (multiLine) { - block.multiLine = true; - } + if (multiLine) + block.multiLine = multiLine; return block; } ts.createBlock = createBlock; function updateBlock(node, statements) { - if (statements !== node.statements) { - return updateNode(createBlock(statements, /*location*/ node, node.multiLine, node.flags), node); - } - return node; + return statements !== node.statements + ? updateNode(createBlock(statements, node.multiLine), node) + : node; } ts.updateBlock = updateBlock; - function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(206 /* VariableStatement */, location, flags); + function createVariableStatement(modifiers, declarationList) { + var node = createSynthesizedNode(207 /* VariableStatement */); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; return node; } ts.createVariableStatement = createVariableStatement; function updateVariableStatement(node, modifiers, declarationList) { - if (node.modifiers !== modifiers || node.declarationList !== declarationList) { - return updateNode(createVariableStatement(modifiers, declarationList, /*location*/ node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.declarationList !== declarationList + ? updateNode(createVariableStatement(modifiers, declarationList), node) + : node; } ts.updateVariableStatement = updateVariableStatement; - function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(225 /* VariableDeclarationList */, location, flags); + function createVariableDeclarationList(declarations, flags) { + var node = createSynthesizedNode(226 /* VariableDeclarationList */); + node.flags |= flags; node.declarations = createNodeArray(declarations); return node; } ts.createVariableDeclarationList = createVariableDeclarationList; function updateVariableDeclarationList(node, declarations) { - if (node.declarations !== declarations) { - return updateNode(createVariableDeclarationList(declarations, /*location*/ node, node.flags), node); - } - return node; + return node.declarations !== declarations + ? updateNode(createVariableDeclarationList(declarations, node.flags), node) + : node; } ts.updateVariableDeclarationList = updateVariableDeclarationList; - function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(224 /* VariableDeclaration */, location, flags); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createVariableDeclaration(name, type, initializer) { + var node = createSynthesizedNode(225 /* VariableDeclaration */); + node.name = asName(name); node.type = type; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createVariableDeclaration = createVariableDeclaration; function updateVariableDeclaration(node, name, type, initializer) { - if (node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createVariableDeclaration(name, type, initializer, /*location*/ node, node.flags), node); - } - return node; + return node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createVariableDeclaration(name, type, initializer), node) + : node; } ts.updateVariableDeclaration = updateVariableDeclaration; - function createEmptyStatement(location) { - return createNode(207 /* EmptyStatement */, location); + function createEmptyStatement() { + return createSynthesizedNode(208 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression, location, flags) { - var node = createNode(208 /* ExpressionStatement */, location, flags); - node.expression = parenthesizeExpressionForExpressionStatement(expression); + function createStatement(expression) { + var node = createSynthesizedNode(209 /* ExpressionStatement */); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } ts.createStatement = createStatement; function updateStatement(node, expression) { - if (node.expression !== expression) { - return updateNode(createStatement(expression, /*location*/ node, node.flags), node); - } - return node; + return node.expression !== expression + ? updateNode(createStatement(expression), node) + : node; } ts.updateStatement = updateStatement; - function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(209 /* IfStatement */, location); + function createIf(expression, thenStatement, elseStatement) { + var node = createSynthesizedNode(210 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11523,42 +11692,43 @@ var ts; } ts.createIf = createIf; function updateIf(node, expression, thenStatement, elseStatement) { - if (node.expression !== expression || node.thenStatement !== thenStatement || node.elseStatement !== elseStatement) { - return updateNode(createIf(expression, thenStatement, elseStatement, /*location*/ node), node); - } - return node; + return node.expression !== expression + || node.thenStatement !== thenStatement + || node.elseStatement !== elseStatement + ? updateNode(createIf(expression, thenStatement, elseStatement), node) + : node; } ts.updateIf = updateIf; - function createDo(statement, expression, location) { - var node = createNode(210 /* DoStatement */, location); + function createDo(statement, expression) { + var node = createSynthesizedNode(211 /* DoStatement */); node.statement = statement; node.expression = expression; return node; } ts.createDo = createDo; function updateDo(node, statement, expression) { - if (node.statement !== statement || node.expression !== expression) { - return updateNode(createDo(statement, expression, node), node); - } - return node; + return node.statement !== statement + || node.expression !== expression + ? updateNode(createDo(statement, expression), node) + : node; } ts.updateDo = updateDo; - function createWhile(expression, statement, location) { - var node = createNode(211 /* WhileStatement */, location); + function createWhile(expression, statement) { + var node = createSynthesizedNode(212 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; } ts.createWhile = createWhile; function updateWhile(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWhile(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWhile(expression, statement), node) + : node; } ts.updateWhile = updateWhile; - function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(212 /* ForStatement */, location, /*flags*/ undefined); + function createFor(initializer, condition, incrementor, statement) { + var node = createSynthesizedNode(213 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11567,14 +11737,16 @@ var ts; } ts.createFor = createFor; function updateFor(node, initializer, condition, incrementor, statement) { - if (node.initializer !== initializer || node.condition !== condition || node.incrementor !== incrementor || node.statement !== statement) { - return updateNode(createFor(initializer, condition, incrementor, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.condition !== condition + || node.incrementor !== incrementor + || node.statement !== statement + ? updateNode(createFor(initializer, condition, incrementor, statement), node) + : node; } ts.updateFor = updateFor; - function createForIn(initializer, expression, statement, location) { - var node = createNode(213 /* ForInStatement */, location); + function createForIn(initializer, expression, statement) { + var node = createSynthesizedNode(214 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11582,14 +11754,15 @@ var ts; } ts.createForIn = createForIn; function updateForIn(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForIn(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForIn(initializer, expression, statement), node) + : node; } ts.updateForIn = updateForIn; - function createForOf(initializer, expression, statement, location) { - var node = createNode(214 /* ForOfStatement */, location); + function createForOf(initializer, expression, statement) { + var node = createSynthesizedNode(215 /* ForOfStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11597,112 +11770,105 @@ var ts; } ts.createForOf = createForOf; function updateForOf(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForOf(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForOf(initializer, expression, statement), node) + : node; } ts.updateForOf = updateForOf; - function createContinue(label, location) { - var node = createNode(215 /* ContinueStatement */, location); - if (label) { - node.label = label; - } + function createContinue(label) { + var node = createSynthesizedNode(216 /* ContinueStatement */); + node.label = asName(label); return node; } ts.createContinue = createContinue; function updateContinue(node, label) { - if (node.label !== label) { - return updateNode(createContinue(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createContinue(label), node) + : node; } ts.updateContinue = updateContinue; - function createBreak(label, location) { - var node = createNode(216 /* BreakStatement */, location); - if (label) { - node.label = label; - } + function createBreak(label) { + var node = createSynthesizedNode(217 /* BreakStatement */); + node.label = asName(label); return node; } ts.createBreak = createBreak; function updateBreak(node, label) { - if (node.label !== label) { - return updateNode(createBreak(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createBreak(label), node) + : node; } ts.updateBreak = updateBreak; - function createReturn(expression, location) { - var node = createNode(217 /* ReturnStatement */, location); + function createReturn(expression) { + var node = createSynthesizedNode(218 /* ReturnStatement */); node.expression = expression; return node; } ts.createReturn = createReturn; function updateReturn(node, expression) { - if (node.expression !== expression) { - return updateNode(createReturn(expression, /*location*/ node), node); - } - return node; + return node.expression !== expression + ? updateNode(createReturn(expression), node) + : node; } ts.updateReturn = updateReturn; - function createWith(expression, statement, location) { - var node = createNode(218 /* WithStatement */, location); + function createWith(expression, statement) { + var node = createSynthesizedNode(219 /* WithStatement */); node.expression = expression; node.statement = statement; return node; } ts.createWith = createWith; function updateWith(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWith(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWith(expression, statement), node) + : node; } ts.updateWith = updateWith; - function createSwitch(expression, caseBlock, location) { - var node = createNode(219 /* SwitchStatement */, location); - node.expression = parenthesizeExpressionForList(expression); + function createSwitch(expression, caseBlock) { + var node = createSynthesizedNode(220 /* SwitchStatement */); + node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; } ts.createSwitch = createSwitch; function updateSwitch(node, expression, caseBlock) { - if (node.expression !== expression || node.caseBlock !== caseBlock) { - return updateNode(createSwitch(expression, caseBlock, node), node); - } - return node; + return node.expression !== expression + || node.caseBlock !== caseBlock + ? updateNode(createSwitch(expression, caseBlock), node) + : node; } ts.updateSwitch = updateSwitch; - function createLabel(label, statement, location) { - var node = createNode(220 /* LabeledStatement */, location); - node.label = typeof label === "string" ? createIdentifier(label) : label; + function createLabel(label, statement) { + var node = createSynthesizedNode(221 /* LabeledStatement */); + node.label = asName(label); node.statement = statement; return node; } ts.createLabel = createLabel; function updateLabel(node, label, statement) { - if (node.label !== label || node.statement !== statement) { - return updateNode(createLabel(label, statement, node), node); - } - return node; + return node.label !== label + || node.statement !== statement + ? updateNode(createLabel(label, statement), node) + : node; } ts.updateLabel = updateLabel; - function createThrow(expression, location) { - var node = createNode(221 /* ThrowStatement */, location); + function createThrow(expression) { + var node = createSynthesizedNode(222 /* ThrowStatement */); node.expression = expression; return node; } ts.createThrow = createThrow; function updateThrow(node, expression) { - if (node.expression !== expression) { - return updateNode(createThrow(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createThrow(expression), node) + : node; } ts.updateThrow = updateThrow; - function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(222 /* TryStatement */, location); + function createTry(tryBlock, catchClause, finallyBlock) { + var node = createSynthesizedNode(223 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11710,32 +11876,20 @@ var ts; } ts.createTry = createTry; function updateTry(node, tryBlock, catchClause, finallyBlock) { - if (node.tryBlock !== tryBlock || node.catchClause !== catchClause || node.finallyBlock !== finallyBlock) { - return updateNode(createTry(tryBlock, catchClause, finallyBlock, node), node); - } - return node; + return node.tryBlock !== tryBlock + || node.catchClause !== catchClause + || node.finallyBlock !== finallyBlock + ? updateNode(createTry(tryBlock, catchClause, finallyBlock), node) + : node; } ts.updateTry = updateTry; - function createCaseBlock(clauses, location) { - var node = createNode(233 /* CaseBlock */, location); - node.clauses = createNodeArray(clauses); - return node; - } - ts.createCaseBlock = createCaseBlock; - function updateCaseBlock(node, clauses) { - if (node.clauses !== clauses) { - return updateNode(createCaseBlock(clauses, node), node); - } - return node; - } - ts.updateCaseBlock = updateCaseBlock; - function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(226 /* FunctionDeclaration */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(227 /* FunctionDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -11743,162 +11897,263 @@ var ts; } ts.createFunctionDeclaration = createFunctionDeclaration; function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionDeclaration = updateFunctionDeclaration; - function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(227 /* ClassDeclaration */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(228 /* ClassDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassDeclaration = createClassDeclaration; function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassDeclaration = updateClassDeclaration; - function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(236 /* ImportDeclaration */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createEnumDeclaration(decorators, modifiers, name, members) { + var node = createSynthesizedNode(231 /* EnumDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.members = createNodeArray(members); + return node; + } + ts.createEnumDeclaration = createEnumDeclaration; + function updateEnumDeclaration(node, decorators, modifiers, name, members) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.members !== members + ? updateNode(createEnumDeclaration(decorators, modifiers, name, members), node) + : node; + } + ts.updateEnumDeclaration = updateEnumDeclaration; + function createModuleDeclaration(decorators, modifiers, name, body, flags) { + var node = createSynthesizedNode(232 /* ModuleDeclaration */); + node.flags |= flags; + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = name; + node.body = body; + return node; + } + ts.createModuleDeclaration = createModuleDeclaration; + function updateModuleDeclaration(node, decorators, modifiers, name, body) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.body !== body + ? updateNode(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node) + : node; + } + ts.updateModuleDeclaration = updateModuleDeclaration; + function createModuleBlock(statements) { + var node = createSynthesizedNode(234 /* CaseBlock */); + node.statements = createNodeArray(statements); + return node; + } + ts.createModuleBlock = createModuleBlock; + function updateModuleBlock(node, statements) { + return node.statements !== statements + ? updateNode(createModuleBlock(statements), node) + : node; + } + ts.updateModuleBlock = updateModuleBlock; + function createCaseBlock(clauses) { + var node = createSynthesizedNode(234 /* CaseBlock */); + node.clauses = createNodeArray(clauses); + return node; + } + ts.createCaseBlock = createCaseBlock; + function updateCaseBlock(node, clauses) { + return node.clauses !== clauses + ? updateNode(createCaseBlock(clauses), node) + : node; + } + ts.updateCaseBlock = updateCaseBlock; + function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { + var node = createSynthesizedNode(236 /* ImportEqualsDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.moduleReference = moduleReference; + return node; + } + ts.createImportEqualsDeclaration = createImportEqualsDeclaration; + function updateImportEqualsDeclaration(node, decorators, modifiers, name, moduleReference) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.moduleReference !== moduleReference + ? updateNode(createImportEqualsDeclaration(decorators, modifiers, name, moduleReference), node) + : node; + } + ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; + function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { + var node = createSynthesizedNode(237 /* ImportDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createImportDeclaration = createImportDeclaration; function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node) + : node; } ts.updateImportDeclaration = updateImportDeclaration; - function createImportClause(name, namedBindings, location) { - var node = createNode(237 /* ImportClause */, location); + function createImportClause(name, namedBindings) { + var node = createSynthesizedNode(238 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; } ts.createImportClause = createImportClause; function updateImportClause(node, name, namedBindings) { - if (node.name !== name || node.namedBindings !== namedBindings) { - return updateNode(createImportClause(name, namedBindings, node), node); - } - return node; + return node.name !== name + || node.namedBindings !== namedBindings + ? updateNode(createImportClause(name, namedBindings), node) + : node; } ts.updateImportClause = updateImportClause; - function createNamespaceImport(name, location) { - var node = createNode(238 /* NamespaceImport */, location); + function createNamespaceImport(name) { + var node = createSynthesizedNode(239 /* NamespaceImport */); node.name = name; return node; } ts.createNamespaceImport = createNamespaceImport; function updateNamespaceImport(node, name) { - if (node.name !== name) { - return updateNode(createNamespaceImport(name, node), node); - } - return node; + return node.name !== name + ? updateNode(createNamespaceImport(name), node) + : node; } ts.updateNamespaceImport = updateNamespaceImport; - function createNamedImports(elements, location) { - var node = createNode(239 /* NamedImports */, location); + function createNamedImports(elements) { + var node = createSynthesizedNode(240 /* NamedImports */); node.elements = createNodeArray(elements); return node; } ts.createNamedImports = createNamedImports; function updateNamedImports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedImports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedImports(elements), node) + : node; } ts.updateNamedImports = updateNamedImports; - function createImportSpecifier(propertyName, name, location) { - var node = createNode(240 /* ImportSpecifier */, location); + function createImportSpecifier(propertyName, name) { + var node = createSynthesizedNode(241 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; } ts.createImportSpecifier = createImportSpecifier; function updateImportSpecifier(node, propertyName, name) { - if (node.propertyName !== propertyName || node.name !== name) { - return updateNode(createImportSpecifier(propertyName, name, node), node); - } - return node; + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createImportSpecifier(propertyName, name), node) + : node; } ts.updateImportSpecifier = updateImportSpecifier; - function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(241 /* ExportAssignment */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportAssignment(decorators, modifiers, isExportEquals, expression) { + var node = createSynthesizedNode(242 /* ExportAssignment */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = expression; return node; } ts.createExportAssignment = createExportAssignment; function updateExportAssignment(node, decorators, modifiers, expression) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.expression !== expression) { - return updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.expression !== expression + ? updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node) + : node; } ts.updateExportAssignment = updateExportAssignment; - function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(242 /* ExportDeclaration */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { + var node = createSynthesizedNode(243 /* ExportDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createExportDeclaration = createExportDeclaration; function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.exportClause !== exportClause + || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier), node) + : node; } ts.updateExportDeclaration = updateExportDeclaration; - function createNamedExports(elements, location) { - var node = createNode(243 /* NamedExports */, location); + function createNamedExports(elements) { + var node = createSynthesizedNode(244 /* NamedExports */); node.elements = createNodeArray(elements); return node; } ts.createNamedExports = createNamedExports; function updateNamedExports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedExports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedExports(elements), node) + : node; } ts.updateNamedExports = updateNamedExports; - function createExportSpecifier(name, propertyName, location) { - var node = createNode(244 /* ExportSpecifier */, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createExportSpecifier(name, propertyName) { + var node = createSynthesizedNode(245 /* ExportSpecifier */); + node.name = asName(name); + node.propertyName = asName(propertyName); return node; } ts.createExportSpecifier = createExportSpecifier; function updateExportSpecifier(node, name, propertyName) { - if (node.name !== name || node.propertyName !== propertyName) { - return updateNode(createExportSpecifier(name, propertyName, node), node); - } - return node; + return node.name !== name || node.propertyName !== propertyName + ? updateNode(createExportSpecifier(name, propertyName), node) + : node; } ts.updateExportSpecifier = updateExportSpecifier; + // Module references + function createExternalModuleReference(expression) { + var node = createSynthesizedNode(247 /* ExternalModuleReference */); + node.expression = expression; + return node; + } + ts.createExternalModuleReference = createExternalModuleReference; + function updateExternalModuleReference(node, expression) { + return node.expression !== expression + ? updateNode(createExternalModuleReference(expression), node) + : node; + } + ts.updateExternalModuleReference = updateExternalModuleReference; // JSX - function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(247 /* JsxElement */, location); + function createJsxElement(openingElement, children, closingElement) { + var node = createSynthesizedNode(248 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11906,97 +12161,108 @@ var ts; } ts.createJsxElement = createJsxElement; function updateJsxElement(node, openingElement, children, closingElement) { - if (node.openingElement !== openingElement || node.children !== children || node.closingElement !== closingElement) { - return updateNode(createJsxElement(openingElement, children, closingElement, node), node); - } - return node; + return node.openingElement !== openingElement + || node.children !== children + || node.closingElement !== closingElement + ? updateNode(createJsxElement(openingElement, children, closingElement), node) + : node; } ts.updateJsxElement = updateJsxElement; - function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(248 /* JsxSelfClosingElement */, location); + function createJsxSelfClosingElement(tagName, attributes) { + var node = createSynthesizedNode(249 /* JsxSelfClosingElement */); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxSelfClosingElement = createJsxSelfClosingElement; function updateJsxSelfClosingElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxSelfClosingElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxSelfClosingElement(tagName, attributes), node) + : node; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; - function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(249 /* JsxOpeningElement */, location); + function createJsxOpeningElement(tagName, attributes) { + var node = createSynthesizedNode(250 /* JsxOpeningElement */); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxOpeningElement = createJsxOpeningElement; function updateJsxOpeningElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxOpeningElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxOpeningElement(tagName, attributes), node) + : node; } ts.updateJsxOpeningElement = updateJsxOpeningElement; - function createJsxClosingElement(tagName, location) { - var node = createNode(250 /* JsxClosingElement */, location); + function createJsxClosingElement(tagName) { + var node = createSynthesizedNode(251 /* JsxClosingElement */); node.tagName = tagName; return node; } ts.createJsxClosingElement = createJsxClosingElement; function updateJsxClosingElement(node, tagName) { - if (node.tagName !== tagName) { - return updateNode(createJsxClosingElement(tagName, node), node); - } - return node; + return node.tagName !== tagName + ? updateNode(createJsxClosingElement(tagName), node) + : node; } ts.updateJsxClosingElement = updateJsxClosingElement; - function createJsxAttribute(name, initializer, location) { - var node = createNode(251 /* JsxAttribute */, location); + function createJsxAttributes(properties) { + var jsxAttributes = createSynthesizedNode(253 /* JsxAttributes */); + jsxAttributes.properties = createNodeArray(properties); + return jsxAttributes; + } + ts.createJsxAttributes = createJsxAttributes; + function updateJsxAttributes(jsxAttributes, properties) { + if (jsxAttributes.properties !== properties) { + return updateNode(createJsxAttributes(properties), jsxAttributes); + } + return jsxAttributes; + } + ts.updateJsxAttributes = updateJsxAttributes; + function createJsxAttribute(name, initializer) { + var node = createSynthesizedNode(252 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; } ts.createJsxAttribute = createJsxAttribute; function updateJsxAttribute(node, name, initializer) { - if (node.name !== name || node.initializer !== initializer) { - return updateNode(createJsxAttribute(name, initializer, node), node); - } - return node; + return node.name !== name + || node.initializer !== initializer + ? updateNode(createJsxAttribute(name, initializer), node) + : node; } ts.updateJsxAttribute = updateJsxAttribute; - function createJsxSpreadAttribute(expression, location) { - var node = createNode(252 /* JsxSpreadAttribute */, location); + function createJsxSpreadAttribute(expression) { + var node = createSynthesizedNode(254 /* JsxSpreadAttribute */); node.expression = expression; return node; } ts.createJsxSpreadAttribute = createJsxSpreadAttribute; function updateJsxSpreadAttribute(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxSpreadAttribute(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxSpreadAttribute(expression), node) + : node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, dotDotDotToken, location) { - var node = createNode(253 /* JsxExpression */, location); + function createJsxExpression(expression, dotDotDotToken) { + var node = createSynthesizedNode(255 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxExpression(expression, node.dotDotDotToken), node) + : node; } ts.updateJsxExpression = updateJsxExpression; // Clauses - function createHeritageClause(token, types, location) { - var node = createNode(256 /* HeritageClause */, location); + function createHeritageClause(token, types) { + var node = createSynthesizedNode(258 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -12004,40 +12270,40 @@ var ts; ts.createHeritageClause = createHeritageClause; function updateHeritageClause(node, types) { if (node.types !== types) { - return updateNode(createHeritageClause(node.token, types, node), node); + return updateNode(createHeritageClause(node.token, types), node); } return node; } ts.updateHeritageClause = updateHeritageClause; - function createCaseClause(expression, statements, location) { - var node = createNode(254 /* CaseClause */, location); - node.expression = parenthesizeExpressionForList(expression); + function createCaseClause(expression, statements) { + var node = createSynthesizedNode(256 /* CaseClause */); + node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; } ts.createCaseClause = createCaseClause; function updateCaseClause(node, expression, statements) { if (node.expression !== expression || node.statements !== statements) { - return updateNode(createCaseClause(expression, statements, node), node); + return updateNode(createCaseClause(expression, statements), node); } return node; } ts.updateCaseClause = updateCaseClause; - function createDefaultClause(statements, location) { - var node = createNode(255 /* DefaultClause */, location); + function createDefaultClause(statements) { + var node = createSynthesizedNode(257 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } ts.createDefaultClause = createDefaultClause; function updateDefaultClause(node, statements) { if (node.statements !== statements) { - return updateNode(createDefaultClause(statements, node), node); + return updateNode(createDefaultClause(statements), node); } return node; } ts.updateDefaultClause = updateDefaultClause; - function createCatchClause(variableDeclaration, block, location) { - var node = createNode(257 /* CatchClause */, location); + function createCatchClause(variableDeclaration, block) { + var node = createSynthesizedNode(259 /* CatchClause */); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -12045,58 +12311,74 @@ var ts; ts.createCatchClause = createCatchClause; function updateCatchClause(node, variableDeclaration, block) { if (node.variableDeclaration !== variableDeclaration || node.block !== block) { - return updateNode(createCatchClause(variableDeclaration, block, node), node); + return updateNode(createCatchClause(variableDeclaration, block), node); } return node; } ts.updateCatchClause = updateCatchClause; // Property assignments - function createPropertyAssignment(name, initializer, location) { - var node = createNode(258 /* PropertyAssignment */, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAssignment(name, initializer) { + var node = createSynthesizedNode(260 /* PropertyAssignment */); + node.name = asName(name); node.questionToken = undefined; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createPropertyAssignment = createPropertyAssignment; function updatePropertyAssignment(node, name, initializer) { if (node.name !== name || node.initializer !== initializer) { - return updateNode(createPropertyAssignment(name, initializer, node), node); + return updateNode(createPropertyAssignment(name, initializer), node); } return node; } ts.updatePropertyAssignment = updatePropertyAssignment; - function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(259 /* ShorthandPropertyAssignment */, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; + function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { + var node = createSynthesizedNode(261 /* ShorthandPropertyAssignment */); + node.name = asName(name); + node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; - function createSpreadAssignment(expression, location) { - var node = createNode(260 /* SpreadAssignment */, location); - node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; + function createSpreadAssignment(expression) { + var node = createSynthesizedNode(262 /* SpreadAssignment */); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; return node; } ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { - return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); + return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); } return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function updateSpreadAssignment(node, expression) { if (node.expression !== expression) { - return updateNode(createSpreadAssignment(expression, node), node); + return updateNode(createSpreadAssignment(expression), node); } return node; } ts.updateSpreadAssignment = updateSpreadAssignment; + // Enum + function createEnumMember(name, initializer) { + var node = createSynthesizedNode(263 /* EnumMember */); + node.name = asName(name); + node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); + return node; + } + ts.createEnumMember = createEnumMember; + function updateEnumMember(node, name, initializer) { + return node.name !== name + || node.initializer !== initializer + ? updateNode(createEnumMember(name, initializer), node) + : node; + } + ts.updateEnumMember = updateEnumMember; // Top-level nodes function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(262 /* SourceFile */, /*location*/ node, node.flags); + var updated = createSynthesizedNode(264 /* SourceFile */); + updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -12155,6 +12437,17 @@ var ts; return node; } ts.updateSourceFileNode = updateSourceFileNode; + /** + * Creates a shallow, memberwise clone of a node for mutation. + */ + function getMutableClone(node) { + var clone = getSynthesizedClone(node); + clone.pos = node.pos; + clone.end = node.end; + clone.parent = node.parent; + return clone; + } + ts.getMutableClone = getMutableClone; // Transformation nodes /** * Creates a synthetic statement to act as a placeholder for a not-emitted statement in @@ -12163,8 +12456,9 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createNode(294 /* NotEmittedStatement */, /*location*/ original); + var node = createSynthesizedNode(297 /* NotEmittedStatement */); node.original = original; + setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; @@ -12172,8 +12466,9 @@ var ts; * Creates a synthetic element to act as a placeholder for the end of an emitted declaration in * order to properly emit exports. */ + /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createNode(297 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(300 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12183,8 +12478,9 @@ var ts; * Creates a synthetic element to act as a placeholder for the beginning of a merged declaration in * order to properly emit exports. */ + /* @internal */ function createMergeDeclarationMarker(original) { - var node = createNode(296 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(299 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12198,31 +12494,45 @@ var ts; * @param original The original outer expression. * @param location The location for the expression. Defaults to the positions from "original" if provided. */ - function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(295 /* PartiallyEmittedExpression */, /*location*/ location || original); + function createPartiallyEmittedExpression(expression, original) { + var node = createSynthesizedNode(298 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; + setTextRange(node, original); return node; } ts.createPartiallyEmittedExpression = createPartiallyEmittedExpression; function updatePartiallyEmittedExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createPartiallyEmittedExpression(expression, node.original, node), node); + return updateNode(createPartiallyEmittedExpression(expression, node.original), node); } return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; + function createBundle(sourceFiles) { + var node = ts.createNode(265 /* Bundle */); + node.sourceFiles = sourceFiles; + return node; + } + ts.createBundle = createBundle; + function updateBundle(node, sourceFiles) { + if (node.sourceFiles !== sourceFiles) { + return createBundle(sourceFiles); + } + return node; + } + ts.updateBundle = updateBundle; // Compound nodes function createComma(left, right) { return createBinary(left, 25 /* CommaToken */, right); } ts.createComma = createComma; - function createLessThan(left, right, location) { - return createBinary(left, 26 /* LessThanToken */, right, location); + function createLessThan(left, right) { + return createBinary(left, 26 /* LessThanToken */, right); } ts.createLessThan = createLessThan; - function createAssignment(left, right, location) { - return createBinary(left, 57 /* EqualsToken */, right, location); + function createAssignment(left, right) { + return createBinary(left, 57 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { @@ -12241,8 +12551,8 @@ var ts; return createBinary(left, 37 /* MinusToken */, right); } ts.createSubtract = createSubtract; - function createPostfixIncrement(operand, location) { - return createPostfix(operand, 42 /* PlusPlusToken */, location); + function createPostfixIncrement(operand) { + return createPostfix(operand, 42 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { @@ -12261,61 +12571,346 @@ var ts; return createVoid(createLiteral(0)); } ts.createVoidZero = createVoidZero; + function createExportDefault(expression) { + return createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportEquals*/ false, expression); + } + ts.createExportDefault = createExportDefault; + function createExternalModuleExport(exportName) { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(exportName)])); + } + ts.createExternalModuleExport = createExternalModuleExport; + function asName(name) { + return typeof name === "string" ? createIdentifier(name) : name; + } + function asExpression(value) { + return typeof value === "string" || typeof value === "number" ? createLiteral(value) : value; + } + function asNodeArray(array) { + return array ? createNodeArray(array) : undefined; + } + function asToken(value) { + return typeof value === "number" ? createToken(value) : value; + } + /** + * Clears any EmitNode entries from parse-tree nodes. + * @param sourceFile A source file. + */ + function disposeEmitNodes(sourceFile) { + // During transformation we may need to annotate a parse tree node with transient + // transformation properties. As parse tree nodes live longer than transformation + // nodes, we need to make sure we reclaim any memory allocated for custom ranges + // from these nodes to ensure we do not hold onto entire subtrees just for position + // information. We also need to reset these nodes to a pre-transformation state + // for incremental parsing scenarios so that we do not impact later emit. + sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); + var emitNode = sourceFile && sourceFile.emitNode; + var annotatedNodes = emitNode && emitNode.annotatedNodes; + if (annotatedNodes) { + for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) { + var node = annotatedNodes_1[_i]; + node.emitNode = undefined; + } + } + } + ts.disposeEmitNodes = disposeEmitNodes; + /** + * Associates a node with the current transformation, initializing + * various transient transformation properties. + */ + /* @internal */ + function getOrCreateEmitNode(node) { + if (!node.emitNode) { + if (ts.isParseTreeNode(node)) { + // To avoid holding onto transformation artifacts, we keep track of any + // parse tree node we are annotating. This allows us to clean them up after + // all transformations have completed. + if (node.kind === 264 /* SourceFile */) { + return node.emitNode = { annotatedNodes: [node] }; + } + var sourceFile = ts.getSourceFileOfNode(node); + getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); + } + node.emitNode = {}; + } + return node.emitNode; + } + ts.getOrCreateEmitNode = getOrCreateEmitNode; + function setTextRange(range, location) { + if (location) { + range.pos = location.pos; + range.end = location.end; + } + return range; + } + ts.setTextRange = setTextRange; + /** + * Gets flags that control emit behavior of a node. + */ + function getEmitFlags(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.flags; + } + ts.getEmitFlags = getEmitFlags; + /** + * Sets flags that control emit behavior of a node. + */ + function setEmitFlags(node, emitFlags) { + getOrCreateEmitNode(node).flags = emitFlags; + return node; + } + ts.setEmitFlags = setEmitFlags; + /** + * Gets a custom text range to use when emitting source maps. + */ + function getSourceMapRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.sourceMapRange) || node; + } + ts.getSourceMapRange = getSourceMapRange; + /** + * Sets a custom text range to use when emitting source maps. + */ + function setSourceMapRange(node, range) { + getOrCreateEmitNode(node).sourceMapRange = range; + return node; + } + ts.setSourceMapRange = setSourceMapRange; + /** + * Gets the TextRange to use for source maps for a token of a node. + */ + function getTokenSourceMapRange(node, token) { + var emitNode = node.emitNode; + var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; + return tokenSourceMapRanges && tokenSourceMapRanges[token]; + } + ts.getTokenSourceMapRange = getTokenSourceMapRange; + /** + * Sets the TextRange to use for source maps for a token of a node. + */ + function setTokenSourceMapRange(node, token, range) { + var emitNode = getOrCreateEmitNode(node); + var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []); + tokenSourceMapRanges[token] = range; + return node; + } + ts.setTokenSourceMapRange = setTokenSourceMapRange; + /** + * Gets a custom text range to use when emitting comments. + */ + function getCommentRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.commentRange) || node; + } + ts.getCommentRange = getCommentRange; + /** + * Sets a custom text range to use when emitting comments. + */ + function setCommentRange(node, range) { + getOrCreateEmitNode(node).commentRange = range; + return node; + } + ts.setCommentRange = setCommentRange; + /** + * Gets the constant value to emit for an expression. + */ + function getConstantValue(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.constantValue; + } + ts.getConstantValue = getConstantValue; + /** + * Sets the constant value to emit for an expression. + */ + function setConstantValue(node, value) { + var emitNode = getOrCreateEmitNode(node); + emitNode.constantValue = value; + return node; + } + ts.setConstantValue = setConstantValue; + /** + * Adds an EmitHelper to a node. + */ + function addEmitHelper(node, helper) { + var emitNode = getOrCreateEmitNode(node); + emitNode.helpers = ts.append(emitNode.helpers, helper); + return node; + } + ts.addEmitHelper = addEmitHelper; + /** + * Add EmitHelpers to a node. + */ + function addEmitHelpers(node, helpers) { + if (ts.some(helpers)) { + var emitNode = getOrCreateEmitNode(node); + for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { + var helper = helpers_1[_i]; + if (!ts.contains(emitNode.helpers, helper)) { + emitNode.helpers = ts.append(emitNode.helpers, helper); + } + } + } + return node; + } + ts.addEmitHelpers = addEmitHelpers; + /** + * Removes an EmitHelper from a node. + */ + function removeEmitHelper(node, helper) { + var emitNode = node.emitNode; + if (emitNode) { + var helpers = emitNode.helpers; + if (helpers) { + return ts.orderedRemoveItem(helpers, helper); + } + } + return false; + } + ts.removeEmitHelper = removeEmitHelper; + /** + * Gets the EmitHelpers of a node. + */ + function getEmitHelpers(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.helpers; + } + ts.getEmitHelpers = getEmitHelpers; + /** + * Moves matching emit helpers from a source node to a target node. + */ + function moveEmitHelpers(source, target, predicate) { + var sourceEmitNode = source.emitNode; + var sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers; + if (!ts.some(sourceEmitHelpers)) + return; + var targetEmitNode = getOrCreateEmitNode(target); + var helpersRemoved = 0; + for (var i = 0; i < sourceEmitHelpers.length; i++) { + var helper = sourceEmitHelpers[i]; + if (predicate(helper)) { + helpersRemoved++; + if (!ts.contains(targetEmitNode.helpers, helper)) { + targetEmitNode.helpers = ts.append(targetEmitNode.helpers, helper); + } + } + else if (helpersRemoved > 0) { + sourceEmitHelpers[i - helpersRemoved] = helper; + } + } + if (helpersRemoved > 0) { + sourceEmitHelpers.length -= helpersRemoved; + } + } + ts.moveEmitHelpers = moveEmitHelpers; + /* @internal */ + function compareEmitHelpers(x, y) { + if (x === y) + return 0 /* EqualTo */; + if (x.priority === y.priority) + return 0 /* EqualTo */; + if (x.priority === undefined) + return 1 /* GreaterThan */; + if (y.priority === undefined) + return -1 /* LessThan */; + return ts.compareValues(x.priority, y.priority); + } + ts.compareEmitHelpers = compareEmitHelpers; + function setOriginalNode(node, original) { + node.original = original; + if (original) { + var emitNode = original.emitNode; + if (emitNode) + node.emitNode = mergeEmitNode(emitNode, node.emitNode); + } + return node; + } + ts.setOriginalNode = setOriginalNode; + function mergeEmitNode(sourceEmitNode, destEmitNode) { + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; + if (!destEmitNode) + destEmitNode = {}; + if (flags) + destEmitNode.flags = flags; + if (commentRange) + destEmitNode.commentRange = commentRange; + if (sourceMapRange) + destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + if (constantValue !== undefined) + destEmitNode.constantValue = constantValue; + if (helpers) + destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); + return destEmitNode; + } + function mergeTokenSourceMapRanges(sourceRanges, destRanges) { + if (!destRanges) + destRanges = []; + for (var key in sourceRanges) { + destRanges[key] = sourceRanges[key]; + } + return destRanges; + } +})(ts || (ts = {})); +/* @internal */ +(function (ts) { + // Compound nodes function createTypeCheck(value, tag) { return tag === "undefined" - ? createStrictEquality(value, createVoidZero()) - : createStrictEquality(createTypeOf(value), createLiteral(tag)); + ? ts.createStrictEquality(value, ts.createVoidZero()) + : ts.createStrictEquality(ts.createTypeOf(value), ts.createLiteral(tag)); } ts.createTypeCheck = createTypeCheck; function createMemberAccessForPropertyName(target, memberName, location) { if (ts.isComputedPropertyName(memberName)) { - return createElementAccess(target, memberName.expression, location); + return ts.setTextRange(ts.createElementAccess(target, memberName.expression), location); } else { - var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - (expression.emitNode || (expression.emitNode = {})).flags |= 64 /* NoNestedSourceMaps */; + var expression = ts.setTextRange(ts.isIdentifier(memberName) + ? ts.createPropertyAccess(target, memberName) + : ts.createElementAccess(target, memberName), memberName); + ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; return expression; } } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createFunctionCall(func, thisArg, argumentsList, location) { - return createCall(createPropertyAccess(func, "call"), + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), /*typeArguments*/ undefined, [ thisArg - ].concat(argumentsList), location); + ].concat(argumentsList)), location); } ts.createFunctionCall = createFunctionCall; function createFunctionApply(func, thisArg, argumentsExpression, location) { - return createCall(createPropertyAccess(func, "apply"), + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "apply"), /*typeArguments*/ undefined, [ thisArg, argumentsExpression - ], location); + ]), location); } ts.createFunctionApply = createFunctionApply; function createArraySlice(array, start) { var argumentsList = []; if (start !== undefined) { - argumentsList.push(typeof start === "number" ? createLiteral(start) : start); + argumentsList.push(typeof start === "number" ? ts.createLiteral(start) : start); } - return createCall(createPropertyAccess(array, "slice"), /*typeArguments*/ undefined, argumentsList); + return ts.createCall(ts.createPropertyAccess(array, "slice"), /*typeArguments*/ undefined, argumentsList); } ts.createArraySlice = createArraySlice; function createArrayConcat(array, values) { - return createCall(createPropertyAccess(array, "concat"), + return ts.createCall(ts.createPropertyAccess(array, "concat"), /*typeArguments*/ undefined, values); } ts.createArrayConcat = createArrayConcat; function createMathPow(left, right, location) { - return createCall(createPropertyAccess(createIdentifier("Math"), "pow"), - /*typeArguments*/ undefined, [left, right], location); + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Math"), "pow"), + /*typeArguments*/ undefined, [left, right]), location); } ts.createMathPow = createMathPow; function createReactNamespace(reactNamespace, parent) { // To ensure the emit resolver can properly resolve the namespace, we need to // treat this identifier as if it were a source tree node by clearing the `Synthesized` // flag and setting a parent node. - var react = createIdentifier(reactNamespace || "React"); + var react = ts.createIdentifier(reactNamespace || "React"); react.flags &= ~8 /* Synthesized */; // Set the parent that is in parse tree // this makes sure that parent chain is intact for checker to traverse complete scope tree @@ -12325,9 +12920,9 @@ var ts; function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { if (ts.isQualifiedName(jsxFactory)) { var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); - var right = createSynthesizedNode(70 /* Identifier */); + var right = ts.createIdentifier(jsxFactory.right.text); right.text = jsxFactory.right.text; - return createPropertyAccess(left, right); + return ts.createPropertyAccess(left, right); } else { return createReactNamespace(jsxFactory.text, parent); @@ -12336,7 +12931,7 @@ var ts; function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { return jsxFactoryEntity ? createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : - createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); + ts.createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); } function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { var argumentsList = [tagName]; @@ -12345,7 +12940,7 @@ var ts; } if (children && children.length > 0) { if (!props) { - argumentsList.push(createNull()); + argumentsList.push(ts.createNull()); } if (children.length > 1) { for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { @@ -12358,33 +12953,13 @@ var ts; argumentsList.push(children[0]); } } - return createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), - /*typeArguments*/ undefined, argumentsList, location); + return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), + /*typeArguments*/ undefined, argumentsList), location); } ts.createExpressionForJsxElement = createExpressionForJsxElement; - function createExportDefault(expression) { - return createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportEquals*/ false, expression); - } - ts.createExportDefault = createExportDefault; - function createExternalModuleExport(exportName) { - return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(exportName)])); - } - ts.createExternalModuleExport = createExternalModuleExport; - function createLetStatement(name, initializer, location) { - return createVariableStatement(/*modifiers*/ undefined, createLetDeclarationList([createVariableDeclaration(name, /*type*/ undefined, initializer)]), location); - } - ts.createLetStatement = createLetStatement; - function createLetDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 1 /* Let */); - } - ts.createLetDeclarationList = createLetDeclarationList; - function createConstDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 2 /* Const */); - } - ts.createConstDeclarationList = createConstDeclarationList; // Helpers function getHelperName(name) { - return setEmitFlags(createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); + return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } ts.getHelperName = getHelperName; // Utilities @@ -12392,7 +12967,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 220 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 221 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -12410,13 +12985,13 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -12427,22 +13002,23 @@ var ts; var thisArg; var target; if (ts.isSuperProperty(callee)) { - thisArg = createThis(); + thisArg = ts.createThis(); target = callee; } else if (callee.kind === 96 /* SuperKeyword */) { - thisArg = createThis(); - target = languageVersion < 2 /* ES2015 */ ? createIdentifier("_super", /*location*/ callee) : callee; + thisArg = ts.createThis(); + target = languageVersion < 2 /* ES2015 */ + ? ts.setTextRange(ts.createIdentifier("_super"), callee) + : callee; } else { switch (callee.kind) { - case 177 /* PropertyAccessExpression */: { + case 178 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` - thisArg = createTempVariable(recordTempVariable); - target = createPropertyAccess(createAssignment(thisArg, callee.expression, - /*location*/ callee.expression), callee.name, - /*location*/ callee); + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); + ts.setTextRange(target, callee); } else { thisArg = callee.expression; @@ -12450,13 +13026,12 @@ var ts; } break; } - case 178 /* ElementAccessExpression */: { + case 179 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` - thisArg = createTempVariable(recordTempVariable); - target = createElementAccess(createAssignment(thisArg, callee.expression, - /*location*/ callee.expression), callee.argumentExpression, - /*location*/ callee); + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); + ts.setTextRange(target, callee); } else { thisArg = callee.expression; @@ -12466,7 +13041,7 @@ var ts; } default: { // for `a()` target is `a` and thisArg is `void 0` - thisArg = createVoidZero(); + thisArg = ts.createVoidZero(); target = parenthesizeForAccess(expression); break; } @@ -12476,42 +13051,42 @@ var ts; } ts.createCallBinding = createCallBinding; function inlineExpressions(expressions) { - return ts.reduceLeft(expressions, createComma); + return ts.reduceLeft(expressions, ts.createComma); } ts.inlineExpressions = inlineExpressions; function createExpressionFromEntityName(node) { if (ts.isQualifiedName(node)) { var left = createExpressionFromEntityName(node.left); - var right = getMutableClone(node.right); - return createPropertyAccess(left, right, /*location*/ node); + var right = ts.getMutableClone(node.right); + return ts.setTextRange(ts.createPropertyAccess(left, right), node); } else { - return getMutableClone(node); + return ts.getMutableClone(node); } } ts.createExpressionFromEntityName = createExpressionFromEntityName; function createExpressionForPropertyName(memberName) { if (ts.isIdentifier(memberName)) { - return createLiteral(memberName, /*location*/ undefined); + return ts.createLiteral(memberName); } else if (ts.isComputedPropertyName(memberName)) { - return getMutableClone(memberName.expression); + return ts.getMutableClone(memberName.expression); } else { - return getMutableClone(memberName); + return ts.getMutableClone(memberName); } } ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -12521,57 +13096,55 @@ var ts; if (property === firstAccessor) { var properties_1 = []; if (getAccessor) { - var getterFunction = createFunctionExpression(getAccessor.modifiers, + var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, getAccessor.parameters, - /*type*/ undefined, getAccessor.body, - /*location*/ getAccessor); - setOriginalNode(getterFunction, getAccessor); - var getter = createPropertyAssignment("get", getterFunction); + /*type*/ undefined, getAccessor.body); + ts.setTextRange(getterFunction, getAccessor); + ts.setOriginalNode(getterFunction, getAccessor); + var getter = ts.createPropertyAssignment("get", getterFunction); properties_1.push(getter); } if (setAccessor) { - var setterFunction = createFunctionExpression(setAccessor.modifiers, + var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, setAccessor.parameters, - /*type*/ undefined, setAccessor.body, - /*location*/ setAccessor); - setOriginalNode(setterFunction, setAccessor); - var setter = createPropertyAssignment("set", setterFunction); + /*type*/ undefined, setAccessor.body); + ts.setTextRange(setterFunction, setAccessor); + ts.setOriginalNode(setterFunction, setAccessor); + var setter = ts.createPropertyAssignment("set", setterFunction); properties_1.push(setter); } - properties_1.push(createPropertyAssignment("enumerable", createLiteral(true))); - properties_1.push(createPropertyAssignment("configurable", createLiteral(true))); - var expression = createCall(createPropertyAccess(createIdentifier("Object"), "defineProperty"), + properties_1.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_1.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ receiver, createExpressionForPropertyName(property.name), - createObjectLiteral(properties_1, /*location*/ undefined, multiLine) - ], + ts.createObjectLiteral(properties_1, multiLine) + ]), /*location*/ firstAccessor); return ts.aggregateTransformFlags(expression); } return undefined; } function createExpressionForPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), property.initializer, - /*location*/ property), - /*original*/ property)); + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), property.initializer), property), property)); } function createExpressionForShorthandPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), getSynthesizedClone(property.name), + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), ts.getSynthesizedClone(property.name)), /*location*/ property), /*original*/ property)); } function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, /*name*/ undefined, /*typeParameters*/ undefined, method.parameters, - /*type*/ undefined, method.body, + /*type*/ undefined, method.body), /*location*/ method), - /*original*/ method), + /*original*/ method)), /*location*/ method), /*original*/ method)); } @@ -12593,7 +13166,7 @@ var ts; * Gets whether an identifier should only be referred to by its local name. */ function isLocalName(node) { - return (getEmitFlags(node) & 16384 /* LocalName */) !== 0; + return (ts.getEmitFlags(node) & 16384 /* LocalName */) !== 0; } ts.isLocalName = isLocalName; /** @@ -12615,7 +13188,7 @@ var ts; * name points to an exported symbol. */ function isExportName(node) { - return (getEmitFlags(node) & 8192 /* ExportName */) !== 0; + return (ts.getEmitFlags(node) & 8192 /* ExportName */) !== 0; } ts.isExportName = isExportName; /** @@ -12631,17 +13204,17 @@ var ts; ts.getDeclarationName = getDeclarationName; function getName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { - var name_8 = getMutableClone(node.name); - emitFlags |= getEmitFlags(node.name); + var name = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) emitFlags |= 48 /* NoSourceMap */; if (!allowComments) emitFlags |= 1536 /* NoComments */; if (emitFlags) - setEmitFlags(name_8, emitFlags); - return name_8; + ts.setEmitFlags(name, emitFlags); + return name; } - return getGeneratedNameForNode(node); + return ts.getGeneratedNameForNode(node); } /** * Gets the exported name of a declaration for use in expressions. @@ -12670,19 +13243,20 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { - var qualifiedName = createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : getSynthesizedClone(name), /*location*/ name); + var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name)); + ts.setTextRange(qualifiedName, name); var emitFlags; if (!allowSourceMaps) emitFlags |= 48 /* NoSourceMap */; if (!allowComments) emitFlags |= 1536 /* NoComments */; if (emitFlags) - setEmitFlags(qualifiedName, emitFlags); + ts.setEmitFlags(qualifiedName, emitFlags); return qualifiedName; } ts.getNamespaceMemberName = getNamespaceMemberName; function convertToFunctionBody(node, multiLine) { - return ts.isBlock(node) ? node : createBlock([createReturn(node, /*location*/ node)], /*location*/ node, multiLine); + return ts.isBlock(node) ? node : ts.setTextRange(ts.createBlock([ts.setTextRange(ts.createReturn(node), node)], multiLine), node); } ts.convertToFunctionBody = convertToFunctionBody; function isUseStrictPrologue(node) { @@ -12718,11 +13292,11 @@ var ts; statementOffset++; } if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); + target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))); } while (statementOffset < numStatements) { var statement = source[statementOffset]; - if (getEmitFlags(statement) & 524288 /* CustomPrologue */) { + if (ts.getEmitFlags(statement) & 524288 /* CustomPrologue */) { target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -12760,9 +13334,9 @@ var ts; } } if (!foundUseStrict) { - return createNodeArray([ - startOnNewLine(createStatement(createLiteral("use strict"))) - ].concat(statements), statements); + return ts.setTextRange(ts.createNodeArray([ + startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) + ].concat(statements)), statements); } return statements; } @@ -12779,11 +13353,11 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 183 /* ParenthesizedExpression */) { + if (skipped.kind === 184 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) - ? createParen(operand) + ? ts.createParen(operand) : operand; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; @@ -12813,8 +13387,8 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(192 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(192 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(193 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(193 /* BinaryExpression */, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -12823,7 +13397,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 195 /* YieldExpression */) { + && operand.kind === 196 /* YieldExpression */) { return false; } return true; @@ -12911,7 +13485,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 192 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { + if (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12926,11 +13500,11 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(193 /* ConditionalExpression */, 54 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(194 /* ConditionalExpression */, 54 /* QuestionToken */); var emittedCondition = skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { - return createParen(condition); + return ts.createParen(condition); } return condition; } @@ -12939,10 +13513,11 @@ var ts; // per ES grammar both 'whenTrue' and 'whenFalse' parts of conditional expression are assignment expressions // so in case when comma expression is introduced as a part of previous transformations // if should be wrapped in parens since comma operator has the lowest precedence - return e.kind === 192 /* BinaryExpression */ && e.operatorToken.kind === 25 /* CommaToken */ - ? createParen(e) + return e.kind === 193 /* BinaryExpression */ && e.operatorToken.kind === 25 /* CommaToken */ + ? ts.createParen(e) : e; } + ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression; /** * Wraps an expression in parentheses if it is needed in order to use the expression * as the expression of a NewExpression node. @@ -12952,12 +13527,12 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 179 /* CallExpression */: - return createParen(expression); - case 180 /* NewExpression */: + case 180 /* CallExpression */: + return ts.createParen(expression); + case 181 /* NewExpression */: return emittedExpression.arguments ? expression - : createParen(expression); + : ts.createParen(expression); } return parenthesizeForAccess(expression); } @@ -12979,23 +13554,23 @@ var ts; // var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 180 /* NewExpression */ || emittedExpression.arguments) + && (emittedExpression.kind !== 181 /* NewExpression */ || emittedExpression.arguments) && emittedExpression.kind !== 8 /* NumericLiteral */) { return expression; } - return createParen(expression, /*location*/ expression); + return ts.setTextRange(ts.createParen(expression), expression); } ts.parenthesizeForAccess = parenthesizeForAccess; function parenthesizePostfixOperand(operand) { return ts.isLeftHandSideExpression(operand) ? operand - : createParen(operand, /*location*/ operand); + : ts.setTextRange(ts.createParen(operand), operand); } ts.parenthesizePostfixOperand = parenthesizePostfixOperand; function parenthesizePrefixOperand(operand) { return ts.isUnaryExpression(operand) ? operand - : createParen(operand, /*location*/ operand); + : ts.setTextRange(ts.createParen(operand), operand); } ts.parenthesizePrefixOperand = parenthesizePrefixOperand; function parenthesizeListElements(elements) { @@ -13010,17 +13585,18 @@ var ts; } } if (result !== undefined) { - return createNodeArray(result, elements, elements.hasTrailingComma); + return ts.setTextRange(ts.createNodeArray(result, elements.hasTrailingComma), elements); } return elements; } + ts.parenthesizeListElements = parenthesizeListElements; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(192 /* BinaryExpression */, 25 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(193 /* BinaryExpression */, 25 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression - : createParen(expression, /*location*/ expression); + : ts.setTextRange(ts.createParen(expression), expression); } ts.parenthesizeExpressionForList = parenthesizeExpressionForList; function parenthesizeExpressionForExpressionStatement(expression) { @@ -13028,16 +13604,16 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 184 /* FunctionExpression */ || kind === 185 /* ArrowFunction */) { - var mutableCall = getMutableClone(emittedExpression); - mutableCall.expression = createParen(callee, /*location*/ callee); + if (kind === 185 /* FunctionExpression */ || kind === 186 /* ArrowFunction */) { + var mutableCall = ts.getMutableClone(emittedExpression); + mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); } } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 176 /* ObjectLiteralExpression */ || leftmostExpressionKind === 184 /* FunctionExpression */) { - return createParen(expression, /*location*/ expression); + if (leftmostExpressionKind === 177 /* ObjectLiteralExpression */ || leftmostExpressionKind === 185 /* FunctionExpression */) { + return ts.setTextRange(ts.createParen(expression), expression); } } return expression; @@ -13051,7 +13627,7 @@ var ts; */ function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { - var clone_1 = getMutableClone(originalOuterExpression); + var clone_1 = ts.getMutableClone(originalOuterExpression); clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); return clone_1; } @@ -13060,21 +13636,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: node = node.operand; continue; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: node = node.left; continue; - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: node = node.condition; continue; - case 179 /* CallExpression */: - case 178 /* ElementAccessExpression */: - case 177 /* PropertyAccessExpression */: + case 180 /* CallExpression */: + case 179 /* ElementAccessExpression */: + case 178 /* PropertyAccessExpression */: node = node.expression; continue; - case 295 /* PartiallyEmittedExpression */: + case 298 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -13083,8 +13659,8 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 176 /* ObjectLiteralExpression */) { - return createParen(body, /*location*/ body); + if (emittedBody.kind === 177 /* ObjectLiteralExpression */) { + return ts.setTextRange(ts.createParen(body), body); } return body; } @@ -13115,7 +13691,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 183 /* ParenthesizedExpression */) { + while (node.kind === 184 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -13129,7 +13705,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 295 /* PartiallyEmittedExpression */) { + while (node.kind === 298 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -13140,188 +13716,6 @@ var ts; return node; } ts.startOnNewLine = startOnNewLine; - function setOriginalNode(node, original) { - node.original = original; - if (original) { - var emitNode = original.emitNode; - if (emitNode) - node.emitNode = mergeEmitNode(emitNode, node.emitNode); - } - return node; - } - ts.setOriginalNode = setOriginalNode; - function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; - if (!destEmitNode) - destEmitNode = {}; - if (flags) - destEmitNode.flags = flags; - if (commentRange) - destEmitNode.commentRange = commentRange; - if (sourceMapRange) - destEmitNode.sourceMapRange = sourceMapRange; - if (tokenSourceMapRanges) - destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); - if (constantValue !== undefined) - destEmitNode.constantValue = constantValue; - if (helpers) - destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); - return destEmitNode; - } - function mergeTokenSourceMapRanges(sourceRanges, destRanges) { - if (!destRanges) - destRanges = ts.createMap(); - ts.copyProperties(sourceRanges, destRanges); - return destRanges; - } - /** - * Clears any EmitNode entries from parse-tree nodes. - * @param sourceFile A source file. - */ - function disposeEmitNodes(sourceFile) { - // During transformation we may need to annotate a parse tree node with transient - // transformation properties. As parse tree nodes live longer than transformation - // nodes, we need to make sure we reclaim any memory allocated for custom ranges - // from these nodes to ensure we do not hold onto entire subtrees just for position - // information. We also need to reset these nodes to a pre-transformation state - // for incremental parsing scenarios so that we do not impact later emit. - sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); - var emitNode = sourceFile && sourceFile.emitNode; - var annotatedNodes = emitNode && emitNode.annotatedNodes; - if (annotatedNodes) { - for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) { - var node = annotatedNodes_1[_i]; - node.emitNode = undefined; - } - } - } - ts.disposeEmitNodes = disposeEmitNodes; - /** - * Associates a node with the current transformation, initializing - * various transient transformation properties. - * - * @param node The node. - */ - function getOrCreateEmitNode(node) { - if (!node.emitNode) { - if (ts.isParseTreeNode(node)) { - // To avoid holding onto transformation artifacts, we keep track of any - // parse tree node we are annotating. This allows us to clean them up after - // all transformations have completed. - if (node.kind === 262 /* SourceFile */) { - return node.emitNode = { annotatedNodes: [node] }; - } - var sourceFile = ts.getSourceFileOfNode(node); - getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); - } - node.emitNode = {}; - } - return node.emitNode; - } - ts.getOrCreateEmitNode = getOrCreateEmitNode; - /** - * Gets flags that control emit behavior of a node. - * - * @param node The node. - */ - function getEmitFlags(node) { - var emitNode = node.emitNode; - return emitNode && emitNode.flags; - } - ts.getEmitFlags = getEmitFlags; - /** - * Sets flags that control emit behavior of a node. - * - * @param node The node. - * @param emitFlags The NodeEmitFlags for the node. - */ - function setEmitFlags(node, emitFlags) { - getOrCreateEmitNode(node).flags = emitFlags; - return node; - } - ts.setEmitFlags = setEmitFlags; - /** - * Gets a custom text range to use when emitting source maps. - * - * @param node The node. - */ - function getSourceMapRange(node) { - var emitNode = node.emitNode; - return (emitNode && emitNode.sourceMapRange) || node; - } - ts.getSourceMapRange = getSourceMapRange; - /** - * Sets a custom text range to use when emitting source maps. - * - * @param node The node. - * @param range The text range. - */ - function setSourceMapRange(node, range) { - getOrCreateEmitNode(node).sourceMapRange = range; - return node; - } - ts.setSourceMapRange = setSourceMapRange; - /** - * Gets the TextRange to use for source maps for a token of a node. - * - * @param node The node. - * @param token The token. - */ - function getTokenSourceMapRange(node, token) { - var emitNode = node.emitNode; - var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; - return tokenSourceMapRanges && tokenSourceMapRanges[token]; - } - ts.getTokenSourceMapRange = getTokenSourceMapRange; - /** - * Sets the TextRange to use for source maps for a token of a node. - * - * @param node The node. - * @param token The token. - * @param range The text range. - */ - function setTokenSourceMapRange(node, token, range) { - var emitNode = getOrCreateEmitNode(node); - var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); - tokenSourceMapRanges[token] = range; - return node; - } - ts.setTokenSourceMapRange = setTokenSourceMapRange; - /** - * Gets a custom text range to use when emitting comments. - * - * @param node The node. - */ - function getCommentRange(node) { - var emitNode = node.emitNode; - return (emitNode && emitNode.commentRange) || node; - } - ts.getCommentRange = getCommentRange; - /** - * Sets a custom text range to use when emitting comments. - */ - function setCommentRange(node, range) { - getOrCreateEmitNode(node).commentRange = range; - return node; - } - ts.setCommentRange = setCommentRange; - /** - * Gets the constant value to emit for an expression. - */ - function getConstantValue(node) { - var emitNode = node.emitNode; - return emitNode && emitNode.constantValue; - } - ts.getConstantValue = getConstantValue; - /** - * Sets the constant value to emit for an expression. - */ - function setConstantValue(node, value) { - var emitNode = getOrCreateEmitNode(node); - emitNode.constantValue = value; - return node; - } - ts.setConstantValue = setConstantValue; function getExternalHelpersModuleName(node) { var parseNode = ts.getOriginalNode(node, ts.isSourceFile); var emitNode = parseNode && parseNode.emitNode; @@ -13334,143 +13728,34 @@ var ts; if (externalHelpersModuleName) { return externalHelpersModuleName; } - var helpers = getEmitHelpers(node); + var helpers = ts.getEmitHelpers(node); if (helpers) { - for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { - var helper = helpers_1[_i]; + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; if (!helper.scoped) { var parseNode = ts.getOriginalNode(node, ts.isSourceFile); - var emitNode = getOrCreateEmitNode(parseNode); - return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = createUniqueName(ts.externalHelpersModuleNameText)); + var emitNode = ts.getOrCreateEmitNode(parseNode); + return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = ts.createUniqueName(ts.externalHelpersModuleNameText)); } } } } } ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; - /** - * Adds an EmitHelper to a node. - */ - function addEmitHelper(node, helper) { - var emitNode = getOrCreateEmitNode(node); - emitNode.helpers = ts.append(emitNode.helpers, helper); - return node; - } - ts.addEmitHelper = addEmitHelper; - /** - * Adds an EmitHelper to a node. - */ - function addEmitHelpers(node, helpers) { - if (ts.some(helpers)) { - var emitNode = getOrCreateEmitNode(node); - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; - if (!ts.contains(emitNode.helpers, helper)) { - emitNode.helpers = ts.append(emitNode.helpers, helper); - } - } - } - return node; - } - ts.addEmitHelpers = addEmitHelpers; - /** - * Removes an EmitHelper from a node. - */ - function removeEmitHelper(node, helper) { - var emitNode = node.emitNode; - if (emitNode) { - var helpers = emitNode.helpers; - if (helpers) { - return ts.orderedRemoveItem(helpers, helper); - } - } - return false; - } - ts.removeEmitHelper = removeEmitHelper; - /** - * Gets the EmitHelpers of a node. - */ - function getEmitHelpers(node) { - var emitNode = node.emitNode; - return emitNode && emitNode.helpers; - } - ts.getEmitHelpers = getEmitHelpers; - /** - * Moves matching emit helpers from a source node to a target node. - */ - function moveEmitHelpers(source, target, predicate) { - var sourceEmitNode = source.emitNode; - var sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers; - if (!ts.some(sourceEmitHelpers)) - return; - var targetEmitNode = getOrCreateEmitNode(target); - var helpersRemoved = 0; - for (var i = 0; i < sourceEmitHelpers.length; i++) { - var helper = sourceEmitHelpers[i]; - if (predicate(helper)) { - helpersRemoved++; - if (!ts.contains(targetEmitNode.helpers, helper)) { - targetEmitNode.helpers = ts.append(targetEmitNode.helpers, helper); - } - } - else if (helpersRemoved > 0) { - sourceEmitHelpers[i - helpersRemoved] = helper; - } - } - if (helpersRemoved > 0) { - sourceEmitHelpers.length -= helpersRemoved; - } - } - ts.moveEmitHelpers = moveEmitHelpers; - function compareEmitHelpers(x, y) { - if (x === y) - return 0 /* EqualTo */; - if (x.priority === y.priority) - return 0 /* EqualTo */; - if (x.priority === undefined) - return 1 /* GreaterThan */; - if (y.priority === undefined) - return -1 /* LessThan */; - return ts.compareValues(x.priority, y.priority); - } - ts.compareEmitHelpers = compareEmitHelpers; - function setTextRange(node, location) { - if (location) { - node.pos = location.pos; - node.end = location.end; - } - return node; - } - ts.setTextRange = setTextRange; - function setNodeFlags(node, flags) { - node.flags = flags; - return node; - } - ts.setNodeFlags = setNodeFlags; - function setMultiLine(node, multiLine) { - node.multiLine = multiLine; - return node; - } - ts.setMultiLine = setMultiLine; - function setHasTrailingComma(nodes, hasTrailingComma) { - nodes.hasTrailingComma = hasTrailingComma; - return nodes; - } - ts.setHasTrailingComma = setHasTrailingComma; /** * Get the name of that target module from an import or export declaration */ function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_9 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 236 /* ImportDeclaration */ && node.importClause) { - return getGeneratedNameForNode(node); + if (node.kind === 237 /* ImportDeclaration */ && node.importClause) { + return ts.getGeneratedNameForNode(node); } - if (node.kind === 242 /* ExportDeclaration */ && node.moduleSpecifier) { - return getGeneratedNameForNode(node); + if (node.kind === 243 /* ExportDeclaration */ && node.moduleSpecifier) { + return ts.getGeneratedNameForNode(node); } return undefined; } @@ -13488,7 +13773,7 @@ var ts; if (moduleName.kind === 9 /* StringLiteral */) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) - || getSynthesizedClone(moduleName); + || ts.getSynthesizedClone(moduleName); } return undefined; } @@ -13498,10 +13783,8 @@ var ts; * Here we check if alternative name was provided for a given moduleName and return it if possible. */ function tryRenameExternalModule(moduleName, sourceFile) { - if (sourceFile.renamedDependencies && ts.hasProperty(sourceFile.renamedDependencies, moduleName.text)) { - return createLiteral(sourceFile.renamedDependencies[moduleName.text]); - } - return undefined; + var rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text); + return rename && ts.createLiteral(rename); } /** * Get the name of a module as should be written in the emitted output. @@ -13515,10 +13798,10 @@ var ts; return undefined; } if (file.moduleName) { - return createLiteral(file.moduleName); + return ts.createLiteral(file.moduleName); } if (!ts.isDeclarationFile(file) && (options.out || options.outFile)) { - return createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); + return ts.createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); } return undefined; } @@ -13589,7 +13872,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -13601,11 +13884,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 260 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -13637,12 +13920,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 144 /* Parameter */: - case 174 /* BindingElement */: + case 145 /* Parameter */: + case 175 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 196 /* SpreadElement */: - case 260 /* SpreadAssignment */: + case 197 /* SpreadElement */: + case 262 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -13654,7 +13937,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 174 /* BindingElement */: + case 175 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -13666,7 +13949,7 @@ var ts; : propertyName; } break; - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -13678,7 +13961,7 @@ var ts; : propertyName; } break; - case 260 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -13696,13 +13979,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: - case 175 /* ArrayLiteralExpression */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: + case 176 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -13712,10 +13995,12 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpread(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpread(element.name), element), element); } var expression = convertToAssignmentElementTarget(element.name); - return element.initializer ? setOriginalNode(createAssignment(expression, element.initializer, element), element) : expression; + return element.initializer + ? ts.setOriginalNode(ts.setTextRange(ts.createAssignment(expression, element.initializer), element), element) + : expression; } ts.Debug.assertNode(element, ts.isExpression); return element; @@ -13725,14 +14010,14 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpreadAssignment(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpreadAssignment(element.name), element), element); } if (element.propertyName) { var expression = convertToAssignmentElementTarget(element.name); - return setOriginalNode(createPropertyAssignment(element.propertyName, element.initializer ? createAssignment(expression, element.initializer) : expression, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createPropertyAssignment(element.propertyName, element.initializer ? ts.createAssignment(expression, element.initializer) : expression), element), element); } ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createShorthandPropertyAssignment(element.name, element.initializer, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createShorthandPropertyAssignment(element.name, element.initializer), element), element); } ts.Debug.assertNode(element, ts.isObjectLiteralElementLike); return element; @@ -13740,18 +14025,18 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 173 /* ArrayBindingPattern */: - case 175 /* ArrayLiteralExpression */: + case 174 /* ArrayBindingPattern */: + case 176 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 172 /* ObjectBindingPattern */: - case 176 /* ObjectLiteralExpression */: + case 173 /* ObjectBindingPattern */: + case 177 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } ts.convertToAssignmentPattern = convertToAssignmentPattern; function convertToObjectAssignmentPattern(node) { if (ts.isObjectBindingPattern(node)) { - return setOriginalNode(createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isObjectLiteralExpression); return node; @@ -13759,7 +14044,7 @@ var ts; ts.convertToObjectAssignmentPattern = convertToObjectAssignmentPattern; function convertToArrayAssignmentPattern(node) { if (ts.isArrayBindingPattern(node)) { - return setOriginalNode(createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isArrayLiteralExpression); return node; @@ -13775,37 +14060,37 @@ var ts; ts.convertToAssignmentElementTarget = convertToAssignmentElementTarget; function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) { var externalImports = []; - var exportSpecifiers = ts.createMap(); - var exportedBindings = ts.createMap(); + var exportSpecifiers = ts.createMultiMap(); + var exportedBindings = []; var uniqueExports = ts.createMap(); var exportedNames; var hasExportDefault = false; var exportEquals = undefined; var hasExportStarsToExportValues = false; var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions); - var externalHelpersImportDeclaration = externalHelpersModuleName && createImportDeclaration( + var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, createImportClause(/*name*/ undefined, createNamespaceImport(externalHelpersModuleName)), createLiteral(ts.externalHelpersModuleNameText)); + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); if (externalHelpersImportDeclaration) { externalImports.push(externalHelpersImportDeclaration); } for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); break; - case 235 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 246 /* ExternalModuleReference */) { + case 236 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 247 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -13821,27 +14106,27 @@ var ts; // export { x, y } for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - if (!uniqueExports[specifier.name.text]) { - var name_10 = specifier.propertyName || specifier.name; - ts.multiMapAdd(exportSpecifiers, name_10.text, specifier); - var decl = resolver.getReferencedImportDeclaration(name_10) - || resolver.getReferencedValueDeclaration(name_10); + if (!uniqueExports.get(specifier.name.text)) { + var name = specifier.propertyName || specifier.name; + exportSpecifiers.add(name.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); if (decl) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); } - uniqueExports[specifier.name.text] = true; + uniqueExports.set(specifier.name.text, true); exportedNames = ts.append(exportedNames, specifier.name); } } } break; - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13849,42 +14134,42 @@ var ts; } } break; - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { // export function x() { } - var name_11 = node.name; - if (!uniqueExports[name_11.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_11); - uniqueExports[name_11.text] = true; - exportedNames = ts.append(exportedNames, name_11); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } break; - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { // export class x { } - var name_12 = node.name; - if (!uniqueExports[name_12.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_12); - uniqueExports[name_12.text] = true; - exportedNames = ts.append(exportedNames, name_12); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } @@ -13904,13 +14189,24 @@ var ts; } } else if (!ts.isGeneratedIdentifier(decl.name)) { - if (!uniqueExports[decl.name.text]) { - uniqueExports[decl.name.text] = true; + if (!uniqueExports.get(decl.name.text)) { + uniqueExports.set(decl.name.text, true); exportedNames = ts.append(exportedNames, decl.name); } } return exportedNames; } + /** Use a sparse array as a multi-map. */ + function multiMapSparseArrayAdd(map, key, value) { + var values = map[key]; + if (values) { + values.push(value); + } + else { + map[key] = values = [value]; + } + return values; + } })(ts || (ts = {})); /// /// @@ -13922,13 +14218,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 262 /* SourceFile */) { + if (kind === 264 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 141 /* FirstNode */) { + else if (kind < 142 /* FirstNode */) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -13971,28 +14267,29 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || + visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 260 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 144 /* Parameter */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 258 /* PropertyAssignment */: - case 224 /* VariableDeclaration */: - case 174 /* BindingElement */: + case 145 /* Parameter */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 260 /* PropertyAssignment */: + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -14001,24 +14298,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 226 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -14029,323 +14326,325 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 161 /* TypeLiteral */: + case 162 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 162 /* ArrayType */: + case 163 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 163 /* TupleType */: + case 164 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 164 /* UnionType */: - case 165 /* IntersectionType */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 166 /* ParenthesizedType */: - case 168 /* TypeOperator */: + case 167 /* ParenthesizedType */: + case 169 /* TypeOperator */: return visitNode(cbNode, node.type); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 170 /* MappedType */: + case 171 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 171 /* LiteralType */: + case 172 /* LiteralType */: return visitNode(cbNode, node.literal); - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 179 /* CallExpression */: - case 180 /* NewExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 182 /* TypeAssertionExpression */: + case 183 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 187 /* TypeOfExpression */: + case 188 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 200 /* AsExpression */: + case 201 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 201 /* NonNullExpression */: + case 202 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 202 /* MetaProperty */: + case 203 /* MetaProperty */: return visitNode(cbNode, node.name); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 205 /* Block */: - case 232 /* ModuleBlock */: + case 206 /* Block */: + case 233 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 262 /* SourceFile */: + case 264 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 225 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 209 /* IfStatement */: + case 210 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 210 /* DoStatement */: + case 211 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 215 /* ContinueStatement */: - case 216 /* BreakStatement */: + case 216 /* ContinueStatement */: + case 217 /* BreakStatement */: return visitNode(cbNode, node.label); - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 218 /* WithStatement */: + case 219 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 233 /* CaseBlock */: + case 234 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 254 /* CaseClause */: + case 256 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 255 /* DefaultClause */: + case 257 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 221 /* ThrowStatement */: + case 222 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 222 /* TryStatement */: + case 223 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 145 /* Decorator */: + case 146 /* Decorator */: return visitNode(cbNode, node.expression); - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* 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 228 /* InterfaceDeclaration */: + case 229 /* 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 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 261 /* EnumMember */: + case 263 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 237 /* ImportClause */: + case 238 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 234 /* NamespaceExportDeclaration */: + case 235 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 238 /* NamespaceImport */: + case 239 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 239 /* NamedImports */: - case 243 /* NamedExports */: + case 240 /* NamedImports */: + case 244 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 240 /* ImportSpecifier */: - case 244 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: + case 245 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 203 /* TemplateSpan */: + case 204 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 256 /* HeritageClause */: + case 258 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 246 /* ExternalModuleReference */: + case 247 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 245 /* MissingDeclaration */: + case 246 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 247 /* JsxElement */: + case 248 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 248 /* JsxSelfClosingElement */: - case 249 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + case 250 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || - visitNodes(cbNodes, node.attributes); - case 251 /* JsxAttribute */: + visitNode(cbNode, node.attributes); + case 253 /* JsxAttributes */: + return visitNodes(cbNodes, node.properties); + case 252 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 252 /* JsxSpreadAttribute */: + case 254 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 253 /* JsxExpression */: + case 255 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 250 /* JsxClosingElement */: + case 251 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 263 /* JSDocTypeExpression */: + case 266 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 267 /* JSDocUnionType */: + case 270 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 268 /* JSDocTupleType */: + case 271 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 266 /* JSDocArrayType */: + case 269 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 270 /* JSDocNonNullableType */: + case 273 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 269 /* JSDocNullableType */: + case 272 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 271 /* JSDocRecordType */: + case 274 /* JSDocRecordType */: return visitNode(cbNode, node.literal); - case 273 /* JSDocTypeReference */: + case 276 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 274 /* JSDocOptionalType */: + case 277 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 275 /* JSDocFunctionType */: + case 278 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 276 /* JSDocVariadicType */: + case 279 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 277 /* JSDocConstructorType */: + case 280 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 278 /* JSDocThisType */: + case 281 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 272 /* JSDocRecordMember */: + case 275 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 279 /* JSDocComment */: + case 282 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 282 /* JSDocParameterTag */: + case 285 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 283 /* JSDocReturnTag */: + case 286 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 284 /* JSDocTypeTag */: + case 287 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 281 /* JSDocAugmentsTag */: + case 284 /* JSDocAugmentsTag */: return visitNode(cbNode, node.typeExpression); - case 285 /* JSDocTemplateTag */: + case 288 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); - case 286 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 288 /* JSDocTypeLiteral */: + case 291 /* JSDocTypeLiteral */: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 287 /* JSDocPropertyTag */: + case 290 /* JSDocPropertyTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 295 /* PartiallyEmittedExpression */: + case 298 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); - case 289 /* JSDocLiteralType */: + case 292 /* JSDocLiteralType */: return visitNode(cbNode, node.literal); } } @@ -14617,7 +14916,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(262 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(264 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -14901,7 +15200,7 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 141 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : + return kind >= 142 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : kind === 70 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } @@ -14941,7 +15240,11 @@ var ts; } function internIdentifier(text) { text = ts.escapeIdentifier(text); - return identifiers[text] || (identifiers[text] = text); + var identifier = identifiers.get(text); + if (identifier === undefined) { + identifiers.set(text, identifier = text); + } + return identifier; } // An identifier that starts with two underscores has an extra underscore character prepended to it to avoid issues // with magic property names like '__proto__'. The 'identifiers' object is used to share a single string instance for @@ -14993,7 +15296,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(142 /* ComputedPropertyName */); + var node = createNode(143 /* ComputedPropertyName */); parseExpected(20 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -15400,14 +15703,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 150 /* Constructor */: - case 155 /* IndexSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 147 /* PropertyDeclaration */: - case 204 /* SemicolonClassElement */: + case 151 /* Constructor */: + case 156 /* IndexSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 148 /* PropertyDeclaration */: + case 205 /* SemicolonClassElement */: return true; - case 149 /* MethodDeclaration */: + case 150 /* 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. @@ -15422,8 +15725,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 254 /* CaseClause */: - case 255 /* DefaultClause */: + case 256 /* CaseClause */: + case 257 /* DefaultClause */: return true; } } @@ -15432,58 +15735,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 226 /* FunctionDeclaration */: - case 206 /* VariableStatement */: - case 205 /* Block */: - case 209 /* IfStatement */: - case 208 /* ExpressionStatement */: - case 221 /* ThrowStatement */: - case 217 /* ReturnStatement */: - case 219 /* SwitchStatement */: - case 216 /* BreakStatement */: - case 215 /* ContinueStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 212 /* ForStatement */: - case 211 /* WhileStatement */: - case 218 /* WithStatement */: - case 207 /* EmptyStatement */: - case 222 /* TryStatement */: - case 220 /* LabeledStatement */: - case 210 /* DoStatement */: - case 223 /* DebuggerStatement */: - case 236 /* ImportDeclaration */: - case 235 /* ImportEqualsDeclaration */: - case 242 /* ExportDeclaration */: - case 241 /* ExportAssignment */: - case 231 /* ModuleDeclaration */: - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 230 /* EnumDeclaration */: - case 229 /* TypeAliasDeclaration */: + case 227 /* FunctionDeclaration */: + case 207 /* VariableStatement */: + case 206 /* Block */: + case 210 /* IfStatement */: + case 209 /* ExpressionStatement */: + case 222 /* ThrowStatement */: + case 218 /* ReturnStatement */: + case 220 /* SwitchStatement */: + case 217 /* BreakStatement */: + case 216 /* ContinueStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 213 /* ForStatement */: + case 212 /* WhileStatement */: + case 219 /* WithStatement */: + case 208 /* EmptyStatement */: + case 223 /* TryStatement */: + case 221 /* LabeledStatement */: + case 211 /* DoStatement */: + case 224 /* DebuggerStatement */: + case 237 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 243 /* ExportDeclaration */: + case 242 /* ExportAssignment */: + case 232 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 230 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 261 /* EnumMember */; + return node.kind === 263 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 154 /* ConstructSignature */: - case 148 /* MethodSignature */: - case 155 /* IndexSignature */: - case 146 /* PropertySignature */: - case 153 /* CallSignature */: + case 155 /* ConstructSignature */: + case 149 /* MethodSignature */: + case 156 /* IndexSignature */: + case 147 /* PropertySignature */: + case 154 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 224 /* VariableDeclaration */) { + if (node.kind !== 225 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -15504,7 +15807,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 144 /* Parameter */) { + if (node.kind !== 145 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -15617,7 +15920,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(22 /* DotToken */)) { - var node = createNode(141 /* QualifiedName */, entity.pos); // !!! + var node = createNode(142 /* QualifiedName */, entity.pos); // !!! node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -15656,7 +15959,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(194 /* TemplateExpression */); + var template = createNode(195 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -15668,7 +15971,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(203 /* TemplateSpan */); + var span = createNode(204 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17 /* CloseBraceToken */) { @@ -15723,7 +16026,7 @@ var ts; // TYPES function parseTypeReference() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - var node = createNode(157 /* TypeReference */, typeName.pos); + var node = createNode(158 /* TypeReference */, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token() === 26 /* LessThanToken */) { node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); @@ -15732,24 +16035,24 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(156 /* TypePredicate */, lhs.pos); + var node = createNode(157 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(167 /* ThisType */); + var node = createNode(168 /* ThisType */); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(160 /* TypeQuery */); + var node = createNode(161 /* TypeQuery */); parseExpected(102 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(143 /* TypeParameter */); + var node = createNode(144 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(84 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -15770,6 +16073,9 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } + if (parseOptional(57 /* EqualsToken */)) { + node.default = parseType(); + } return finishNode(node); } function parseTypeParameters() { @@ -15787,7 +16093,7 @@ var ts; return token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 /* AtToken */ || token() === 98 /* ThisKeyword */; } function parseParameter() { - var node = createNode(144 /* Parameter */); + var node = createNode(145 /* Parameter */); if (token() === 98 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true, undefined); node.type = parseParameterType(); @@ -15886,7 +16192,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 154 /* ConstructSignature */) { + if (kind === 155 /* ConstructSignature */) { parseExpected(93 /* NewKeyword */); } fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -15950,7 +16256,7 @@ var ts; return token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || token() === 21 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(155 /* IndexSignature */, fullStart); + var node = createNode(156 /* IndexSignature */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); @@ -15962,7 +16268,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(54 /* QuestionToken */); if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { - var method = createNode(148 /* MethodSignature */, fullStart); + var method = createNode(149 /* MethodSignature */, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; @@ -15973,7 +16279,7 @@ var ts; return addJSDocComment(finishNode(method)); } else { - var property = createNode(146 /* PropertySignature */, fullStart); + var property = createNode(147 /* PropertySignature */, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; @@ -16022,10 +16328,10 @@ var ts; } function parseTypeMember() { if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { - return parseSignatureMember(153 /* CallSignature */); + return parseSignatureMember(154 /* CallSignature */); } if (token() === 93 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(154 /* ConstructSignature */); + return parseSignatureMember(155 /* ConstructSignature */); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -16039,7 +16345,7 @@ var ts; return token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(161 /* TypeLiteral */); + var node = createNode(162 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -16062,14 +16368,14 @@ var ts; return token() === 20 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 91 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(143 /* TypeParameter */); + var node = createNode(144 /* TypeParameter */); node.name = parseIdentifier(); parseExpected(91 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(170 /* MappedType */); + var node = createNode(171 /* MappedType */); parseExpected(16 /* OpenBraceToken */); node.readonlyToken = parseOptionalToken(130 /* ReadonlyKeyword */); parseExpected(20 /* OpenBracketToken */); @@ -16082,12 +16388,12 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(163 /* TupleType */); + var node = createNode(164 /* TupleType */); node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(166 /* ParenthesizedType */); + var node = createNode(167 /* ParenthesizedType */); parseExpected(18 /* OpenParenToken */); node.type = parseType(); parseExpected(19 /* CloseParenToken */); @@ -16095,7 +16401,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 159 /* ConstructorType */) { + if (kind === 160 /* ConstructorType */) { parseExpected(93 /* NewKeyword */); } fillSignature(35 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -16106,7 +16412,7 @@ var ts; return token() === 22 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(171 /* LiteralType */); + var node = createNode(172 /* LiteralType */); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -16117,12 +16423,13 @@ var ts; function parseNonArrayType() { switch (token()) { case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: - case 137 /* UndefinedKeyword */: + case 136 /* SymbolKeyword */: + case 138 /* UndefinedKeyword */: case 129 /* NeverKeyword */: + case 133 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); @@ -16160,12 +16467,12 @@ var ts; function isStartOfType() { switch (token()) { case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 94 /* NullKeyword */: case 98 /* ThisKeyword */: case 102 /* TypeOfKeyword */: @@ -16180,6 +16487,7 @@ var ts; case 8 /* NumericLiteral */: case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: + case 133 /* ObjectKeyword */: return true; case 37 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral); @@ -16199,14 +16507,14 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(20 /* OpenBracketToken */)) { if (isStartOfType()) { - var node = createNode(169 /* IndexedAccessType */, type.pos); + var node = createNode(170 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(21 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(162 /* ArrayType */, type.pos); + var node = createNode(163 /* ArrayType */, type.pos); node.elementType = type; parseExpected(21 /* CloseBracketToken */); type = finishNode(node); @@ -16215,7 +16523,7 @@ var ts; return type; } function parseTypeOperator(operator) { - var node = createNode(168 /* TypeOperator */); + var node = createNode(169 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); @@ -16244,10 +16552,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(165 /* IntersectionType */, parseTypeOperatorOrHigher, 47 /* AmpersandToken */); + return parseUnionOrIntersectionType(166 /* IntersectionType */, parseTypeOperatorOrHigher, 47 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(164 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); + return parseUnionOrIntersectionType(165 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); } function isStartOfFunctionType() { if (token() === 26 /* LessThanToken */) { @@ -16304,7 +16612,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(156 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(157 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -16327,10 +16635,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(158 /* FunctionType */); + return parseFunctionOrConstructorType(159 /* FunctionType */); } if (token() === 93 /* NewKeyword */) { - return parseFunctionOrConstructorType(159 /* ConstructorType */); + return parseFunctionOrConstructorType(160 /* ConstructorType */); } return parseUnionTypeOrHigher(); } @@ -16531,7 +16839,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(195 /* YieldExpression */); + var node = createNode(196 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -16553,13 +16861,13 @@ var ts; ts.Debug.assert(token() === 35 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(185 /* ArrowFunction */, asyncModifier.pos); + node = createNode(186 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(185 /* ArrowFunction */, identifier.pos); + node = createNode(186 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(144 /* Parameter */, identifier.pos); + var parameter = createNode(145 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); @@ -16741,7 +17049,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(185 /* ArrowFunction */); + var node = createNode(186 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); // Arrow functions are never generators. @@ -16807,7 +17115,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(193 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(194 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -16820,7 +17128,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 /* InKeyword */ || t === 140 /* OfKeyword */; + return t === 91 /* InKeyword */ || t === 141 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -16928,39 +17236,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(192 /* BinaryExpression */, left.pos); + var node = createNode(193 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(200 /* AsExpression */, left.pos); + var node = createNode(201 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(190 /* PrefixUnaryExpression */); + var node = createNode(191 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(186 /* DeleteExpression */); + var node = createNode(187 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(187 /* TypeOfExpression */); + var node = createNode(188 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(188 /* VoidExpression */); + var node = createNode(189 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -16976,7 +17284,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(189 /* AwaitExpression */); + var node = createNode(190 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -17019,7 +17327,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39 /* AsteriskAsteriskToken */) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 182 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 183 /* TypeAssertionExpression */) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -17115,7 +17423,7 @@ var ts; */ function parseIncrementExpression() { if (token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) { - var node = createNode(190 /* PrefixUnaryExpression */); + var node = createNode(191 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -17128,7 +17436,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(191 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(192 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -17232,7 +17540,7 @@ 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(177 /* PropertyAccessExpression */, expression.pos); + var node = createNode(178 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(22 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -17257,8 +17565,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 249 /* JsxOpeningElement */) { - var node = createNode(247 /* JsxElement */, opening.pos); + if (opening.kind === 250 /* JsxOpeningElement */) { + var node = createNode(248 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -17268,7 +17576,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 248 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 249 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -17283,7 +17591,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(192 /* BinaryExpression */, result.pos); + var badNode = createNode(193 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -17332,17 +17640,22 @@ var ts; parsingContext = saveParsingContext; return result; } + function parseJsxAttributes() { + var jsxAttributes = createNode(253 /* JsxAttributes */); + jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); + return finishNode(jsxAttributes); + } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); parseExpected(26 /* LessThanToken */); var tagName = parseJsxElementName(); - var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); + var attributes = parseJsxAttributes(); var node; if (token() === 28 /* GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(249 /* JsxOpeningElement */, fullStart); + node = createNode(250 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -17354,7 +17667,7 @@ var ts; parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(248 /* JsxSelfClosingElement */, fullStart); + node = createNode(249 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -17370,7 +17683,7 @@ var ts; var expression = token() === 98 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22 /* DotToken */)) { - var propertyAccess = createNode(177 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(178 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -17378,7 +17691,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(253 /* JsxExpression */); + var node = createNode(255 /* JsxExpression */); parseExpected(16 /* OpenBraceToken */); if (token() !== 17 /* CloseBraceToken */) { node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); @@ -17398,7 +17711,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(251 /* JsxAttribute */); + var node = createNode(252 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 57 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -17413,7 +17726,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(252 /* JsxSpreadAttribute */); + var node = createNode(254 /* JsxSpreadAttribute */); parseExpected(16 /* OpenBraceToken */); parseExpected(23 /* DotDotDotToken */); node.expression = parseExpression(); @@ -17421,7 +17734,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(250 /* JsxClosingElement */); + var node = createNode(251 /* JsxClosingElement */); parseExpected(27 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -17434,7 +17747,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(182 /* TypeAssertionExpression */); + var node = createNode(183 /* TypeAssertionExpression */); parseExpected(26 /* LessThanToken */); node.type = parseType(); parseExpected(28 /* GreaterThanToken */); @@ -17445,7 +17758,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(177 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(178 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -17453,14 +17766,14 @@ var ts; } if (token() === 50 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(201 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(202 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(20 /* OpenBracketToken */)) { - var indexedAccess = createNode(178 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(179 /* 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. @@ -17476,7 +17789,7 @@ var ts; continue; } if (token() === 12 /* NoSubstitutionTemplateLiteral */ || token() === 13 /* TemplateHead */) { - var tagExpression = createNode(181 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(182 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -17499,7 +17812,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(179 /* CallExpression */, expression.pos); + var callExpr = createNode(180 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -17507,7 +17820,7 @@ var ts; continue; } else if (token() === 18 /* OpenParenToken */) { - var callExpr = createNode(179 /* CallExpression */, expression.pos); + var callExpr = createNode(180 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -17617,28 +17930,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(183 /* ParenthesizedExpression */); + var node = createNode(184 /* ParenthesizedExpression */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(196 /* SpreadElement */); + var node = createNode(197 /* SpreadElement */); parseExpected(23 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 25 /* CommaToken */ ? createNode(198 /* OmittedExpression */) : + token() === 25 /* CommaToken */ ? createNode(199 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(175 /* ArrayLiteralExpression */); + var node = createNode(176 /* ArrayLiteralExpression */); parseExpected(20 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17649,10 +17962,10 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(124 /* GetKeyword */)) { - return parseAccessorDeclaration(151 /* GetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(152 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(133 /* SetKeyword */)) { - return parseAccessorDeclaration(152 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(134 /* SetKeyword */)) { + return parseAccessorDeclaration(153 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -17660,7 +17973,7 @@ var ts; var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); if (dotDotDotToken) { - var spreadElement = createNode(260 /* SpreadAssignment */, fullStart); + var spreadElement = createNode(262 /* SpreadAssignment */, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -17685,7 +17998,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 /* CommaToken */ || token() === 17 /* CloseBraceToken */ || token() === 57 /* EqualsToken */); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(259 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(261 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57 /* EqualsToken */); @@ -17696,7 +18009,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(258 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(260 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -17706,7 +18019,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(176 /* ObjectLiteralExpression */); + var node = createNode(177 /* ObjectLiteralExpression */); parseExpected(16 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17725,7 +18038,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(184 /* FunctionExpression */); + var node = createNode(185 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(88 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); @@ -17750,12 +18063,12 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(93 /* NewKeyword */); if (parseOptional(22 /* DotToken */)) { - var node_1 = createNode(202 /* MetaProperty */, fullStart); + var node_1 = createNode(203 /* MetaProperty */, fullStart); node_1.keywordToken = 93 /* NewKeyword */; node_1.name = parseIdentifierName(); return finishNode(node_1); } - var node = createNode(180 /* NewExpression */, fullStart); + var node = createNode(181 /* NewExpression */, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18 /* OpenParenToken */) { @@ -17765,7 +18078,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(205 /* Block */); + var node = createNode(206 /* Block */); if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17798,12 +18111,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(207 /* EmptyStatement */); + var node = createNode(208 /* EmptyStatement */); parseExpected(24 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(209 /* IfStatement */); + var node = createNode(210 /* IfStatement */); parseExpected(89 /* IfKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17813,7 +18126,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(210 /* DoStatement */); + var node = createNode(211 /* DoStatement */); parseExpected(80 /* DoKeyword */); node.statement = parseStatement(); parseExpected(105 /* WhileKeyword */); @@ -17828,7 +18141,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(211 /* WhileStatement */); + var node = createNode(212 /* WhileStatement */); parseExpected(105 /* WhileKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17851,21 +18164,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91 /* InKeyword */)) { - var forInStatement = createNode(213 /* ForInStatement */, pos); + var forInStatement = createNode(214 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(140 /* OfKeyword */)) { - var forOfStatement = createNode(214 /* ForOfStatement */, pos); + else if (parseOptional(141 /* OfKeyword */)) { + var forOfStatement = createNode(215 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(212 /* ForStatement */, pos); + var forStatement = createNode(213 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(24 /* SemicolonToken */); if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { @@ -17883,7 +18196,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 216 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); + parseExpected(kind === 217 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -17891,7 +18204,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(217 /* ReturnStatement */); + var node = createNode(218 /* ReturnStatement */); parseExpected(95 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -17900,7 +18213,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(218 /* WithStatement */); + var node = createNode(219 /* WithStatement */); parseExpected(106 /* WithKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17909,7 +18222,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(254 /* CaseClause */); + var node = createNode(256 /* CaseClause */); parseExpected(72 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(55 /* ColonToken */); @@ -17917,7 +18230,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(255 /* DefaultClause */); + var node = createNode(257 /* DefaultClause */); parseExpected(78 /* DefaultKeyword */); parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -17927,12 +18240,12 @@ var ts; return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(219 /* SwitchStatement */); + var node = createNode(220 /* SwitchStatement */); parseExpected(97 /* SwitchKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); - var caseBlock = createNode(233 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(234 /* CaseBlock */, scanner.getStartPos()); parseExpected(16 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(17 /* CloseBraceToken */); @@ -17947,7 +18260,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(221 /* ThrowStatement */); + var node = createNode(222 /* ThrowStatement */); parseExpected(99 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -17955,7 +18268,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(222 /* TryStatement */); + var node = createNode(223 /* TryStatement */); parseExpected(101 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 73 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -17968,7 +18281,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(257 /* CatchClause */); + var result = createNode(259 /* CatchClause */); parseExpected(73 /* CatchKeyword */); if (parseExpected(18 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -17978,7 +18291,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(223 /* DebuggerStatement */); + var node = createNode(224 /* DebuggerStatement */); parseExpected(77 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -17990,13 +18303,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 /* Identifier */ && parseOptional(55 /* ColonToken */)) { - var labeledStatement = createNode(220 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(221 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(208 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(209 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -18046,7 +18359,7 @@ var ts; // // could be legal, it would add complexity for very little gain. case 108 /* InterfaceKeyword */: - case 136 /* TypeKeyword */: + case 137 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); case 127 /* ModuleKeyword */: case 128 /* NamespaceKeyword */: @@ -18064,7 +18377,7 @@ var ts; return false; } continue; - case 139 /* GlobalKeyword */: + case 140 /* GlobalKeyword */: nextToken(); return token() === 16 /* OpenBraceToken */ || token() === 70 /* Identifier */ || token() === 83 /* ExportKeyword */; case 90 /* ImportKeyword */: @@ -18126,8 +18439,8 @@ var ts; case 108 /* InterfaceKeyword */: case 127 /* ModuleKeyword */: case 128 /* NamespaceKeyword */: - case 136 /* TypeKeyword */: - case 139 /* GlobalKeyword */: + case 137 /* TypeKeyword */: + case 140 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; case 113 /* PublicKeyword */: @@ -18177,9 +18490,9 @@ var ts; case 87 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 76 /* ContinueKeyword */: - return parseBreakOrContinueStatement(215 /* ContinueStatement */); + return parseBreakOrContinueStatement(216 /* ContinueStatement */); case 71 /* BreakKeyword */: - return parseBreakOrContinueStatement(216 /* BreakStatement */); + return parseBreakOrContinueStatement(217 /* BreakStatement */); case 95 /* ReturnKeyword */: return parseReturnStatement(); case 106 /* WithKeyword */: @@ -18199,7 +18512,7 @@ var ts; return parseDeclaration(); case 119 /* AsyncKeyword */: case 108 /* InterfaceKeyword */: - case 136 /* TypeKeyword */: + case 137 /* TypeKeyword */: case 127 /* ModuleKeyword */: case 128 /* NamespaceKeyword */: case 123 /* DeclareKeyword */: @@ -18213,7 +18526,7 @@ var ts; case 116 /* AbstractKeyword */: case 114 /* StaticKeyword */: case 130 /* ReadonlyKeyword */: - case 139 /* GlobalKeyword */: + case 140 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -18236,11 +18549,11 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 108 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 136 /* TypeKeyword */: + case 137 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 82 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 139 /* GlobalKeyword */: + case 140 /* GlobalKeyword */: case 127 /* ModuleKeyword */: case 128 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -18261,7 +18574,7 @@ var ts; 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(245 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(246 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -18283,16 +18596,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 25 /* CommaToken */) { - return createNode(198 /* OmittedExpression */); + return createNode(199 /* OmittedExpression */); } - var node = createNode(174 /* BindingElement */); + var node = createNode(175 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(174 /* BindingElement */); + var node = createNode(175 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -18308,14 +18621,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(172 /* ObjectBindingPattern */); + var node = createNode(173 /* ObjectBindingPattern */); parseExpected(16 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(173 /* ArrayBindingPattern */); + var node = createNode(174 /* ArrayBindingPattern */); parseExpected(20 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(21 /* CloseBracketToken */); @@ -18334,7 +18647,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(224 /* VariableDeclaration */); + var node = createNode(225 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -18343,7 +18656,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(225 /* VariableDeclarationList */); + var node = createNode(226 /* VariableDeclarationList */); switch (token()) { case 103 /* VarKeyword */: break; @@ -18366,7 +18679,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() === 140 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 141 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -18381,7 +18694,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(206 /* VariableStatement */, fullStart); + var node = createNode(207 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -18389,7 +18702,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226 /* FunctionDeclaration */, fullStart); + var node = createNode(227 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88 /* FunctionKeyword */); @@ -18402,7 +18715,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(150 /* Constructor */, pos); + var node = createNode(151 /* Constructor */, pos); node.decorators = decorators; node.modifiers = modifiers; parseExpected(122 /* ConstructorKeyword */); @@ -18411,7 +18724,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(149 /* MethodDeclaration */, fullStart); + var method = createNode(150 /* MethodDeclaration */, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -18424,7 +18737,7 @@ var ts; return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(147 /* PropertyDeclaration */, fullStart); + var property = createNode(148 /* PropertyDeclaration */, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -18517,7 +18830,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 === 133 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 134 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -18547,7 +18860,7 @@ var ts; if (!parseOptional(56 /* AtToken */)) { break; } - var decorator = createNode(145 /* Decorator */, decoratorStart); + var decorator = createNode(146 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -18613,7 +18926,7 @@ var ts; } function parseClassElement() { if (token() === 24 /* SemicolonToken */) { - var result = createNode(204 /* SemicolonClassElement */); + var result = createNode(205 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -18641,8 +18954,8 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_13 = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_13, /*questionToken*/ undefined); + var name = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. ts.Debug.fail("Should not have attempted to parse class member declaration."); @@ -18651,10 +18964,10 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 197 /* ClassExpression */); + /*modifiers*/ undefined, 198 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 227 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 228 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -18698,7 +19011,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */) { - var node = createNode(256 /* HeritageClause */); + var node = createNode(258 /* HeritageClause */); node.token = token(); nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -18707,7 +19020,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(199 /* ExpressionWithTypeArguments */); + var node = createNode(200 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26 /* LessThanToken */) { node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); @@ -18721,7 +19034,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228 /* InterfaceDeclaration */, fullStart); + var node = createNode(229 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108 /* InterfaceKeyword */); @@ -18732,10 +19045,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229 /* TypeAliasDeclaration */, fullStart); + var node = createNode(230 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(136 /* TypeKeyword */); + parseExpected(137 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57 /* EqualsToken */); @@ -18748,13 +19061,13 @@ 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(261 /* EnumMember */, scanner.getStartPos()); + var node = createNode(263 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230 /* EnumDeclaration */, fullStart); + var node = createNode(231 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82 /* EnumKeyword */); @@ -18769,7 +19082,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(232 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(233 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(16 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(17 /* CloseBraceToken */); @@ -18780,7 +19093,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(231 /* ModuleDeclaration */, fullStart); + var node = createNode(232 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -18794,10 +19107,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(231 /* ModuleDeclaration */, fullStart); + var node = createNode(232 /* ModuleDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 139 /* GlobalKeyword */) { + if (token() === 140 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -18815,7 +19128,7 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 139 /* GlobalKeyword */) { + if (token() === 140 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -18841,7 +19154,7 @@ var ts; return nextToken() === 40 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(234 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(235 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117 /* AsKeyword */); @@ -18856,11 +19169,11 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 /* CommaToken */ && token() !== 138 /* FromKeyword */) { + if (token() !== 25 /* CommaToken */ && token() !== 139 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(235 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(236 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -18871,7 +19184,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(236 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(237 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: @@ -18881,7 +19194,7 @@ var ts; token() === 38 /* AsteriskToken */ || token() === 16 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(138 /* FromKeyword */); + parseExpected(139 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -18894,7 +19207,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(237 /* ImportClause */, fullStart); + var importClause = createNode(238 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -18904,7 +19217,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(25 /* CommaToken */)) { - importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(239 /* NamedImports */); + importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(240 /* NamedImports */); } return finishNode(importClause); } @@ -18914,7 +19227,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(246 /* ExternalModuleReference */); + var node = createNode(247 /* ExternalModuleReference */); parseExpected(131 /* RequireKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -18937,7 +19250,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(238 /* NamespaceImport */); + var namespaceImport = createNode(239 /* NamespaceImport */); parseExpected(38 /* AsteriskToken */); parseExpected(117 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -18952,14 +19265,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 239 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 240 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(244 /* ExportSpecifier */); + return parseImportOrExportSpecifier(245 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(240 /* ImportSpecifier */); + return parseImportOrExportSpecifier(241 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -18984,27 +19297,27 @@ var ts; else { node.name = identifierName; } - if (kind === 240 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 241 /* 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(242 /* ExportDeclaration */, fullStart); + var node = createNode(243 /* ExportDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38 /* AsteriskToken */)) { - parseExpected(138 /* FromKeyword */); + parseExpected(139 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(243 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(244 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 138 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(138 /* FromKeyword */); + if (token() === 139 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(139 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -19012,7 +19325,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(241 /* ExportAssignment */, fullStart); + var node = createNode(242 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57 /* EqualsToken */)) { @@ -19094,10 +19407,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 246 /* ExternalModuleReference */ - || node.kind === 236 /* ImportDeclaration */ - || node.kind === 241 /* ExportAssignment */ - || node.kind === 242 /* ExportDeclaration */ + || node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 247 /* ExternalModuleReference */ + || node.kind === 237 /* ImportDeclaration */ + || node.kind === 242 /* ExportAssignment */ + || node.kind === 243 /* ExportDeclaration */ ? node : undefined; }); @@ -19172,7 +19485,7 @@ var ts; // Parses out a JSDoc type expression. /* @internal */ function parseJSDocTypeExpression() { - var result = createNode(263 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(266 /* JSDocTypeExpression */, scanner.getTokenPos()); parseExpected(16 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(17 /* CloseBraceToken */); @@ -19183,12 +19496,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48 /* BarToken */) { - var unionType = createNode(267 /* JSDocUnionType */, type.pos); + var unionType = createNode(270 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57 /* EqualsToken */) { - var optionalType = createNode(274 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(277 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -19199,20 +19512,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20 /* OpenBracketToken */) { - var arrayType = createNode(266 /* JSDocArrayType */, type.pos); + var arrayType = createNode(269 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token() === 54 /* QuestionToken */) { - var nullableType = createNode(269 /* JSDocNullableType */, type.pos); + var nullableType = createNode(272 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50 /* ExclamationToken */) { - var nonNullableType = createNode(270 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(273 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -19246,14 +19559,15 @@ var ts; case 98 /* ThisKeyword */: return parseJSDocThisType(); case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: case 94 /* NullKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 129 /* NeverKeyword */: + case 133 /* ObjectKeyword */: return parseTokenNode(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: @@ -19264,27 +19578,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(278 /* JSDocThisType */); + var result = createNode(281 /* JSDocThisType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(277 /* JSDocConstructorType */); + var result = createNode(280 /* JSDocConstructorType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(276 /* JSDocVariadicType */); + var result = createNode(279 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(275 /* JSDocFunctionType */); + var result = createNode(278 /* JSDocFunctionType */); nextToken(); parseExpected(18 /* OpenParenToken */); result.parameters = parseDelimitedList(23 /* JSDocFunctionParameters */, parseJSDocParameter); @@ -19297,7 +19611,7 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(144 /* Parameter */); + var parameter = createNode(145 /* Parameter */); parameter.type = parseJSDocType(); if (parseOptional(57 /* EqualsToken */)) { // TODO(rbuckton): Can this be changed to SyntaxKind.QuestionToken? @@ -19306,7 +19620,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(273 /* JSDocTypeReference */); + var result = createNode(276 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); @@ -19341,24 +19655,24 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(141 /* QualifiedName */, left.pos); + var result = createNode(142 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(271 /* JSDocRecordType */); + var result = createNode(274 /* JSDocRecordType */); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(270 /* JSDocNonNullableType */); + var result = createNode(273 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(268 /* JSDocTupleType */); + var result = createNode(271 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(26 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); @@ -19372,7 +19686,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(267 /* JSDocUnionType */); + var result = createNode(270 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19 /* CloseParenToken */); @@ -19388,12 +19702,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(264 /* JSDocAllType */); + var result = createNode(267 /* JSDocAllType */); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(289 /* JSDocLiteralType */); + var result = createNode(292 /* JSDocLiteralType */); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -19416,11 +19730,11 @@ var ts; token() === 28 /* GreaterThanToken */ || token() === 57 /* EqualsToken */ || token() === 48 /* BarToken */) { - var result = createNode(265 /* JSDocUnknownType */, pos); + var result = createNode(268 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(269 /* JSDocNullableType */, pos); + var result = createNode(272 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -19585,7 +19899,7 @@ var ts; content.charCodeAt(start + 3) !== 42 /* asterisk */; } function createJSDocComment() { - var result = createNode(279 /* JSDocComment */, start); + var result = createNode(282 /* JSDocComment */, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -19701,7 +20015,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(280 /* JSDocTag */, atToken.pos); + var result = createNode(283 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -19758,7 +20072,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(282 /* JSDocParameterTag */, atToken.pos); + var result = createNode(285 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -19769,20 +20083,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 286 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283 /* JSDocReturnTag */, atToken.pos); + var result = createNode(286 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 287 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(284 /* JSDocTypeTag */, atToken.pos); + var result = createNode(287 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -19797,7 +20111,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(287 /* JSDocPropertyTag */, atToken.pos); + var result = createNode(290 /* JSDocPropertyTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -19806,7 +20120,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(281 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(284 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -19815,25 +20129,30 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(286 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(289 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0); if (typedefTag.fullName) { var rightNode = typedefTag.fullName; - while (rightNode.kind !== 70 /* Identifier */) { + while (true) { + if (rightNode.kind === 70 /* Identifier */ || !rightNode.body) { + // if node is identifier - use it as name + // otherwise use name of the rightmost part that we were able to parse + typedefTag.name = rightNode.kind === 70 /* Identifier */ ? rightNode : rightNode.name; + break; + } rightNode = rightNode.body; } - typedefTag.name = rightNode; } typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 273 /* JSDocTypeReference */) { + if (typeExpression.type.kind === 276 /* JSDocTypeReference */) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70 /* Identifier */) { - var name_14 = jsDocTypeReference.name; - if (name_14.text === "Object") { + var name = jsDocTypeReference.name; + if (name.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -19847,7 +20166,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(288 /* JSDocTypeLiteral */, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(291 /* JSDocTypeLiteral */, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -19888,7 +20207,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22 /* DotToken */)) { - var jsDocNamespaceNode = createNode(231 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(232 /* ModuleDeclaration */, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */); @@ -19934,20 +20253,20 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 285 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 288 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } // Type parameter list looks like '@template T,U,V' var typeParameters = createNodeArray(); while (true) { - var name_15 = parseJSDocIdentifierName(); + var name = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_15) { + if (!name) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(143 /* TypeParameter */, name_15.pos); - typeParameter.name = name_15; + var typeParameter = createNode(144 /* TypeParameter */, name.pos); + typeParameter.name = name; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25 /* CommaToken */) { @@ -19958,7 +20277,7 @@ var ts; break; } } - var result = createNode(285 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(288 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -20478,16 +20797,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 228 /* InterfaceDeclaration */ || node.kind === 229 /* TypeAliasDeclaration */) { + if (node.kind === 229 /* InterfaceDeclaration */ || node.kind === 230 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 236 /* ImportDeclaration */ || node.kind === 235 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { + else if ((node.kind === 237 /* ImportDeclaration */ || node.kind === 236 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 232 /* ModuleBlock */) { + else if (node.kind === 233 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -20506,7 +20825,7 @@ var ts; }); return state_1; } - else if (node.kind === 231 /* ModuleDeclaration */) { + else if (node.kind === 232 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } @@ -20647,7 +20966,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 231 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 232 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -20660,7 +20979,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression)) { @@ -20672,21 +20991,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 150 /* Constructor */: + case 151 /* Constructor */: return "__constructor"; - case 158 /* FunctionType */: - case 153 /* CallSignature */: + case 159 /* FunctionType */: + case 154 /* CallSignature */: return "__call"; - case 159 /* ConstructorType */: - case 154 /* ConstructSignature */: + case 160 /* ConstructorType */: + case 155 /* ConstructSignature */: return "__new"; - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: return "__index"; - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return "__export"; - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... @@ -20701,22 +21020,22 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 226 /* FunctionDeclaration */: - case 227 /* ClassDeclaration */: + case 227 /* FunctionDeclaration */: + case 228 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; - case 275 /* JSDocFunctionType */: + case 278 /* JSDocFunctionType */: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 144 /* Parameter */: + case 145 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 275 /* JSDocFunctionType */); + ts.Debug.assert(node.parent.kind === 278 /* JSDocFunctionType */); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 286 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 206 /* VariableStatement */) { + if (parentNode && parentNode.kind === 207 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -20771,15 +21090,18 @@ var ts; // Otherwise, we'll be merging into a compatible existing symbol (for example when // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. - symbol = symbolTable[name] || (symbolTable[name] = createSymbol(0 /* None */, name)); + symbol = symbolTable.get(name); + if (!symbol) { + symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + } if (name && (includes & 788448 /* Classifiable */)) { - classifiableNames[name] = name; + classifiableNames.set(name, name); } if (symbol.flags & excludes) { if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbol = symbolTable[name] = createSymbol(0 /* None */, name); + symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); } else { if (node.name) { @@ -20803,7 +21125,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 241 /* ExportAssignment */ && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 242 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -20823,7 +21145,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 244 /* ExportSpecifier */ || (node.kind === 235 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 245 /* ExportSpecifier */ || (node.kind === 236 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -20846,7 +21168,7 @@ var ts; // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation // and this case is specially handled. Module augmentations should only be merged with original module definition // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. - var isJSDocTypedefInJSDocNamespace = node.kind === 286 /* JSDocTypedefTag */ && + var isJSDocTypedefInJSDocNamespace = node.kind === 289 /* JSDocTypedefTag */ && node.name && node.name.kind === 70 /* Identifier */ && node.name.isInJSDocNamespace; @@ -20933,7 +21255,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 262 /* SourceFile */) { + if (node.kind === 264 /* SourceFile */) { node.flags |= emitFlags; } if (isIIFE) { @@ -21012,64 +21334,64 @@ var ts; return; } switch (node.kind) { - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: bindWhileStatement(node); break; - case 210 /* DoStatement */: + case 211 /* DoStatement */: bindDoStatement(node); break; - case 212 /* ForStatement */: + case 213 /* ForStatement */: bindForStatement(node); break; - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 209 /* IfStatement */: + case 210 /* IfStatement */: bindIfStatement(node); break; - case 217 /* ReturnStatement */: - case 221 /* ThrowStatement */: + case 218 /* ReturnStatement */: + case 222 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 216 /* BreakStatement */: - case 215 /* ContinueStatement */: + case 217 /* BreakStatement */: + case 216 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 222 /* TryStatement */: + case 223 /* TryStatement */: bindTryStatement(node); break; - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: bindSwitchStatement(node); break; - case 233 /* CaseBlock */: + case 234 /* CaseBlock */: bindCaseBlock(node); break; - case 254 /* CaseClause */: + case 256 /* CaseClause */: bindCaseClause(node); break; - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: bindLabeledStatement(node); break; - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 179 /* CallExpression */: + case 180 /* CallExpression */: bindCallExpressionFlow(node); break; default: @@ -21081,15 +21403,15 @@ var ts; switch (expr.kind) { case 70 /* Identifier */: case 98 /* ThisKeyword */: - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return hasNarrowableArgument(expr); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return expr.operator === 50 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -21097,7 +21419,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 /* Identifier */ || expr.kind === 98 /* ThisKeyword */ || - expr.kind === 177 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 178 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -21108,14 +21430,14 @@ var ts; } } } - if (expr.expression.kind === 177 /* PropertyAccessExpression */ && + if (expr.expression.kind === 178 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 187 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; + return expr1.kind === 188 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -21136,9 +21458,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 57 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -21233,33 +21555,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 209 /* IfStatement */: - case 211 /* WhileStatement */: - case 210 /* DoStatement */: + case 210 /* IfStatement */: + case 212 /* WhileStatement */: + case 211 /* DoStatement */: return parent.expression === node; - case 212 /* ForStatement */: - case 193 /* ConditionalExpression */: + case 213 /* ForStatement */: + case 194 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 183 /* ParenthesizedExpression */) { + if (node.kind === 184 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 190 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { + else if (node.kind === 191 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 192 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || + return node.kind === 193 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 53 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 183 /* ParenthesizedExpression */ || - node.parent.kind === 190 /* PrefixUnaryExpression */ && + while (node.parent.kind === 184 /* ParenthesizedExpression */ || + node.parent.kind === 191 /* PrefixUnaryExpression */ && node.parent.operator === 50 /* ExclamationToken */) { node = node.parent; } @@ -21301,7 +21623,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 220 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 221 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -21338,7 +21660,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 225 /* VariableDeclarationList */) { + if (node.initializer.kind !== 226 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -21360,7 +21682,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 217 /* ReturnStatement */) { + if (node.kind === 218 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -21380,7 +21702,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 216 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 217 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -21416,7 +21738,32 @@ var ts; if (node.finallyBlock) { // in finally flow is combined from pre-try/flow from try/flow from catch // pre-flow is necessary to make sure that finally is reachable even if finally flows in both try and finally blocks are unreachable - addAntecedent(preFinallyLabel, preTryFlow); + // also for finally blocks we inject two extra edges into the flow graph. + // first -> edge that connects pre-try flow with the label at the beginning of the finally block, it has lock associated with it + // second -> edge that represents post-finally flow. + // these edges are used in following scenario: + // let a; (1) + // try { a = someOperation(); (2)} + // finally { (3) console.log(a) } (4) + // (5) a + // flow graph for this case looks roughly like this (arrows show ): + // (1-pre-try-flow) <--.. <-- (2-post-try-flow) + // ^ ^ + // |*****(3-pre-finally-label) -----| + // ^ + // |-- ... <-- (4-post-finally-label) <--- (5) + // In case when we walk the flow starting from inside the finally block we want to take edge '*****' into account + // since it ensures that finally is always reachable. However when we start outside the finally block and go through label (5) + // then edge '*****' should be discarded because label 4 is only reachable if post-finally label-4 is reachable + // Simply speaking code inside finally block is treated as reachable as pre-try-flow + // since we conservatively assume that any line in try block can throw or return in which case we'll enter finally. + // However code after finally is reachable only if control flow was not abrupted in try/catch or finally blocks - it should be composed from + // final flows of these blocks without taking pre-try flow into account. + // + // extra edges that we inject allows to control this behavior + // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. + var preFinallyFlow = { flags: 2048 /* PreFinally */, antecedent: preTryFlow, lock: {} }; + addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); // if flow after finally is unreachable - keep it @@ -21432,6 +21779,11 @@ var ts; : unreachableFlow; } } + if (!(currentFlow.flags & 1 /* Unreachable */)) { + var afterFinallyFlow = { flags: 4096 /* AfterFinally */, antecedent: currentFlow }; + preFinallyFlow.lock = afterFinallyFlow; + currentFlow = afterFinallyFlow; + } } else { currentFlow = finishFlowLabel(preFinallyLabel); @@ -21446,7 +21798,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 255 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 257 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -21513,14 +21865,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 210 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 211 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 192 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { + if (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -21531,10 +21883,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 175 /* ArrayLiteralExpression */) { + else if (node.kind === 176 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 196 /* SpreadElement */) { + if (e.kind === 197 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -21542,16 +21894,16 @@ var ts; } } } - else if (node.kind === 176 /* ObjectLiteralExpression */) { + else if (node.kind === 177 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 258 /* PropertyAssignment */) { + if (p.kind === 260 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 259 /* ShorthandPropertyAssignment */) { + else if (p.kind === 261 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 260 /* SpreadAssignment */) { + else if (p.kind === 262 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -21607,7 +21959,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 57 /* EqualsToken */ && node.left.kind === 178 /* ElementAccessExpression */) { + if (operator === 57 /* EqualsToken */ && node.left.kind === 179 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -21618,7 +21970,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 177 /* PropertyAccessExpression */) { + if (node.expression.kind === 178 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -21651,7 +22003,7 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 213 /* ForInStatement */ || node.parent.parent.kind === 214 /* ForOfStatement */) { + if (node.initializer || node.parent.parent.kind === 214 /* ForInStatement */ || node.parent.parent.kind === 215 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } @@ -21660,10 +22012,10 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 183 /* ParenthesizedExpression */) { + while (expr.kind === 184 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 184 /* FunctionExpression */ || expr.kind === 185 /* ArrowFunction */) { + if (expr.kind === 185 /* FunctionExpression */ || expr.kind === 186 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -21671,7 +22023,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 177 /* PropertyAccessExpression */) { + if (node.expression.kind === 178 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -21680,52 +22032,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 197 /* ClassExpression */: - case 227 /* ClassDeclaration */: - case 230 /* EnumDeclaration */: - case 176 /* ObjectLiteralExpression */: - case 161 /* TypeLiteral */: - case 288 /* JSDocTypeLiteral */: - case 271 /* JSDocRecordType */: + case 198 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 177 /* ObjectLiteralExpression */: + case 162 /* TypeLiteral */: + case 291 /* JSDocTypeLiteral */: + case 274 /* JSDocRecordType */: + case 253 /* JsxAttributes */: return 1 /* IsContainer */; - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 275 /* JSDocFunctionType */: - case 231 /* ModuleDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 170 /* MappedType */: + case 278 /* JSDocFunctionType */: + case 232 /* ModuleDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 171 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 262 /* SourceFile */: + case 264 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } - case 150 /* Constructor */: - case 226 /* FunctionDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 151 /* Constructor */: + case 227 /* FunctionDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 232 /* ModuleBlock */: + case 233 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 257 /* CatchClause */: - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 233 /* CaseBlock */: + case 259 /* CatchClause */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 234 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 205 /* Block */: + case 206 /* 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. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -21762,42 +22115,43 @@ 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 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 262 /* SourceFile */: + case 264 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 197 /* ClassExpression */: - case 227 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 228 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 161 /* TypeLiteral */: - case 176 /* ObjectLiteralExpression */: - case 228 /* InterfaceDeclaration */: - case 271 /* JSDocRecordType */: - case 288 /* JSDocTypeLiteral */: + case 162 /* TypeLiteral */: + case 177 /* ObjectLiteralExpression */: + case 229 /* InterfaceDeclaration */: + case 274 /* JSDocRecordType */: + case 291 /* JSDocTypeLiteral */: + case 253 /* JsxAttributes */: // 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 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 275 /* JSDocFunctionType */: - case 229 /* TypeAliasDeclaration */: - case 170 /* MappedType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 278 /* JSDocFunctionType */: + case 230 /* TypeAliasDeclaration */: + case 171 /* MappedType */: // 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 @@ -21818,11 +22172,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 262 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 262 /* SourceFile */ || body.kind === 232 /* ModuleBlock */)) { + var body = node.kind === 264 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 264 /* SourceFile */ || body.kind === 233 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 242 /* ExportDeclaration */ || stat.kind === 241 /* ExportAssignment */) { + if (stat.kind === 243 /* ExportDeclaration */ || stat.kind === 242 /* ExportAssignment */) { return true; } } @@ -21846,7 +22200,7 @@ var ts; errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isExternalModuleAugmentation(node)) { - declareSymbolAndAddToSymbolTable(node, 1024 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */); + declareModuleSymbol(node); } else { var pattern = void 0; @@ -21866,12 +22220,8 @@ var ts; } } else { - var state = getModuleInstanceState(node); - if (state === 0 /* NonInstantiated */) { - declareSymbolAndAddToSymbolTable(node, 1024 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */); - } - else { - declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); + var state = declareModuleSymbol(node); + if (state !== 0 /* NonInstantiated */) { if (node.symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */)) { // if module was already merged with some function, class or non-const enum // treat is a non-const-enum-only @@ -21891,6 +22241,12 @@ var ts; } } } + function declareModuleSymbol(node) { + var state = getModuleInstanceState(node); + var instantiated = state !== 0 /* NonInstantiated */; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* ValueModule */ : 1024 /* NamespaceModule */, instantiated ? 106639 /* ValueModuleExcludes */ : 0 /* NamespaceModuleExcludes */); + return state; + } function bindFunctionOrConstructorType(node) { // For a given function symbol "<...>(...) => T" we want to generate a symbol identical // to the one we would get for: { <...>(...): T } @@ -21903,7 +22259,7 @@ var ts; var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); typeLiteralSymbol.members = ts.createMap(); - typeLiteralSymbol.members[symbol.name] = symbol; + typeLiteralSymbol.members.set(symbol.name, symbol); } function bindObjectLiteralExpression(node) { var ElementKind; @@ -21915,7 +22271,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 260 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { + if (prop.kind === 262 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { continue; } var identifier = prop.name; @@ -21927,12 +22283,12 @@ 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 === 258 /* PropertyAssignment */ || prop.kind === 259 /* ShorthandPropertyAssignment */ || prop.kind === 149 /* MethodDeclaration */ + var currentKind = prop.kind === 260 /* PropertyAssignment */ || prop.kind === 261 /* ShorthandPropertyAssignment */ || prop.kind === 150 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; - var existingKind = seen[identifier.text]; + var existingKind = seen.get(identifier.text); if (!existingKind) { - seen[identifier.text] = currentKind; + seen.set(identifier.text, currentKind); continue; } if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { @@ -21943,16 +22299,22 @@ var ts; } return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); } + function bindJsxAttributes(node) { + return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__jsxAttributes"); + } + function bindJsxAttribute(node, symbolFlags, symbolExcludes) { + return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 262 /* SourceFile */: + case 264 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -22063,8 +22425,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 262 /* SourceFile */ && - blockScopeContainer.kind !== 231 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 264 /* SourceFile */ && + blockScopeContainer.kind !== 232 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -22130,7 +22492,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 140 /* LastToken */) { + if (node.kind > 141 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -22177,23 +22539,23 @@ var ts; // current "blockScopeContainer" needs to be set to its immediate namespace parent. if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 286 /* JSDocTypedefTag */) { + while (parentNode && parentNode.kind !== 289 /* JSDocTypedefTag */) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); break; } case 98 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 259 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 261 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -22217,48 +22579,48 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return checkStrictModeCatchClause(node); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 218 /* WithStatement */: + case 219 /* WithStatement */: return checkStrictModeWithStatement(node); - case 167 /* ThisType */: + case 168 /* ThisType */: seenThisKeyword = true; return; - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return checkTypePredicate(node); - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530920 /* TypeParameterExcludes */); - case 144 /* Parameter */: + case 145 /* Parameter */: return bindParameter(node); - case 224 /* VariableDeclaration */: - case 174 /* BindingElement */: + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 272 /* JSDocRecordMember */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); - case 287 /* JSDocPropertyTag */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 275 /* JSDocRecordMember */: + return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 67108864 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + case 290 /* JSDocPropertyTag */: return bindJSDocProperty(node); - case 258 /* PropertyAssignment */: - case 259 /* ShorthandPropertyAssignment */: + case 260 /* PropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 261 /* EnumMember */: + case 263 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 260 /* SpreadAssignment */: - case 252 /* JsxSpreadAttribute */: + case 262 /* SpreadAssignment */: + case 254 /* JsxSpreadAttribute */: var root = container; var hasRest = false; while (root.parent) { - if (root.kind === 176 /* ObjectLiteralExpression */ && - root.parent.kind === 192 /* BinaryExpression */ && + if (root.kind === 177 /* ObjectLiteralExpression */ && + root.parent.kind === 193 /* BinaryExpression */ && root.parent.operatorToken.kind === 57 /* EqualsToken */ && root.parent.left === root) { hasRest = true; @@ -22267,86 +22629,91 @@ var ts; root = root.parent; } return; - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* 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) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 226 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 67108864 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); + case 227 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 275 /* JSDocFunctionType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 278 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); - case 161 /* TypeLiteral */: - case 170 /* MappedType */: - case 288 /* JSDocTypeLiteral */: - case 271 /* JSDocRecordType */: + case 162 /* TypeLiteral */: + case 171 /* MappedType */: + case 291 /* JSDocTypeLiteral */: + case 274 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return bindFunctionExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 197 /* ClassExpression */: - case 227 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 228 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); - case 286 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: if (!node.fullName || node.fullName.kind === 70 /* Identifier */) { return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); } break; - case 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return bindModuleDeclaration(node); + // Jsx-attributes + case 253 /* JsxAttributes */: + return bindJsxAttributes(node); + case 252 /* JsxAttribute */: + return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 235 /* ImportEqualsDeclaration */: - case 238 /* NamespaceImport */: - case 240 /* ImportSpecifier */: - case 244 /* ExportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 239 /* NamespaceImport */: + case 241 /* ImportSpecifier */: + case 245 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 234 /* NamespaceExportDeclaration */: + case 235 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 237 /* ImportClause */: + case 238 /* ImportClause */: return bindImportClause(node); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return bindExportDeclaration(node); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return bindExportAssignment(node); - case 262 /* SourceFile */: + case 264 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 205 /* Block */: + case 206 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // Fall through - case 232 /* ModuleBlock */: + case 233 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } @@ -22355,7 +22722,7 @@ var ts; if (parameterName && parameterName.kind === 70 /* Identifier */) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 167 /* ThisType */) { + if (parameterName && parameterName.kind === 168 /* ThisType */) { seenThisKeyword = true; } bind(type); @@ -22378,7 +22745,7 @@ var ts; // An export default clause with an expression exports a value // We want to exclude both class and function here, this is necessary to issue an error when there are both // default export-assignment and default export function and class declaration. - var flags = node.kind === 241 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 242 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -22388,17 +22755,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 262 /* SourceFile */) { + if (node.parent.kind !== 264 /* SourceFile */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_4 = node.parent; - if (!ts.isExternalModule(parent_4)) { + var parent_1 = node.parent; + if (!ts.isExternalModule(parent_1)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_4.isDeclarationFile) { + if (!parent_1.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -22409,11 +22776,11 @@ var ts; function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { // Export * in some sort of block construct - bindAnonymousDeclaration(node, 1073741824 /* ExportStar */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 33554432 /* ExportStar */, getDeclarationName(node)); } else if (!node.exportClause) { // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, 1073741824 /* ExportStar */, 0 /* None */); + declareSymbol(container.symbol.exports, container.symbol, node, 33554432 /* ExportStar */, 0 /* None */); } } function bindImportClause(node) { @@ -22443,12 +22810,12 @@ var ts; function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === 226 /* FunctionDeclaration */ || container.kind === 184 /* FunctionExpression */) { + if (container.kind === 227 /* FunctionDeclaration */ || container.kind === 185 /* FunctionExpression */) { container.symbol.members = container.symbol.members || ts.createMap(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); } - else if (container.kind === 150 /* Constructor */) { + else if (container.kind === 151 /* Constructor */) { // this.foo assignment in a JavaScript class // Bind this property to the containing class var saveContainer = container; @@ -22472,7 +22839,7 @@ var ts; leftSideOfAssignment.parent = node; constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - var funcSymbol = container.locals[constructorFunction.text]; + var funcSymbol = container.locals.get(constructorFunction.text); if (!funcSymbol || !(funcSymbol.flags & 16 /* Function */ || ts.isDeclarationOfFunctionExpression(funcSymbol))) { return; } @@ -22491,7 +22858,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 227 /* ClassDeclaration */) { + if (node.kind === 228 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -22499,7 +22866,7 @@ var ts; bindAnonymousDeclaration(node, 32 /* Class */, bindingName); // Add name of class expression into the map for semantic classifier if (node.name) { - classifiableNames[node.name.text] = node.name.text; + classifiableNames.set(node.name.text, node.name.text); } } var symbol = node.symbol; @@ -22512,14 +22879,15 @@ var ts; // Note: we check for this here because this class may be merging into a module. The // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. - var prototypeSymbol = createSymbol(4 /* Property */ | 134217728 /* Prototype */, "prototype"); - if (symbol.exports[prototypeSymbol.name]) { + var prototypeSymbol = createSymbol(4 /* Property */ | 16777216 /* Prototype */, "prototype"); + var symbolExport = symbol.exports.get(prototypeSymbol.name); + if (symbolExport) { if (node.name) { node.name.parent = node; } - file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbolExport.declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; + symbol.exports.set(prototypeSymbol.name, prototypeSymbol); prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { @@ -22568,7 +22936,7 @@ var ts; // containing class. if (ts.isParameterPropertyDeclaration(node)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 67108864 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } } function bindFunctionDeclaration(node) { @@ -22627,13 +22995,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 207 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 208 /* EmptyStatement */) || // report error on class declarations - node.kind === 227 /* ClassDeclaration */ || + node.kind === 228 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 231 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 232 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 230 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 231 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -22647,7 +23015,7 @@ var ts; // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 206 /* VariableStatement */ || + (node.kind !== 207 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -22667,56 +23035,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 179 /* CallExpression */: + case 180 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 144 /* Parameter */: + case 145 /* Parameter */: return computeParameter(node, subtreeFlags); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 225 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 256 /* HeritageClause */: + case 258 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 150 /* Constructor */: + case 151 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -22743,8 +23111,8 @@ var ts; switch (kind) { case 96 /* SuperKeyword */: return true; - case 177 /* PropertyAccessExpression */: - case 178 /* ElementAccessExpression */: + case 178 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96 /* SuperKeyword */; @@ -22768,12 +23136,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 176 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 177 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ESNext if they contain rest transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 175 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 176 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } @@ -22823,8 +23191,8 @@ 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 (expressionKind === 200 /* AsExpression */ - || expressionKind === 182 /* TypeAssertionExpression */) { + if (expressionKind === 201 /* AsExpression */ + || expressionKind === 183 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -23189,7 +23557,7 @@ var ts; var excludeFlags = 536872257 /* NodeExcludes */; switch (kind) { case 119 /* AsyncKeyword */: - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: // async/await is ES2017 syntax transformFlags |= 16 /* AssertES2017 */; break; @@ -23199,27 +23567,28 @@ var ts; case 116 /* AbstractKeyword */: case 123 /* DeclareKeyword */: case 75 /* ConstKeyword */: - case 230 /* EnumDeclaration */: - case 261 /* EnumMember */: - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: - case 201 /* NonNullExpression */: + case 231 /* EnumDeclaration */: + case 263 /* EnumMember */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: + case 202 /* NonNullExpression */: case 130 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 247 /* JsxElement */: - case 248 /* JsxSelfClosingElement */: - case 249 /* JsxOpeningElement */: + case 248 /* JsxElement */: + case 249 /* JsxSelfClosingElement */: + case 250 /* JsxOpeningElement */: case 10 /* JsxText */: - case 250 /* JsxClosingElement */: - case 251 /* JsxAttribute */: - case 252 /* JsxSpreadAttribute */: - case 253 /* JsxExpression */: + case 251 /* JsxClosingElement */: + case 252 /* JsxAttribute */: + case 253 /* JsxAttributes */: + case 254 /* JsxSpreadAttribute */: + case 255 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: // for-of might be ESNext if it has a rest destructuring transformFlags |= 8 /* AssertESNext */; // FALLTHROUGH @@ -23227,54 +23596,55 @@ var ts; case 13 /* TemplateHead */: case 14 /* TemplateMiddle */: case 15 /* TemplateTail */: - case 194 /* TemplateExpression */: - case 181 /* TaggedTemplateExpression */: - case 259 /* ShorthandPropertyAssignment */: + case 195 /* TemplateExpression */: + case 182 /* TaggedTemplateExpression */: + case 261 /* ShorthandPropertyAssignment */: case 114 /* StaticKeyword */: - case 202 /* MetaProperty */: + case 203 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: // This node is ES6 syntax. transformFlags |= 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; break; case 118 /* AnyKeyword */: case 132 /* NumberKeyword */: case 129 /* NeverKeyword */: - case 134 /* StringKeyword */: + case 133 /* ObjectKeyword */: + case 135 /* StringKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 143 /* TypeParameter */: - case 146 /* PropertySignature */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 156 /* TypePredicate */: - case 157 /* TypeReference */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 160 /* TypeQuery */: - case 161 /* TypeLiteral */: - case 162 /* ArrayType */: - case 163 /* TupleType */: - case 164 /* UnionType */: - case 165 /* IntersectionType */: - case 166 /* ParenthesizedType */: - case 228 /* InterfaceDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 167 /* ThisType */: - case 168 /* TypeOperator */: - case 169 /* IndexedAccessType */: - case 170 /* MappedType */: - case 171 /* LiteralType */: + case 144 /* TypeParameter */: + case 147 /* PropertySignature */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 157 /* TypePredicate */: + case 158 /* TypeReference */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 161 /* TypeQuery */: + case 162 /* TypeLiteral */: + case 163 /* ArrayType */: + case 164 /* TupleType */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: + case 167 /* ParenthesizedType */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 168 /* ThisType */: + case 169 /* TypeOperator */: + case 170 /* IndexedAccessType */: + case 171 /* MappedType */: + case 172 /* LiteralType */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. @@ -23291,10 +23661,10 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 260 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 96 /* SuperKeyword */: @@ -23305,28 +23675,28 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 172 /* ObjectBindingPattern */: + case 173 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 537396545 /* BindingPatternExcludes */; break; - case 173 /* ArrayBindingPattern */: + case 174 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 537396545 /* BindingPatternExcludes */; break; - case 174 /* BindingElement */: + case 175 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; } break; - case 145 /* Decorator */: + case 146 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: excludeFlags = 540087617 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -23344,8 +23714,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 175 /* ArrayLiteralExpression */: - case 180 /* NewExpression */: + case 176 /* ArrayLiteralExpression */: + case 181 /* NewExpression */: excludeFlags = 537396545 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -23353,23 +23723,23 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 210 /* DoStatement */: - case 211 /* WhileStatement */: - case 212 /* ForStatement */: - case 213 /* ForInStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 262 /* SourceFile */: + case 264 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 217 /* ReturnStatement */: - case 215 /* ContinueStatement */: - case 216 /* BreakStatement */: + case 218 /* ReturnStatement */: + case 216 /* ContinueStatement */: + case 217 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -23385,56 +23755,57 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 156 /* FirstTypeNode */ && kind <= 171 /* LastTypeNode */) { + if (kind >= 157 /* FirstTypeNode */ && kind <= 172 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 175 /* ArrayLiteralExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 176 /* ArrayLiteralExpression */: return 537396545 /* ArrayLiteralOrCallOrNewExcludes */; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return 574674241 /* ModuleExcludes */; - case 144 /* Parameter */: + case 145 /* Parameter */: return 536872257 /* ParameterExcludes */; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return 601249089 /* ArrowFunctionExcludes */; - case 184 /* FunctionExpression */: - case 226 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: return 601281857 /* FunctionExcludes */; - case 225 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return 546309441 /* VariableDeclarationListExcludes */; - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: return 539358529 /* ClassExcludes */; - case 150 /* Constructor */: + case 151 /* Constructor */: return 601015617 /* ConstructorExcludes */; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return 601015617 /* MethodOrAccessorExcludes */; case 118 /* AnyKeyword */: case 132 /* NumberKeyword */: case 129 /* NeverKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: + case 133 /* ObjectKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 143 /* TypeParameter */: - case 146 /* PropertySignature */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 228 /* InterfaceDeclaration */: - case 229 /* TypeAliasDeclaration */: + case 144 /* TypeParameter */: + case 147 /* PropertySignature */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return 540087617 /* ObjectLiteralExcludes */; - case 257 /* CatchClause */: + case 259 /* CatchClause */: return 537920833 /* CatchClauseExcludes */; - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: return 537396545 /* BindingPatternExcludes */; default: return 536872257 /* NodeExcludes */; @@ -23486,37 +23857,28 @@ var ts; } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; /** Reads from "main" or "types"/"typings" depending on `extensions`. */ - function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { + function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); - switch (extensions) { - case Extensions.DtsOnly: - case Extensions.TypeScript: - return tryReadFromField("typings") || tryReadFromField("types"); - case Extensions.JavaScript: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; - } + return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); - } - return typesFilePath; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } + if (!ts.hasProperty(jsonContent, fieldName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName); } + return; } + var fileName = jsonContent[fieldName]; + if (typeof fileName !== "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof fileName); + } + return; + } + var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path); + } + return path; } } function readJson(path, host) { @@ -23552,6 +23914,7 @@ var ts; function getDefaultTypeRoots(currentDirectory, host) { if (!host.directoryExists) { return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; + // And if it doesn't exist, tough. } var typeRoots; forEachAncestorDirectory(currentDirectory, function (directory) { @@ -23712,9 +24075,10 @@ var ts; if (!moduleHasNonRelativeName(nonRelativeModuleName)) { return undefined; } - var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); if (!perModuleNameCache) { - moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + perModuleNameCache = createPerModuleNameCache(); + moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); } return perModuleNameCache; } @@ -23750,12 +24114,12 @@ var ts; var commonPrefix = getCommonPrefix(path, resolvedFileName); var current = path; while (true) { - var parent_5 = ts.getDirectoryPath(current); - if (parent_5 === current || directoryPathMap.contains(parent_5)) { + var parent = ts.getDirectoryPath(current); + if (parent === current || directoryPathMap.contains(parent)) { break; } - directoryPathMap.set(parent_5, result); - current = parent_5; + directoryPathMap.set(parent, result); + current = parent; if (current == commonPrefix) { break; } @@ -23788,7 +24152,7 @@ var ts; } var containingDirectory = ts.getDirectoryPath(containingFile); var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); - var result = perFolderCache && perFolderCache[moduleName]; + var result = perFolderCache && perFolderCache.get(moduleName); if (result) { if (traceEnabled) { trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); @@ -23816,7 +24180,7 @@ var ts; break; } if (perFolderCache) { - perFolderCache[moduleName] = result; + perFolderCache.set(moduleName, result); // put result in per-module name cache var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); if (perModuleNameCache) { @@ -24016,18 +24380,25 @@ var ts; } } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /* jsOnly*/ false); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + /* @internal */ + function nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, jsOnly) { + if (jsOnly === void 0) { jsOnly = false; } var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + var result = jsOnly ? tryResolve(Extensions.JavaScript) : (tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript)); if (result && result.value) { var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { - var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + var loader = function (extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/ true); }; + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); if (resolved) { return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } @@ -24041,12 +24412,12 @@ var ts; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true); return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } - ts.nodeModuleNameResolver = nodeModuleNameResolver; + ts.nodeModuleNameResolverWorker = nodeModuleNameResolverWorker; function realpath(path, host, traceEnabled) { if (!host.realpath) { return path; @@ -24057,7 +24428,7 @@ var ts; } return real; } - function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } @@ -24085,7 +24456,7 @@ var ts; onlyRecordFailures = true; } } - return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson); } /* @internal */ function directoryProbablyExists(directoryName, host) { @@ -24154,47 +24525,51 @@ var ts; failedLookupLocations.push(fileName); return undefined; } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { + if (considerPackageJson === void 0) { considerPackageJson = true; } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); - if (mainOrTypesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); - // A package.json "typings" may specify an exact filename, or may choose to omit an extension. - var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromExactFile) { - var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); - if (resolved_3) { - return resolved_3; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); - } - } - var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); - if (resolved) { - return resolved; + if (considerPackageJson) { + var packageJsonPath = pathToPackageJson(candidate); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; } } else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); + if (directoryExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocations.push(packageJsonPath); } } - else { - if (directoryExists && state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results - failedLookupLocations.push(packageJsonPath); - } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + if (!file) { + return undefined; + } + var onlyRecordFailures = !directoryProbablyExists(ts.getDirectoryPath(file), state.host); + var fromFile = tryFile(file, failedLookupLocations, onlyRecordFailures, state); + if (fromFile) { + var resolved = fromFile && resolvedIfExtensionMatches(extensions, fromFile); + if (resolved) { + return resolved; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile); + } + } + // Even if extensions is DtsOnly, we can still look up a .ts file as a result of package.json "types" + var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; + // Don't do package.json lookup recursively, because Node.js' package lookup doesn't. + return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/ false); + } /** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */ function resolvedIfExtensionMatches(extensions, path) { var extension = ts.tryGetExtensionFromPath(path); @@ -24286,7 +24661,7 @@ var ts; var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { // Climb up parent directories looking for a module. - var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); if (resolutionFromCache) { return resolutionFromCache; @@ -24294,8 +24669,8 @@ var ts; var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state)); }); - if (resolved_4) { - return resolved_4; + if (resolved_3) { + return resolved_3; } if (extensions === Extensions.TypeScript) { // If we didn't find the file normally, look it up in @types. @@ -24400,9 +24775,9 @@ var ts; var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; var strictNullChecks = compilerOptions.strictNullChecks; var emitResolver = createResolver(); - var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); + var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); undefinedSymbol.declarations = []; - var argumentsSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "arguments"); + var argumentsSymbol = createSymbol(4 /* Property */, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, @@ -24423,6 +24798,7 @@ var ts; getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, getTypeFromTypeNode: getTypeFromTypeNode, + getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -24447,8 +24823,9 @@ var ts; getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getAmbientModules: getAmbientModules, - getJsxElementAttributesType: getJsxElementAttributesType, + getAllAttributesTypeFromJsxOpeningLikeElement: getAllAttributesTypeFromJsxOpeningLikeElement, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, isOptionalParameter: isOptionalParameter, tryGetMemberInModuleExports: tryGetMemberInModuleExports, @@ -24466,8 +24843,8 @@ var ts; var numericLiteralTypes = ts.createMap(); var indexedAccessTypes = ts.createMap(); var evolvingArrayTypes = []; - var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); - var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); + var unknownSymbol = createSymbol(4 /* Property */, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__"); var anyType = createIntrinsicType(1 /* Any */, "any"); var autoType = createIntrinsicType(1 /* Any */, "any"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); @@ -24484,8 +24861,9 @@ var ts; var voidType = createIntrinsicType(1024 /* Void */, "void"); var neverType = createIntrinsicType(8192 /* Never */, "never"); var silentNeverType = createIntrinsicType(8192 /* Never */, "never"); + var nonPrimitiveType = createIntrinsicType(16777216 /* NonPrimitive */, "object"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */ | 67108864 /* Transient */, "__type"); + var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); emptyTypeLiteralSymbol.members = ts.createMap(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -24495,6 +24873,7 @@ var ts; // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); @@ -24627,7 +25006,7 @@ var ts; TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; })(TypeFacts || (TypeFacts = {})); - var typeofEQFacts = ts.createMap({ + var typeofEQFacts = ts.createMapFromTemplate({ "string": 1 /* TypeofEQString */, "number": 2 /* TypeofEQNumber */, "boolean": 4 /* TypeofEQBoolean */, @@ -24636,7 +25015,7 @@ var ts; "object": 16 /* TypeofEQObject */, "function": 32 /* TypeofEQFunction */ }); - var typeofNEFacts = ts.createMap({ + var typeofNEFacts = ts.createMapFromTemplate({ "string": 128 /* TypeofNEString */, "number": 256 /* TypeofNENumber */, "boolean": 512 /* TypeofNEBoolean */, @@ -24645,13 +25024,14 @@ var ts; "object": 2048 /* TypeofNEObject */, "function": 4096 /* TypeofNEFunction */ }); - var typeofTypesByName = ts.createMap({ + var typeofTypesByName = ts.createMapFromTemplate({ "string": stringType, "number": numberType, "boolean": booleanType, "symbol": esSymbolType, "undefined": undefinedType }); + var typeofType = createTypeofType(); var jsxElementType; var _jsxNamespace; var _jsxFactoryEntity; @@ -24681,7 +25061,7 @@ var ts; TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); - builtinGlobals[undefinedSymbol.name] = undefinedSymbol; + builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); return checker; function getJsxNamespace() { @@ -24713,7 +25093,9 @@ var ts; } function createSymbol(flags, name) { symbolCount++; - return new Symbol(flags, name); + var symbol = (new Symbol(flags | 134217728 /* Transient */, name)); + symbol.checkFlags = 0; + return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; @@ -24759,7 +25141,7 @@ var ts; mergedSymbols[source.mergeId] = target; } function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 33554432 /* Merged */, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) @@ -24782,7 +25164,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 231 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 231 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 232 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 232 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -24799,6 +25181,9 @@ var ts; } recordMergedSymbol(target, source); } + else if (target.flags & 1024 /* NamespaceModule */) { + error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + } else { var message_2 = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -24811,18 +25196,19 @@ var ts; } } function mergeSymbolTable(target, source) { - for (var id in source) { - var targetSymbol = target[id]; + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); if (!targetSymbol) { - target[id] = source[id]; + target.set(id, sourceSymbol); } else { - if (!(targetSymbol.flags & 33554432 /* Merged */)) { - target[id] = targetSymbol = cloneSymbol(targetSymbol); + if (!(targetSymbol.flags & 134217728 /* Transient */)) { + targetSymbol = cloneSymbol(targetSymbol); + target.set(id, targetSymbol); } - mergeSymbol(targetSymbol, source[id]); + mergeSymbol(targetSymbol, sourceSymbol); } - } + }); } function mergeModuleAugmentation(moduleName) { var moduleAugmentation = moduleName.parent; @@ -24851,7 +25237,7 @@ var ts; if (mainModule.flags & 1920 /* Namespace */) { // if module symbol has already been merged - it is safe to use it. // otherwise clone it - mainModule = mainModule.flags & 33554432 /* Merged */ ? mainModule : cloneSymbol(mainModule); + mainModule = mainModule.flags & 134217728 /* Transient */ ? mainModule : cloneSymbol(mainModule); mergeSymbol(mainModule, moduleAugmentation.symbol); } else { @@ -24860,21 +25246,22 @@ var ts; } } function addToSymbolTable(target, source, message) { - for (var id in source) { - if (target[id]) { + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); + if (targetSymbol) { // Error on redeclarations - ts.forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); + ts.forEach(targetSymbol.declarations, addDeclarationDiagnostic(id, message)); } else { - target[id] = source[id]; + target.set(id, sourceSymbol); } - } + }); function addDeclarationDiagnostic(id, message) { return function (declaration) { return diagnostics.add(ts.createDiagnosticForNode(declaration, message, id)); }; } } function getSymbolLinks(symbol) { - if (symbol.flags & 67108864 /* Transient */) + if (symbol.flags & 134217728 /* Transient */) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = {}); @@ -24886,14 +25273,17 @@ var ts; function getObjectFlags(type) { return type.flags & 32768 /* Object */ ? type.objectFlags : 0; } + function getCheckFlags(symbol) { + return symbol.flags & 134217728 /* Transient */ ? symbol.checkFlags : 0; + } function isGlobalSourceFile(node) { - return node.kind === 262 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 264 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { - var symbol = symbols[name]; + var symbol = symbols.get(name); if (symbol) { - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } @@ -24935,7 +25325,7 @@ var ts; } // declaration is after usage // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) - if (isUsedInFunctionOrNonStaticProperty(usage)) { + if (isUsedInFunctionOrInstanceProperty(usage)) { return true; } var sourceFiles = host.getSourceFiles(); @@ -24943,32 +25333,34 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 174 /* BindingElement */) { + if (declaration.kind === 175 /* BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 174 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 175 /* BindingElement */); if (errorBindingElement) { return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 224 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 225 /* VariableDeclaration */), usage); } - else if (declaration.kind === 224 /* VariableDeclaration */) { + else if (declaration.kind === 225 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return true; } - // declaration is after usage - // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) + // declaration is after usage, but it can still be legal if usage is deferred: + // 1. inside a function + // 2. inside an instance property initializer, a reference to a non-instance property var container = ts.getEnclosingBlockScopeContainer(declaration); - return isUsedInFunctionOrNonStaticProperty(usage, container); + var isInstanceProperty = declaration.kind === 148 /* PropertyDeclaration */ && !(ts.getModifierFlags(declaration) & 32 /* Static */); + return isUsedInFunctionOrInstanceProperty(usage, isInstanceProperty, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 206 /* VariableStatement */: - case 212 /* ForStatement */: - case 214 /* ForOfStatement */: + case 207 /* VariableStatement */: + case 213 /* ForStatement */: + case 215 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -24977,8 +25369,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -24986,7 +25378,7 @@ var ts; } return false; } - function isUsedInFunctionOrNonStaticProperty(usage, container) { + function isUsedInFunctionOrInstanceProperty(usage, isDeclarationInstanceProperty, container) { var current = usage; while (current) { if (current === container) { @@ -24995,12 +25387,12 @@ var ts; if (ts.isFunctionLike(current)) { return true; } - var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 147 /* PropertyDeclaration */ && + var initializerOfInstanceProperty = current.parent && + current.parent.kind === 148 /* PropertyDeclaration */ && (ts.getModifierFlags(current.parent) & 32 /* Static */) === 0 && current.parent.initializer === current; - if (initializerOfNonStaticProperty) { - return true; + if (initializerOfInstanceProperty) { + return !isDeclarationInstanceProperty; } current = current.parent; } @@ -25038,11 +25430,11 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 279 /* JSDocComment */) { + if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 282 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || - lastLocation.kind === 144 /* Parameter */ || - lastLocation.kind === 143 /* TypeParameter */ + lastLocation.kind === 145 /* Parameter */ || + lastLocation.kind === 144 /* TypeParameter */ : false; } if (meaning & 107455 /* Value */ && result.flags & 1 /* FunctionScopedVariable */) { @@ -25051,9 +25443,9 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 144 /* Parameter */ || + lastLocation.kind === 145 /* Parameter */ || (lastLocation === location.type && - result.valueDeclaration.kind === 144 /* Parameter */); + result.valueDeclaration.kind === 145 /* Parameter */); } } if (useResult) { @@ -25065,16 +25457,16 @@ var ts; } } switch (location.kind) { - case 262 /* SourceFile */: + case 264 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 262 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 264 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports["default"]) { + if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; @@ -25092,9 +25484,10 @@ var ts; // 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely* // an alias. If we used &, we'd be throwing out symbols that have non alias aspects, // which is not the desired behavior. - if (moduleExports[name] && - moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 244 /* ExportSpecifier */)) { + var moduleExport = moduleExports.get(name); + if (moduleExport && + moduleExport.flags === 8388608 /* Alias */ && + ts.getDeclarationOfKind(moduleExport, 245 /* ExportSpecifier */)) { break; } } @@ -25102,13 +25495,13 @@ var ts; break loop; } break; - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* 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 @@ -25125,10 +25518,15 @@ var ts; } } break; - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 228 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064 /* Type */)) { + if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { + // ignore type parameters not declared in this container + result = undefined; + break; + } if (lastLocation && ts.getModifierFlags(lastLocation) & 32 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 // The scope of a type parameter extends over the entire declaration with which the type @@ -25138,7 +25536,7 @@ var ts; } break loop; } - if (location.kind === 197 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 198 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -25154,9 +25552,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 228 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 229 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -25164,19 +25562,19 @@ var ts; } } break; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 226 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -25189,7 +25587,7 @@ var ts; } } break; - case 145 /* Decorator */: + case 146 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -25198,7 +25596,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 === 144 /* Parameter */) { + if (location.parent && location.parent.kind === 145 /* Parameter */) { location = location.parent; } // @@ -25249,10 +25647,10 @@ var ts; // interface bar {} // } // const foo/*1*/: foo/*2*/.bar; - // The foo at /*1*/ and /*2*/ will share same symbol with two meaning - // block - scope variable and namespace module. However, only when we + // The foo at /*1*/ and /*2*/ will share same symbol with two meanings: + // block-scoped variable and namespace module. However, only when we // try to resolve name in /*1*/ which is used in variable position, - // we want to check for block- scoped + // we want to check for block-scoped if (meaning & 2 /* BlockScopedVariable */) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */) { @@ -25262,18 +25660,27 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 107455 /* Value */) === 107455 /* Value */) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 234 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 235 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } } return result; } + function isTypeParameterSymbolDeclaredInContainer(symbol, container) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 144 /* TypeParameter */ && decl.parent === container) { + return true; + } + } + return false; + } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { if ((errorLocation.kind === 70 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } - var container = ts.getThisContainer(errorLocation, /* includeArrowFunctions */ true); + var container = ts.getThisContainer(errorLocation, /*includeArrowFunctions*/ true); var location = container; while (location) { if (ts.isClassLike(location.parent)) { @@ -25316,9 +25723,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70 /* Identifier */: - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -25371,10 +25778,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 235 /* ImportEqualsDeclaration */) { + if (node.kind === 236 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 236 /* ImportDeclaration */) { + while (node && node.kind !== 237 /* ImportDeclaration */) { node = node.parent; } return node; @@ -25384,7 +25791,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 246 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 247 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -25392,11 +25799,16 @@ var ts; function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { - var exportDefaultSymbol = ts.isShorthandAmbientModuleSymbol(moduleSymbol) ? - moduleSymbol : - moduleSymbol.exports["export="] ? - getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") : - resolveSymbol(moduleSymbol.exports["default"]); + var exportDefaultSymbol = void 0; + if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { + exportDefaultSymbol = moduleSymbol; + } + else { + var exportValue = moduleSymbol.exports.get("export="); + exportDefaultSymbol = exportValue + ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") + : resolveSymbol(moduleSymbol.exports.get("default")); + } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } @@ -25445,7 +25857,7 @@ var ts; } function getExportOfModule(symbol, name) { if (symbol.flags & 1536 /* Module */) { - var exportedSymbol = getExportsOfSymbol(symbol)[name]; + var exportedSymbol = getExportsOfSymbol(symbol).get(name); if (exportedSymbol) { return resolveSymbol(exportedSymbol); } @@ -25463,31 +25875,31 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_16 = specifier.propertyName || specifier.name; - if (name_16.text) { + var name = specifier.propertyName || specifier.name; + if (name.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_16.text); + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) { + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_16.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_16.text); + var symbolFromModule = getExportOfModule(targetSymbol, name.text); // If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default - if (!symbolFromModule && allowSyntheticDefaultImports && name_16.text === "default") { + if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_16, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_16)); + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name)); } return symbol; } @@ -25509,19 +25921,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 237 /* ImportClause */: + case 238 /* ImportClause */: return getTargetOfImportClause(node); - case 238 /* NamespaceImport */: + case 239 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 240 /* ImportSpecifier */: + case 241 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 244 /* ExportSpecifier */: + case 245 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return getTargetOfExportAssignment(node); - case 234 /* NamespaceExportDeclaration */: + case 235 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node); } } @@ -25568,11 +25980,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 241 /* ExportAssignment */) { + if (node.kind === 242 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 244 /* ExportSpecifier */) { + else if (node.kind === 245 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -25594,13 +26006,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 141 /* QualifiedName */) { + if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 142 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 235 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 236 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -25622,9 +26034,9 @@ var ts; return undefined; } } - else if (name.kind === 141 /* QualifiedName */ || name.kind === 177 /* PropertyAccessExpression */) { - var left = name.kind === 141 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 141 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 142 /* QualifiedName */ || name.kind === 178 /* PropertyAccessExpression */) { + var left = name.kind === 142 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 142 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1920 /* Namespace */, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -25643,7 +26055,7 @@ var ts; else { ts.Debug.fail("Unknown entity name kind."); } - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); } function resolveExternalModuleName(location, moduleReferenceExpression) { @@ -25723,7 +26135,7 @@ var ts; // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, // and an external module with no 'export =' declaration resolves to the module itself. function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="))) || moduleSymbol; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may @@ -25737,15 +26149,23 @@ var ts; return symbol; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="] !== undefined; + return moduleSymbol.exports.get("export=") !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); } + function getExportsAndPropertiesOfModule(moduleSymbol) { + var exports = getExportsOfModuleAsArray(moduleSymbol); + var exportEquals = resolveExternalModuleSymbol(moduleSymbol); + if (exportEquals !== moduleSymbol) { + ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + } + return exports; + } function tryGetMemberInModuleExports(memberName, moduleSymbol) { var symbolTable = getExportsOfModule(moduleSymbol); if (symbolTable) { - return symbolTable[memberName]; + return symbolTable.get(memberName); } } function getExportsOfSymbol(symbol) { @@ -25760,24 +26180,28 @@ var ts; * Not passing `lookupTable` and `exportNode` disables this collection, and just extends the tables */ function extendExportSymbols(target, source, lookupTable, exportNode) { - for (var id in source) { - if (id !== "default" && !target[id]) { - target[id] = source[id]; + source && source.forEach(function (sourceSymbol, id) { + if (id === "default") + return; + var targetSymbol = target.get(id); + if (!targetSymbol) { + target.set(id, sourceSymbol); if (lookupTable && exportNode) { - lookupTable[id] = { + lookupTable.set(id, { specifierText: ts.getTextOfNode(exportNode.moduleSpecifier) - }; + }); } } - else if (lookupTable && exportNode && id !== "default" && target[id] && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { - if (!lookupTable[id].exportsWithDuplicate) { - lookupTable[id].exportsWithDuplicate = [exportNode]; + else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) { + var collisionTracker = lookupTable.get(id); + if (!collisionTracker.exportsWithDuplicate) { + collisionTracker.exportsWithDuplicate = [exportNode]; } else { - lookupTable[id].exportsWithDuplicate.push(exportNode); + collisionTracker.exportsWithDuplicate.push(exportNode); } } - } + }); } function getExportsForModule(moduleSymbol) { var visitedSymbols = []; @@ -25793,27 +26217,27 @@ var ts; visitedSymbols.push(symbol); var symbols = ts.cloneMap(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - var exportStars = symbol.exports["__export"]; + var exportStars = symbol.exports.get("__export"); if (exportStars) { var nestedSymbols = ts.createMap(); - var lookupTable = ts.createMap(); + var lookupTable_1 = ts.createMap(); for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { var node = _a[_i]; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable, node); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); } - for (var id in lookupTable) { - var exportsWithDuplicate = lookupTable[id].exportsWithDuplicate; + lookupTable_1.forEach(function (_a, id) { + var exportsWithDuplicate = _a.exportsWithDuplicate; // It's not an error if the file with multiple `export *`s with duplicate names exports a member with that name itself - if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols[id]) { - continue; + if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) { + return; } - for (var _b = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _b < exportsWithDuplicate_1.length; _b++) { - var node = exportsWithDuplicate_1[_b]; - diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable[id].specifierText, id)); + for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) { + var node = exportsWithDuplicate_1[_i]; + diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable_1.get(id).specifierText, id)); } - } + }); extendExportSymbols(symbols, nestedSymbols); } return symbols; @@ -25835,26 +26259,13 @@ var ts; : symbol; } function symbolIsValue(symbol) { - // If it is an instantiated symbol, then it is a value if the symbol it is an - // instantiation of is a value. - if (symbol.flags & 16777216 /* Instantiated */) { - return symbolIsValue(getSymbolLinks(symbol).target); - } - // If the symbol has the value flag, it is trivially a value. - if (symbol.flags & 107455 /* Value */) { - return true; - } - // If it is an alias, then it is a value if the symbol it resolves to is a value. - if (symbol.flags & 8388608 /* Alias */) { - return (resolveAlias(symbol).flags & 107455 /* Value */) !== 0; - } - return false; + return !!(symbol.flags & 107455 /* Value */ || symbol.flags & 8388608 /* Alias */ && resolveAlias(symbol).flags & 107455 /* Value */); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 150 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 151 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -25882,6 +26293,9 @@ var ts; type.symbol = symbol; return type; } + function createTypeofType() { + return getUnionType(ts.convertToArray(typeofEQFacts.keys(), function (s) { return getLiteralTypeForText(32 /* StringLiteral */, s); })); + } // A reserved member name starts with two underscores, but the third character cannot be an underscore // or the @ symbol. A third underscore indicates an escaped form of an identifer that started // with at least two underscores. The @ character indicates that the name is denoted by a well known ES @@ -25894,16 +26308,15 @@ var ts; } function getNamedMembers(members) { var result; - for (var id in members) { + members.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { if (!result) result = []; - var symbol = members[id]; if (symbolIsValue(symbol)) { result.push(symbol); } } - } + }); return result || emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -25922,20 +26335,20 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { + for (var location = enclosingDeclaration; location; location = location.parent) { // Locals of a source file are not in scope (because they get merged into the global symbol table) - if (location_1.locals && !isGlobalSourceFile(location_1)) { - if (result = callback(location_1.locals)) { + if (location.locals && !isGlobalSourceFile(location)) { + if (result = callback(location.locals)) { return result; } } - switch (location_1.kind) { - case 262 /* SourceFile */: - if (!ts.isExternalOrCommonJsModule(location_1)) { + switch (location.kind) { + case 264 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 231 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location_1).exports)) { + case 232 /* ModuleDeclaration */: + if (result = callback(getSymbolOfNode(location).exports)) { return result; } break; @@ -25979,14 +26392,14 @@ var ts; } function trySymbolTable(symbols) { // If symbol is directly available by its name in the symbol table - if (isAccessible(symbols[symbol.name])) { + if (isAccessible(symbols.get(symbol.name))) { return [symbol]; } // Check if symbol is any of the alias - return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { + return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -26015,7 +26428,7 @@ var ts; var qualify = false; forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { // If symbol of this name is not available in the symbol table we are ok - var symbolFromSymbolTable = symbolTable[symbol.name]; + var symbolFromSymbolTable = symbolTable.get(symbol.name); if (!symbolFromSymbolTable) { // Continue to the next symbol table return false; @@ -26026,7 +26439,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -26041,10 +26454,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 147 /* PropertyDeclaration */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 148 /* PropertyDeclaration */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: continue; default: return false; @@ -26125,7 +26538,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 264 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -26166,12 +26579,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 160 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 161 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 141 /* QualifiedName */ || entityName.kind === 177 /* PropertyAccessExpression */ || - entityName.parent.kind === 235 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 142 /* QualifiedName */ || entityName.kind === 178 /* PropertyAccessExpression */ || + entityName.parent.kind === 236 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -26267,10 +26680,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 166 /* ParenthesizedType */) { + while (node.kind === 167 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 229 /* TypeAliasDeclaration */) { + if (node.kind === 230 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -26278,29 +26691,29 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 232 /* ModuleBlock */ && + node.parent.kind === 233 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { return type.flags & 32 /* StringLiteral */ ? "\"" + ts.escapeString(type.text) + "\"" : type.text; } - function getSymbolDisplayBuilder() { - function getNameOfSymbol(symbol) { - if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - if (declaration.name) { - return ts.declarationNameToString(declaration.name); - } - switch (declaration.kind) { - case 197 /* ClassExpression */: - return "(Anonymous class)"; - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - return "(Anonymous function)"; - } + function getNameOfSymbol(symbol) { + if (symbol.declarations && symbol.declarations.length) { + var declaration = symbol.declarations[0]; + if (declaration.name) { + return ts.declarationNameToString(declaration.name); + } + switch (declaration.kind) { + case 198 /* ClassExpression */: + return "(Anonymous class)"; + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + return "(Anonymous function)"; } - return symbol.name; } + return symbol.name; + } + function getSymbolDisplayBuilder() { /** * Writes only the name of the symbol out to the writer. Uses the original source text * for the name of the symbol if it is available to match how the user wrote the name. @@ -26342,7 +26755,7 @@ var ts; if (parentSymbol) { // Write type arguments of instantiated class/interface here if (flags & 1 /* WriteTypeParametersOrArguments */) { - if (symbol.flags & 16777216 /* Instantiated */) { + if (getCheckFlags(symbol) & 1 /* Instantiated */) { buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); } else { @@ -26370,9 +26783,9 @@ var ts; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - var parent_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_6) { - walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + walkSymbol(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); } } if (accessibleSymbolChain) { @@ -26410,7 +26823,7 @@ var ts; function writeType(type, flags) { var nextFlags = flags & ~512 /* InTypeAlias */; // Write undefined/null type as any - if (type.flags & 16015 /* Intrinsic */) { + if (type.flags & 16793231 /* 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" @@ -26437,7 +26850,7 @@ var ts; else if (!(flags & 512 /* InTypeAlias */) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === 0 /* Accessible */) { var typeArguments = type.aliasTypeArguments; - writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); + writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, ts.length(typeArguments), nextFlags); } else if (type.flags & 196608 /* UnionOrIntersection */) { writeUnionOrIntersectionType(type, nextFlags); @@ -26522,14 +26935,14 @@ var ts; while (i < length_1) { // Find group of type arguments for type parameters with the same declaring container. var start = i; - var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); + writeSymbolTypeReference(parent, typeArguments, start, i, flags); writePunctuation(writer, 22 /* DotToken */); } } @@ -26556,7 +26969,8 @@ var ts; var symbol = type.symbol; if (symbol) { // Always use 'typeof T' for type of class, enum, and module objects - if (symbol.flags & (32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (384 /* Enum */ | 512 /* ValueModule */)) { writeTypeOfSymbol(type, flags); } else if (shouldWriteTypeOfFunctionSymbol()) { @@ -26595,7 +27009,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 262 /* SourceFile */ || declaration.parent.kind === 232 /* ModuleBlock */; + return declaration.parent.kind === 264 /* SourceFile */ || declaration.parent.kind === 233 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -26615,7 +27029,7 @@ var ts; writeSpace(writer); } buildSymbolDisplay(prop, writer); - if (prop.flags & 536870912 /* Optional */) { + if (prop.flags & 67108864 /* Optional */) { writePunctuation(writer, 54 /* QuestionToken */); } } @@ -26759,6 +27173,13 @@ var ts; writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } + var defaultType = getDefaultFromTypeParameter(tp); + if (defaultType) { + writeSpace(writer); + writePunctuation(writer, 57 /* EqualsToken */); + writeSpace(writer); + buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack); + } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; @@ -26776,16 +27197,20 @@ var ts; } writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); - buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); + var type = getTypeOfSymbol(p); + if (isRequiredInitializedParameter(parameterNode)) { + type = includeFalsyTypes(type, 2048 /* Undefined */); + } + buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { // We have to explicitly emit square bracket and bracket because these tokens are not stored inside the node. - if (bindingPattern.kind === 172 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 173 /* ObjectBindingPattern */) { writePunctuation(writer, 16 /* OpenBraceToken */); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); writePunctuation(writer, 17 /* CloseBraceToken */); } - else if (bindingPattern.kind === 173 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 174 /* ArrayBindingPattern */) { writePunctuation(writer, 20 /* OpenBracketToken */); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -26799,7 +27224,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 174 /* BindingElement */); + ts.Debug.assert(bindingElement.kind === 175 /* BindingElement */); if (bindingElement.propertyName) { writer.writeProperty(ts.getTextOfNode(bindingElement.propertyName)); writePunctuation(writer, 55 /* ColonToken */); @@ -26923,7 +27348,7 @@ var ts; writeKeyword(writer, 132 /* NumberKeyword */); break; case 0 /* String */: - writeKeyword(writer, 134 /* StringKeyword */); + writeKeyword(writer, 135 /* StringKeyword */); break; } writePunctuation(writer, 21 /* CloseBracketToken */); @@ -26959,75 +27384,75 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 174 /* BindingElement */: + case 175 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 224 /* VariableDeclaration */: + case 225 /* 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 231 /* ModuleDeclaration */: - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 226 /* FunctionDeclaration */: - case 230 /* EnumDeclaration */: - case 235 /* ImportEqualsDeclaration */: + case 232 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 227 /* FunctionDeclaration */: + case 231 /* EnumDeclaration */: + case 236 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_8 = getDeclarationContainer(node); + var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 235 /* ImportEqualsDeclaration */ && parent_8.kind !== 262 /* SourceFile */ && ts.isInAmbientContext(parent_8))) { - return isGlobalSourceFile(parent_8); + !(node.kind !== 236 /* ImportEqualsDeclaration */ && parent.kind !== 264 /* SourceFile */ && ts.isInAmbientContext(parent))) { + return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent_8); - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + return isDeclarationVisible(parent); + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: if (ts.getModifierFlags(node) & (8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so const it fall into next case statement - case 150 /* Constructor */: - case 154 /* ConstructSignature */: - case 153 /* CallSignature */: - case 155 /* IndexSignature */: - case 144 /* Parameter */: - case 232 /* ModuleBlock */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 161 /* TypeLiteral */: - case 157 /* TypeReference */: - case 162 /* ArrayType */: - case 163 /* TupleType */: - case 164 /* UnionType */: - case 165 /* IntersectionType */: - case 166 /* ParenthesizedType */: + case 151 /* Constructor */: + case 155 /* ConstructSignature */: + case 154 /* CallSignature */: + case 156 /* IndexSignature */: + case 145 /* Parameter */: + case 233 /* ModuleBlock */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 162 /* TypeLiteral */: + case 158 /* TypeReference */: + case 163 /* ArrayType */: + case 164 /* TupleType */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: + case 167 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 237 /* ImportClause */: - case 238 /* NamespaceImport */: - case 240 /* ImportSpecifier */: + case 238 /* ImportClause */: + case 239 /* NamespaceImport */: + case 241 /* ImportSpecifier */: return false; // Type parameters are always visible - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: // Source file and namespace export are always visible - case 262 /* SourceFile */: - case 234 /* NamespaceExportDeclaration */: + case 264 /* SourceFile */: + case 235 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return false; default: return false; @@ -27036,10 +27461,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 241 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 242 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 244 /* ExportSpecifier */) { + else if (node.parent.kind === 245 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -27132,12 +27557,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 224 /* VariableDeclaration */: - case 225 /* VariableDeclarationList */: - case 240 /* ImportSpecifier */: - case 239 /* NamedImports */: - case 238 /* NamespaceImport */: - case 237 /* ImportClause */: + case 225 /* VariableDeclaration */: + case 226 /* VariableDeclarationList */: + case 241 /* ImportSpecifier */: + case 240 /* NamedImports */: + case 239 /* NamespaceImport */: + case 238 /* ImportClause */: node = node.parent; break; default: @@ -27168,7 +27593,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 142 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 143 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 6144 /* Nullable */); }); @@ -27181,17 +27606,16 @@ var ts; var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name_17 = properties_2[_i]; - names[ts.getTextOfPropertyName(name_17)] = true; + var name = properties_2[_i]; + names.set(ts.getTextOfPropertyName(name), true); } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - var inNamesToRemove = prop.name in names; + var inNamesToRemove = names.has(prop.name); var isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */); - var isMethod = prop.flags & 8192 /* Method */; var isSetOnlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { - members[prop.name] = prop; + if (!inNamesToRemove && !isPrivate && !isClassMethod(prop) && !isSetOnlyAccessor) { + members.set(prop.name, prop); } } var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); @@ -27216,7 +27640,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 172 /* ObjectBindingPattern */) { + if (pattern.kind === 173 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -27233,8 +27657,8 @@ var ts; } else { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) - var name_18 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_18)) { + var name = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name)) { // computed properties with non-literal names are treated as 'any' return anyType; } @@ -27243,12 +27667,12 @@ var ts; } // 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. - var text = ts.getTextOfPropertyName(name_18); + var text = ts.getTextOfPropertyName(name); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); if (!type) { - error(name_18, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_18)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); return unknownType; } } @@ -27288,7 +27712,7 @@ var ts; getUnionType([type, checkExpressionCached(declaration.initializer)], /*subtypeReduction*/ true) : type; } - function getTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); if (jsdocType) { return getTypeFromTypeNode(jsdocType); @@ -27301,29 +27725,38 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 175 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 176 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048 /* Undefined */) : type; } + /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ + function removeOptionalityFromAnnotation(annotatedType, declaration) { + var annotationIncludesUndefined = strictNullChecks && + declaration.kind === 145 /* Parameter */ && + declaration.initializer && + getFalsyFlags(annotatedType) & 2048 /* Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048 /* Undefined */); + return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; + } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { if (declaration.flags & 65536 /* JavaScriptFile */) { // If this is a variable in a JavaScript file, then use the JSDoc type (if it has // one as its type), otherwise fallback to the below standard TS codepaths to // try to figure it out. - var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); + var type = getTypeForDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } } // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (declaration.parent.parent.kind === 213 /* ForInStatement */) { + if (declaration.parent.parent.kind === 214 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 /* TypeParameter */ | 262144 /* Index */) ? indexType : stringType; } - if (declaration.parent.parent.kind === 214 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 215 /* 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, @@ -27335,10 +27768,11 @@ var ts; } // Use type from type annotation if one is present if (declaration.type) { - return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); + var declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + return addOptionality(declaredType, /*optional*/ declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536 /* JavaScriptFile */) && - declaration.kind === 224 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 225 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -27352,11 +27786,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 144 /* Parameter */) { + if (declaration.kind === 145 /* 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 === 152 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 151 /* GetAccessor */); + if (func.kind === 153 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 152 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -27385,8 +27819,13 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); } + if (ts.isJsxAttribute(declaration)) { + // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. + // I.e is sugar for + return trueType; + } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 259 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 261 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -27396,6 +27835,23 @@ var ts; // No type specified and nothing can be inferred return undefined; } + // Return the inferred type for a variable, parameter, or property declaration + function getTypeForJSSpecialPropertyDeclaration(declaration) { + var expression = declaration.kind === 193 /* BinaryExpression */ ? declaration : + declaration.kind === 178 /* PropertyAccessExpression */ ? ts.getAncestor(declaration, 193 /* BinaryExpression */) : + undefined; + if (!expression) { + return unknownType; + } + if (expression.flags & 65536 /* JavaScriptFile */) { + // If there is a JSDoc type, use it + var type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + return getWidenedType(type); + } + } + return getWidenedLiteralType(checkExpressionCached(expression.right)); + } // Return the type implied by a binding pattern element. This is the type of the initializer of the element if // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding // pattern. Otherwise, it is the type any. @@ -27428,11 +27884,11 @@ var ts; return; } var text = ts.getTextOfPropertyName(name); - var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0); + var flags = 4 /* Property */ | (e.initializer ? 67108864 /* Optional */ : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; - members[symbol.name] = symbol; + members.set(symbol.name, symbol); }); var result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { @@ -27467,7 +27923,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, includePatternInType, reportErrors) { - return pattern.kind === 172 /* ObjectBindingPattern */ + return pattern.kind === 173 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -27489,7 +27945,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. - if (declaration.kind === 258 /* PropertyAssignment */) { + if (declaration.kind === 260 /* PropertyAssignment */) { return type; } return getWidenedType(type); @@ -27506,14 +27962,14 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 144 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 145 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { // Handle prototype property - if (symbol.flags & 134217728 /* Prototype */) { + if (symbol.flags & 16777216 /* Prototype */) { return links.type = getTypeOfPrototypeProperty(symbol); } // Handle catch clause variables @@ -27522,10 +27978,10 @@ var ts; return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 241 /* ExportAssignment */) { + if (declaration.kind === 242 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 287 /* JSDocPropertyTag */ && declaration.typeExpression) { + if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 290 /* JSDocPropertyTag */ && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } // Handle variable, parameter or property @@ -27538,19 +27994,9 @@ var ts; // * exports.p = expr // * this.p = expr // * className.prototype.method = expr - if (declaration.kind === 192 /* BinaryExpression */ || - declaration.kind === 177 /* PropertyAccessExpression */ && declaration.parent.kind === 192 /* BinaryExpression */) { - // Use JS Doc type if present on parent expression statement - if (declaration.flags & 65536 /* JavaScriptFile */) { - var jsdocType = ts.getJSDocType(declaration.parent); - if (jsdocType) { - return links.type = getTypeFromTypeNode(jsdocType); - } - } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 192 /* BinaryExpression */ ? - checkExpressionCached(decl.right) : - checkExpressionCached(decl.parent.right); }); - type = getUnionType(declaredTypes, /*subtypeReduction*/ true); + if (declaration.kind === 193 /* BinaryExpression */ || + declaration.kind === 178 /* PropertyAccessExpression */ && declaration.parent.kind === 193 /* BinaryExpression */) { + type = getWidenedType(getUnionType(ts.map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), /*subtypeReduction*/ true)); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); @@ -27564,7 +28010,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 151 /* GetAccessor */) { + if (accessor.kind === 152 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -27584,10 +28030,10 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 151 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 152 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 152 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 153 /* SetAccessor */); if (getter && getter.flags & 65536 /* JavaScriptFile */) { - var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); + var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; } @@ -27629,7 +28075,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 151 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 152 /* 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)); } } @@ -27637,6 +28083,10 @@ var ts; } return links.type; } + function getBaseTypeVariableOfClass(symbol) { + var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); + return baseConstructorType.flags & 540672 /* TypeVariable */ ? baseConstructorType : undefined; + } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { @@ -27645,8 +28095,13 @@ var ts; } else { var type = createObjectType(16 /* Anonymous */, symbol); - links.type = strictNullChecks && symbol.flags & 536870912 /* Optional */ ? - includeFalsyTypes(type, 2048 /* Undefined */) : type; + if (symbol.flags & 32 /* Class */) { + var baseTypeVariable = getBaseTypeVariableOfClass(symbol); + links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; + } + else { + links.type = strictNullChecks && symbol.flags & 67108864 /* Optional */ ? includeFalsyTypes(type, 2048 /* Undefined */) : type; + } } } return links.type; @@ -27700,7 +28155,7 @@ var ts; return anyType; } function getTypeOfSymbol(symbol) { - if (symbol.flags & 16777216 /* Instantiated */) { + if (getCheckFlags(symbol) & 1 /* Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { @@ -27726,16 +28181,21 @@ var ts; function hasBaseType(type, checkBase) { return check(type); function check(type) { - var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); + if (getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + var target = getTargetType(type); + return target === checkBase || ts.forEach(getBaseTypes(target), check); + } + else if (type.flags & 131072 /* Intersection */) { + return ts.forEach(type.types, check); + } } } // Appends the type parameters given by a list of declarations to a set of type parameters and returns the resulting set. // The function allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set // in-place and returns the same array. function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { - var declaration = declarations_2[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -27755,9 +28215,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 227 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */ || - node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || - node.kind === 149 /* MethodDeclaration */ || node.kind === 185 /* ArrowFunction */) { + if (node.kind === 228 /* ClassDeclaration */ || node.kind === 198 /* ClassExpression */ || + node.kind === 227 /* FunctionDeclaration */ || node.kind === 185 /* FunctionExpression */ || + node.kind === 150 /* MethodDeclaration */ || node.kind === 186 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -27767,7 +28227,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, 228 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 229 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -27776,8 +28236,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 228 /* InterfaceDeclaration */ || node.kind === 227 /* ClassDeclaration */ || - node.kind === 197 /* ClassExpression */ || node.kind === 229 /* TypeAliasDeclaration */) { + if (node.kind === 229 /* InterfaceDeclaration */ || node.kind === 228 /* ClassDeclaration */ || + node.kind === 198 /* ClassExpression */ || node.kind === 230 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -27791,15 +28251,32 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } + // A type is a mixin constructor if it has a single construct signature taking no type parameters and a single + // rest parameter of type any[]. + function isMixinConstructorType(type) { + var signatures = getSignaturesOfType(type, 1 /* Construct */); + if (signatures.length === 1) { + var s = signatures[0]; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + } + return false; + } function isConstructorType(type) { - return type.flags & 32768 /* Object */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; + if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { + return true; + } + if (type.flags & 540672 /* TypeVariable */) { + var constraint = getBaseConstraintOfType(type); + return isValidBaseType(constraint) && isMixinConstructorType(constraint); + } + return false; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); } function getConstructorsForTypeArguments(type, typeArgumentNodes) { - var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; - return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + var typeArgCount = ts.length(typeArgumentNodes); + return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); @@ -27826,7 +28303,7 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 32768 /* Object */) { + if (baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */)) { // 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. resolveStructuredTypeMembers(baseConstructorType); @@ -27864,8 +28341,8 @@ var ts; } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - var baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & 32768 /* Object */)) { + var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); + if (!(baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */))) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -27900,7 +28377,7 @@ var ts; if (baseType === unknownType) { return; } - if (!(getObjectFlags(getTargetType(baseType)) & 3 /* ClassOrInterface */)) { + if (!isValidBaseType(baseType)) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -27926,16 +28403,22 @@ var ts; } return true; } + // A valid base type is any non-generic object type or intersection of non-generic + // object types. + function isValidBaseType(type) { + return type.flags & (32768 /* Object */ | 16777216 /* NonPrimitive */) && !isGenericMappedType(type) || + type.flags & 131072 /* Intersection */ && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); + } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 228 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 229 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { - if (getObjectFlags(getTargetType(baseType)) & 3 /* ClassOrInterface */) { + if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -27962,7 +28445,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 228 /* InterfaceDeclaration */) { + if (declaration.kind === 229 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -28000,7 +28483,7 @@ var ts; type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384 /* TypeParameter */); @@ -28019,7 +28502,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 286 /* JSDocTypedefTag */); + var declaration = ts.getDeclarationOfKind(symbol, 289 /* JSDocTypedefTag */); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -28030,7 +28513,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 229 /* TypeAliasDeclaration */); + declaration = ts.getDeclarationOfKind(symbol, 230 /* TypeAliasDeclaration */); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -28040,7 +28523,7 @@ var ts; // an instantiation of the type alias with the type parameters supplied as type arguments. links.typeParameters = typeParameters; links.instantiations = ts.createMap(); - links.instantiations[getTypeListId(typeParameters)] = type; + links.instantiations.set(getTypeListId(typeParameters), type); } } else { @@ -28057,14 +28540,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 /* NumericLiteral */ || - expr.kind === 190 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 191 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */ || - expr.kind === 70 /* Identifier */ && !!symbol.exports[expr.text]; + expr.kind === 70 /* Identifier */ && !!symbol.exports.get(expr.text); } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 230 /* EnumDeclaration */) { + if (declaration.kind === 231 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -28089,10 +28572,10 @@ var ts; enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { var memberTypeList = []; - var memberTypes = ts.createMap(); + var memberTypes = []; for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 230 /* EnumDeclaration */) { + if (declaration.kind === 231 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -28109,7 +28592,7 @@ var ts; if (memberTypeList.length > 1) { enumType.flags |= 65536 /* Union */; enumType.types = memberTypeList; - unionTypes[getTypeListId(memberTypeList)] = enumType; + unionTypes.set(getTypeListId(memberTypeList), enumType); } } } @@ -28130,9 +28613,6 @@ var ts; if (!links.declaredType) { var type = createType(16384 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 143 /* TypeParameter */).constraint) { - type.constraint = noConstraintType; - } links.declaredType = type; } return links.declaredType; @@ -28145,7 +28625,6 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0); if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { return getDeclaredTypeOfClassOrInterface(symbol); } @@ -28184,19 +28663,20 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: + case 133 /* ObjectKeyword */: case 104 /* VoidKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 94 /* NullKeyword */: case 129 /* NeverKeyword */: - case 171 /* LiteralType */: + case 172 /* LiteralType */: return true; - case 162 /* ArrayType */: + case 163 /* ArrayType */: return isIndependentType(node.elementType); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -28209,7 +28689,7 @@ var ts; // A function-like declaration is considered independent (free of this references) if it has a return type // annotation that is considered independent and if each parameter is considered independent. function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 150 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 151 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -28230,12 +28710,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return isIndependentVariableLikeDeclaration(declaration); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -28246,7 +28726,7 @@ var ts; var result = ts.createMap(); for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { var symbol = symbols_1[_i]; - result[symbol.name] = symbol; + result.set(symbol.name, symbol); } return result; } @@ -28256,15 +28736,15 @@ var ts; var result = ts.createMap(); for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { var symbol = symbols_2[_i]; - result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); + result.set(symbol.name, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } function addInheritedMembers(symbols, baseSymbols) { for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { var s = baseSymbols_1[_i]; - if (!symbols[s.name]) { - symbols[s.name] = s; + if (!symbols.has(s.name)) { + symbols.set(s.name, s); } } } @@ -28272,8 +28752,8 @@ var ts; if (!type.declaredProperties) { var symbol = type.symbol; type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members.get("__call")); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members.get("__new")); type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0 /* String */); type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1 /* Number */); } @@ -28281,7 +28761,14 @@ var ts; } function getTypeWithThisArgument(type, thisArgument) { if (getObjectFlags(type) & 4 /* Reference */) { - return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + var target = type.target; + var typeArguments = type.typeArguments; + if (ts.length(target.typeParameters) === ts.length(typeArguments)) { + return createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); + } + } + else if (type.flags & 131072 /* Intersection */) { + return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument); })); } return type; } @@ -28317,7 +28804,7 @@ var ts; for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) { var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0 /* String */); @@ -28360,13 +28847,14 @@ var ts; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); - var typeArgCount = typeArguments ? typeArguments.length : 0; + var typeArgCount = ts.length(typeArguments); var result = []; for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { var baseSig = baseSignatures_1[_i]; - var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; - if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); + var typeParamCount = ts.length(baseSig.typeParameters); + if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -28429,7 +28917,7 @@ var ts; s = cloneSignature(signature); if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return getTypeOfSymbol(sig.thisParameter) || anyType; }), /*subtypeReduction*/ true); - s.thisParameter = createTransientSymbol(signature.thisParameter, thisType); + s.thisParameter = createSymbolWithType(signature.thisParameter, thisType); } // Clear resolved return type we possibly got from cloneSignature s.resolvedReturnType = undefined; @@ -28474,19 +28962,51 @@ var ts; function unionSpreadIndexInfos(info1, info2) { return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); } + function includeMixinType(type, types, index) { + var mixedTypes = []; + for (var i = 0; i < types.length; i++) { + if (i === index) { + mixedTypes.push(type); + } + else if (isMixinConstructorType(types[i])) { + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* Construct */)[0])); + } + } + return getIntersectionType(mixedTypes); + } 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 stringIndexInfo = undefined; - var numberIndexInfo = undefined; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + var stringIndexInfo; + var numberIndexInfo; + var types = type.types; + var mixinCount = ts.countWhere(types, isMixinConstructorType); + var _loop_3 = function (i) { + var t = type.types[i]; + // When an intersection type contains mixin constructor types, the construct signatures from + // those types are discarded and their return types are mixed into the return types of all + // other construct signatures in the intersection type. For example, the intersection type + // '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature + // 'new(s: string) => A & B'. + if (mixinCount === 0 || mixinCount === types.length && i === 0 || !isMixinConstructorType(t)) { + var signatures = getSignaturesOfType(t, 1 /* Construct */); + if (signatures.length && mixinCount > 0) { + signatures = ts.map(signatures, function (s) { + var clone = cloneSignature(s); + clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, i); + return clone; + }); + } + constructSignatures = ts.concatenate(constructSignatures, signatures); + } callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1 /* Construct */)); stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0 /* String */)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); + }; + for (var i = 0; i < types.length; i++) { + _loop_3(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } @@ -28505,8 +29025,8 @@ var ts; } else if (symbol.flags & 2048 /* TypeLiteral */) { var members = symbol.members; - var callSignatures = getSignaturesOfSymbol(members["__call"]); - var constructSignatures = getSignaturesOfSymbol(members["__new"]); + var callSignatures = getSignaturesOfSymbol(members.get("__call")); + var constructSignatures = getSignaturesOfSymbol(members.get("__new")); var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0 /* String */); var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1 /* Number */); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -28520,14 +29040,14 @@ var ts; } if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 32768 /* Object */) { + if (baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */ | 540672 /* TypeVariable */)) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); + addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } } var numberIndexInfo = symbol.flags & 384 /* Enum */ ? enumNumberIndexInfo : undefined; @@ -28552,12 +29072,15 @@ var ts; var typeParameter = getTypeParameterFromMappedType(type); var constraintType = getConstraintTypeFromMappedType(type); var templateType = getTemplateTypeFromMappedType(type); - var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); + var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateReadonly = !!type.declaration.readonlyToken; var templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === 168 /* TypeOperator */) { + if (type.declaration.typeParameter.constraint.kind === 169 /* TypeOperator */) { // We have a { [P in keyof T]: X } - forEachType(getLiteralTypeFromPropertyNames(modifiersType), addMemberForKeyType); + for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { + var propertySymbol = _a[_i]; + addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); + } if (getIndexInfoOfType(modifiersType, 0 /* String */)) { addMemberForKeyType(stringType); } @@ -28571,11 +29094,11 @@ var ts; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t) { + function addMemberForKeyType(t, propertySymbol) { // Create a mapper from T to the current iteration type constituent. Then, if the // mapped type is itself an instantiated type, combine the iteration mapper with the // instantiation mapper. - var iterationMapper = createUnaryTypeMapper(typeParameter, t); + var iterationMapper = createTypeMapper([typeParameter], [t]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; var propType = instantiateType(templateType, templateMapper); // If the current iteration type constituent is a string literal type, create a property. @@ -28583,11 +29106,14 @@ var ts; if (t.flags & 32 /* StringLiteral */) { var propName = t.text; var modifiersProp = getPropertyOfType(modifiersType, propName); - var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 536870912 /* Optional */); - var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | (isOptional ? 536870912 /* Optional */ : 0), propName); + var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 67108864 /* Optional */); + var prop = createSymbol(4 /* Property */ | (isOptional ? 67108864 /* Optional */ : 0), propName); + prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 4 /* Readonly */ : 0; prop.type = propType; - prop.isReadonly = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp); - members[propName] = prop; + if (propertySymbol) { + prop.mappedTypeOrigin = propertySymbol; + } + members.set(propName, prop); } else if (t.flags & 2 /* String */) { stringIndexInfo = createIndexInfo(propType, templateReadonly); @@ -28611,7 +29137,7 @@ var ts; function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { var constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === 168 /* TypeOperator */) { + if (constraintDeclaration.kind === 169 /* TypeOperator */) { // If the constraint declaration is a 'keyof T' node, the modifiers type is T. We check // AST nodes here because, when T is a non-generic type, the logic below eagerly resolves // 'keyof T' to a literal union type and we can't recover T from that type. @@ -28629,9 +29155,6 @@ var ts; } return type.modifiersType; } - function getErasedTemplateTypeFromMappedType(type) { - return instantiateType(getTemplateTypeFromMappedType(type), createUnaryTypeMapper(getTypeParameterFromMappedType(type), anyType)); - } function isGenericMappedType(type) { if (getObjectFlags(type) & 32 /* Mapped */) { var constraintType = getConstraintTypeFromMappedType(type); @@ -28676,38 +29199,35 @@ var ts; function getPropertyOfObjectType(type, name) { if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } } } 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]; - getUnionOrIntersectionProperty(type, prop.name); - } - // 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 & 65536 /* Union */) { - break; - } - } - var props = type.resolvedProperties; - if (props) { - var result = []; - for (var key in props) { - var prop = props[key]; - // We need to filter out partial properties in union types - if (!(prop.flags & 268435456 /* SyntheticProperty */ && prop.isPartial)) { - result.push(prop); + if (!type.resolvedProperties) { + var members = ts.createMap(); + 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]; + if (!members.has(prop.name)) { + var combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.name); + if (combinedProp) { + members.set(prop.name, combinedProp); + } + } + } + // 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 & 65536 /* Union */) { + break; } } - return result; + type.resolvedProperties = getNamedMembers(members); } - return emptyArray; + return type.resolvedProperties; } function getPropertiesOfType(type) { type = getApparentType(type); @@ -28715,19 +29235,99 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } + function getConstraintOfType(type) { + return type.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + } + function getConstraintOfTypeParameter(typeParameter) { + return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; + } + function getBaseConstraintOfType(type) { + var constraint = getResolvedBaseConstraint(type); + return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + } + function hasNonCircularBaseConstraint(type) { + return getResolvedBaseConstraint(type) !== circularConstraintType; + } /** - * The apparent type of a type parameter is the base constraint instantiated with the type parameter - * as the type argument for the 'this' type. + * Return the resolved base constraint of a type variable. The noConstraintType singleton is returned if the + * type variable has no constraint, and the circularConstraintType singleton is returned if the constraint + * circularly references the type variable. */ - function getApparentTypeOfTypeVariable(type) { - if (!type.resolvedApparentType) { - var constraintType = getConstraintOfTypeVariable(type); - while (constraintType && constraintType.flags & 16384 /* TypeParameter */) { - constraintType = getConstraintOfTypeVariable(constraintType); - } - type.resolvedApparentType = getTypeWithThisArgument(constraintType || emptyObjectType, type); + function getResolvedBaseConstraint(type) { + var typeStack; + var circular; + if (!type.resolvedBaseConstraint) { + typeStack = []; + var constraint = getBaseConstraint(type); + type.resolvedBaseConstraint = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type); } - return type.resolvedApparentType; + return type.resolvedBaseConstraint; + function getBaseConstraint(t) { + if (ts.contains(typeStack, t)) { + circular = true; + return undefined; + } + typeStack.push(t); + var result = computeBaseConstraint(t); + typeStack.pop(); + return result; + } + function computeBaseConstraint(t) { + if (t.flags & 16384 /* TypeParameter */) { + var constraint = getConstraintFromTypeParameter(t); + return t.isThisType ? constraint : + constraint ? getBaseConstraint(constraint) : undefined; + } + if (t.flags & 196608 /* UnionOrIntersection */) { + var types = t.types; + var baseTypes = []; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var type_1 = types_2[_i]; + var baseType = getBaseConstraint(type_1); + if (baseType) { + baseTypes.push(baseType); + } + } + return t.flags & 65536 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 131072 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + undefined; + } + if (t.flags & 262144 /* Index */) { + return stringType; + } + if (t.flags & 524288 /* IndexedAccess */) { + var baseObjectType = getBaseConstraint(t.objectType); + var baseIndexType = getBaseConstraint(t.indexType); + var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; + return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + } + return t; + } + } + function getApparentTypeOfIntersectionType(type) { + return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type)); + } + /** + * Gets the default type for a type parameter. + * + * If the type parameter is the result of an instantiation, this gets the instantiated + * default type of its target. If the type parameter has no default type, `undefined` + * is returned. + * + * This function *does not* perform a circularity check. + */ + function getDefaultFromTypeParameter(typeParameter) { + if (!typeParameter.default) { + if (typeParameter.target) { + var targetDefault = getDefaultFromTypeParameter(typeParameter.target); + typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType; + } + else { + var defaultDeclaration = typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameter(decl) && decl.default; }); + typeParameter.default = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType; + } + } + return typeParameter.default === noConstraintType ? undefined : typeParameter.default; } /** * For a type parameter, return the base constraint of the type parameter. For the string, number, @@ -28735,26 +29335,30 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - var t = type.flags & 540672 /* TypeVariable */ ? getApparentTypeOfTypeVariable(type) : type; - return t.flags & 262178 /* StringLike */ ? globalStringType : - t.flags & 340 /* NumberLike */ ? globalNumberType : - t.flags & 136 /* BooleanLike */ ? globalBooleanType : - t.flags & 512 /* ESSymbol */ ? getGlobalESSymbolType() : - t; + var t = type.flags & 540672 /* TypeVariable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; + return t.flags & 131072 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 262178 /* StringLike */ ? globalStringType : + t.flags & 340 /* NumberLike */ ? globalNumberType : + t.flags & 136 /* BooleanLike */ ? globalBooleanType : + t.flags & 512 /* ESSymbol */ ? getGlobalESSymbolType() : + t.flags & 16777216 /* NonPrimitive */ ? emptyObjectType : + t; } function createUnionOrIntersectionProperty(containingType, name) { - var types = containingType.types; var props; + var types = containingType.types; + var isUnion = containingType.flags & 65536 /* Union */; + var excludeModifiers = isUnion ? 24 /* NonPublicAccessibilityModifier */ : 0; // Flags we want to propagate to the result if they exist in all source symbols - var commonFlags = (containingType.flags & 131072 /* Intersection */) ? 536870912 /* Optional */ : 0 /* None */; - var isReadonly = false; - var isPartial = false; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var current = types_2[_i]; + var commonFlags = isUnion ? 0 /* None */ : 67108864 /* Optional */; + var checkFlags = 2 /* SyntheticProperty */; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var current = types_3[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */))) { + var modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0; + if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; if (!props) { props = [prop]; @@ -28762,25 +29366,26 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } - if (isReadonlySymbol(prop)) { - isReadonly = true; - } + checkFlags |= (isReadonlySymbol(prop) ? 4 /* Readonly */ : 0) | + (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 32 /* ContainsPublic */ : 0) | + (modifiers & 16 /* Protected */ ? 64 /* ContainsProtected */ : 0) | + (modifiers & 8 /* Private */ ? 128 /* ContainsPrivate */ : 0) | + (modifiers & 32 /* Static */ ? 256 /* ContainsStatic */ : 0); } - else if (containingType.flags & 65536 /* Union */) { - isPartial = true; + else if (isUnion) { + checkFlags |= 8 /* Partial */; } } } if (!props) { return undefined; } - if (props.length === 1 && !isPartial) { + if (props.length === 1 && !(checkFlags & 8 /* Partial */)) { return props[0]; } var propTypes = []; var declarations = []; var commonType = undefined; - var hasNonUniformType = false; for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; if (prop.declarations) { @@ -28791,17 +29396,15 @@ var ts; commonType = type; } else if (type !== commonType) { - hasNonUniformType = true; + checkFlags |= 16 /* HasNonUniformType */; } propTypes.push(type); } - var result = createSymbol(4 /* Property */ | 67108864 /* Transient */ | 268435456 /* SyntheticProperty */ | commonFlags, name); + var result = createSymbol(4 /* Property */ | commonFlags, name); + result.checkFlags = checkFlags; result.containingType = containingType; - result.hasNonUniformType = hasNonUniformType; - result.isPartial = isPartial; result.declarations = declarations; - result.isReadonly = isReadonly; - result.type = containingType.flags & 65536 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } // Return the symbol for a given property in a union or intersection type, or undefined if the property @@ -28810,12 +29413,12 @@ var ts; // these partial properties when identifying discriminant properties, but otherwise they are filtered out // and do not appear to be present in the union type. function getUnionOrIntersectionProperty(type, name) { - var properties = type.resolvedProperties || (type.resolvedProperties = ts.createMap()); - var property = properties[name]; + var properties = type.propertyCache || (type.propertyCache = ts.createMap()); + var property = properties.get(name); if (!property) { property = createUnionOrIntersectionProperty(type, name); if (property) { - properties[name] = property; + properties.set(name, property); } } return property; @@ -28823,7 +29426,7 @@ var ts; function getPropertyOfUnionOrIntersectionType(type, name) { var property = getUnionOrIntersectionProperty(type, name); // We need to filter out partial properties in union types - return property && !(property.flags & 268435456 /* SyntheticProperty */ && property.isPartial) ? property : undefined; + return property && !(getCheckFlags(property) & 8 /* Partial */) ? property : undefined; } /** * Return the symbol for the property with the given name in the given type. Creates synthetic union properties when @@ -28837,7 +29440,7 @@ var ts; type = getApparentType(type); if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } @@ -28926,16 +29529,16 @@ var ts; } function symbolsToArray(symbols) { var result = []; - for (var id in symbols) { + symbols.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { - result.push(symbols[id]); + result.push(symbol); } - } + }); return result; } function isJSDocOptionalParameter(node) { if (node.flags & 65536 /* JavaScriptFile */) { - if (node.type && node.type.kind === 274 /* JSDocOptionalType */) { + if (node.type && node.type.kind === 277 /* JSDocOptionalType */) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -28946,7 +29549,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 274 /* JSDocOptionalType */; + return paramTag.typeExpression.type.kind === 277 /* JSDocOptionalType */; } } } @@ -28971,6 +29574,12 @@ var ts; ts.Debug.assert(parameterIndex >= 0); return parameterIndex >= signature.minArgumentCount; } + var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); + if (iife) { + return !node.type && + !node.dotDotDotToken && + ts.indexOf(node.parent.parameters, node) >= iife.arguments.length; + } return false; } function createTypePredicateFromTypePredicateNode(node) { @@ -28990,15 +29599,63 @@ var ts; }; } } + /** + * Gets the minimum number of type arguments needed to satisfy all non-optional type + * parameters. + */ + function getMinTypeArgumentCount(typeParameters) { + var minTypeArgumentCount = 0; + if (typeParameters) { + for (var i = 0; i < typeParameters.length; i++) { + if (!getDefaultFromTypeParameter(typeParameters[i])) { + minTypeArgumentCount = i + 1; + } + } + } + return minTypeArgumentCount; + } + /** + * Fill in default types for unsupplied type arguments. If `typeArguments` is undefined + * when a default type is supplied, a new array will be created and returned. + * + * @param typeArguments The supplied type arguments. + * @param typeParameters The requested type parameters. + * @param minTypeArgumentCount The minimum number of required type arguments. + */ + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount) { + var numTypeParameters = ts.length(typeParameters); + if (numTypeParameters) { + var numTypeArguments = ts.length(typeArguments); + if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + if (!typeArguments) { + typeArguments = []; + } + // Map an unsatisfied type parameter with a default type. + // If a type parameter does not have a default type, or if the default type + // is a forward reference, the empty object type is used. + for (var i = numTypeArguments; i < numTypeParameters; i++) { + typeArguments[i] = emptyObjectType; + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + var mapper = createTypeMapper(typeParameters, typeArguments); + var defaultType = getDefaultFromTypeParameter(typeParameters[i]); + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + } + } + } + return typeArguments; + } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; var hasLiteralTypes = false; - var minArgumentCount = -1; + var minArgumentCount = 0; var thisParameter = undefined; var hasThisParameter = void 0; + var iife = ts.getImmediatelyInvokedFunctionExpression(declaration); var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); + var isUntypedSignatureInJSFile = !iife && !isJSConstructSignature && ts.isInJavaScriptFile(declaration) && !ts.hasJSDocParameterTags(declaration); // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct // signature. @@ -29017,43 +29674,36 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 171 /* LiteralType */) { + if (param.type && param.type.kind === 172 /* LiteralType */) { hasLiteralTypes = true; } - if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { - if (minArgumentCount < 0) { - minArgumentCount = i - (hasThisParameter ? 1 : 0); - } - } - else { - // If we see any required parameters, it means the prior ones were not in fact optional. - minArgumentCount = -1; + // Record a new minimum argument count if this is not an optional parameter + var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken || + iife && parameters.length > iife.arguments.length && !param.type || + isJSDocOptionalParameter(param) || + isUntypedSignatureInJSFile; + if (!isOptionalParameter_1) { + minArgumentCount = parameters.length; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 151 /* GetAccessor */ || declaration.kind === 152 /* SetAccessor */) && + if ((declaration.kind === 152 /* GetAccessor */ || declaration.kind === 153 /* SetAccessor */) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 151 /* GetAccessor */ ? 152 /* SetAccessor */ : 151 /* GetAccessor */; + var otherKind = declaration.kind === 152 /* GetAccessor */ ? 153 /* SetAccessor */ : 152 /* GetAccessor */; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); - } - if (isJSConstructSignature) { - minArgumentCount--; - } - var classType = declaration.kind === 150 /* Constructor */ ? + var classType = declaration.kind === 151 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 156 /* TypePredicate */ ? + var typePredicate = declaration.type && declaration.type.kind === 157 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -29078,8 +29728,8 @@ var ts; } // 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 === 151 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 152 /* SetAccessor */); + if (declaration.kind === 152 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 153 /* SetAccessor */); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -29093,20 +29743,20 @@ var ts; for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 226 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 275 /* JSDocFunctionType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 278 /* JSDocFunctionType */: // 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). @@ -29177,9 +29827,14 @@ var ts; return anyType; } function getSignatureInstantiation(signature, typeArguments) { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); - return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + var instantiation = instantiations.get(id); + if (!instantiation) { + instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments)); + } + return instantiation; } function createSignatureInstantiation(signature, typeArguments) { return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), /*eraseTypeParameters*/ true); @@ -29198,7 +29853,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 150 /* Constructor */ || signature.declaration.kind === 154 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 151 /* Constructor */ || signature.declaration.kind === 155 /* ConstructSignature */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = emptyArray; @@ -29209,10 +29864,10 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members["__index"]; + return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 132 /* NumberKeyword */ : 134 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 132 /* NumberKeyword */ : 135 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -29239,21 +29894,9 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 143 /* TypeParameter */).constraint; + return ts.getDeclarationOfKind(type.symbol, 144 /* TypeParameter */).constraint; } - function hasConstraintReferenceTo(type, target) { - var checked; - while (type && type.flags & 16384 /* TypeParameter */ && !(type.isThisType) && !ts.contains(checked, type)) { - if (type === target) { - return true; - } - (checked || (checked = [])).push(type); - var constraintDeclaration = getConstraintDeclaration(type); - type = constraintDeclaration && getTypeFromTypeNode(constraintDeclaration); - } - return false; - } - function getConstraintOfTypeParameter(typeParameter) { + function getConstraintFromTypeParameter(typeParameter) { if (!typeParameter.constraint) { if (typeParameter.target) { var targetConstraint = getConstraintOfTypeParameter(typeParameter.target); @@ -29261,23 +29904,13 @@ var ts; } else { var constraintDeclaration = getConstraintDeclaration(typeParameter); - var constraint = getTypeFromTypeNode(constraintDeclaration); - if (hasConstraintReferenceTo(constraint, typeParameter)) { - error(constraintDeclaration, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); - constraint = unknownType; - } - typeParameter.constraint = constraint; + typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : noConstraintType; } } return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } - function getConstraintOfTypeVariable(type) { - return type.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 524288 /* IndexedAccess */ ? type.constraint : - undefined; - } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 143 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 144 /* TypeParameter */).parent); } function getTypeListId(types) { var result = ""; @@ -29308,8 +29941,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var type = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -29318,9 +29951,10 @@ var ts; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); - var type = target.instantiations[id]; + var type = target.instantiations.get(id); if (!type) { - type = target.instantiations[id] = createObjectType(4 /* Reference */, target.symbol); + type = createObjectType(4 /* Reference */, target.symbol); + target.instantiations.set(id, type); type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; type.typeArguments = typeArguments; @@ -29336,21 +29970,26 @@ var ts; return type; } function getTypeReferenceArity(type) { - return type.target.typeParameters ? type.target.typeParameters.length : 0; + return ts.length(type.target.typeParameters); } // Get type from reference to class or interface function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), minTypeArgumentCount, typeParameters.length); return unknownType; } // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + return createTypeReference(type, typeArguments); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -29363,7 +30002,11 @@ var ts; var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + var instantiation = links.instantiations.get(id); + if (!instantiation) { + links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + } + return instantiation; } // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include // references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the @@ -29372,8 +30015,12 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return unknownType; } var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); @@ -29395,11 +30042,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 157 /* TypeReference */: + case 158 /* TypeReference */: return node.typeName; - case 273 /* JSDocTypeReference */: + case 276 /* JSDocTypeReference */: return node.name; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -29425,7 +30072,7 @@ var ts; if (symbol.flags & 524288 /* TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 /* Value */ && node.kind === 273 /* JSDocTypeReference */) { + if (symbol.flags & 107455 /* Value */ && node.kind === 276 /* JSDocTypeReference */) { // A JSDocTypeReference may have resolved to a value (as opposed to a type). In // that case, the type of this reference is just the type of the value we resolved // to. @@ -29438,14 +30085,14 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 273 /* JSDocTypeReference */) { + if (node.kind === 276 /* JSDocTypeReference */) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 157 /* TypeReference */ + var typeNameOrExpression = node.kind === 158 /* TypeReference */ ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -29477,12 +30124,12 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var declaration = declarations_4[_i]; switch (declaration.kind) { - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 230 /* EnumDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: return declaration; } } @@ -29495,7 +30142,7 @@ var ts; error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return arity ? emptyGenericType : emptyObjectType; } - if ((type.typeParameters ? type.typeParameters.length : 0) !== arity) { + if (ts.length(type.typeParameters) !== arity) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); return arity ? emptyGenericType : emptyObjectType; } @@ -29567,7 +30214,7 @@ var ts; for (var i = 0; i < arity; i++) { var typeParameter = createType(16384 /* TypeParameter */); typeParameters.push(typeParameter); - var property = createSymbol(4 /* Property */ | 67108864 /* Transient */, "" + i); + var property = createSymbol(4 /* Property */, "" + i); property.type = typeParameter; properties.push(property); } @@ -29576,7 +30223,7 @@ var ts; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384 /* TypeParameter */); @@ -29660,14 +30307,14 @@ var ts; // 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 addTypesToUnion(typeSet, types) { - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var t = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var t = types_6[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -29675,8 +30322,8 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } @@ -29763,10 +30410,11 @@ var ts; return types[0]; } var id = getTypeListId(types); - var type = unionTypes[id]; + var type = unionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 6144 /* Nullable */); - type = unionTypes[id] = createType(65536 /* Union */ | propagatedFlags); + type = createType(65536 /* Union */ | propagatedFlags); + unionTypes.set(id, type); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -29791,14 +30439,17 @@ var ts; if (type.flags & 65536 /* Union */ && typeSet.unionIndex === undefined) { typeSet.unionIndex = typeSet.length; } - typeSet.push(type); + if (!(type.flags & 32768 /* Object */ && type.objectFlags & 16 /* Anonymous */ && + type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */) && containsIdenticalType(typeSet, type))) { + typeSet.push(type); + } } } // 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 addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; addTypeToIntersection(typeSet, type); } } @@ -29833,10 +30484,11 @@ var ts; /*subtypeReduction*/ false, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); - var type = intersectionTypes[id]; + var type = intersectionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 6144 /* Nullable */); - type = intersectionTypes[id] = createType(131072 /* Intersection */ | propagatedFlags); + type = createType(131072 /* Intersection */ | propagatedFlags); + intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -29886,28 +30538,10 @@ var ts; var type = createType(524288 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; - // We eagerly compute the constraint of the indexed access type such that circularity - // errors are immediately caught and reported. For example, class C { x: this["x"] } - // becomes an error only when the constraint is eagerly computed. - if (type.objectType.flags & 229376 /* StructuredType */) { - // The constraint of T[K], where T is an object, union, or intersection type, - // is the type of the string index signature of T, if any. - type.constraint = getIndexTypeOfType(type.objectType, 0 /* String */); - } - else if (type.objectType.flags & 540672 /* TypeVariable */) { - // The constraint of T[K], where T is a type variable, is A[K], where A is the - // apparent type of T. - var apparentType = getApparentTypeOfTypeVariable(type.objectType); - if (apparentType !== emptyObjectType) { - type.constraint = isTypeOfKind(type.indexType, 262178 /* StringLike */) ? - getIndexedAccessType(apparentType, type.indexType) : - getIndexTypeOfType(apparentType, 0 /* String */); - } - } return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 178 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode : undefined; var propName = indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */ | 256 /* EnumLiteral */) ? indexType.text : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -29955,7 +30589,7 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 178 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); } @@ -29969,12 +30603,12 @@ var ts; return unknownType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 178 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode : undefined; if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; } - var mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); + var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } @@ -29986,18 +30620,11 @@ var ts; // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. if (maybeTypeOfKind(indexType, 540672 /* TypeVariable */ | 262144 /* Index */) || - maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && !(accessNode && accessNode.kind === 178 /* ElementAccessExpression */) || + maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && !(accessNode && accessNode.kind === 179 /* ElementAccessExpression */) || isGenericMappedType(objectType)) { if (objectType.flags & 1 /* Any */) { return objectType; } - // We first check that the index type is assignable to 'keyof T' for the object type. - if (accessNode) { - if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { - error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); - return unknownType; - } - } // If the object type is a mapped type { [P in K]: E }, we instantiate E using a mapper that substitutes // the index type for P. For example, for an index access { [P in K]: Box }[X], we construct the // type Box. @@ -30006,7 +30633,11 @@ var ts; } // Otherwise we defer the operation by creating an indexed access type. var id = objectType.id + "," + indexType.id; - return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType)); + var type = indexedAccessTypes.get(id); + if (!type) { + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType)); + } + return type; } // In the following we resolve T[K] to the type of the property in T selected by K. var apparentObjectType = getApparentType(objectType); @@ -30050,7 +30681,7 @@ var ts; if (!links.resolvedType) { // Deferred resolution of members is handled by resolveObjectTypeMembers var aliasSymbol = getAliasSymbolForTypeNode(node); - if (ts.isEmpty(node.symbol.members) && !aliasSymbol) { + if (node.symbol.members.size === 0 && !aliasSymbol) { links.resolvedType = emptyTypeLiteralType; } else { @@ -30063,7 +30694,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 229 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 230 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -30074,7 +30705,7 @@ var ts; * this function should be called in a left folding style, with left = previous result of getSpreadType * and right = the new element to be spread. */ - function getSpreadType(left, right, isFromObjectLiteral) { + function getSpreadType(left, right) { if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { return anyType; } @@ -30087,10 +30718,13 @@ var ts; return left; } if (left.flags & 65536 /* Union */) { - return mapType(left, function (t) { return getSpreadType(t, right, isFromObjectLiteral); }); + return mapType(left, function (t) { return getSpreadType(t, right); }); } if (right.flags & 65536 /* Union */) { - return mapType(right, function (t) { return getSpreadType(left, t, isFromObjectLiteral); }); + return mapType(right, function (t) { return getSpreadType(left, t); }); + } + if (right.flags & 16777216 /* NonPrimitive */) { + return emptyObjectType; } var members = ts.createMap(); var skippedPrivateMembers = ts.createMap(); @@ -30108,42 +30742,45 @@ var ts; for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; // we approximate own properties as non-methods plus methods that are inside the object literal - var isOwnProperty = !(rightProp.flags & 8192 /* Method */) || isFromObjectLiteral; var isSetterWithoutGetter = rightProp.flags & 65536 /* SetAccessor */ && !(rightProp.flags & 32768 /* GetAccessor */); if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { - skippedPrivateMembers[rightProp.name] = true; + skippedPrivateMembers.set(rightProp.name, true); } - else if (isOwnProperty && !isSetterWithoutGetter) { - members[rightProp.name] = rightProp; + else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { + members.set(rightProp.name, rightProp); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { var leftProp = _c[_b]; if (leftProp.flags & 65536 /* SetAccessor */ && !(leftProp.flags & 32768 /* GetAccessor */) - || leftProp.name in skippedPrivateMembers) { + || skippedPrivateMembers.has(leftProp.name) + || isClassMethod(leftProp)) { continue; } - if (leftProp.name in members) { - var rightProp = members[leftProp.name]; + if (members.has(leftProp.name)) { + var rightProp = members.get(leftProp.name); var rightType = getTypeOfSymbol(rightProp); - if (maybeTypeOfKind(rightType, 2048 /* Undefined */) || rightProp.flags & 536870912 /* Optional */) { + if (maybeTypeOfKind(rightType, 2048 /* Undefined */) || rightProp.flags & 67108864 /* Optional */) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 /* Property */ | 67108864 /* Transient */ | (leftProp.flags & 536870912 /* Optional */); + var flags = 4 /* Property */ | (leftProp.flags & 67108864 /* Optional */); var result = createSymbol(flags, leftProp.name); + result.checkFlags = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp) ? 4 /* Readonly */ : 0; result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072 /* NEUndefined */)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; - result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); - members[leftProp.name] = result; + members.set(leftProp.name, result); } } else { - members[leftProp.name] = leftProp; + members.set(leftProp.name, leftProp); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function isClassMethod(prop) { + return prop.flags & 8192 /* Method */ && ts.find(prop.declarations, function (decl) { return ts.isClassLike(decl.parent); }); + } function createLiteralType(flags, text) { var type = createType(flags); type.text = text; @@ -30165,7 +30802,11 @@ var ts; } function getLiteralTypeForText(flags, text) { var map = flags & 32 /* StringLiteral */ ? stringLiteralTypes : numericLiteralTypes; - return map[text] || (map[text] = createLiteralType(flags, text)); + var type = map.get(text); + if (!type) { + map.set(text, type = createLiteralType(flags, text)); + } + return type; } function getTypeFromLiteralTypeNode(node) { var links = getNodeLinks(node); @@ -30193,9 +30834,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 228 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 229 /* InterfaceDeclaration */)) { if (!(ts.getModifierFlags(container) & 32 /* Static */) && - (container.kind !== 150 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 151 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -30212,87 +30853,89 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118 /* AnyKeyword */: - case 264 /* JSDocAllType */: - case 265 /* JSDocUnknownType */: + case 267 /* JSDocAllType */: + case 268 /* JSDocUnknownType */: return anyType; - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: return stringType; case 132 /* NumberKeyword */: return numberType; case 121 /* BooleanKeyword */: return booleanType; - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: return esSymbolType; case 104 /* VoidKeyword */: return voidType; - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: return undefinedType; case 94 /* NullKeyword */: return nullType; case 129 /* NeverKeyword */: return neverType; - case 290 /* JSDocNullKeyword */: + case 133 /* ObjectKeyword */: + return nonPrimitiveType; + case 293 /* JSDocNullKeyword */: return nullType; - case 291 /* JSDocUndefinedKeyword */: + case 294 /* JSDocUndefinedKeyword */: return undefinedType; - case 292 /* JSDocNeverKeyword */: + case 295 /* JSDocNeverKeyword */: return neverType; - case 167 /* ThisType */: + case 168 /* ThisType */: case 98 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 171 /* LiteralType */: + case 172 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 289 /* JSDocLiteralType */: + case 292 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); - case 157 /* TypeReference */: - case 273 /* JSDocTypeReference */: + case 158 /* TypeReference */: + case 276 /* JSDocTypeReference */: return getTypeFromTypeReference(node); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return booleanType; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 162 /* ArrayType */: - case 266 /* JSDocArrayType */: + case 163 /* ArrayType */: + case 269 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); - case 163 /* TupleType */: + case 164 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 164 /* UnionType */: - case 267 /* JSDocUnionType */: + case 165 /* UnionType */: + case 270 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node); - case 165 /* IntersectionType */: + case 166 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 166 /* ParenthesizedType */: - case 269 /* JSDocNullableType */: - case 270 /* JSDocNonNullableType */: - case 277 /* JSDocConstructorType */: - case 278 /* JSDocThisType */: - case 274 /* JSDocOptionalType */: + case 167 /* ParenthesizedType */: + case 272 /* JSDocNullableType */: + case 273 /* JSDocNonNullableType */: + case 280 /* JSDocConstructorType */: + case 281 /* JSDocThisType */: + case 277 /* JSDocOptionalType */: return getTypeFromTypeNode(node.type); - case 271 /* JSDocRecordType */: + case 274 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 161 /* TypeLiteral */: - case 288 /* JSDocTypeLiteral */: - case 275 /* JSDocFunctionType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 162 /* TypeLiteral */: + case 291 /* JSDocTypeLiteral */: + case 278 /* JSDocFunctionType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 168 /* TypeOperator */: + case 169 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 170 /* MappedType */: + case 171 /* MappedType */: return getTypeFromMappedTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 70 /* Identifier */: - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 268 /* JSDocTupleType */: + case 271 /* JSDocTupleType */: return getTypeFromJSDocTupleType(node); - case 276 /* JSDocVariadicType */: + case 279 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -30319,13 +30962,13 @@ var ts; var instantiations = mapper.instantiations || (mapper.instantiations = []); return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); } - function createUnaryTypeMapper(source, target) { + function makeUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } - function createBinaryTypeMapper(source1, target1, source2, target2) { + function makeBinaryTypeMapper(source1, target1, source2, target2) { return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; } - function createArrayTypeMapper(sources, targets) { + function makeArrayTypeMapper(sources, targets) { return function (t) { for (var i = 0; i < sources.length; i++) { if (t === sources[i]) { @@ -30336,16 +30979,24 @@ var ts; }; } function createTypeMapper(sources, targets) { - var count = sources.length; - var mapper = count == 1 ? createUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : - count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - createArrayTypeMapper(sources, targets); + var mapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : + makeArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; return mapper; } function createTypeEraser(sources) { return createTypeMapper(sources, undefined); } + /** + * Maps forward-references to later types parameters to the empty object type. + * This is used during inference when instantiating type parameter defaults. + */ + function createBackreferenceMapper(typeParameters, index) { + var mapper = function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; + mapper.mappedTypes = typeParameters; + return mapper; + } function getInferenceMapper(context) { if (!context.mapper) { var mapper = function (t) { @@ -30369,7 +31020,12 @@ var ts; } function combineTypeMappers(mapper1, mapper2) { var mapper = function (t) { return instantiateType(mapper1(t), mapper2); }; - mapper.mappedTypes = mapper1.mappedTypes; + mapper.mappedTypes = ts.concatenate(mapper1.mappedTypes, mapper2.mappedTypes); + return mapper; + } + function createReplacementMapper(source, target, baseMapper) { + var mapper = function (t) { return t === source ? target : baseMapper(t); }; + mapper.mappedTypes = baseMapper.mappedTypes; return mapper; } function cloneTypeParameter(typeParameter) { @@ -30417,7 +31073,7 @@ var ts; return result; } function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 16777216 /* Instantiated */) { + if (getCheckFlags(symbol) & 1 /* Instantiated */) { var links = getSymbolLinks(symbol); // If symbol being instantiated is itself a instantiation, fetch the original target and combine the // type mappers. This ensures that original type identities are properly preserved and that aliases @@ -30427,7 +31083,8 @@ var ts; } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(16777216 /* Instantiated */ | 67108864 /* Transient */ | symbol.flags, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); + result.checkFlags = 1 /* Instantiated */; result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -30459,10 +31116,7 @@ var ts; if (typeVariable_1 !== mappedTypeVariable) { return mapType(mappedTypeVariable, function (t) { if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); + return instantiateMappedObjectType(type, createReplacementMapper(typeVariable_1, t, mapper)); } return t; }); @@ -30493,23 +31147,23 @@ var ts; var node = symbol.declarations[0]; while (node) { switch (node.kind) { - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 226 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 228 /* InterfaceDeclaration */: - case 229 /* TypeAliasDeclaration */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -30519,14 +31173,19 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 228 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 229 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 275 /* JSDocFunctionType */: + case 171 /* MappedType */: + if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { + return true; + } + break; + case 278 /* JSDocFunctionType */: var func = node; for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { var p = _c[_b]; @@ -30535,8 +31194,8 @@ var ts; } } break; - case 231 /* ModuleDeclaration */: - case 262 /* SourceFile */: + case 232 /* ModuleDeclaration */: + case 264 /* SourceFile */: return false; } node = node.parent; @@ -30546,7 +31205,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 262 /* SourceFile */ || parentKind === 232 /* ModuleBlock */; + return parentKind === 264 /* SourceFile */ || parentKind === 233 /* ModuleBlock */; } return false; } @@ -30623,28 +31282,36 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return node.operatorToken.kind === 53 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return isContextSensitive(node.expression); + case 253 /* JsxAttributes */: + return ts.forEach(node.properties, isContextSensitive); + case 252 /* JsxAttribute */: + // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. + return node.initializer && isContextSensitive(node.initializer); + case 255 /* JsxExpression */: + // It is possible to that node.expression is undefined (e.g
) + return node.expression && isContextSensitive(node.expression); } return false; } @@ -30658,7 +31325,7 @@ var ts; return true; } // For arrow functions we now know we're not context sensitive. - if (node.kind === 185 /* ArrowFunction */) { + if (node.kind === 186 /* ArrowFunction */) { return false; } // If the first parameter is not an explicit 'this' parameter, then the function has @@ -30680,9 +31347,12 @@ var ts; result.properties = resolved.properties; result.callSignatures = emptyArray; result.constructSignatures = emptyArray; - type = result; + return result; } } + else if (type.flags & 131072 /* Intersection */) { + return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); + } return type; } // TYPE CHECKING @@ -30873,13 +31543,15 @@ var ts; return true; } var id = source.id + "," + target.id; - if (enumRelation[id] !== undefined) { - return enumRelation[id]; + var relation = enumRelation.get(id); + if (relation !== undefined) { + return relation; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & 256 /* RegularEnum */) || !(target.symbol.flags & 256 /* RegularEnum */) || (source.flags & 65536 /* Union */) !== (target.flags & 65536 /* Union */)) { - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } var targetEnumType = getTypeOfSymbol(target.symbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(source.symbol)); _i < _a.length; _i++) { @@ -30890,11 +31562,13 @@ var ts; if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, property.name, typeToString(target, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */)); } - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } } } - return enumRelation[id] = true; + enumRelation.set(id, true); + return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { if (target.flags & 8192 /* Never */) @@ -30915,6 +31589,8 @@ var ts; return true; if (source.flags & 4096 /* Null */ && (!strictNullChecks || target.flags & 4096 /* Null */)) return true; + if (source.flags & 32768 /* Object */ && target.flags & 16777216 /* NonPrimitive */) + return true; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & 1 /* Any */) return true; @@ -30946,12 +31622,12 @@ var ts; } if (source.flags & 32768 /* Object */ && target.flags & 32768 /* Object */) { var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { return related === 1 /* Succeeded */; } } - if (source.flags & 507904 /* StructuredOrTypeParameter */ || target.flags & 507904 /* StructuredOrTypeParameter */) { + if (source.flags & 1032192 /* StructuredOrTypeVariable */ || target.flags & 1032192 /* StructuredOrTypeVariable */) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -31130,16 +31806,6 @@ var ts; } } } - else { - // Given a type parameter K with a constraint keyof T, a type S is - // assignable to K if S is assignable to keyof T. - var constraint = getConstraintOfTypeParameter(target); - if (constraint && constraint.flags & 262144 /* Index */) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - return result; - } - } - } } else if (target.flags & 262144 /* Index */) { // A keyof S is related to a keyof T if T is related to S. @@ -31148,14 +31814,12 @@ var ts; return result; } } - // Given a type variable T with a constraint C, a type S is assignable to - // keyof T if S is assignable to keyof C. - if (target.type.flags & 540672 /* TypeVariable */) { - var constraint = getConstraintOfTypeVariable(target.type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } + // A type S is assignable to keyof T if S is assignable to keyof C, where C is the + // constraint of T. + var constraint = getConstraintOfType(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; } } } @@ -31169,8 +31833,9 @@ var ts; } // A type S is related to a type T[K] if S is related to A[K], where K is string-like and // A is the apparent type of S. - if (target.constraint) { - if (result = isRelatedTo(source, target.constraint, reportErrors)) { + var constraint = getBaseConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -31188,24 +31853,28 @@ var ts; } else { var constraint = getConstraintOfTypeParameter(source); - if (!constraint || constraint.flags & 1 /* Any */) { - constraint = emptyObjectType; - } - // The constraint may need to be further instantiated with its 'this' type. - constraint = getTypeWithThisArgument(constraint, source); - // Report constraint errors only if the constraint is not the empty object type - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; + // A type parameter with no constraint is not related to the non-primitive object type. + if (constraint || !(target.flags & 16777216 /* NonPrimitive */)) { + if (!constraint || constraint.flags & 1 /* Any */) { + constraint = emptyObjectType; + } + // The constraint may need to be further instantiated with its 'this' type. + constraint = getTypeWithThisArgument(constraint, source); + // Report constraint errors only if the constraint is not the empty object type + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } } else if (source.flags & 524288 /* IndexedAccess */) { // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and // A is the apparent type of S. - if (source.constraint) { - if (result = isRelatedTo(source.constraint, target, reportErrors)) { + var constraint = getBaseConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -31269,45 +31938,61 @@ var ts; // is considered known if the object type is empty and the check is for assignability, if the object type has // index signatures, or if the property is actually declared in the object type. In a union or intersection // type, a property is considered known if it is known in any constituent type. - function isKnownProperty(type, name) { + function isKnownProperty(type, name, isComparingJsxAttributes) { if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); - if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || - resolved.stringIndexInfo || - (resolved.numberIndexInfo && isNumericLiteralName(name)) || - getPropertyOfType(type, name)) { + if ((relation === assignableRelation || relation === comparableRelation) && + (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) { + return true; + } + else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) { + return true; + } + else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) { + // For JSXAttributes, if the attribute has a hyphenated name, consider that the attribute to be known. return true; } } else if (type.flags & 196608 /* UnionOrIntersection */) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (isKnownProperty(t, name)) { + if (isKnownProperty(t, name, isComparingJsxAttributes)) { return true; } } } return false; } - function isEmptyObjectType(t) { + function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && !t.stringIndexInfo && !t.numberIndexInfo; } + function isEmptyObjectType(type) { + return type.flags & 32768 /* Object */ && isEmptyResolvedType(resolveStructuredTypeMembers(type)); + } function hasExcessProperties(source, target, reportErrors) { if (maybeTypeOfKind(target, 32768 /* Object */) && !(getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + var isComparingJsxAttributes = !!(source.flags & 33554432 /* JsxAttributes */); for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; - if (!isKnownProperty(target, prop.name)) { + if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { if (reportErrors) { // We know *exactly* where things went wrong when comparing the types. // Use this property as the error node as this will be more helpful in // reasoning about what went wrong. ts.Debug.assert(!!errorNode); - errorNode = prop.valueDeclaration; - reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + if (ts.isJsxAttributes(errorNode)) { + // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. + // However, using an object-literal error message will be very confusing to the users so we give different a message. + reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); + } + else { + errorNode = prop.valueDeclaration; + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } } return true; } @@ -31333,20 +32018,42 @@ var ts; if (target.flags & 65536 /* Union */ && containsType(targetTypes, source)) { return -1 /* True */; } - var len = targetTypes.length; - for (var i = 0; i < len; i++) { - var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var type = targetTypes_1[_i]; + var related = isRelatedTo(source, type, /*reportErrors*/ false); if (related) { return related; } } + if (reportErrors) { + var discriminantType = findMatchingDiscriminantType(source, target); + isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); + } return 0 /* False */; } + function findMatchingDiscriminantType(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProperty = sourceProperties_1[_i]; + if (isDiscriminantProperty(target, sourceProperty.name)) { + var sourceType = getTypeOfSymbol(sourceProperty); + for (var _a = 0, _b = target.types; _a < _b.length; _a++) { + var type = _b[_a]; + var targetType = getTypeOfPropertyOfType(type, sourceProperty.name); + if (targetType && isRelatedTo(sourceType, targetType)) { + return type; + } + } + } + } + } + } function typeRelatedToEachType(source, target, reportErrors) { var result = -1 /* True */; var targetTypes = target.types; - for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { - var targetType = targetTypes_1[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var targetType = targetTypes_2[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0 /* False */; @@ -31409,12 +32116,12 @@ var ts; return 0 /* False */; } var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2 /* Failed */) { // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported // failure and continue computing the relation such that errors get reported. - relation[id] = 3 /* FailedAndReported */; + relation.set(id, 3 /* FailedAndReported */); } else { return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; @@ -31423,7 +32130,7 @@ var ts; if (depth > 0) { for (var i = 0; i < depth; i++) { // If source and target are already being compared, consider them related with assumptions - if (maybeStack[i][id]) { + if (maybeStack[i].get(id)) { return 1 /* Maybe */; } } @@ -31441,7 +32148,7 @@ var ts; sourceStack[depth] = source; targetStack[depth] = target; maybeStack[depth] = ts.createMap(); - maybeStack[depth][id] = 1 /* Succeeded */; + maybeStack[depth].set(id, 1 /* Succeeded */); depth++; var saveExpandingFlags = expandingFlags; if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) @@ -31476,41 +32183,43 @@ var ts; var maybeCache = maybeStack[depth]; // If result is definitely true, copy assumptions to global cache, else copy to next level up var destinationCache = (result === -1 /* True */ || depth === 0) ? relation : maybeStack[depth - 1]; - ts.copyProperties(maybeCache, destinationCache); + ts.copyEntries(maybeCache, destinationCache); } else { // A false result goes straight into global cache (when something is false under assumptions it // will also be false without assumptions) - relation[id] = reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */; + relation.set(id, reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */); } return result; } - // A type [P in S]: X is related to a type [P in T]: Y if T is related to S and X is related to Y. + // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is + // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice + // that S and T are contra-variant whereas X and Y are co-variant. function mappedTypeRelatedTo(source, target, reportErrors) { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { - var result_2; - if (relation === identityRelation) { - var readonlyMatches = !source.declaration.readonlyToken === !target.declaration.readonlyToken; - var optionalMatches = !source.declaration.questionToken === !target.declaration.questionToken; - if (readonlyMatches && optionalMatches) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getErasedTemplateTypeFromMappedType(source), getErasedTemplateTypeFromMappedType(target), reportErrors); - } - } - } - else { - if (relation === comparableRelation || !source.declaration.questionToken || target.declaration.questionToken) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors); - } + var sourceReadonly = !!source.declaration.readonlyToken; + var sourceOptional = !!source.declaration.questionToken; + var targetReadonly = !!target.declaration.readonlyToken; + var targetOptional = !!target.declaration.questionToken; + var modifiersRelated = relation === identityRelation ? + sourceReadonly === targetReadonly && sourceOptional === targetOptional : + relation === comparableRelation || !sourceOptional || targetOptional; + if (modifiersRelated) { + var result_2; + if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { + var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); + return result_2 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } + else if (target.declaration.questionToken && isEmptyObjectType(source)) { + return -1 /* True */; + } } else if (relation !== identityRelation) { var resolved = resolveStructuredTypeMembers(target); - if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1 /* Any */) { + if (isEmptyResolvedType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1 /* Any */) { return -1 /* True */; } } @@ -31528,17 +32237,23 @@ var ts; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { - if (!(targetProp.flags & 536870912 /* Optional */) || requireOptionalProperties) { + if (!(targetProp.flags & 67108864 /* Optional */) || requireOptionalProperties) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); } return 0 /* False */; } } - else if (!(targetProp.flags & 134217728 /* Prototype */)) { + else if (!(targetProp.flags & 16777216 /* Prototype */)) { var sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (getCheckFlags(sourceProp) & 128 /* ContainsPrivate */) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); + } + return 0 /* False */; + } if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { @@ -31552,12 +32267,9 @@ var ts; } } else if (targetPropFlags & 16 /* Protected */) { - var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(getParentOfSymbol(sourceProp)) : undefined; - var targetClass = getDeclaredTypeOfSymbol(getParentOfSymbol(targetProp)); - if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { + if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); + reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } return 0 /* False */; } @@ -31577,7 +32289,7 @@ var ts; } result &= related; // When checking for comparability, be more lenient with optional properties. - if (relation !== comparableRelation && sourceProp.flags & 536870912 /* Optional */ && !(targetProp.flags & 536870912 /* Optional */)) { + if (relation !== comparableRelation && sourceProp.flags & 67108864 /* Optional */ && !(targetProp.flags & 67108864 /* Optional */)) { // TypeScript 1.0 spec (April 2014): 3.8.3 // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. @@ -31605,8 +32317,8 @@ var ts; return 0 /* False */; } var result = -1 /* True */; - for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { - var sourceProp = sourceProperties_1[_i]; + for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { + var sourceProp = sourceProperties_2[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0 /* False */; @@ -31779,6 +32491,45 @@ var ts; return false; } } + // Invoke the callback for each underlying property symbol of the given symbol and return the first + // value that isn't undefined. + function forEachProperty(prop, callback) { + if (getCheckFlags(prop) & 2 /* SyntheticProperty */) { + for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var p = getPropertyOfType(t, prop.name); + var result = p && forEachProperty(p, callback); + if (result) { + return result; + } + } + return undefined; + } + return callback(prop); + } + // Return the declaring class type of a property or undefined if property not declared in class + function getDeclaringClass(prop) { + return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + } + // Return true if some underlying source property is declared in a class that derives + // from the given base class. + function isPropertyInClassDerivedFrom(prop, baseClass) { + return forEachProperty(prop, function (sp) { + var sourceClass = getDeclaringClass(sp); + return sourceClass ? hasBaseType(sourceClass, baseClass) : false; + }); + } + // Return true if source property is a valid override of protected parts of target property. + function isValidOverrideOf(sourceProp, targetProp) { + return !forEachProperty(targetProp, function (tp) { return getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? + !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); + } + // Return true if the given class derives from each of the declaring classes of the protected + // constituents of the given property. + function isClassDerivedFromDeclaringClasses(checkClass, prop) { + return forEachProperty(prop, function (p) { return getDeclarationModifierFlagsFromSymbol(p) & 16 /* Protected */ ? + !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; + } // Return true if the given type is the constructor type for an abstract class function isAbstractConstructorType(type) { if (getObjectFlags(type) & 16 /* Anonymous */) { @@ -31834,7 +32585,7 @@ var ts; } } else { - if ((sourceProp.flags & 536870912 /* Optional */) !== (targetProp.flags & 536870912 /* Optional */)) { + if ((sourceProp.flags & 67108864 /* Optional */) !== (targetProp.flags & 67108864 /* Optional */)) { return 0 /* False */; } } @@ -31878,7 +32629,7 @@ var ts; // the constraints with a common set of type arguments to get relatable entities in places where // type parameters occur in the constraints. The complexity of doing that doesn't seem worthwhile, // particularly as we're comparing erased versions of the signatures below. - if ((source.typeParameters ? source.typeParameters.length : 0) !== (target.typeParameters ? target.typeParameters.length : 0)) { + if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { return 0 /* False */; } // Spec 1.0 Section 3.8.3 & 3.8.4: @@ -31918,8 +32669,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -31927,8 +32678,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -32034,8 +32785,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getFalsyFlags(t); } return result; @@ -32067,7 +32818,7 @@ var ts; types.push(undefinedType); if (flags & 4096 /* Null */) types.push(nullType); - return getUnionType(types, /*subtypeReduction*/ true); + return getUnionType(types); } function removeDefinitelyFalsyTypes(type) { return getFalsyFlags(type) & 7392 /* DefinitelyFalsy */ ? @@ -32086,8 +32837,8 @@ var ts; getSignaturesOfType(type, 0 /* Call */).length === 0 && getSignaturesOfType(type, 1 /* Construct */).length === 0; } - function createTransientSymbol(source, type) { - var symbol = createSymbol(source.flags | 67108864 /* Transient */, source.name); + function createSymbolWithType(source, type) { + var symbol = createSymbol(source.flags, source.name); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -32103,7 +32854,7 @@ var ts; var property = _a[_i]; var original = getTypeOfSymbol(property); var updated = f(original); - members[property.name] = updated === original ? property : createTransientSymbol(property, updated); + members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); } ; return members; @@ -32205,25 +32956,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 144 /* Parameter */: + case 145 /* 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 174 /* BindingElement */: + case 175 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 226 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -32316,7 +33067,7 @@ var ts; var typeInferencesArray = [typeInferences]; var templateType = getTemplateTypeFromMappedType(target); var readonlyMask = target.declaration.readonlyToken ? false : true; - var optionalMask = target.declaration.questionToken ? 0 : 536870912 /* Optional */; + var optionalMask = target.declaration.questionToken ? 0 : 67108864 /* Optional */; var members = createSymbolTable(properties); for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var prop = properties_4[_i]; @@ -32324,11 +33075,11 @@ var ts; if (!inferredPropType) { return undefined; } - var inferredProp = createSymbol(4 /* Property */ | 67108864 /* Transient */ | prop.flags & optionalMask, prop.name); + var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.name); + inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 4 /* Readonly */ : 0; inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; - inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); - members[prop.name] = inferredProp; + members.set(prop.name, inferredProp); } if (indexInfo) { var inferredIndexType = inferTargetType(indexInfo.type); @@ -32465,8 +33216,8 @@ var ts; var typeVariableCount = 0; var typeVariable = void 0; // First infer to each type in union or intersection that isn't a type variable - for (var _d = 0, targetTypes_2 = targetTypes; _d < targetTypes_2.length; _d++) { - var t = targetTypes_2[_d]; + for (var _d = 0, targetTypes_3 = targetTypes; _d < targetTypes_3.length; _d++) { + var t = targetTypes_3[_d]; if (t.flags & 540672 /* TypeVariable */ && ts.contains(typeVariables, t)) { typeVariable = t; typeVariableCount++; @@ -32502,10 +33253,10 @@ var ts; return; } var key = source.id + "," + target.id; - if (visited[key]) { + if (visited.get(key)) { return; } - visited[key] = true; + visited.set(key, true); if (depth === 0) { sourceStack = []; targetStack = []; @@ -32603,8 +33354,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -32654,11 +33405,20 @@ var ts; inferenceSucceeded = !!unionOrSuperType; } else { - // Infer the empty object type when no inferences were made. It is important to remember that - // in this case, inference still succeeds, meaning there is no error for not having inference - // candidates. An inference error only occurs when there are *conflicting* candidates, i.e. + // Infer either the default or the empty object type when no inferences were + // made. It is important to remember that in this case, inference still + // succeeds, meaning there is no error for not having inference candidates. An + // inference error only occurs when there are *conflicting* candidates, i.e. // candidates with no common supertype. - inferredType = emptyObjectType; + var defaultType = getDefaultFromTypeParameter(context.signature.typeParameters[index]); + if (defaultType) { + // Instantiate the default type. Any forward reference to a type + // parameter should be instantiated to the empty object type. + inferredType = instantiateType(defaultType, combineTypeMappers(createBackreferenceMapper(context.signature.typeParameters, index), getInferenceMapper(context))); + } + else { + inferredType = emptyObjectType; + } inferenceSucceeded = true; } context.inferredTypes[index] = inferredType; @@ -32701,10 +33461,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 160 /* TypeQuery */: + case 161 /* TypeQuery */: return true; case 70 /* Identifier */: - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: node = node.parent; continue; default: @@ -32725,7 +33485,7 @@ var ts; if (node.kind === 98 /* ThisKeyword */) { return "0"; } - if (node.kind === 177 /* PropertyAccessExpression */) { + if (node.kind === 178 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -32736,7 +33496,7 @@ var ts; case 70 /* Identifier */: case 98 /* ThisKeyword */: return node; - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -32745,19 +33505,19 @@ var ts; switch (source.kind) { case 70 /* Identifier */: return target.kind === 70 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 224 /* VariableDeclaration */ || target.kind === 174 /* BindingElement */) && + (target.kind === 225 /* VariableDeclaration */ || target.kind === 175 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98 /* ThisKeyword */: return target.kind === 98 /* ThisKeyword */; - case 177 /* PropertyAccessExpression */: - return target.kind === 177 /* PropertyAccessExpression */ && + case 178 /* PropertyAccessExpression */: + return target.kind === 178 /* PropertyAccessExpression */ && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 177 /* PropertyAccessExpression */) { + while (source.kind === 178 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -32770,7 +33530,7 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 177 /* PropertyAccessExpression */ && + return target.kind === 178 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -32778,7 +33538,7 @@ var ts; if (expr.kind === 70 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 177 /* PropertyAccessExpression */) { + if (expr.kind === 178 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -32787,9 +33547,9 @@ var ts; function isDiscriminantProperty(type, name) { if (type && type.flags & 65536 /* Union */) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && prop.flags & 268435456 /* SyntheticProperty */) { + if (prop && getCheckFlags(prop) & 2 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.hasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.checkFlags & 16 /* HasNonUniformType */ && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -32808,7 +33568,7 @@ var ts; } } } - if (callExpression.expression.kind === 177 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 178 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -32850,8 +33610,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -32861,7 +33621,7 @@ var ts; // check. This gives us a quicker out in the common case where an object type is not a function. var resolved = resolveStructuredTypeMembers(type); return !!(resolved.callSignatures.length || resolved.constructSignatures.length || - resolved.members["bind"] && isTypeSubtypeOf(type, globalFunctionType)); + resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type) { var flags = type.flags; @@ -32904,6 +33664,9 @@ var ts; if (flags & 512 /* ESSymbol */) { return strictNullChecks ? 1981320 /* SymbolStrictFacts */ : 4193160 /* SymbolFacts */; } + if (flags & 16777216 /* NonPrimitive */) { + return strictNullChecks ? 6166480 /* ObjectStrictFacts */ : 8378320 /* ObjectFacts */; + } if (flags & 16384 /* TypeParameter */) { var constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); @@ -32939,10 +33702,16 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 /* ArrayLiteralExpression */ || node.parent.kind === 258 /* PropertyAssignment */ ? + var isDestructuringDefaultAssignment = node.parent.kind === 176 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 260 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } + function isDestructuringAssignmentTarget(parent) { + return parent.parent.kind === 193 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 215 /* ForOfStatement */ && parent.parent.initializer === parent; + } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); } @@ -32958,21 +33727,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return stringType; - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return undefinedType; - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -32980,7 +33749,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 172 /* ObjectBindingPattern */ ? + var type = pattern.kind === 173 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -32998,35 +33767,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 213 /* ForInStatement */) { + if (node.parent.parent.kind === 214 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 214 /* ForOfStatement */) { + if (node.parent.parent.kind === 215 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 224 /* VariableDeclaration */ ? + return node.kind === 225 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 224 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */ ? + return node.kind === 225 /* VariableDeclaration */ || node.kind === 175 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 224 /* VariableDeclaration */ && node.initializer && + return node.kind === 225 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 174 /* BindingElement */ && node.parent.kind === 192 /* BinaryExpression */ && + node.kind !== 175 /* BindingElement */ && node.parent.kind === 193 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (node.operatorToken.kind) { case 57 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -33038,13 +33807,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 183 /* ParenthesizedExpression */ || - parent.kind === 192 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || - parent.kind === 192 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? + return parent.kind === 184 /* ParenthesizedExpression */ || + parent.kind === 193 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || + parent.kind === 193 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 254 /* CaseClause */) { + if (clause.kind === 256 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -33159,8 +33928,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; if (!(t.flags & 8192 /* Never */)) { if (!(getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -33183,11 +33952,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 177 /* PropertyAccessExpression */ && (parent.name.text === "length" || - parent.parent.kind === 179 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 178 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 178 /* PropertyAccessExpression */ && (parent.name.text === "length" || + parent.parent.kind === 180 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 179 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 192 /* BinaryExpression */ && + parent.parent.kind === 193 /* BinaryExpression */ && parent.parent.operatorToken.kind === 57 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -33216,7 +33985,7 @@ var ts; } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215 /* Narrowable */)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 17810431 /* Narrowable */)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -33230,7 +33999,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 201 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { + if (reference.parent.kind === 202 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { return declaredType; } return resultType; @@ -33247,7 +34016,19 @@ var ts; } } var type = void 0; - if (flow.flags & 16 /* Assignment */) { + if (flow.flags & 4096 /* AfterFinally */) { + // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement + flow.locked = true; + type = getTypeAtFlowNode(flow.antecedent); + flow.locked = false; + } + else if (flow.flags & 2048 /* PreFinally */) { + // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel + // so here just redirect to antecedent + flow = flow.antecedent; + continue; + } + else if (flow.flags & 16 /* Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; @@ -33279,7 +34060,7 @@ var ts; else if (flow.flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 177 /* PropertyAccessExpression */) { + if (container && container !== flowContainer && reference.kind !== 178 /* PropertyAccessExpression */) { flow = container.flowNode; continue; } @@ -33333,7 +34114,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 179 /* CallExpression */ ? + var expr = node.kind === 180 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -33341,7 +34122,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 179 /* CallExpression */) { + if (node.kind === 180 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -33400,6 +34181,12 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; + if (antecedent.flags & 2048 /* PreFinally */ && antecedent.lock.locked) { + // if flow correspond to branch from pre-try to finally and this branch is locked - this means that + // we initially have started following the flow outside the finally block. + // in this case we should ignore this branch. + continue; + } var flowType = getTypeAtFlowNode(antecedent); var type = getTypeFromFlowType(flowType); // If the type at a particular antecedent path is the declared type and the @@ -33432,8 +34219,9 @@ var ts; if (!key) { key = getFlowCacheKey(reference); } - if (cache[key]) { - return cache[key]; + var cached = cache.get(key); + if (cached) { + return cached; } // If this flow loop junction and reference are already being processed, return // the union of the types computed for each branch so far, marked as incomplete. @@ -33468,8 +34256,9 @@ var ts; // If we see a value appear in the cache it is a sign that control flow analysis // was restarted and completed by checkExpressionCached. We can simply pick up // the resulting type and bail out. - if (cache[key]) { - return cache[key]; + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; } if (!ts.contains(antecedentTypes, type)) { antecedentTypes.push(type); @@ -33493,10 +34282,11 @@ var ts; if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } - return cache[key] = result; + cache.set(key, result); + return result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 177 /* PropertyAccessExpression */ && + return expr.kind === 178 /* PropertyAccessExpression */ && declaredType.flags & 65536 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -33530,10 +34320,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 187 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { + if (left_1.kind === 188 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 187 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { + if (right_1.kind === 188 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -33579,7 +34369,7 @@ var ts; assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); } - if (type.flags & 33281 /* NotUnionOrUnit */) { + if (type.flags & 16810497 /* NotUnionOrUnit */) { return type; } if (assumeTrue) { @@ -33610,14 +34400,14 @@ var ts; // We narrow a non-union type to an exact primitive type if the non-union type // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. - var targetType = typeofTypesByName[literal.text]; + var targetType = typeofTypesByName.get(literal.text); if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; } } var facts = assumeTrue ? - typeofEQFacts[literal.text] || 64 /* TypeofEQHostObject */ : - typeofNEFacts[literal.text] || 8192 /* TypeofNEHostObject */; + typeofEQFacts.get(literal.text) || 64 /* TypeofEQHostObject */ : + typeofNEFacts.get(literal.text) || 8192 /* TypeofNEHostObject */; return getTypeWithFacts(type, facts); } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { @@ -33732,7 +34522,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 178 /* ElementAccessExpression */ || invokedExpression.kind === 177 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 179 /* ElementAccessExpression */ || invokedExpression.kind === 178 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -33751,15 +34541,15 @@ var ts; switch (expr.kind) { case 70 /* Identifier */: case 98 /* ThisKeyword */: - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: if (expr.operator === 50 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -33795,9 +34585,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 232 /* ModuleBlock */ || - node.kind === 262 /* SourceFile */ || - node.kind === 147 /* PropertyDeclaration */) { + node.kind === 233 /* ModuleBlock */ || + node.kind === 264 /* SourceFile */ || + node.kind === 148 /* PropertyDeclaration */) { return node; } } @@ -33829,7 +34619,7 @@ var ts; if (node.kind === 70 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 144 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 145 /* Parameter */) { symbol.isAssigned = true; } } @@ -33855,7 +34645,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 185 /* ArrowFunction */) { + if (container.kind === 186 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -33876,7 +34666,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration_1.kind === 227 /* ClassDeclaration */ + if (declaration_1.kind === 228 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -33888,14 +34678,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 197 /* ClassExpression */) { + else if (declaration_1.kind === 198 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 147 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 148 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration_1).flags |= 8388608 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 16777216 /* ConstructorReferenceInClass */; } @@ -33930,15 +34720,15 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 144 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 145 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 184 /* FunctionExpression */ || - flowContainer.kind === 185 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 185 /* FunctionExpression */ || + flowContainer.kind === 186 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -33981,7 +34771,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 257 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 259 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -34006,8 +34796,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 212 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 225 /* VariableDeclarationList */).parent === container && + if (container.kind === 213 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 226 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -34021,7 +34811,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { var current = node; // skip parenthesized nodes - while (current.parent.kind === 183 /* ParenthesizedExpression */) { + while (current.parent.kind === 184 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -34029,7 +34819,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 190 /* PrefixUnaryExpression */ || current.parent.kind === 191 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 191 /* PrefixUnaryExpression */ || current.parent.kind === 192 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 42 /* PlusPlusToken */ || expr.operator === 43 /* MinusMinusToken */; } @@ -34050,7 +34840,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 147 /* PropertyDeclaration */ || container.kind === 150 /* Constructor */) { + if (container.kind === 148 /* PropertyDeclaration */ || container.kind === 151 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -34118,36 +34908,38 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; - if (container.kind === 150 /* Constructor */) { + if (container.kind === 151 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 185 /* ArrowFunction */) { + if (container.kind === 186 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ 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 /* ES2015 */); } switch (container.kind) { - case 231 /* ModuleDeclaration */: + case 232 /* 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 230 /* EnumDeclaration */: + case 231 /* 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 150 /* Constructor */: + case 151 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); + // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: if (ts.getModifierFlags(container) & 32 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); + // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -34159,7 +34951,7 @@ var ts; // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } - if (container.kind === 184 /* FunctionExpression */ && + if (container.kind === 185 /* FunctionExpression */ && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') @@ -34196,28 +34988,28 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 275 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 278 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 278 /* JSDocThisType */) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 281 /* JSDocThisType */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 144 /* Parameter */) { + if (n.kind === 145 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 179 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 180 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 185 /* ArrowFunction */) { + while (container && container.kind === 186 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -34231,16 +35023,16 @@ var ts; // [super.foo()]() {} // } var current = node; - while (current && current !== container && current.kind !== 142 /* ComputedPropertyName */) { + while (current && current !== container && current.kind !== 143 /* ComputedPropertyName */) { current = current.parent; } - if (current && current.kind === 142 /* ComputedPropertyName */) { + if (current && current.kind === 143 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 176 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 177 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -34248,7 +35040,7 @@ var ts; } return unknownType; } - if (!isCallExpression && container.kind === 150 /* Constructor */) { + if (!isCallExpression && container.kind === 151 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if ((ts.getModifierFlags(container) & 32 /* Static */) || isCallExpression) { @@ -34314,7 +35106,7 @@ var ts; // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment // while a property access can. - if (container.kind === 149 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { + if (container.kind === 150 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -34328,7 +35120,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 176 /* ObjectLiteralExpression */) { + if (container.parent.kind === 177 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -34348,7 +35140,7 @@ var ts; } return unknownType; } - if (container.kind === 150 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 151 /* 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); return unknownType; @@ -34363,7 +35155,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 150 /* Constructor */; + return container.kind === 151 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -34371,21 +35163,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 176 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 177 /* ObjectLiteralExpression */) { if (ts.getModifierFlags(container) & 32 /* Static */) { - return container.kind === 149 /* MethodDeclaration */ || - container.kind === 148 /* MethodSignature */ || - container.kind === 151 /* GetAccessor */ || - container.kind === 152 /* SetAccessor */; + return container.kind === 150 /* MethodDeclaration */ || + container.kind === 149 /* MethodSignature */ || + container.kind === 152 /* GetAccessor */ || + container.kind === 153 /* SetAccessor */; } else { - return container.kind === 149 /* MethodDeclaration */ || - container.kind === 148 /* MethodSignature */ || - container.kind === 151 /* GetAccessor */ || - container.kind === 152 /* SetAccessor */ || - container.kind === 147 /* PropertyDeclaration */ || - container.kind === 146 /* PropertySignature */ || - container.kind === 150 /* Constructor */; + return container.kind === 150 /* MethodDeclaration */ || + container.kind === 149 /* MethodSignature */ || + container.kind === 152 /* GetAccessor */ || + container.kind === 153 /* SetAccessor */ || + container.kind === 148 /* PropertyDeclaration */ || + container.kind === 147 /* PropertySignature */ || + container.kind === 151 /* Constructor */; } } } @@ -34393,7 +35185,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 185 /* ArrowFunction */) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 186 /* ArrowFunction */) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -34409,23 +35201,23 @@ var ts; var func = parameter.parent; if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { var iife = ts.getImmediatelyInvokedFunctionExpression(func); - if (iife) { + if (iife && iife.arguments) { var indexOfParameter = ts.indexOf(func.parameters, parameter); - if (iife.arguments && indexOfParameter < iife.arguments.length) { - if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return createArrayType(getUnionType(restTypes)); + if (parameter.dotDotDotToken) { + var restTypes = []; + for (var i = indexOfParameter; i < iife.arguments.length; i++) { + restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); } - var links = getNodeLinks(iife); - var cached = links.resolvedSignature; - links.resolvedSignature = anySignature; - var type = getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])); - links.resolvedSignature = cached; - return type; + return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; } + var links = getNodeLinks(iife); + var cached = links.resolvedSignature; + links.resolvedSignature = anySignature; + var type = indexOfParameter < iife.arguments.length ? + getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + parameter.initializer ? undefined : undefinedWideningType; + links.resolvedSignature = cached; + return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -34459,7 +35251,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 144 /* Parameter */) { + if (declaration.kind === 145 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -34470,11 +35262,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_19 = declaration.propertyName || declaration.name; + var name = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_19)) { - var text = ts.getTextOfPropertyName(name_19); + !ts.isBindingPattern(name)) { + var text = ts.getTextOfPropertyName(name); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -34511,7 +35303,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 144 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 145 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -34522,8 +35314,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 150 /* Constructor */ || - functionDecl.kind === 151 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 152 /* SetAccessor */))) { + functionDecl.kind === 151 /* Constructor */ || + functionDecl.kind === 152 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 153 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -34545,7 +35337,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 181 /* TaggedTemplateExpression */) { + if (template.parent.kind === 182 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -34589,8 +35381,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -34670,19 +35462,19 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxAttribute(attribute) { - var kind = attribute.kind; - var jsxElement = attribute.parent; - var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 251 /* JsxAttribute */) { - if (!attrsType || isTypeAny(attrsType)) { + // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type + // which is a type of the parameter of the signature we are trying out. + // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName + var attributesType = getContextualType(attribute.parent); + if (ts.isJsxAttribute(attribute)) { + if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attrsType, attribute.name.text); + return getTypeOfPropertyOfType(attributesType, attribute.name.text); } - else if (attribute.kind === 252 /* JsxSpreadAttribute */) { - return attrsType; + else { + return attributesType; } - ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); } // 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. @@ -34717,42 +35509,45 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 224 /* VariableDeclaration */: - case 144 /* Parameter */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 174 /* BindingElement */: + case 225 /* VariableDeclaration */: + case 145 /* Parameter */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 175 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 185 /* ArrowFunction */: - case 217 /* ReturnStatement */: + case 186 /* ArrowFunction */: + case 218 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 179 /* CallExpression */: - case 180 /* NewExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 258 /* PropertyAssignment */: - case 259 /* ShorthandPropertyAssignment */: + case 260 /* PropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 203 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 194 /* TemplateExpression */); + case 204 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 195 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return getContextualType(parent); - case 253 /* JsxExpression */: + case 255 /* JsxExpression */: return getContextualType(parent); - case 251 /* JsxAttribute */: - case 252 /* JsxSpreadAttribute */: + case 252 /* JsxAttribute */: + case 254 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); + case 250 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + return getAttributesTypeFromJsxOpeningLikeElement(parent); } return undefined; } @@ -34783,7 +35578,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 184 /* FunctionExpression */ || node.kind === 185 /* ArrowFunction */; + return node.kind === 185 /* FunctionExpression */ || node.kind === 186 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -34802,7 +35597,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 !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -34812,8 +35607,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var current = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -34863,8 +35658,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 174 /* BindingElement */ && !!node.initializer) || - (node.kind === 192 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); + return (node.kind === 175 /* BindingElement */ && !!node.initializer) || + (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -34873,7 +35668,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 196 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 197 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -34897,7 +35692,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 196 /* SpreadElement */; + hasSpreadElement = hasSpreadElement || e.kind === 197 /* SpreadElement */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -34912,7 +35707,7 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (pattern && (pattern.kind === 173 /* ArrayBindingPattern */ || pattern.kind === 175 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 174 /* ArrayBindingPattern */ || pattern.kind === 176 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -34920,7 +35715,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 198 /* OmittedExpression */) { + if (patternElement.kind !== 199 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -34937,7 +35732,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 142 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 143 /* 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, @@ -35009,7 +35804,7 @@ var ts; var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 172 /* ObjectBindingPattern */ || contextualType.pattern.kind === 176 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 173 /* ObjectBindingPattern */ || contextualType.pattern.kind === 177 /* ObjectLiteralExpression */); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -35018,29 +35813,29 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 258 /* PropertyAssignment */ || - memberDecl.kind === 259 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 260 /* PropertyAssignment */ || + memberDecl.kind === 261 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 258 /* PropertyAssignment */) { + if (memberDecl.kind === 260 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 149 /* MethodDeclaration */) { + else if (memberDecl.kind === 150 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 259 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 261 /* ShorthandPropertyAssignment */); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; - var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name); + var prop = createSymbol(4 /* Property */ | member.flags, member.name); if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 258 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 259 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 260 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 261 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 536870912 /* Optional */; + prop.flags |= 67108864 /* Optional */; } if (ts.hasDynamicName(memberDecl)) { patternWithComputedProperties = true; @@ -35051,7 +35846,7 @@ var ts; // binding pattern specifies a default value for the property, make the property optional. var impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { - prop.flags |= impliedProp.flags & 536870912 /* Optional */; + prop.flags |= impliedProp.flags & 67108864 /* Optional */; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0 /* String */)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -35066,12 +35861,12 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 260 /* SpreadAssignment */) { - if (languageVersion < 5 /* ESNext */) { + else if (memberDecl.kind === 262 /* SpreadAssignment */) { + if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + spread = getSpreadType(spread, createObjectLiteralType()); propertiesArray = []; propertiesTable = ts.createMap(); hasComputedStringProperty = false; @@ -35083,7 +35878,7 @@ var ts; error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } - spread = getSpreadType(spread, type, /*isFromObjectLiteral*/ false); + spread = getSpreadType(spread, type); offset = i + 1; continue; } @@ -35093,7 +35888,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 === 151 /* GetAccessor */ || memberDecl.kind === 152 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 152 /* GetAccessor */ || memberDecl.kind === 153 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -35105,7 +35900,7 @@ var ts; } } else { - propertiesTable[member.name] = member; + propertiesTable.set(member.name, member); } propertiesArray.push(member); } @@ -35114,18 +35909,18 @@ var ts; if (contextualTypeHasPattern) { for (var _i = 0, _a = getPropertiesOfType(contextualType); _i < _a.length; _i++) { var prop = _a[_i]; - if (!propertiesTable[prop.name]) { - if (!(prop.flags & 536870912 /* Optional */)) { + if (!propertiesTable.get(prop.name)) { + if (!(prop.flags & 67108864 /* Optional */)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } - propertiesTable[prop.name] = prop; + propertiesTable.set(prop.name, prop); propertiesArray.push(prop); } } } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + spread = getSpreadType(spread, createObjectLiteralType()); } if (spread.flags & 32768 /* Object */) { // only set the symbol and flags if this is a (fresh) object type @@ -35155,7 +35950,7 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (1 /* Any */ | 4096 /* Null */ | 2048 /* Undefined */) || + return !!(type.flags & (1 /* Any */ | 4096 /* Null */ | 2048 /* Undefined */ | 16777216 /* NonPrimitive */) || type.flags & 32768 /* Object */ && !isGenericMappedType(type) || type.flags & 196608 /* UnionOrIntersection */ && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } @@ -35177,13 +35972,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 253 /* JsxExpression */: + case 255 /* JsxExpression */: checkJsxExpression(child); break; - case 247 /* JsxElement */: + case 248 /* JsxElement */: checkJsxElement(child); break; - case 248 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -35202,77 +35997,105 @@ var ts; */ function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment - if (tagName.kind === 177 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { + if (tagName.kind === 178 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { 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 (isUnhyphenatedJsxName(node.name.text)) { - var attributeType = getTypeOfPropertyOfType(elementAttributesType, ts.getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0 /* String */); - if (attributeType) { - correspondingPropType = attributeType; + /** + * Get attributes type of the JSX opening-like element. The result is from resolving "attributes" property of the opening-like element. + * + * @param openingLikeElement a JSX opening-like element + * @param filter a function to remove attributes that will not participate in checking whether attributes are assignable + * @return an anonymous type (similar to the one returned by checkObjectLiteral) in which its properties are attributes property. + */ + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, contextualMapper) { + var attributes = openingLikeElement.attributes; + var attributesTable = ts.createMap(); + var spread = emptyObjectType; + var attributesArray = []; + for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { + var attributeDecl = _a[_i]; + var member = attributeDecl.symbol; + if (ts.isJsxAttribute(attributeDecl)) { + var exprType = attributeDecl.initializer ? + checkExpression(attributeDecl.initializer, contextualMapper) : + trueType; // is sugar for + var attributeSymbol = createSymbol(4 /* Property */ | 134217728 /* Transient */ | member.flags, member.name); + attributeSymbol.declarations = member.declarations; + attributeSymbol.parent = member.parent; + if (member.valueDeclaration) { + attributeSymbol.valueDeclaration = member.valueDeclaration; } - else { - // If there's no corresponding property with this name, error - if (!correspondingPropType) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; - } + attributeSymbol.type = exprType; + attributeSymbol.target = member; + attributesTable.set(attributeSymbol.name, attributeSymbol); + attributesArray.push(attributeSymbol); + } + else { + ts.Debug.assert(attributeDecl.kind === 254 /* JsxSpreadAttribute */); + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); } + var exprType = checkExpression(attributeDecl.expression); + if (!(exprType.flags & (32768 /* Object */ | 1 /* Any */))) { + error(attributeDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + return anyType; + } + if (isTypeAny(exprType)) { + return anyType; + } + spread = getSpreadType(spread, exprType); } } - var exprType; - if (node.initializer) { - exprType = checkExpression(node.initializer); + if (spread !== emptyObjectType) { + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); + } + attributesArray = getPropertiesOfType(spread); } - else { - // is sugar for - exprType = booleanType; + attributesTable = ts.createMap(); + if (attributesArray) { + ts.forEach(attributesArray, function (attr) { + if (!filter || filter(attr)) { + attributesTable.set(attr.name, attr); + } + }); } - if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, node); + return createJsxAttributesType(attributes.symbol, attributesTable); + /** + * Create anonymous type from given attributes symbol table. + * @param symbol a symbol of JsxAttributes containing attributes corresponding to attributesTable + * @param attributesTable a symbol table of attributes property + */ + function createJsxAttributesType(symbol, attributesTable) { + var result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshLiteral */; + result.flags |= 33554432 /* JsxAttributes */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag; + result.objectFlags |= 128 /* ObjectLiteral */; + return result; } - nameTable[node.name.text] = true; - return exprType; } - function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { - if (compilerOptions.jsx === 2 /* React */) { - checkExternalEmitHelpers(node, 2 /* Assign */); - } - var type = checkExpression(node.expression); - var props = getPropertiesOfType(type); - for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { - var prop = props_2[_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; + /** + * Check attributes property of opening-like element. This function is called during chooseOverload to get call signature of a JSX opening-like element. + * (See "checkApplicableSignatureForJsxOpeningLikeElement" for how the function is used) + * @param node a JSXAttributes to be resolved of its type + */ + function checkJsxAttributes(node, contextualMapper) { + return createJsxAttributesTypeFromAttributesProperty(node.parent, /*filter*/ undefined, contextualMapper); } function getJsxType(name) { - if (jsxTypes[name] === undefined) { - return jsxTypes[name] = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType; + var jsxType = jsxTypes.get(name); + if (jsxType === undefined) { + jsxTypes.set(name, jsxType = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType); } - return jsxTypes[name]; + return jsxType; } /** * Looks up an intrinsic tag name and returns a symbol that either points to an intrinsic @@ -35367,28 +36190,131 @@ var ts; } } /** - * Given React element instance type and the class type, resolve the Jsx type - * Pass elemType to handle individual type in the union typed element type. + * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. + * Return only attributes type of successfully resolved call signature. + * This function assumes that the caller handled other possible element type of the JSX element (e.g. stateful component) + * Unlike tryGetAllJsxStatelessFunctionAttributesType, this function is a default behavior of type-checkers. + * @param openingLikeElement a JSX opening-like element to find attributes type + * @param elementType a type of the opening-like element. This elementType can't be an union type + * @param elemInstanceType an element instance type (the result of newing or invoking this tag) + * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global */ - function getResolvedJsxType(node, elemType, elemClassType) { - if (!elemType) { - elemType = checkExpression(node.tagName); + function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536 /* Union */)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + // We don't call getResolvedSignature here because we have already resolve the type of JSX Element. + var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, /*candidatesOutArray*/ undefined); + if (callSignature !== unknownSignature) { + var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); + var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + // Intersect in JSX.IntrinsicAttributes if it exists + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + paramType = intersectTypes(intrinsicAttributes, paramType); + } + return paramType; + } + } + } } - if (elemType.flags & 65536 /* Union */) { - var types = elemType.types; - return getUnionType(ts.map(types, function (type) { - return getResolvedJsxType(node, type, elemClassType); + return undefined; + } + /** + * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. + * Return all attributes type of resolved call signature including candidate signatures. + * This function assumes that the caller handled other possible element type of the JSX element. + * This function is a behavior used by language service when looking up completion in JSX element. + * @param openingLikeElement a JSX opening-like element to find attributes type + * @param elementType a type of the opening-like element. This elementType can't be an union type + * @param elemInstanceType an element instance type (the result of newing or invoking this tag) + * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global + */ + function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536 /* Union */)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type + if (jsxElementType) { + // We don't call getResolvedSignature because here we have already resolve the type of JSX Element. + var candidatesOutArray = []; + getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); + var result = void 0; + var allMatchingAttributesType = void 0; + for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { + var candidate = candidatesOutArray_1[_i]; + var callReturnType = getReturnTypeOfSignature(candidate); + var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var shouldBeCandidate = true; + for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { + var attribute = _b[_a]; + if (ts.isJsxAttribute(attribute) && + isUnhyphenatedJsxName(attribute.name.text) && + !getPropertyOfType(paramType, attribute.name.text)) { + shouldBeCandidate = false; + break; + } + } + if (shouldBeCandidate) { + result = intersectTypes(result, paramType); + } + allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); + } + } + // If we can't find any matching, just return everything. + if (!result) { + result = allMatchingAttributesType; + } + // Intersect in JSX.IntrinsicAttributes if it exists + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + result = intersectTypes(intrinsicAttributes, result); + } + return result; + } + } + return undefined; + } + /** + * Resolve attributes type of the given opening-like element. The attributes type is a type of attributes associated with the given elementType. + * For instance: + * declare function Foo(attr: { p1: string}): JSX.Element; + * ; // This function will try resolve "Foo" and return an attributes type of "Foo" which is "{ p1: string }" + * + * The function is intended to initially be called from getAttributesTypeFromJsxOpeningLikeElement which already handle JSX-intrinsic-element.. + * This function will try to resolve custom JSX attributes type in following order: string literal, stateless function, and stateful component + * + * @param openingLikeElement a non-intrinsic JSXOPeningLikeElement + * @param shouldIncludeAllStatelessAttributesType a boolean indicating whether to include all attributes types from all stateless function signature + * @param elementType an instance type of the given opening-like element. If undefined, the function will check type openinglikeElement's tagname. + * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global (imported from react.d.ts) + * @return attributes type if able to resolve the type of node + * anyType if there is no type ElementAttributesProperty or there is an error + * emptyObjectType if there is no "prop" in the element instance type + **/ + function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { + if (!elementType) { + elementType = checkExpression(openingLikeElement.tagName); + } + if (elementType.flags & 65536 /* Union */) { + var types = elementType.types; + return getUnionType(types.map(function (type) { + return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); }), /*subtypeReduction*/ true); } // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - if (elemType.flags & 2 /* String */) { + if (elementType.flags & 2 /* String */) { return anyType; } - else if (elemType.flags & 32 /* StringLiteral */) { + else if (elementType.flags & 32 /* StringLiteral */) { // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type + // For example: + // var CustomTag: "h1" = "h1"; + // Hello World var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { - var stringLiteralTypeName = elemType.text; + var stringLiteralTypeName = elementType.text; var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); if (intrinsicProp) { return getTypeOfSymbol(intrinsicProp); @@ -35397,34 +36323,24 @@ var ts; if (indexSignatureType) { return indexSignatureType; } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + error(openingLikeElement, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); } // If we need to report an error, we already done so here. So just return any to prevent any more error downstream return anyType; } // Get the element instance type (the result of newing or invoking this tag) - var elemInstanceType = getJsxElementInstanceType(node, elemType); - if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { - // Is this is a stateless function component? See if its single signature's return type is - // assignable to the JSX Element Type - if (jsxElementType) { - var callSignatures = elemType && getSignaturesOfType(elemType, 0 /* Call */); - var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { - // Intersect in JSX.IntrinsicAttributes if it exists - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); - if (intrinsicAttributes !== unknownType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } + var elemInstanceType = getJsxElementInstanceType(openingLikeElement, elementType); + // If we should include all stateless attributes type, then get all attributes type from all stateless function signature. + // Otherwise get only attributes type from the signature picked by choose-overload logic. + var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? + tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : + defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); + if (statelessAttributesType) { + return statelessAttributesType; } // Issue an error if this return type isn't assignable to JSX.ElementClass - if (elemClassType) { - checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + if (elementClassType) { + checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } if (isTypeAny(elemInstanceType)) { return elemInstanceType; @@ -35450,7 +36366,7 @@ var ts; } else if (attributesType.flags & 65536 /* Union */) { // Props cannot be a union type - error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); + error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); return anyType; } else { @@ -35477,30 +36393,68 @@ var ts; } } /** - * 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. + * Get attributes type of the given intrinsic opening-like Jsx element by resolving the tag name. + * The function is intended to be called from a function which has checked that the opening element is an intrinsic element. + * @param node an intrinsic JSX opening-like element */ - function getJsxElementAttributesType(node) { + function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) { + ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName)); var links = getNodeLinks(node); - if (!links.resolvedJsxType) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { - return links.resolvedJsxType = getTypeOfSymbol(symbol); - } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { - return links.resolvedJsxType = getIndexInfoOfSymbol(symbol, 0 /* String */).type; - } - else { - return links.resolvedJsxType = unknownType; - } + if (!links.resolvedJsxElementAttributesType) { + var symbol = getIntrinsicTagSymbol(node); + if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + } + else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, 0 /* String */).type; } else { - var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxType = getResolvedJsxType(node, undefined, elemClassType); + return links.resolvedJsxElementAttributesType = unknownType; } } - return links.resolvedJsxType; + return links.resolvedJsxElementAttributesType; + } + /** + * Get attributes type of the given custom opening-like JSX element. + * This function is intended to be called from a caller that handles intrinsic JSX element already. + * @param node a custom JSX opening-like element + * @param shouldIncludeAllStatelessAttributesType a boolean value used by language service to get all possible attributes type from an overload stateless function component + */ + function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { + var links = getNodeLinks(node); + if (!links.resolvedJsxElementAttributesType) { + var elemClassType = getJsxGlobalElementClassType(); + return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); + } + return links.resolvedJsxElementAttributesType; + } + /** + * Get all possible attributes type, especially from an overload stateless function component, of the given JSX opening-like element. + * This function is called by language service (see: completions-tryGetGlobalSymbols). + * @param node a JSX opening-like element to get attributes type for + */ + function getAllAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + // Because in language service, the given JSX opening-like element may be incomplete and therefore, + // we can't resolve to exact signature if the element is a stateless function component so the best thing to do is return all attributes type from all overloads. + return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ true); + } + } + /** + * Get the attributes type, which indicates the attributes that are valid on the given JSXOpeningLikeElement. + * @param node a JSXOpeningLikeElement node + * @return an attributes type of the given node + */ + function getAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ false); + } } /** * Given a JSX attribute, returns the symbol for the corresponds property @@ -35508,7 +36462,7 @@ var ts; * that have no matching element attributes type property. */ function getJsxAttributePropertySymbol(attrib) { - var attributesType = getJsxElementAttributesType(attrib.parent); + var attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent); var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } @@ -35518,7 +36472,9 @@ var ts; } return jsxElementClassType; } - /// Returns all the properties of the Jsx.IntrinsicElements interface + /** + * Returns all the properties of the Jsx.IntrinsicElements interface + */ function getJsxIntrinsicTagNames() { var intrinsics = getJsxType(JsxNames.IntrinsicElements); return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; @@ -35551,39 +36507,42 @@ var ts; markAliasSymbolAsReferenced(reactSym); } } - var targetAttributesType = getJsxElementAttributesType(node); - var nameTable = ts.createMap(); - // 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 === 251 /* JsxAttribute */) { - checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); - } - else { - ts.Debug.assert(node.attributes[i].kind === 252 /* JsxSpreadAttribute */); - var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if (isTypeAny(spreadType)) { - sawSpreadedAny = true; - } - } + checkJsxAttributesAssignableToTagNameAttributes(node); + } + /** + * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. + * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" + * Check assignablity between given attributes property, "source attributes", and the "target attributes" + * @param openingLikeElement an opening-like JSX element to check its JSXAttributes + */ + function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement) { + // The function involves following steps: + // 1. Figure out expected attributes type by resolving tagName of the JSX opening-like element, targetAttributesType. + // During these steps, we will try to resolve the tagName as intrinsic name, stateless function, stateful component (in the order) + // 2. Solved JSX attributes type given by users, sourceAttributesType, which is by resolving "attributes" property of the JSX opening-like element. + // 3. Check if the two are assignable to each other + // targetAttributesType is a type of an attributes from resolving tagName of an opening-like JSX element. + var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? + getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : + getCustomJsxElementAttributesType(openingLikeElement, /*shouldIncludeAllStatelessAttributesType*/ false); + // sourceAttributesType is a type of an attributes properties. + // i.e
+ // attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes". + var sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, function (attribute) { + return isUnhyphenatedJsxName(attribute.name) || !!(getPropertyOfType(targetAttributesType, attribute.name)); + }); + // If the targetAttributesType is an emptyObjectType, indicating that there is no property named 'props' on this instance type. + // but there exists a sourceAttributesType, we need to explicitly give an error as normal assignability check allow excess properties and will pass. + if (targetAttributesType === emptyObjectType && (isTypeAny(sourceAttributesType) || sourceAttributesType.properties.length > 0)) { + error(openingLikeElement, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); } - // 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]) { - error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); - } - } + else { + checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); } } - function checkJsxExpression(node) { + function checkJsxExpression(node, contextualMapper) { if (node.expression) { - var type = checkExpression(node.expression); + var type = checkExpression(node.expression, contextualMapper); if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); } @@ -35596,10 +36555,25 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 147 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 148 /* PropertyDeclaration */; } function getDeclarationModifierFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 4 /* Public */ | 32 /* Static */ : 0; + if (s.valueDeclaration) { + var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + } + if (getCheckFlags(s) & 2 /* SyntheticProperty */) { + var checkFlags = s.checkFlags; + var accessModifier = checkFlags & 128 /* ContainsPrivate */ ? 8 /* Private */ : + checkFlags & 32 /* ContainsPublic */ ? 4 /* Public */ : + 16 /* Protected */; + var staticModifier = checkFlags & 256 /* ContainsStatic */ ? 32 /* Static */ : 0; + return accessModifier | staticModifier; + } + if (s.flags & 16777216 /* Prototype */) { + return 4 /* Public */ | 32 /* Static */; + } + return 0; } function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; @@ -35612,12 +36586,16 @@ var ts; * @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) { + function checkPropertyAccessibility(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 /* PropertyAccessExpression */ || node.kind === 224 /* VariableDeclaration */ ? + var errorNode = node.kind === 178 /* PropertyAccessExpression */ || node.kind === 225 /* VariableDeclaration */ ? node.name : node.right; + if (getCheckFlags(prop) & 128 /* ContainsPrivate */) { + // Synthetic property with private constituent property + error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); + return false; + } if (left.kind === 96 /* SuperKeyword */) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or @@ -35626,18 +36604,21 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES2015 */ && getDeclarationKindFromSymbol(prop) !== 149 /* 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 (languageVersion < 2 /* ES2015 */) { + var propKind = getDeclarationKindFromSymbol(prop); + if (propKind !== 150 /* MethodDeclaration */ && propKind !== 149 /* MethodSignature */) { + // `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 & 128 /* 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)); + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } } @@ -35650,7 +36631,7 @@ var ts; if (flags & 8 /* Private */) { var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } return true; @@ -35660,14 +36641,15 @@ var ts; if (left.kind === 96 /* SuperKeyword */) { return true; } - // Get the enclosing class that has the declaring class as its base type + // Find the first enclosing class that has the declaring classes of the protected constituents + // of the property as base classes var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return hasBaseType(enclosingClass, declaringClass) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; }); // A protected property is accessible if the property is within the declaring class or classes derived from it if (!enclosingClass) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); return false; } // No further restrictions for static properties @@ -35679,7 +36661,6 @@ var ts; // get the original type -- represented as the type constraint of the 'this' type type = getConstraintOfTypeParameter(type); } - // TODO: why is the first part of this check here? if (!(getObjectFlags(getTargetType(type)) & 3 /* ClassOrInterface */ && hasBaseType(type, enclosingClass))) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; @@ -35687,16 +36668,17 @@ var ts; return true; } function checkNonNullExpression(node) { - var type = checkExpression(node); - if (strictNullChecks) { - var kind = getFalsyFlags(type) & 6144 /* Nullable */; - if (kind) { - error(node, kind & 2048 /* Undefined */ ? kind & 4096 /* Null */ ? - ts.Diagnostics.Object_is_possibly_null_or_undefined : - ts.Diagnostics.Object_is_possibly_undefined : - ts.Diagnostics.Object_is_possibly_null); - } - return getNonNullableType(type); + return checkNonNullType(checkExpression(node), node); + } + function checkNonNullType(type, errorNode) { + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 6144 /* Nullable */; + if (kind) { + error(errorNode, kind & 2048 /* Undefined */ ? kind & 4096 /* Null */ ? + ts.Diagnostics.Object_is_possibly_null_or_undefined : + ts.Diagnostics.Object_is_possibly_undefined : + ts.Diagnostics.Object_is_possibly_null); + var t = getNonNullableType(type); + return t.flags & (6144 /* Nullable */ | 8192 /* Never */) ? unknownType : t; } return type; } @@ -35725,7 +36707,7 @@ var ts; noUnusedIdentifiers && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8 /* Private */)) { - if (prop.flags & 16777216 /* Instantiated */) { + if (getCheckFlags(prop) & 1 /* Instantiated */) { getSymbolLinks(prop).target.isReferenced = true; } else { @@ -35733,6 +36715,15 @@ var ts; } } } + function isInPropertyInitializer(node) { + while (node) { + if (node.parent && node.parent.kind === 148 /* PropertyDeclaration */ && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { var type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -35745,16 +36736,23 @@ var ts; } var prop = getPropertyOfType(apparentType, right.text); if (!prop) { + var stringIndexType = getIndexTypeOfType(apparentType, 0 /* String */); + if (stringIndexType) { + return stringIndexType; + } if (right.text && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & 16384 /* TypeParameter */ && type.isThisType ? apparentType : type); } return unknownType; } + if (prop.valueDeclaration && + isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; - if (prop.parent && prop.parent.flags & 32 /* Class */) { - checkClassPropertyAccess(node, left, apparentType, prop); - } + checkPropertyAccessibility(node, left, apparentType, prop); var propType = getTypeOfSymbol(prop); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { @@ -35766,7 +36764,7 @@ var ts; // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 177 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || + if (node.kind !== 178 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 65536 /* Union */)) { return propType; @@ -35775,14 +36773,14 @@ var ts; return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 177 /* PropertyAccessExpression */ + var left = node.kind === 178 /* 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 */) { - return checkClassPropertyAccess(node, left, type, prop); + if (prop) { + return checkPropertyAccessibility(node, left, type, prop); } } return true; @@ -35792,7 +36790,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 225 /* VariableDeclarationList */) { + if (initializer.kind === 226 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -35821,7 +36819,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 213 /* ForInStatement */ && + if (node.kind === 214 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -35839,7 +36837,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 180 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 181 /* 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); @@ -35859,7 +36857,7 @@ var ts; error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } - return getIndexedAccessType(objectType, indexType, node); + return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === unknownType) { @@ -35897,10 +36895,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 181 /* TaggedTemplateExpression */) { + if (node.kind === 182 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 145 /* Decorator */) { + else if (node.kind !== 146 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -35930,13 +36928,13 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_9 = signature.declaration && signature.declaration.parent; + var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_9 === lastParent) { + if (lastParent && parent === lastParent) { index++; } else { - lastParent = parent_9; + lastParent = parent; index = cutoffIndex; } } @@ -35944,7 +36942,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_9; + lastParent = parent; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -35966,7 +36964,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 196 /* SpreadElement */) { + if (arg && arg.kind === 197 /* SpreadElement */) { return i; } } @@ -35979,13 +36977,17 @@ 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 === 181 /* TaggedTemplateExpression */) { + if (ts.isJsxOpeningLikeElement(node)) { + // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". + return true; + } + if (node.kind === 182 /* 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 argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 194 /* TemplateExpression */) { + if (tagExpression.template.kind === 195 /* 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; @@ -36002,7 +37004,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 145 /* Decorator */) { + else if (node.kind === 146 /* Decorator */) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -36011,19 +37013,21 @@ 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 === 180 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 181 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; - // If we are missing the close paren, the call is incomplete. + // If we are missing the close parenthesis, the call is incomplete. callIsIncomplete = callExpression.arguments.end === callExpression.end; typeArguments = callExpression.typeArguments; spreadArgIndex = getSpreadArgumentIndex(args); } // If the user supplied type arguments, but the number of type arguments does not match // the declared number of type parameters, the call has an incorrect arity. + var numTypeParameters = ts.length(signature.typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters); var hasRightNumberOfTypeArgs = !typeArguments || - (signature.typeParameters && typeArguments.length === signature.typeParameters.length); + (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters); if (!hasRightNumberOfTypeArgs) { return false; } @@ -36095,7 +37099,7 @@ 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 !== 198 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 199 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -36130,7 +37134,7 @@ var ts; var typeParameters = signature.typeParameters; var typeArgumentsAreAssignable = true; var mapper; - for (var i = 0; i < typeParameters.length; i++) { + for (var i = 0; i < typeArgumentNodes.length; i++) { if (typeArgumentsAreAssignable /* so far */) { var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { @@ -36150,9 +37154,44 @@ var ts; } return typeArgumentsAreAssignable; } + /** + * Check if the given signature can possibly be a signature called by the JSX opening-like element. + * @param node a JSX opening-like element we are trying to figure its call signature + * @param signature a candidate signature we are trying whether it is a call signature + * @param relation a relationship to check parameter and argument type + * @param excludeArgument + */ + function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { + // JSX opening-like element has correct arity for stateless-function component if the one of the following condition is true: + // 1. callIsIncomplete + // 2. attributes property has same number of properties as the parameter object type. + // We can figure that out by resolving attributes property and check number of properties in the resolved type + // If the call has correct arity, we will then check if the argument type and parameter type is assignable + var callIsIncomplete = node.attributes.end === node.end; // If we are missing the close "/>", the call is incomplete + if (callIsIncomplete) { + return true; + } + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + // Stateless function components can have maximum of three arguments: "props", "context", and "updater". + // However "context" and "updater" are implicit and can't be specify by users. Only the first parameter, props, + // can be specified by users through attributes property. + var paramType = getTypeAtPosition(signature, 0); + var attributesType = checkExpressionWithContextualType(node.attributes, paramType, /*contextualMapper*/ undefined); + var argProperties = getPropertiesOfType(attributesType); + for (var _i = 0, argProperties_1 = argProperties; _i < argProperties_1.length; _i++) { + var arg = argProperties_1[_i]; + if (!getPropertyOfType(paramType, arg.name) && isUnhyphenatedJsxName(arg.name)) { + return false; + } + } + return checkTypeRelatedTo(attributesType, paramType, relation, /*errorNode*/ undefined, headMessage); + } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { + if (ts.isJsxOpeningLikeElement(node)) { + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 180 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 181 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -36169,7 +37208,7 @@ 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 !== 198 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 199 /* 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); @@ -36191,12 +37230,12 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 179 /* CallExpression */) { + if (node.kind === 180 /* CallExpression */) { var callee = node.expression; - if (callee.kind === 177 /* PropertyAccessExpression */) { + if (callee.kind === 178 /* PropertyAccessExpression */) { return callee.expression; } - else if (callee.kind === 178 /* ElementAccessExpression */) { + else if (callee.kind === 179 /* ElementAccessExpression */) { return callee.expression; } } @@ -36212,21 +37251,24 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 181 /* TaggedTemplateExpression */) { + if (node.kind === 182 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 194 /* TemplateExpression */) { + if (template.kind === 195 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 145 /* Decorator */) { + else if (node.kind === 146 /* 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. return undefined; } + else if (ts.isJsxOpeningLikeElement(node)) { + args = node.attributes.properties.length > 0 ? [node.attributes] : emptyArray; + } else { args = node.arguments || emptyArray; } @@ -36246,19 +37288,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 145 /* Decorator */) { + if (node.kind === 146 /* Decorator */) { switch (node.parent.kind) { - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) // If we are emitting decorators for ES3, we will only pass two arguments. @@ -36268,7 +37310,7 @@ var ts; // 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 144 /* Parameter */: + case 145 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -36292,25 +37334,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 227 /* ClassDeclaration */) { + if (node.kind === 228 /* ClassDeclaration */) { // 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); } - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 150 /* Constructor */) { + if (node.kind === 151 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 147 /* PropertyDeclaration */ || - node.kind === 149 /* MethodDeclaration */ || - node.kind === 151 /* GetAccessor */ || - node.kind === 152 /* SetAccessor */) { + if (node.kind === 148 /* PropertyDeclaration */ || + node.kind === 150 /* MethodDeclaration */ || + node.kind === 152 /* GetAccessor */ || + node.kind === 153 /* 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 @@ -36337,21 +37379,23 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 227 /* ClassDeclaration */) { + if (node.kind === 228 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { node = node.parent; - if (node.kind === 150 /* Constructor */) { + if (node.kind === 151 /* 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. } - if (node.kind === 147 /* PropertyDeclaration */ || - node.kind === 149 /* MethodDeclaration */ || - node.kind === 151 /* GetAccessor */ || - node.kind === 152 /* SetAccessor */) { + if (node.kind === 148 /* PropertyDeclaration */ || + node.kind === 150 /* MethodDeclaration */ || + node.kind === 152 /* GetAccessor */ || + node.kind === 153 /* 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; // otherwise, if the member name is a computed property name it will @@ -36362,7 +37406,7 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getLiteralTypeForText(32 /* StringLiteral */, element.name.text); - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512 /* ESSymbol */)) { return nameType; @@ -36388,21 +37432,21 @@ var ts; function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 227 /* ClassDeclaration */) { + if (node.kind === 228 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 147 /* PropertyDeclaration */) { + if (node.kind === 148 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 149 /* MethodDeclaration */ || - node.kind === 151 /* GetAccessor */ || - node.kind === 152 /* SetAccessor */) { + if (node.kind === 150 /* MethodDeclaration */ || + node.kind === 152 /* GetAccessor */ || + node.kind === 153 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -36434,10 +37478,10 @@ var ts; // 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 === 145 /* Decorator */) { + if (node.kind === 146 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 181 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -36449,8 +37493,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 === 145 /* Decorator */ || - (argIndex === 0 && node.kind === 181 /* TaggedTemplateExpression */)) { + if (node.kind === 146 /* Decorator */ || + (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -36459,11 +37503,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 145 /* Decorator */) { + if (node.kind === 146 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 181 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -36472,10 +37516,11 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 181 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 145 /* Decorator */; + var isTaggedTemplate = node.kind === 182 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 146 /* Decorator */; + var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; - if (!isTaggedTemplate && !isDecorator) { + if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. if (node.expression.kind !== 96 /* SuperKeyword */) { @@ -36544,7 +37589,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 179 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 180 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -36573,6 +37618,10 @@ var ts; // If candidate is undefined, it means that no candidates had a suitable arity. In that case, // skip the checkApplicableSignature check. if (candidateForArgumentError) { + if (isJsxOpeningOrSelfClosingElement) { + // We do not report any error here because any error will be handled in "resolveCustomJsxElementAttributesType". + return candidateForArgumentError; + } // excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...] // The importance of excludeArgument is to prevent us from typing function expression parameters // in arguments too early. If possible, we'd like to only type them once we know the correct @@ -36594,7 +37643,7 @@ var ts; if (headMessage) { diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); } - reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); + reportNoCommonSupertypeError(inferenceCandidates, node.tagName || node.expression || node.tag, diagnosticChainHead); } } else { @@ -36642,13 +37691,13 @@ var ts; if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNode); + typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); - typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; } if (!typeArgumentsAreValid) { break; @@ -36893,16 +37942,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 144 /* Parameter */: + case 145 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -36930,21 +37979,73 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray, headMessage); } + /** + * This function is similar to getResolvedSignature but is exclusively for trying to resolve JSX stateless-function component. + * The main reason we have to use this function instead of getResolvedSignature because, the caller of this function will already check the type of openingLikeElement's tagName + * and pass the type as elementType. The elementType can not be a union (as such case should be handled by the caller of this function) + * Note: at this point, we are still not sure whether the opening-like element is a stateless function component or not. + * @param openingLikeElement an opening-like JSX element to try to resolve as JSX stateless function + * @param elementType an element type of the opneing-like element by checking opening-like element's tagname. + * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; + * the function will fill it up with appropriate candidate signatures + */ + function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray) { + ts.Debug.assert(!(elementType.flags & 65536 /* Union */)); + var callSignature = resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray); + return callSignature; + } + /** + * Try treating a given opening-like element as stateless function component and resolve a tagName to a function signature. + * @param openingLikeElement an JSX opening-like element we want to try resolve its stateless function if possible + * @param elementType a type of the opening-like JSX element, a result of resolving tagName in opening-like element. + * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; + * the function will fill it up with appropriate candidate signatures + * @return a resolved signature if we can find function matching function signature through resolve call or a first signature in the list of functions. + * otherwise return undefined if tag-name of the opening-like element doesn't have call signatures + */ + function resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray) { + // If this function is called from language service, elementType can be a union type. This is not possible if the function is called from compiler (see: resolveCustomJsxElementAttributesType) + if (elementType.flags & 65536 /* Union */) { + var types = elementType.types; + var result = void 0; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); + } + return result; + } + var callSignatures = elementType && getSignaturesOfType(elementType, 0 /* Call */); + if (callSignatures && callSignatures.length > 0) { + var callSignature = void 0; + callSignature = resolveCall(openingLikeElement, callSignatures, candidatesOutArray); + return callSignature; + } + return undefined; + } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 179 /* CallExpression */: + case 180 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 145 /* Decorator */: + case 146 /* Decorator */: return resolveDecorator(node, candidatesOutArray); + case 250 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + // This code-path is called by language service + return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); } - // candidatesOutArray is passed by signature help in the language service, and collectCandidates - // must fill it up with the appropriate candidate signatures + /** + * Resolve a signature of a given call-like expression. + * @param node a call-like expression to try resolve a signature for + * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; + * the function will fill it up with appropriate candidate signatures + * @return a signature of the call-like expression or undefined if one can't be found + */ function getResolvedSignature(node, candidatesOutArray) { var links = getNodeLinks(node); // If getResolvedSignature has already been called, we will have cached the resolvedSignature. @@ -36987,12 +38088,12 @@ var ts; if (node.expression.kind === 96 /* SuperKeyword */) { return voidType; } - if (node.kind === 180 /* NewExpression */) { + if (node.kind === 181 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 150 /* Constructor */ && - declaration.kind !== 154 /* ConstructSignature */ && - declaration.kind !== 159 /* ConstructorType */ && + declaration.kind !== 151 /* Constructor */ && + declaration.kind !== 155 /* ConstructSignature */ && + declaration.kind !== 160 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations @@ -37032,9 +38133,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 226 /* FunctionDeclaration */ + ? 227 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 224 /* VariableDeclaration */ + ? 225 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -37069,7 +38170,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return unknownType; } - else if (container.kind === 150 /* Constructor */) { + else if (container.kind === 151 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -37107,7 +38208,7 @@ var ts; var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { if (!parameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); } assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } @@ -37148,8 +38249,8 @@ var ts; links.type = instantiateType(contextualType, mapper); // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 172 /* ObjectBindingPattern */ || - parameter.valueDeclaration.name.kind === 173 /* ArrayBindingPattern */)) { + (parameter.valueDeclaration.name.kind === 173 /* ObjectBindingPattern */ || + parameter.valueDeclaration.name.kind === 174 /* ArrayBindingPattern */)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -37210,6 +38311,9 @@ var ts; error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } + else if (!getGlobalPromiseConstructorSymbol()) { + error(func, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } return promiseType; } function getReturnTypeFromBody(func, contextualMapper) { @@ -37219,7 +38323,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 205 /* Block */) { + if (func.body.kind !== 206 /* 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 @@ -37309,7 +38413,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 219 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 220 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -37342,7 +38446,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 184 /* FunctionExpression */ || func.kind === 185 /* ArrowFunction */)) { + func.kind === 185 /* FunctionExpression */ || func.kind === 186 /* ArrowFunction */)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -37371,7 +38475,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (ts.nodeIsMissing(func.body) || func.body.kind !== 205 /* Block */ || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 206 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -37404,10 +38508,10 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 184 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 185 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -37448,7 +38552,7 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 149 /* MethodDeclaration */) { + if (produceDiagnostics && node.kind !== 150 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithCapturedNewTargetVariable(node, node.name); @@ -37456,7 +38560,7 @@ var ts; return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -37472,7 +38576,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 205 /* Block */) { + if (node.body.kind === 206 /* Block */) { checkSourceElement(node.body); } else { @@ -37509,21 +38613,21 @@ var ts; // Get accessors without matching set accessors // Enum members // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return symbol.isReadonly || - symbol.flags & 4 /* Property */ && (getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */) !== 0 || - symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0 || + return !!(getCheckFlags(symbol) & 4 /* Readonly */ || + symbol.flags & 4 /* Property */ && getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || + symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ || symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || - (symbol.flags & 8 /* EnumMember */) !== 0; + symbol.flags & 8 /* EnumMember */); } function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 177 /* PropertyAccessExpression */ || expr.kind === 178 /* ElementAccessExpression */) && + (expr.kind === 178 /* PropertyAccessExpression */ || expr.kind === 179 /* ElementAccessExpression */) && expr.expression.kind === 98 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 150 /* Constructor */)) + if (!(func && func.kind === 151 /* Constructor */)) return true; // If func.parent is a class and symbol is a (readonly) property of that class, or // if func is a constructor and symbol is a (readonly) parameter property declared in it, @@ -37535,13 +38639,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 177 /* PropertyAccessExpression */ || expr.kind === 178 /* ElementAccessExpression */) { + if (expr.kind === 178 /* PropertyAccessExpression */ || expr.kind === 179 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); if (node.kind === 70 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 238 /* NamespaceImport */; + return declaration && declaration.kind === 239 /* NamespaceImport */; } } } @@ -37550,7 +38654,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipParentheses(expr); - if (node.kind !== 70 /* Identifier */ && node.kind !== 177 /* PropertyAccessExpression */ && node.kind !== 178 /* ElementAccessExpression */) { + if (node.kind !== 70 /* Identifier */ && node.kind !== 178 /* PropertyAccessExpression */ && node.kind !== 179 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -37559,7 +38663,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 177 /* PropertyAccessExpression */ && expr.kind !== 178 /* ElementAccessExpression */) { + if (expr.kind !== 178 /* PropertyAccessExpression */ && expr.kind !== 179 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -37572,7 +38676,7 @@ var ts; } function checkTypeOfExpression(node) { checkExpression(node.expression); - return stringType; + return typeofType; } function checkVoidExpression(node) { checkExpression(node.expression); @@ -37603,6 +38707,7 @@ var ts; case 36 /* PlusToken */: case 37 /* MinusToken */: case 51 /* TildeToken */: + checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 512 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } @@ -37614,7 +38719,7 @@ var ts; booleanType; case 42 /* PlusPlusToken */: case 43 /* MinusMinusToken */: - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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 checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); @@ -37628,7 +38733,7 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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 checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); @@ -37643,8 +38748,8 @@ var ts; } if (type.flags & 196608 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -37661,8 +38766,8 @@ var ts; } if (type.flags & 65536 /* Union */) { var types = type.types; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var t = types_19[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -37671,8 +38776,8 @@ var ts; } if (type.flags & 131072 /* Intersection */) { var types = type.types; - for (var _a = 0, types_18 = types; _a < types_18.length; _a++) { - var t = types_18[_a]; + for (var _a = 0, types_20 = types; _a < types_20.length; _a++) { + var t = types_20[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -37692,14 +38797,17 @@ var ts; } // TypeScript 1.0 spec (April 2014): 4.15.4 // The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, - // and the right operand to be of type Any or a subtype of the 'Function' interface type. + // and the right operand to be of type Any, a subtype of the 'Function' interface type, or have a call or construct signature. // 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 (isTypeOfKind(leftType, 8190 /* Primitive */)) { error(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 - if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { + if (!(isTypeAny(rightType) || + getSignaturesOfType(rightType, 0 /* Call */).length || + getSignaturesOfType(rightType, 1 /* Construct */).length || + isTypeSubtypeOf(rightType, globalFunctionType))) { error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; @@ -37708,6 +38816,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); // TypeScript 1.0 spec (April 2014): 4.15.5 // 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. @@ -37730,22 +38840,22 @@ var ts; } /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 258 /* PropertyAssignment */ || property.kind === 259 /* ShorthandPropertyAssignment */) { - var name_20 = property.name; - if (name_20.kind === 142 /* ComputedPropertyName */) { - checkComputedPropertyName(name_20); + if (property.kind === 260 /* PropertyAssignment */ || property.kind === 261 /* ShorthandPropertyAssignment */) { + var name = property.name; + if (name.kind === 143 /* ComputedPropertyName */) { + checkComputedPropertyName(name); } - if (isComputedNonLiteralName(name_20)) { + if (isComputedNonLiteralName(name)) { return undefined; } - var text = ts.getTextOfPropertyName(name_20); + var text = ts.getTextOfPropertyName(name); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 259 /* ShorthandPropertyAssignment */) { + if (property.kind === 261 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -37754,10 +38864,10 @@ var ts; } } else { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 260 /* SpreadAssignment */) { + else if (property.kind === 262 /* SpreadAssignment */) { if (languageVersion < 5 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -37788,8 +38898,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 198 /* OmittedExpression */) { - if (element.kind !== 196 /* SpreadElement */) { + if (element.kind !== 199 /* OmittedExpression */) { + if (element.kind !== 197 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -37817,7 +38927,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 192 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { + if (restExpression.kind === 193 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -37830,7 +38940,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 259 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 261 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -37846,21 +38956,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 192 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { + if (target.kind === 193 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 176 /* ObjectLiteralExpression */) { + if (target.kind === 177 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 175 /* ArrayLiteralExpression */) { + if (target.kind === 176 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 260 /* SpreadAssignment */ ? + var error = target.parent.kind === 262 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -37882,35 +38992,35 @@ var ts; case 70 /* Identifier */: case 9 /* StringLiteral */: case 11 /* RegularExpressionLiteral */: - case 181 /* TaggedTemplateExpression */: - case 194 /* TemplateExpression */: + case 182 /* TaggedTemplateExpression */: + case 195 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: case 94 /* NullKeyword */: - case 137 /* UndefinedKeyword */: - case 184 /* FunctionExpression */: - case 197 /* ClassExpression */: - case 185 /* ArrowFunction */: - case 175 /* ArrayLiteralExpression */: - case 176 /* ObjectLiteralExpression */: - case 187 /* TypeOfExpression */: - case 201 /* NonNullExpression */: - case 248 /* JsxSelfClosingElement */: - case 247 /* JsxElement */: + case 138 /* UndefinedKeyword */: + case 185 /* FunctionExpression */: + case 198 /* ClassExpression */: + case 186 /* ArrowFunction */: + case 176 /* ArrayLiteralExpression */: + case 177 /* ObjectLiteralExpression */: + case 188 /* TypeOfExpression */: + case 202 /* NonNullExpression */: + case 249 /* JsxSelfClosingElement */: + case 248 /* JsxElement */: return true; - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -37922,9 +39032,9 @@ var ts; } return false; // Some forms listed here for clarity - case 188 /* VoidExpression */: // Explicit opt-out - case 182 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 200 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 189 /* VoidExpression */: // Explicit opt-out + case 183 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 201 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -37944,7 +39054,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 57 /* EqualsToken */ && (left.kind === 176 /* ObjectLiteralExpression */ || left.kind === 175 /* ArrayLiteralExpression */)) { + if (operator === 57 /* EqualsToken */ && (left.kind === 177 /* ObjectLiteralExpression */ || left.kind === 176 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -37975,18 +39085,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - // TypeScript 1.0 spec (April 2014): 4.19.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 - // as having the primitive type Number. If one operand is the null or undefined value, - // it is treated as having the type of the other operand. - // The result is always of the Number primitive type. - if (leftType.flags & 6144 /* Nullable */) - leftType = rightType; - if (rightType.flags & 6144 /* Nullable */) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion @@ -38009,16 +39109,10 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - // TypeScript 1.0 spec (April 2014): 4.19.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. - // If one operand is the null or undefined value, it is treated as having the type of the other operand. - if (leftType.flags & 6144 /* Nullable */) - leftType = rightType; - if (rightType.flags & 6144 /* Nullable */) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + if (!isTypeOfKind(leftType, 1 /* Any */ | 262178 /* StringLike */) && !isTypeOfKind(rightType, 1 /* Any */ | 262178 /* StringLike */)) { + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); + } var resultType = void 0; if (isTypeOfKind(leftType, 340 /* NumberLike */) && isTypeOfKind(rightType, 340 /* NumberLike */)) { // Operands of an enum type are treated as having the primitive type Number. @@ -38053,8 +39147,8 @@ var ts; case 29 /* LessThanEqualsToken */: case 30 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { - leftType = getBaseTypeOfLiteralType(leftType); - rightType = getBaseTypeOfLiteralType(rightType); + leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); + rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } @@ -38246,7 +39340,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 182 /* TypeAssertionExpression */ || node.kind === 200 /* AsExpression */; + return node.kind === 183 /* TypeAssertionExpression */ || node.kind === 201 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -38257,14 +39351,14 @@ var ts; function isLiteralContextualType(contextualType) { if (contextualType) { if (contextualType.flags & 540672 /* TypeVariable */) { - var apparentType = getApparentTypeOfTypeVariable(contextualType); + var constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; // If the type parameter is constrained to the base primitive type we're checking for, // consider this a literal context. For example, given a type parameter 'T extends string', // this causes us to infer string literal types for T. - if (apparentType.flags & (2 /* String */ | 4 /* Number */ | 8 /* Boolean */ | 16 /* Enum */)) { + if (constraint.flags & (2 /* String */ | 4 /* Number */ | 8 /* Boolean */ | 16 /* Enum */)) { return true; } - contextualType = apparentType; + contextualType = constraint; } return maybeTypeOfKind(contextualType, (480 /* Literal */ | 262144 /* Index */)); } @@ -38278,7 +39372,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 === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); @@ -38289,7 +39383,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 === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -38315,7 +39409,7 @@ var ts; function getTypeOfExpression(node) { // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (node.kind === 179 /* CallExpression */ && node.expression.kind !== 96 /* SuperKeyword */) { + if (node.kind === 180 /* CallExpression */ && node.expression.kind !== 96 /* SuperKeyword */) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -38336,7 +39430,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 141 /* QualifiedName */) { + if (node.kind === 142 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -38348,9 +39442,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 177 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 178 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 179 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 70 /* Identifier */ || node.kind === 142 /* 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); } @@ -38372,68 +39466,70 @@ var ts; case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: return checkLiteralExpression(node); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* NoSubstitutionTemplateLiteral */: return stringType; case 11 /* RegularExpressionLiteral */: return globalRegExpType; - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 179 /* CallExpression */: - case 180 /* NewExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: return checkCallExpression(node); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return checkClassExpression(node); - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 187 /* TypeOfExpression */: + case 188 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: return checkAssertion(node); - case 201 /* NonNullExpression */: + case 202 /* NonNullExpression */: return checkNonNullAssertion(node); - case 202 /* MetaProperty */: + case 203 /* MetaProperty */: return checkMetaProperty(node); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return checkDeleteExpression(node); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return checkVoidExpression(node); - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: return checkAwaitExpression(node); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return checkSpreadExpression(node, contextualMapper); - case 198 /* OmittedExpression */: + case 199 /* OmittedExpression */: return undefinedWideningType; - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return checkYieldExpression(node); - case 253 /* JsxExpression */: - return checkJsxExpression(node); - case 247 /* JsxElement */: + case 255 /* JsxExpression */: + return checkJsxExpression(node, contextualMapper); + case 248 /* JsxElement */: return checkJsxElement(node); - case 248 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 249 /* JsxOpeningElement */: + case 253 /* JsxAttributes */: + return checkJsxAttributes(node, contextualMapper); + case 250 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -38445,7 +39541,16 @@ var ts; grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } checkSourceElement(node.constraint); - getConstraintOfTypeParameter(getDeclaredTypeOfTypeParameter(getSymbolOfNode(node))); + checkSourceElement(node.default); + var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); + if (!hasNonCircularBaseConstraint(typeParameter)) { + error(node.constraint, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); + } + var constraintType = getConstraintOfTypeParameter(typeParameter); + var defaultType = getDefaultFromTypeParameter(typeParameter); + if (constraintType && defaultType) { + checkTypeAssignableTo(defaultType, getTypeWithThisArgument(constraintType, defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } @@ -38461,7 +39566,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92 /* ParameterPropertyModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 150 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 151 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -38472,7 +39577,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 150 /* Constructor */ || func.kind === 154 /* ConstructSignature */ || func.kind === 159 /* ConstructorType */) { + if (func.kind === 151 /* Constructor */ || func.kind === 155 /* ConstructSignature */ || func.kind === 160 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -38486,9 +39591,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 149 /* MethodDeclaration */ || - node.kind === 226 /* FunctionDeclaration */ || - node.kind === 184 /* FunctionExpression */; + return node.kind === 150 /* MethodDeclaration */ || + node.kind === 227 /* FunctionDeclaration */ || + node.kind === 185 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -38531,9 +39636,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_21 = _a[_i].name; - if (ts.isBindingPattern(name_21) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_21, parameterName, typePredicate.parameterName)) { + var name = _a[_i].name; + if (ts.isBindingPattern(name) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -38546,16 +39651,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 185 /* ArrowFunction */: - case 153 /* CallSignature */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 158 /* FunctionType */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - var parent_10 = node.parent; - if (node === parent_10.type) { - return parent_10; + case 186 /* ArrowFunction */: + case 154 /* CallSignature */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 159 /* FunctionType */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + var parent = node.parent; + if (node === parent.type) { + return parent; } } } @@ -38565,15 +39670,15 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_22 = element.name; - if (name_22.kind === 70 /* Identifier */ && - name_22.text === predicateVariableName) { + var name = element.name; + if (name.kind === 70 /* Identifier */ && + name.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_22.kind === 173 /* ArrayBindingPattern */ || - name_22.kind === 172 /* ObjectBindingPattern */) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, predicateVariableNode, predicateVariableName)) { + else if (name.kind === 174 /* ArrayBindingPattern */ || + name.kind === 173 /* ObjectBindingPattern */) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } } @@ -38581,12 +39686,12 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 155 /* IndexSignature */) { + if (node.kind === 156 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 /* FunctionType */ || node.kind === 226 /* FunctionDeclaration */ || node.kind === 159 /* ConstructorType */ || - node.kind === 153 /* CallSignature */ || node.kind === 150 /* Constructor */ || - node.kind === 154 /* ConstructSignature */) { + else if (node.kind === 159 /* FunctionType */ || node.kind === 227 /* FunctionDeclaration */ || node.kind === 160 /* ConstructorType */ || + node.kind === 154 /* CallSignature */ || node.kind === 151 /* Constructor */ || + node.kind === 155 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } if (ts.isAsyncFunctionLike(node) && languageVersion < 4 /* ES2017 */) { @@ -38604,10 +39709,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 153 /* CallSignature */: + case 154 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -38640,17 +39745,18 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { - var Accessor; - (function (Accessor) { - Accessor[Accessor["Getter"] = 1] = "Getter"; - Accessor[Accessor["Setter"] = 2] = "Setter"; - Accessor[Accessor["Property"] = 3] = "Property"; - })(Accessor || (Accessor = {})); + var Declaration; + (function (Declaration) { + Declaration[Declaration["Getter"] = 1] = "Getter"; + Declaration[Declaration["Setter"] = 2] = "Setter"; + Declaration[Declaration["Method"] = 4] = "Method"; + Declaration[Declaration["Property"] = 3] = "Property"; + })(Declaration || (Declaration = {})); var instanceNames = ts.createMap(); var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150 /* Constructor */) { + if (member.kind === 151 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -38659,36 +39765,76 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114 /* StaticKeyword */; }); + var isStatic = ts.getModifierFlags(member) & 32 /* Static */; var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: addName(names, member.name, memberName, 1 /* Getter */); break; - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: addName(names, member.name, memberName, 2 /* Setter */); break; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: addName(names, member.name, memberName, 3 /* Property */); break; + case 150 /* MethodDeclaration */: + addName(names, member.name, memberName, 4 /* Method */); + break; } } } } function addName(names, location, name, meaning) { - var prev = names[name]; + var prev = names.get(name); if (prev) { - if (prev & meaning) { + if (prev & 4 /* Method */) { + if (meaning !== 4 /* Method */) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + } + else if (prev & meaning) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { - names[name] = prev | meaning; + names.set(name, prev | meaning); } } else { - names[name] = meaning; + names.set(name, meaning); + } + } + } + /** + * Static members being set on a constructor function may conflict with built-in properties + * of Function. Esp. in ECMAScript 5 there are non-configurable and non-writable + * built-in properties. This check issues a transpile error when a class has a static + * member with the same name as a non-writable built-in property. + * + * @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.3 + * @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5 + * @see http://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-function-constructor + * @see http://www.ecma-international.org/ecma-262/6.0/#sec-function-instances + */ + function checkClassForStaticPropertyNameConflicts(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + var memberNameNode = member.name; + var isStatic = ts.getModifierFlags(member) & 32 /* Static */; + if (isStatic && memberNameNode) { + var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode); + switch (memberName) { + case "name": + case "length": + case "caller": + case "arguments": + case "prototype": + var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; + var className = getNameOfSymbol(getSymbolOfNode(node)); + error(memberNameNode, message, memberName, className); + break; + } } } } @@ -38696,7 +39842,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 146 /* PropertySignature */) { + if (member.kind == 147 /* PropertySignature */) { var memberName = void 0; switch (member.name.kind) { case 9 /* StringLiteral */: @@ -38707,18 +39853,18 @@ var ts; default: continue; } - if (names[memberName]) { + if (names.get(memberName)) { error(member.symbol.valueDeclaration.name, ts.Diagnostics.Duplicate_identifier_0, memberName); error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName); } else { - names[memberName] = true; + names.set(memberName, true); } } } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 228 /* InterfaceDeclaration */) { + if (node.kind === 229 /* 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 @@ -38738,7 +39884,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -38814,12 +39960,12 @@ var ts; if (n.kind === 98 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 /* FunctionExpression */ && n.kind !== 226 /* FunctionDeclaration */) { + else if (n.kind !== 185 /* FunctionExpression */ && n.kind !== 227 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 147 /* PropertyDeclaration */ && + return n.kind === 148 /* PropertyDeclaration */ && !(ts.getModifierFlags(n) & 32 /* Static */) && !!n.initializer; } @@ -38849,7 +39995,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -38873,7 +40019,7 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 151 /* GetAccessor */) { + if (node.kind === 152 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -38883,13 +40029,13 @@ 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 === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } 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 === 151 /* GetAccessor */ ? 152 /* SetAccessor */ : 151 /* GetAccessor */; + var otherKind = node.kind === 152 /* GetAccessor */ ? 153 /* SetAccessor */ : 152 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28 /* AccessibilityModifier */) !== (ts.getModifierFlags(otherAccessor) & 28 /* AccessibilityModifier */)) { @@ -38905,11 +40051,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 151 /* GetAccessor */) { + if (node.kind === 152 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 176 /* ObjectLiteralExpression */) { + if (node.parent.kind !== 177 /* ObjectLiteralExpression */) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -38932,6 +40078,7 @@ var ts; checkDecorators(node); } function checkTypeArgumentConstraints(typeParameters, typeArgumentNodes) { + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); var typeArguments; var mapper; var result = true; @@ -38939,7 +40086,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -38992,16 +40139,36 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessIndexType(type, accessNode) { + if (!(type.flags & 524288 /* IndexedAccess */)) { + return type; + } + // Check if the index type is assignable to 'keyof T' for the object type. + var objectType = type.objectType; + var indexType = type.indexType; + if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + return type; + } + // Check if we're indexing with a numeric type and the object type is a generic + // type with a constraint that has a numeric index signature. + if (maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && isTypeOfKind(indexType, 340 /* NumberLike */)) { + var constraint = getBaseConstraintOfType(objectType); + if (constraint && getIndexInfoOfType(constraint, 1 /* Number */)) { + return type; + } + } + error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); + return type; + } function checkIndexedAccessType(node) { - getTypeFromIndexedAccessTypeNode(node); + checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node) { checkSourceElement(node.typeParameter); checkSourceElement(node.type); var type = getTypeFromMappedTypeNode(node); var constraintType = getConstraintTypeFromMappedType(type); - var keyType = constraintType.flags & 540672 /* TypeVariable */ ? getApparentTypeOfTypeVariable(constraintType) : constraintType; - checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint); + checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8 /* Private */) && ts.isInAmbientContext(node); @@ -39010,9 +40177,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 228 /* InterfaceDeclaration */ && - n.parent.kind !== 227 /* ClassDeclaration */ && - n.parent.kind !== 197 /* ClassExpression */ && + if (n.parent.kind !== 229 /* InterfaceDeclaration */ && + n.parent.kind !== 228 /* ClassDeclaration */ && + n.parent.kind !== 198 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported @@ -39100,7 +40267,7 @@ var ts; var errorNode_1 = subsequentNode.name || subsequentNode; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */) && + var reportError = (node.kind === 150 /* MethodDeclaration */ || node.kind === 149 /* MethodSignature */) && (ts.getModifierFlags(node) & 32 /* Static */) !== (ts.getModifierFlags(subsequentNode) & 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -39135,11 +40302,11 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var current = declarations_5[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 228 /* InterfaceDeclaration */ || node.parent.kind === 161 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 229 /* InterfaceDeclaration */ || node.parent.kind === 162 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -39150,7 +40317,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 === 226 /* FunctionDeclaration */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */ || node.kind === 150 /* Constructor */) { + if (node.kind === 227 /* FunctionDeclaration */ || node.kind === 150 /* MethodDeclaration */ || node.kind === 149 /* MethodSignature */ || node.kind === 151 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -39272,16 +40439,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 227 /* ClassDeclaration */: - case 230 /* EnumDeclaration */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -39510,7 +40677,12 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; if (promiseConstructorType === unknownType) { - error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + if (promiseConstructorName.kind === 70 /* Identifier */ && promiseConstructorName.text === "Promise" && getTargetType(returnType) === tryGetGlobalPromiseType()) { + error(node.type, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } + else { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + } return unknownType; } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); @@ -39545,22 +40717,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 144 /* Parameter */: + case 145 /* 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 147 /* PropertyDeclaration */: + case 148 /* 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 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -39601,14 +40773,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -39617,19 +40789,19 @@ var ts; } } break; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markTypeNodeAsReferenced(node.type); break; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); break; - case 144 /* Parameter */: + case 145 /* Parameter */: markTypeNodeAsReferenced(node.type); break; } @@ -39653,7 +40825,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 && node.name.kind === 142 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 143 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -39713,43 +40885,43 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 262 /* SourceFile */: - case 231 /* ModuleDeclaration */: + case 264 /* SourceFile */: + case 232 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 205 /* Block */: - case 233 /* CaseBlock */: - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: + case 206 /* Block */: + case 234 /* CaseBlock */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: checkUnusedLocalsAndParameters(node); break; - case 150 /* Constructor */: - case 184 /* FunctionExpression */: - case 226 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 151 /* Constructor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: checkUnusedTypeParameters(node); break; } @@ -39758,11 +40930,10 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 228 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_2 = function (key) { - var local = node.locals[key]; + if (node.parent.kind !== 229 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + node.locals.forEach(function (local) { if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144 /* Parameter */) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 145 /* Parameter */) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -39775,10 +40946,7 @@ var ts; ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d.name || d, local.name); }); } } - }; - for (var key in node.locals) { - _loop_2(key); - } + }); } } function isRemovedPropertyFromObjectSpread(node) { @@ -39791,9 +40959,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 224 /* VariableDeclaration */ && - (declaration.parent.parent.kind === 213 /* ForInStatement */ || - declaration.parent.parent.kind === 214 /* ForOfStatement */)) { + if (declaration.kind === 225 /* VariableDeclaration */ && + (declaration.parent.parent.kind === 214 /* ForInStatement */ || + declaration.parent.parent.kind === 215 /* ForOfStatement */)) { return; } } @@ -39812,12 +40980,12 @@ var ts; if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149 /* MethodDeclaration */ || member.kind === 147 /* PropertyDeclaration */) { + if (member.kind === 150 /* MethodDeclaration */ || member.kind === 148 /* PropertyDeclaration */) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8 /* Private */) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 150 /* Constructor */) { + else if (member.kind === 151 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8 /* Private */) { @@ -39850,8 +41018,7 @@ var ts; } function checkUnusedModuleMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { - for (var key in node.locals) { - var local = node.locals[key]; + node.locals.forEach(function (local) { if (!local.isReferenced && !local.exportSymbol) { for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; @@ -39860,12 +41027,12 @@ var ts; } } } - } + }); } } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 205 /* Block */) { + if (node.kind === 206 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -39888,12 +41055,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 147 /* PropertyDeclaration */ || - node.kind === 146 /* PropertySignature */ || - node.kind === 149 /* MethodDeclaration */ || - node.kind === 148 /* MethodSignature */ || - node.kind === 151 /* GetAccessor */ || - node.kind === 152 /* SetAccessor */) { + if (node.kind === 148 /* PropertyDeclaration */ || + node.kind === 147 /* PropertySignature */ || + node.kind === 150 /* MethodDeclaration */ || + node.kind === 149 /* MethodSignature */ || + node.kind === 152 /* GetAccessor */ || + node.kind === 153 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -39902,7 +41069,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 144 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 145 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -39980,12 +41147,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 231 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 232 /* 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 === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 264 /* SourceFile */ && ts.isExternalOrCommonJsModule(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)); } @@ -39995,12 +41162,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 231 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 232 /* 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 === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 264 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -40035,7 +41202,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 224 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 225 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -40045,24 +41212,24 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 225 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 206 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 226 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 207 /* 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 === 205 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 232 /* ModuleBlock */ || - container.kind === 231 /* ModuleDeclaration */ || - container.kind === 262 /* SourceFile */); + (container.kind === 206 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 233 /* ModuleBlock */ || + container.kind === 232 /* ModuleDeclaration */ || + container.kind === 264 /* 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_23 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_23, name_23); + var name = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); } } } @@ -40070,7 +41237,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 144 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 145 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -40081,7 +41248,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 177 /* PropertyAccessExpression */) { + if (n.kind === 178 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -40100,8 +41267,8 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144 /* Parameter */ || - symbol.valueDeclaration.kind === 174 /* BindingElement */) { + if (symbol.valueDeclaration.kind === 145 /* Parameter */ || + symbol.valueDeclaration.kind === 175 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -40115,13 +41282,14 @@ var ts; } // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - if (current.parent.kind === 147 /* PropertyDeclaration */ && + if (current.parent.kind === 148 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)) { return; } current = current.parent; } + // fall through to report error } error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); } @@ -40142,28 +41310,28 @@ 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 === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 174 /* BindingElement */) { - if (node.parent.kind === 172 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */ && !ts.isInAmbientContext(node)) { + if (node.kind === 175 /* BindingElement */) { + if (node.parent.kind === 173 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */ && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 142 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access - var parent_11 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_11); - var name_24 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_24)); + var parent = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent); + var name = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); markPropertyAsReferenced(property); - if (parent_11.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); + if (parent.initializer && property) { + checkPropertyAccessibility(parent, parent.initializer, parentType, property); } } // For a binding pattern, check contained binding elements @@ -40171,14 +41339,14 @@ 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 === 144 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 145 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 213 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 214 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -40189,7 +41357,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 213 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 214 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -40209,10 +41377,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 146 /* PropertySignature */) { + if (node.kind !== 148 /* PropertyDeclaration */ && node.kind !== 147 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 224 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */) { + if (node.kind === 225 /* VariableDeclaration */ || node.kind === 175 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -40223,8 +41391,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 /* Parameter */ && right.kind === 224 /* VariableDeclaration */) || - (left.kind === 224 /* VariableDeclaration */ && right.kind === 144 /* Parameter */)) { + if ((left.kind === 145 /* Parameter */ && right.kind === 225 /* VariableDeclaration */) || + (left.kind === 225 /* VariableDeclaration */ && right.kind === 145 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -40254,7 +41422,7 @@ var ts; } 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 === 176 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 177 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -40275,7 +41443,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 207 /* EmptyStatement */) { + if (node.thenStatement.kind === 208 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -40295,12 +41463,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 225 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 226 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 225 /* VariableDeclarationList */) { + if (node.initializer.kind === 226 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -40323,14 +41491,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 === 225 /* VariableDeclarationList */) { + if (node.initializer.kind === 226 /* 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 === 175 /* ArrayLiteralExpression */ || varExpr.kind === 176 /* ObjectLiteralExpression */) { + if (varExpr.kind === 176 /* ArrayLiteralExpression */ || varExpr.kind === 177 /* 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. @@ -40362,7 +41530,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 === 225 /* VariableDeclarationList */) { + if (node.initializer.kind === 226 /* 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); @@ -40376,7 +41544,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 === 175 /* ArrayLiteralExpression */ || varExpr.kind === 176 /* ObjectLiteralExpression */) { + if (varExpr.kind === 176 /* ArrayLiteralExpression */ || varExpr.kind === 177 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -40629,7 +41797,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 151 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 152 /* SetAccessor */))); + return !!(node.kind === 152 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 153 /* SetAccessor */))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -40656,33 +41824,33 @@ var ts; // for generators. return; } - if (func.kind === 152 /* SetAccessor */) { + if (func.kind === 153 /* SetAccessor */) { if (node.expression) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); + error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 150 /* Constructor */) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { - error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + else if (func.kind === 151 /* Constructor */) { + if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node.expression || node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); if (promisedType) { // If the function has a return type, but promisedType is // undefined, an error will be reported in checkAsyncFunctionReturnType // so we don't need to report one here. - checkTypeAssignableTo(awaitedType, promisedType, node.expression || node); + checkTypeAssignableTo(awaitedType, promisedType, node); } } else { - checkTypeAssignableTo(exprType, returnType, node.expression || node); + checkTypeAssignableTo(exprType, returnType, node); } } } - else if (func.kind !== 150 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 151 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -40712,7 +41880,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 255 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 257 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -40724,7 +41892,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 254 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 256 /* 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 comparable @@ -40755,7 +41923,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 220 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 221 /* 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; @@ -40792,14 +41960,14 @@ var ts; grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - var blockLocals = catchClause.block.locals; - if (blockLocals) { - for (var caughtName in catchClause.locals) { - var blockLocal = blockLocals[caughtName]; + var blockLocals_1 = catchClause.block.locals; + if (blockLocals_1) { + ts.forEachKey(catchClause.locals, function (caughtName) { + var blockLocal = blockLocals_1.get(caughtName); if (blockLocal && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } - } + }); } } } @@ -40851,15 +42019,16 @@ var ts; if (!indexType) { return; } + var propDeclaration = prop.valueDeclaration; // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !isNumericName(prop.valueDeclaration.name)) { + if (indexKind === 1 /* Number */ && !(propDeclaration ? isNumericName(propDeclaration.name) : isNumericLiteralName(prop.name))) { return; } // 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 === 142 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { - errorNode = prop.valueDeclaration; + if (propDeclaration && (propDeclaration.name.kind === 143 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { + errorNode = propDeclaration; } else if (indexDeclaration) { errorNode = indexDeclaration; @@ -40889,16 +42058,26 @@ var ts; case "string": case "symbol": case "void": + case "object": error(name, message, name.text); } } - /** Check each type parameter and check that type parameters have no duplicate type parameter declarations */ + /** + * Check each type parameter and check that type parameters have no duplicate type parameter declarations + */ function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { + var seenDefault = false; for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { + if (node.default) { + seenDefault = true; + } + else if (seenDefault) { + error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters); + } for (var j = 0; j < i; j++) { if (typeParameterDeclarations[j].symbol === node.symbol) { error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name)); @@ -40909,23 +42088,65 @@ var ts; } } /** Check that type parameter lists are identical across multiple declarations */ - function checkTypeParameterListsIdentical(node, symbol) { + function checkTypeParameterListsIdentical(symbol) { if (symbol.declarations.length === 1) { return; } - var firstDecl; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 227 /* ClassDeclaration */ || declaration.kind === 228 /* InterfaceDeclaration */) { - if (!firstDecl) { - firstDecl = declaration; - } - else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); + var links = getSymbolLinks(symbol); + if (!links.typeParametersChecked) { + links.typeParametersChecked = true; + var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); + if (declarations.length <= 1) { + return; + } + var type = getDeclaredTypeOfSymbol(symbol); + if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { + // Report an error on every conflicting declaration. + var name = symbolToString(symbol); + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; + error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } } } + function areTypeParametersIdentical(declarations, typeParameters) { + var maxTypeArgumentCount = ts.length(typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; + // If this declaration has too few or too many type parameters, we report an error + var numTypeParameters = ts.length(declaration.typeParameters); + if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { + return false; + } + for (var i = 0; i < numTypeParameters; i++) { + var source = declaration.typeParameters[i]; + var target = typeParameters[i]; + // If the type parameter node does not have the same as the resolved type + // parameter at this position, we report an error. + if (source.name.text !== target.symbol.name) { + return false; + } + // If the type parameter node does not have an identical constraint as the resolved + // type parameter at this position, we report an error. + var sourceConstraint = source.constraint && getTypeFromTypeNode(source.constraint); + var targetConstraint = getConstraintFromTypeParameter(target); + if ((sourceConstraint || targetConstraint) && + (!sourceConstraint || !targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint))) { + return false; + } + // If the type parameter node has a default and it is not identical to the default + // for the type parameter at this position, we report an error. + var sourceDefault = source.default && getTypeFromTypeNode(source.default); + var targetDefault = getDefaultFromTypeParameter(target); + if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) { + return false; + } + } + } + return true; + } function checkClassExpression(node) { checkClassLikeDeclaration(node); checkNodeDeferred(node); @@ -40959,8 +42180,12 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); + // Only check for reserved static identifiers on non-ambient context. + if (!ts.isInAmbientContext(node)) { + checkClassForStaticPropertyNameConflicts(node); + } var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { if (languageVersion < 2 /* ES2015 */ && !ts.isInAmbientContext(node)) { @@ -40969,7 +42194,8 @@ var ts; var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType_1 = baseTypes[0]; - var staticBaseType = getBaseConstructorTypeOfClass(type); + var baseConstructorType = getBaseConstructorTypeOfClass(type); + var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { @@ -40983,14 +42209,17 @@ var ts; } checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType_1.symbol.valueDeclaration && + if (baseConstructorType.flags & 540672 /* TypeVariable */ && !isMixinConstructorType(staticType)) { + error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); + } + if (baseType_1.symbol && baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 227 /* ClassDeclaration */) { + baseType_1.symbol.valueDeclaration.kind === 228 /* ClassDeclaration */) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 540672 /* TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. We can simply compare the type // references (as opposed to checking the structure of the types) because elsewhere we have already checked @@ -41014,8 +42243,7 @@ var ts; if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - var declaredType = getObjectFlags(t) & 4 /* Reference */ ? t.target : t; - if (getObjectFlags(declaredType) & 3 /* ClassOrInterface */) { + if (isValidBaseType(t)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -41045,11 +42273,16 @@ var ts; function getTargetSymbol(s) { // if symbol is instantiated its flags are not copied from the 'target' // so we'll need to get back original 'target' symbol to work with correct set of flags - return s.flags & 16777216 /* Instantiated */ ? getSymbolLinks(s).target : s; + return getCheckFlags(s) & 1 /* Instantiated */ ? s.target : s; } function getClassLikeDeclarationOfSymbol(symbol) { return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); } + function getClassOrInterfaceDeclarationsOfSymbol(symbol) { + return ts.filter(symbol.declarations, function (d) { + return d.kind === 228 /* ClassDeclaration */ || d.kind === 229 /* InterfaceDeclaration */; + }); + } function checkKindsOfPropertyMemberOverrides(type, baseType) { // TypeScript 1.0 spec (April 2014): 8.2.3 // A derived class inherits all members from its base class it doesn't override. @@ -41065,11 +42298,11 @@ var ts; // Base class instance member variables and accessors can be overridden by // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration - var baseProperties = getPropertiesOfObjectType(baseType); + var baseProperties = getPropertiesOfType(baseType); for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); - if (base.flags & 134217728 /* Prototype */) { + if (base.flags & 16777216 /* Prototype */) { continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); @@ -41086,7 +42319,7 @@ var ts; // 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 & 128 /* Abstract */ && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128 /* Abstract */))) { - if (derivedClassDecl.kind === 197 /* ClassExpression */) { + if (derivedClassDecl.kind === 198 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -41134,35 +42367,7 @@ var ts; } } function isAccessor(kind) { - return kind === 151 /* GetAccessor */ || kind === 152 /* SetAccessor */; - } - function areTypeParametersIdentical(list1, list2) { - if (!list1 && !list2) { - return true; - } - if (!list1 || !list2 || list1.length !== list2.length) { - return false; - } - // TypeScript 1.0 spec (April 2014): - // When a generic interface has multiple declarations, all declarations must have identical type parameter - // lists, i.e. identical type parameter names with identical constraints in identical order. - for (var i = 0; i < list1.length; i++) { - var tp1 = list1[i]; - var tp2 = list2[i]; - if (tp1.name.text !== tp2.name.text) { - return false; - } - if (!tp1.constraint && !tp2.constraint) { - continue; - } - if (!tp1.constraint || !tp2.constraint) { - return false; - } - if (!isTypeIdenticalTo(getTypeFromTypeNode(tp1.constraint), getTypeFromTypeNode(tp2.constraint))) { - return false; - } - } - return true; + return kind === 152 /* GetAccessor */ || kind === 153 /* SetAccessor */; } function checkInheritedPropertiesAreIdentical(type, typeNode) { var baseTypes = getBaseTypes(type); @@ -41170,16 +42375,16 @@ var ts; return true; } var seen = ts.createMap(); - ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.name, { prop: p, containingType: type }); }); var ok = true; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; - var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { var prop = properties_7[_a]; - var existing = seen[prop.name]; + var existing = seen.get(prop.name); if (!existing) { - seen[prop.name] = { prop: prop, containingType: base }; + seen.set(prop.name, { prop: prop, containingType: base }); } else { var isInheritedProperty = existing.containingType !== type; @@ -41204,9 +42409,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 228 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 229 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -41313,7 +42518,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -41324,7 +42529,7 @@ var ts; case 51 /* TildeToken */: return ~value_1; } return undefined; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -41350,11 +42555,11 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(e); return +e.text; - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return evalConstant(e.expression); case 70 /* Identifier */: - case 178 /* ElementAccessExpression */: - case 177 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: + case 178 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -41367,7 +42572,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 178 /* ElementAccessExpression */) { + if (e.kind === 179 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -41385,7 +42590,7 @@ var ts; if (current.kind === 70 /* Identifier */) { break; } - else if (current.kind === 177 /* PropertyAccessExpression */) { + else if (current.kind === 178 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -41458,7 +42663,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 230 /* EnumDeclaration */) { + if (declaration.kind !== 231 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -41479,10 +42684,10 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var declaration = declarations_5[_i]; - if ((declaration.kind === 227 /* ClassDeclaration */ || - (declaration.kind === 226 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 228 /* ClassDeclaration */ || + (declaration.kind === 227 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -41546,7 +42751,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 227 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 228 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -41559,7 +42764,7 @@ var ts; // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Merged */); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 134217728 /* Transient */); if (checkBody && node.body) { // body of ambient external module is always a module block for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { @@ -41597,26 +42802,26 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 241 /* ExportAssignment */: - case 242 /* ExportDeclaration */: + case 242 /* ExportAssignment */: + case 243 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 235 /* ImportEqualsDeclaration */: - case 236 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 174 /* BindingElement */: - case 224 /* VariableDeclaration */: - var name_25 = node.name; - if (ts.isBindingPattern(name_25)) { - for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { + case 175 /* BindingElement */: + case 225 /* VariableDeclaration */: + var name = node.name; + if (ts.isBindingPattern(name)) { + for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { var el = _c[_b]; // mark individual names in binding pattern checkModuleAugmentationElement(el, isGlobalAugmentation); @@ -41624,12 +42829,12 @@ var ts; break; } // fallthrough - case 227 /* ClassDeclaration */: - case 230 /* EnumDeclaration */: - case 226 /* FunctionDeclaration */: - case 228 /* InterfaceDeclaration */: - case 231 /* ModuleDeclaration */: - case 229 /* TypeAliasDeclaration */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 227 /* FunctionDeclaration */: + case 229 /* InterfaceDeclaration */: + case 232 /* ModuleDeclaration */: + case 230 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -41639,7 +42844,7 @@ var ts; // this is done it two steps // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error // 2. main check - report error if value declaration of the parent symbol is module augmentation) - var reportError = !(symbol.flags & 33554432 /* Merged */); + var reportError = !(symbol.flags & 134217728 /* Transient */); if (!reportError) { // symbol should not originate in augmentation reportError = ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); @@ -41652,12 +42857,12 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return node; - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: do { node = node.left; } while (node.kind !== 70 /* Identifier */); return node; - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 70 /* Identifier */); @@ -41670,9 +42875,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 232 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 262 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 242 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 233 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 264 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 243 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -41705,7 +42910,7 @@ var ts; (symbol.flags & 793064 /* Type */ ? 793064 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 244 /* ExportSpecifier */ ? + var message = node.kind === 245 /* 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)); @@ -41733,7 +42938,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 238 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 239 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -41790,8 +42995,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 232 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 262 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 233 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 233 /* ModuleBlock */ && + !node.moduleSpecifier && ts.isInAmbientContext(node); + if (node.parent.kind !== 264 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -41805,7 +43012,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 262 /* SourceFile */ || node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 231 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 264 /* SourceFile */ || node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 232 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -41831,8 +43038,8 @@ 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 === 262 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 231 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 264 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 232 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -41864,18 +43071,13 @@ var ts; } } function hasExportedMembers(moduleSymbol) { - for (var id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; + return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; }); } function checkExternalModuleExports(node) { var moduleSymbol = getSymbolOfNode(node); var links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - var exportEqualsSymbol = moduleSymbol.exports["export="]; + var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; if (!isTopLevelInExternalModuleAugmentation(declaration)) { @@ -41884,35 +43086,35 @@ var ts; } // Checks for export * conflicts var exports = getExportsOfModule(moduleSymbol); - for (var id in exports) { + exports && exports.forEach(function (_a, id) { + var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { - continue; + return; } - var _a = exports[id], declarations = _a.declarations, flags = _a.flags; // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) if (flags & (1920 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) { - continue; + return; } var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) - continue; + return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, id)); } } } - } + }); links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 226 /* FunctionDeclaration */ && declaration.kind !== 149 /* MethodDeclaration */) || + return (declaration.kind !== 227 /* FunctionDeclaration */ && declaration.kind !== 150 /* MethodDeclaration */) || !!declaration.body; } } @@ -41925,123 +43127,123 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 231 /* ModuleDeclaration */: - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 226 /* FunctionDeclaration */: + case 232 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 227 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return checkTypeParameter(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return checkParameter(node); - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return checkPropertyDeclaration(node); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: return checkSignatureDeclaration(node); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: return checkMethodDeclaration(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return checkConstructorDeclaration(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return checkAccessorDeclaration(node); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return checkTypeReferenceNode(node); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return checkTypePredicate(node); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return checkTypeQuery(node); - case 161 /* TypeLiteral */: + case 162 /* TypeLiteral */: return checkTypeLiteral(node); - case 162 /* ArrayType */: + case 163 /* ArrayType */: return checkArrayType(node); - case 163 /* TupleType */: + case 164 /* TupleType */: return checkTupleType(node); - case 164 /* UnionType */: - case 165 /* IntersectionType */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 166 /* ParenthesizedType */: - case 168 /* TypeOperator */: + case 167 /* ParenthesizedType */: + case 169 /* TypeOperator */: return checkSourceElement(node.type); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 170 /* MappedType */: + case 171 /* MappedType */: return checkMappedType(node); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 205 /* Block */: - case 232 /* ModuleBlock */: + case 206 /* Block */: + case 233 /* ModuleBlock */: return checkBlock(node); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return checkVariableStatement(node); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return checkExpressionStatement(node); - case 209 /* IfStatement */: + case 210 /* IfStatement */: return checkIfStatement(node); - case 210 /* DoStatement */: + case 211 /* DoStatement */: return checkDoStatement(node); - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: return checkWhileStatement(node); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return checkForStatement(node); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return checkForInStatement(node); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return checkForOfStatement(node); - case 215 /* ContinueStatement */: - case 216 /* BreakStatement */: + case 216 /* ContinueStatement */: + case 217 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: return checkReturnStatement(node); - case 218 /* WithStatement */: + case 219 /* WithStatement */: return checkWithStatement(node); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: return checkSwitchStatement(node); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return checkLabeledStatement(node); - case 221 /* ThrowStatement */: + case 222 /* ThrowStatement */: return checkThrowStatement(node); - case 222 /* TryStatement */: + case 223 /* TryStatement */: return checkTryStatement(node); - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 174 /* BindingElement */: + case 175 /* BindingElement */: return checkBindingElement(node); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return checkClassDeclaration(node); - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return checkImportDeclaration(node); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return checkExportDeclaration(node); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return checkExportAssignment(node); - case 207 /* EmptyStatement */: + case 208 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 223 /* DebuggerStatement */: + case 224 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 245 /* MissingDeclaration */: + case 246 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -42063,17 +43265,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: checkAccessorDeferred(node); break; - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -42179,7 +43381,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 218 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 219 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -42202,25 +43404,25 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 262 /* SourceFile */: + case 264 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } // 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 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* 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. @@ -42229,7 +43431,7 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793064 /* Type */); } break; - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -42257,17 +43459,16 @@ var ts; // 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 (!symbols[id]) { - symbols[id] = symbol; + if (!symbols.has(id)) { + symbols.set(id, symbol); } } } function copySymbols(source, meaning) { if (meaning) { - for (var id in source) { - var symbol = source[id]; + source.forEach(function (symbol) { copySymbol(symbol, meaning); - } + }); } } } @@ -42278,28 +43479,28 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 143 /* TypeParameter */: - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 230 /* EnumDeclaration */: + case 144 /* TypeParameter */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 231 /* 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 === 141 /* QualifiedName */) { + while (node.parent && node.parent.kind === 142 /* QualifiedName */) { node = node.parent; } - return node.parent && (node.parent.kind === 157 /* TypeReference */ || node.parent.kind === 273 /* JSDocTypeReference */); + return node.parent && (node.parent.kind === 158 /* TypeReference */ || node.parent.kind === 276 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 177 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 178 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 199 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 200 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -42316,13 +43517,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 141 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 142 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 235 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 236 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 241 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 242 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -42334,7 +43535,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 177 /* PropertyAccessExpression */) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 178 /* PropertyAccessExpression */) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1 /* ExportsProperty */: @@ -42346,13 +43547,13 @@ var ts; default: } } - if (entityName.parent.kind === 241 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 242 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 177 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { + if (entityName.kind !== 178 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 235 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 236 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -42362,7 +43563,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 199 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 200 /* ExpressionWithTypeArguments */) { meaning = 793064 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -42386,14 +43587,14 @@ var ts; } return resolveEntityName(entityName, 107455 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 177 /* PropertyAccessExpression */) { + else if (entityName.kind === 178 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 141 /* QualifiedName */) { + else if (entityName.kind === 142 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -42402,20 +43603,20 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 /* TypeReference */ || entityName.parent.kind === 273 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = (entityName.parent.kind === 158 /* TypeReference */ || entityName.parent.kind === 276 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 251 /* JsxAttribute */) { + else if (entityName.parent.kind === 252 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 156 /* TypePredicate */) { + if (entityName.parent.kind === 157 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 262 /* SourceFile */) { + if (node.kind === 264 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -42433,8 +43634,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 174 /* BindingElement */ && - node.parent.parent.kind === 172 /* ObjectBindingPattern */ && + else if (node.parent.kind === 175 /* BindingElement */ && + node.parent.parent.kind === 173 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -42445,8 +43646,8 @@ var ts; } switch (node.kind) { case 70 /* Identifier */: - case 177 /* PropertyAccessExpression */: - case 141 /* QualifiedName */: + case 178 /* PropertyAccessExpression */: + case 142 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -42460,12 +43661,12 @@ var ts; case 96 /* SuperKeyword */: var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 167 /* ThisType */: + case 168 /* ThisType */: return getTypeFromTypeNode(node).symbol; case 122 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 150 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 151 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -42473,7 +43674,7 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 236 /* ImportDeclaration */ || node.parent.kind === 242 /* ExportDeclaration */) && + ((node.parent.kind === 237 /* ImportDeclaration */ || node.parent.kind === 243 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -42483,7 +43684,7 @@ var ts; // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 178 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 179 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -42500,7 +43701,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 === 259 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 261 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; @@ -42562,28 +43763,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 176 /* ObjectLiteralExpression */ || expr.kind === 175 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 177 /* ObjectLiteralExpression */ || expr.kind === 176 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 214 /* ForOfStatement */) { + if (expr.parent.kind === 215 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 192 /* BinaryExpression */) { + if (expr.parent.kind === 193 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 258 /* PropertyAssignment */) { + if (expr.parent.kind === 260 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 175 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 176 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false) || unknownType; @@ -42623,30 +43824,33 @@ var ts; var propsByName = createSymbolTable(getPropertiesOfType(type)); if (getSignaturesOfType(type, 0 /* Call */).length || getSignaturesOfType(type, 1 /* Construct */).length) { ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { - if (!propsByName[p.name]) { - propsByName[p.name] = p; + if (!propsByName.has(p.name)) { + propsByName.set(p.name, p); } }); } return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (symbol.flags & 268435456 /* SyntheticProperty */) { + if (getCheckFlags(symbol) & 2 /* SyntheticProperty */) { var symbols_3 = []; - var name_26 = symbol.name; + var name_2 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_26); + var symbol = getPropertyOfType(t, name_2); if (symbol) { symbols_3.push(symbol); } }); return symbols_3; } - else if (symbol.flags & 67108864 /* Transient */) { + else if (symbol.flags & 134217728 /* Transient */) { if (symbol.leftSpread) { var links = symbol; return [links.leftSpread, links.rightSpread]; } + if (symbol.mappedTypeOrigin) { + return getRootSymbols(symbol.mappedTypeOrigin); + } var target = void 0; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -42663,7 +43867,8 @@ var ts; if (!ts.isGeneratedIdentifier(node)) { node = ts.getParseTreeNode(node, ts.isIdentifier); if (node) { - return getReferencedValueSymbol(node) === argumentsSymbol; + var isPropertyName_1 = node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node; + return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } return false; @@ -42684,7 +43889,7 @@ var ts; // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & 107455 /* Value */) - : ts.forEachProperty(getExportsOfModule(moduleSymbol), isValue); + : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { @@ -42719,7 +43924,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 262 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 264 /* SourceFile */) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -42776,7 +43981,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 205 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 206 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -42822,16 +44027,16 @@ var ts; return true; } switch (node.kind) { - case 235 /* ImportEqualsDeclaration */: - case 237 /* ImportClause */: - case 238 /* NamespaceImport */: - case 240 /* ImportSpecifier */: - case 244 /* ExportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 238 /* ImportClause */: + case 239 /* NamespaceImport */: + case 241 /* ImportSpecifier */: + case 245 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return node.expression && node.expression.kind === 70 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -42841,7 +44046,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 262 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 264 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -42898,6 +44103,12 @@ var ts; } return false; } + function isRequiredInitializedParameter(parameter) { + return strictNullChecks && + !isOptionalParameter(parameter) && + parameter.initializer && + !(ts.getModifierFlags(parameter) & 92 /* ParameterPropertyModifier */); + } function getNodeCheckFlags(node) { node = ts.getParseTreeNode(node); return node ? getNodeLinks(node).flags : undefined; @@ -42907,7 +44118,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 261 /* EnumMember */) { + if (node.kind === 263 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -42925,16 +44136,18 @@ var ts; function getTypeReferenceSerializationKind(typeName, location) { // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. var valueSymbol = resolveEntityName(typeName, 107455 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); - var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); - if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { - return ts.TypeReferenceSerializationKind.Promise; - } - var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; - if (constructorType && isConstructorType(constructorType)) { - return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; - } // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. var typeSymbol = resolveEntityName(typeName, 793064 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + if (valueSymbol && valueSymbol === typeSymbol) { + var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); + if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { + return ts.TypeReferenceSerializationKind.Promise; + } + var constructorType = getTypeOfSymbol(valueSymbol); + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + } // We might not be able to resolve type symbol so use unknown type in that case (eg error case) if (!typeSymbol) { return ts.TypeReferenceSerializationKind.ObjectType; @@ -42980,6 +44193,9 @@ var ts; var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : unknownType; + if (flags & 4096 /* AddUndefined */) { + type = includeFalsyTypes(type, 2048 /* Undefined */); + } getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { @@ -42994,10 +44210,13 @@ var ts; var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(node)); resolveBaseTypesOfClass(classType); var baseType = classType.resolvedBaseTypes.length ? classType.resolvedBaseTypes[0] : unknownType; + if (!baseType.symbol) { + writer.reportIllegalExtends(); + } getSymbolDisplayBuilder().buildTypeDisplay(baseType, writer, enclosingDeclaration, flags); } function hasGlobalName(name) { - return !!globals[name]; + return globals.has(name); } function getReferencedValueSymbol(reference, startInDeclarationContainer) { var resolvedSymbol = getNodeLinks(reference).resolvedSymbol; @@ -43008,9 +44227,9 @@ var ts; if (startInDeclarationContainer) { // When resolving the name of a declaration as a value, we need to start resolution // at a point outside of the declaration. - var parent_12 = reference.parent; - if (ts.isDeclaration(parent_12) && reference === parent_12.name) { - location = getDeclarationContainer(parent_12); + var parent = reference.parent; + if (ts.isDeclaration(parent) && reference === parent.name) { + location = getDeclarationContainer(parent); } } return resolveName(location, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -43046,14 +44265,13 @@ var ts; if (resolvedTypeReferenceDirectives) { // populate reverse mapping: file path -> type reference directive that was resolved to this file fileToDirective = ts.createFileMap(); - for (var key in resolvedTypeReferenceDirectives) { - var resolvedDirective = resolvedTypeReferenceDirectives[key]; + resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) { if (!resolvedDirective) { - continue; + return; } var file = host.getSourceFile(resolvedDirective.resolvedFileName); fileToDirective.set(file.path, key); - } + }); } return { getReferencedExportContainer: getReferencedExportContainer, @@ -43067,6 +44285,7 @@ var ts; isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, + isRequiredInitializedParameter: isRequiredInitializedParameter, writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, writeTypeOfExpression: writeTypeOfExpression, @@ -43096,7 +44315,7 @@ var ts; // property access can only be used as values // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = (node.kind === 177 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) + var meaning = (node.kind === 178 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) ? 107455 /* Value */ | 1048576 /* ExportValue */ : 793064 /* Type */ | 1920 /* Namespace */; var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -43139,15 +44358,15 @@ var ts; // external modules cannot define or contribute to type declaration files var current = symbol; while (true) { - var parent_13 = getParentOfSymbol(current); - if (parent_13) { - current = parent_13; + var parent = getParentOfSymbol(current); + if (parent) { + current = parent; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 262 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 264 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -43167,7 +44386,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 262 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 264 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -43191,11 +44410,11 @@ var ts; if (file.symbol && file.symbol.globalExports) { // Merge in UMD exports with first-in-wins semantics (see #9771) var source = file.symbol.globalExports; - for (var id in source) { - if (!(id in globals)) { - globals[id] = source[id]; + source.forEach(function (sourceSymbol, id) { + if (!globals.has(id)) { + globals.set(id, sourceSymbol); } - } + }); } } if (augmentations) { @@ -43265,10 +44484,10 @@ var ts; var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1 /* FirstEmitHelper */; helper <= 128 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { - var name_27 = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_27), 107455 /* Value */); + var name = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name), 107455 /* Value */); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_27); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); } } } @@ -43304,7 +44523,7 @@ var ts; } 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"); + var thenPropertySymbol = createSymbol(4 /* Property */, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; var thenableType = createObjectType(16 /* Anonymous */); thenableType.properties = [thenPropertySymbol]; @@ -43319,14 +44538,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 149 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 150 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 151 /* GetAccessor */ || node.kind === 152 /* SetAccessor */) { + else if (node.kind === 152 /* GetAccessor */ || node.kind === 153 /* 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); @@ -43344,16 +44563,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 130 /* ReadonlyKeyword */) { - if (node.kind === 146 /* PropertySignature */ || node.kind === 148 /* MethodSignature */) { + if (node.kind === 147 /* PropertySignature */ || node.kind === 149 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 155 /* IndexSignature */) { + if (node.kind === 156 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 75 /* ConstKeyword */: - if (node.kind !== 230 /* EnumDeclaration */ && node.parent.kind === 227 /* ClassDeclaration */) { + if (node.kind !== 231 /* EnumDeclaration */ && node.parent.kind === 228 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); } break; @@ -43379,7 +44598,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { + else if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -43402,10 +44621,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { + else if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 144 /* Parameter */) { + else if (node.kind === 145 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -43418,7 +44637,7 @@ var ts; if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 146 /* PropertySignature */ && node.kind !== 155 /* IndexSignature */ && node.kind !== 144 /* Parameter */) { + else if (node.kind !== 148 /* PropertyDeclaration */ && node.kind !== 147 /* PropertySignature */ && node.kind !== 156 /* IndexSignature */ && node.kind !== 145 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } @@ -43438,10 +44657,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 227 /* ClassDeclaration */) { + else if (node.parent.kind === 228 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 144 /* Parameter */) { + else if (node.kind === 145 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; @@ -43453,13 +44672,13 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 227 /* ClassDeclaration */) { + else if (node.parent.kind === 228 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 144 /* Parameter */) { + else if (node.kind === 145 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 232 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 233 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -43469,14 +44688,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 227 /* ClassDeclaration */) { - if (node.kind !== 149 /* MethodDeclaration */ && - node.kind !== 147 /* PropertyDeclaration */ && - node.kind !== 151 /* GetAccessor */ && - node.kind !== 152 /* SetAccessor */) { + if (node.kind !== 228 /* ClassDeclaration */) { + if (node.kind !== 150 /* MethodDeclaration */ && + node.kind !== 148 /* PropertyDeclaration */ && + node.kind !== 152 /* GetAccessor */ && + node.kind !== 153 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 227 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 228 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -43495,7 +44714,7 @@ var ts; 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 === 144 /* Parameter */) { + else if (node.kind === 145 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -43503,7 +44722,7 @@ var ts; break; } } - if (node.kind === 150 /* Constructor */) { + if (node.kind === 151 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -43518,13 +44737,13 @@ var ts; } return; } - else if ((node.kind === 236 /* ImportDeclaration */ || node.kind === 235 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 237 /* ImportDeclaration */ || node.kind === 236 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 144 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 145 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 144 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 145 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -43544,37 +44763,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 150 /* Constructor */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 155 /* IndexSignature */: - case 231 /* ModuleDeclaration */: - case 236 /* ImportDeclaration */: - case 235 /* ImportEqualsDeclaration */: - case 242 /* ExportDeclaration */: - case 241 /* ExportAssignment */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 144 /* Parameter */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 151 /* Constructor */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 156 /* IndexSignature */: + case 232 /* ModuleDeclaration */: + case 237 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 243 /* ExportDeclaration */: + case 242 /* ExportAssignment */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 145 /* Parameter */: return false; default: - if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { + if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { return false; } switch (node.kind) { - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); - case 228 /* InterfaceDeclaration */: - case 206 /* VariableStatement */: - case 229 /* TypeAliasDeclaration */: + case 229 /* InterfaceDeclaration */: + case 207 /* VariableStatement */: + case 230 /* TypeAliasDeclaration */: return true; - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); default: ts.Debug.fail(); @@ -43587,10 +44806,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 149 /* MethodDeclaration */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -43653,7 +44872,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 185 /* ArrowFunction */) { + if (node.kind === 186 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -43688,7 +44907,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 !== 134 /* StringKeyword */ && parameter.type.kind !== 132 /* NumberKeyword */) { + if (parameter.type.kind !== 135 /* StringKeyword */ && parameter.type.kind !== 132 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -43716,7 +44935,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 198 /* OmittedExpression */) { + if (arg.kind === 199 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -43789,19 +45008,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 142 /* ComputedPropertyName */) { + if (node.kind !== 143 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 192 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* CommaToken */) { + if (computedPropertyName.expression.kind === 193 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* 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 === 226 /* FunctionDeclaration */ || - node.kind === 184 /* FunctionExpression */ || - node.kind === 149 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 227 /* FunctionDeclaration */ || + node.kind === 185 /* FunctionExpression */ || + node.kind === 150 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -43826,15 +45045,15 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 260 /* SpreadAssignment */) { + if (prop.kind === 262 /* SpreadAssignment */) { continue; } - var name_28 = prop.name; - if (name_28.kind === 142 /* ComputedPropertyName */) { + var name = prop.name; + if (name.kind === 143 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_28); + checkGrammarComputedPropertyName(name); } - if (prop.kind === 259 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 261 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -43843,7 +45062,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 149 /* MethodDeclaration */) { + if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 150 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -43857,69 +45076,69 @@ 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 === 258 /* PropertyAssignment */ || prop.kind === 259 /* ShorthandPropertyAssignment */) { + if (prop.kind === 260 /* PropertyAssignment */ || prop.kind === 261 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_28.kind === 8 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_28); + if (name.kind === 8 /* NumericLiteral */) { + checkGrammarNumericLiteral(name); } currentKind = Property; } - else if (prop.kind === 149 /* MethodDeclaration */) { + else if (prop.kind === 150 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 151 /* GetAccessor */) { + else if (prop.kind === 152 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 152 /* SetAccessor */) { + else if (prop.kind === 153 /* SetAccessor */) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_28); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { continue; } - if (!seen[effectiveName]) { - seen[effectiveName] = currentKind; + var existingKind = seen.get(effectiveName); + if (!existingKind) { + seen.set(effectiveName, currentKind); } else { - var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_28, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_28)); + grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[effectiveName] = currentKind | existingKind; + seen.set(effectiveName, currentKind | existingKind); } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } } function checkGrammarJsxElement(node) { var seen = ts.createMap(); - for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 252 /* JsxSpreadAttribute */) { + if (attr.kind === 254 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; - var name_29 = jsxAttr.name; - if (!seen[name_29.text]) { - seen[name_29.text] = true; + var name = jsxAttr.name; + if (!seen.get(name.text)) { + seen.set(name.text, true); } else { - return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 253 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 255 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -43928,7 +45147,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 225 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 226 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -43943,20 +45162,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 213 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 214 /* 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 = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 213 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 214 /* 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 === 213 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 214 /* 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); @@ -43983,11 +45202,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 151 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 152 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 152 /* SetAccessor */) { + else if (kind === 153 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -44010,10 +45229,10 @@ var ts; A get accessor has no parameters or a single `this` parameter. A set accessor has one parameter or a `this` parameter and one more parameter */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 151 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 152 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 151 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 152 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -44028,7 +45247,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 176 /* ObjectLiteralExpression */) { + if (node.parent.kind === 177 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -44049,10 +45268,10 @@ 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 === 228 /* InterfaceDeclaration */) { + else if (node.parent.kind === 229 /* 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 === 161 /* TypeLiteral */) { + else if (node.parent.kind === 162 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -44063,11 +45282,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 220 /* LabeledStatement */: + case 221 /* 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 === 215 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 216 /* ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -44075,8 +45294,8 @@ var ts; return false; } break; - case 219 /* SwitchStatement */: - if (node.kind === 216 /* BreakStatement */ && !node.label) { + case 220 /* SwitchStatement */: + if (node.kind === 217 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -44091,13 +45310,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 216 /* BreakStatement */ + var message = node.kind === 217 /* 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 === 216 /* BreakStatement */ + var message = node.kind === 217 /* 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); @@ -44109,7 +45328,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 173 /* ArrayBindingPattern */ || node.name.kind === 172 /* ObjectBindingPattern */) { + if (node.name.kind === 174 /* ArrayBindingPattern */ || node.name.kind === 173 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -44120,11 +45339,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 190 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 191 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 213 /* ForInStatement */ && node.parent.parent.kind !== 214 /* ForOfStatement */) { + if (node.parent.parent.kind !== 214 /* ForInStatement */ && node.parent.parent.kind !== 215 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -44153,6 +45372,10 @@ var ts; } } } + if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && + !ts.isInAmbientContext(node.parent.parent) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { + checkESModuleMarker(node.name); + } var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". @@ -44162,6 +45385,22 @@ var ts; // and its Identifier is eval or arguments return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } + function checkESModuleMarker(name) { + if (name.kind === 70 /* Identifier */) { + if (ts.unescapeIdentifier(name.text) === "__esModule") { + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); + } + } + else { + var elements = name.elements; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; + if (!ts.isOmittedExpression(element)) { + return checkESModuleMarker(element.name); + } + } + } + } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 70 /* Identifier */) { if (name.originalKeywordKind === 109 /* LetKeyword */) { @@ -44170,8 +45409,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { - var element = elements_2[_i]; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var element = elements_3[_i]; if (!ts.isOmittedExpression(element)) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -44189,15 +45428,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 209 /* IfStatement */: - case 210 /* DoStatement */: - case 211 /* WhileStatement */: - case 218 /* WithStatement */: - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: + case 210 /* IfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 219 /* WithStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: return false; - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -44259,7 +45498,7 @@ var ts; return true; } } - else if (node.parent.kind === 228 /* InterfaceDeclaration */) { + else if (node.parent.kind === 229 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -44267,7 +45506,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 161 /* TypeLiteral */) { + else if (node.parent.kind === 162 /* 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; } @@ -44292,13 +45531,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 228 /* InterfaceDeclaration */ || - node.kind === 229 /* TypeAliasDeclaration */ || - node.kind === 236 /* ImportDeclaration */ || - node.kind === 235 /* ImportEqualsDeclaration */ || - node.kind === 242 /* ExportDeclaration */ || - node.kind === 241 /* ExportAssignment */ || - node.kind === 234 /* NamespaceExportDeclaration */ || + if (node.kind === 229 /* InterfaceDeclaration */ || + node.kind === 230 /* TypeAliasDeclaration */ || + node.kind === 237 /* ImportDeclaration */ || + node.kind === 236 /* ImportEqualsDeclaration */ || + node.kind === 243 /* ExportDeclaration */ || + node.kind === 242 /* ExportAssignment */ || + node.kind === 235 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -44307,7 +45546,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 === 206 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 207 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -44333,7 +45572,7 @@ var ts; // to prevent noisiness. 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 === 205 /* Block */ || node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { + if (node.parent.kind === 206 /* Block */ || node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -44341,6 +45580,9 @@ var ts; } } else { + // We must be parented by a statement. If so, there's no need + // to report the error as our parent will have already done it. + // Debug.assert(isStatement(node.parent)); } } } @@ -44351,10 +45593,10 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 171 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 172 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 261 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 263 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -44374,11 +45616,11 @@ var ts; } function getAmbientModules() { var result = []; - for (var sym in globals) { + globals.forEach(function (global, sym) { if (ambientModuleSymbolRegex.test(sym)) { - result.push(globals[sym]); + result.push(global); } - } + }); return result; } } @@ -44390,70 +45632,6 @@ var ts; /* @internal */ var ts; (function (ts) { - ; - /** - * This map contains information about the shape of each Node in "types.ts" pertaining to how - * each node should be traversed during a transformation. - * - * Each edge corresponds to a property in a Node subtype that should be traversed when visiting - * each child. The properties are assigned in the order in which traversal should occur. - * - * We only add entries for nodes that do not have a create/update pair defined in factory.ts - * - * NOTE: This needs to be kept up to date with changes to nodes in "types.ts". Currently, this - * map is not comprehensive. Only node edges relevant to tree transformation are - * currently defined. We may extend this to be more comprehensive, and eventually - * supplant the existing `forEachChild` implementation if performance is not - * significantly impacted. - */ - var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[141 /* QualifiedName */] = [ - { name: "left", test: ts.isEntityName }, - { name: "right", test: ts.isIdentifier } - ], - _a[145 /* Decorator */] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[182 /* TypeAssertionExpression */] = [ - { name: "type", test: ts.isTypeNode }, - { name: "expression", test: ts.isUnaryExpression } - ], - _a[200 /* AsExpression */] = [ - { name: "expression", test: ts.isExpression }, - { name: "type", test: ts.isTypeNode } - ], - _a[201 /* NonNullExpression */] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[230 /* EnumDeclaration */] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "members", test: ts.isEnumMember } - ], - _a[231 /* ModuleDeclaration */] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isModuleName }, - { name: "body", test: ts.isModuleBody } - ], - _a[232 /* ModuleBlock */] = [ - { name: "statements", test: ts.isStatement } - ], - _a[235 /* ImportEqualsDeclaration */] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "moduleReference", test: ts.isModuleReference } - ], - _a[246 /* ExternalModuleReference */] = [ - { name: "expression", test: ts.isExpression, optional: true } - ], - _a[261 /* EnumMember */] = [ - { name: "name", test: ts.isPropertyName }, - { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } - ], - _a)); function reduceNode(node, f, initial) { return node ? f(initial, node) : initial; } @@ -44462,8 +45640,7 @@ var ts; } /** * Similar to `reduceLeft`, performs a reduction against each child of a node. - * NOTE: Unlike `forEachChild`, this does *not* visit every node. Only nodes added to the - * `nodeEdgeTraversalMap` above will be visited. + * NOTE: Unlike `forEachChild`, this does *not* visit every node. * * @param node The node containing the children to reduce. * @param initial The initial value to supply to the reduction. @@ -44477,47 +45654,51 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 140 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 141 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 156 /* TypePredicate */ && kind <= 171 /* LiteralType */)) { + if ((kind >= 157 /* TypePredicate */ && kind <= 172 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 204 /* SemicolonClassElement */: - case 207 /* EmptyStatement */: - case 198 /* OmittedExpression */: - case 223 /* DebuggerStatement */: - case 294 /* NotEmittedStatement */: + case 205 /* SemicolonClassElement */: + case 208 /* EmptyStatement */: + case 199 /* OmittedExpression */: + case 224 /* DebuggerStatement */: + case 297 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 142 /* ComputedPropertyName */: + case 142 /* QualifiedName */: + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); + break; + case 143 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 144 /* Parameter */: + case 145 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 145 /* Decorator */: + case 146 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44526,12 +45707,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 150 /* Constructor */: + case 151 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44539,7 +45720,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44547,45 +45728,49 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 174 /* BindingElement */: + case 175 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 179 /* CallExpression */: + case 180 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 180 /* NewExpression */: + case 181 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 184 /* FunctionExpression */: + case 183 /* TypeAssertionExpression */: + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 185 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -44593,119 +45778,126 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 183 /* ParenthesizedExpression */: - case 186 /* DeleteExpression */: - case 187 /* TypeOfExpression */: - case 188 /* VoidExpression */: - case 189 /* AwaitExpression */: - case 195 /* YieldExpression */: - case 196 /* SpreadElement */: - case 201 /* NonNullExpression */: + case 184 /* ParenthesizedExpression */: + case 187 /* DeleteExpression */: + case 188 /* TypeOfExpression */: + case 189 /* VoidExpression */: + case 190 /* AwaitExpression */: + case 196 /* YieldExpression */: + case 197 /* SpreadElement */: + case 202 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; + case 201 /* AsExpression */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.type, cbNode, result); + break; + case 202 /* NonNullExpression */: + result = reduceNode(node.expression, cbNode, result); + break; // Misc - case 203 /* TemplateSpan */: + case 204 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 205 /* Block */: + case 206 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 209 /* IfStatement */: + case 210 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 210 /* DoStatement */: + case 211 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 211 /* WhileStatement */: - case 218 /* WithStatement */: + case 212 /* WhileStatement */: + case 219 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212 /* ForStatement */: + case 213 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 217 /* ReturnStatement */: - case 221 /* ThrowStatement */: + case 218 /* ReturnStatement */: + case 222 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 222 /* TryStatement */: + case 223 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 225 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44714,7 +45906,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44722,118 +45914,148 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 233 /* CaseBlock */: + case 231 /* EnumDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 232 /* ModuleDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 233 /* ModuleBlock */: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 234 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 236 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.moduleReference, cbNode, result); + break; + case 237 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 237 /* ImportClause */: + case 238 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 238 /* NamespaceImport */: + case 239 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 239 /* NamedImports */: - case 243 /* NamedExports */: + case 240 /* NamedImports */: + case 244 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 240 /* ImportSpecifier */: - case 244 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: + case 245 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; + // Module references + case 247 /* ExternalModuleReference */: + result = reduceNode(node.expression, cbNode, result); + break; // JSX - case 247 /* JsxElement */: + case 248 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 248 /* JsxSelfClosingElement */: - case 249 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + case 250 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); - result = reduceNodes(node.attributes, cbNodes, result); + result = reduceNode(node.attributes, cbNode, result); break; - case 250 /* JsxClosingElement */: + case 251 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 251 /* JsxAttribute */: + case 253 /* JsxAttributes */: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 252 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 252 /* JsxSpreadAttribute */: + case 254 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 253 /* JsxExpression */: + case 255 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 254 /* CaseClause */: + case 256 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // fall-through - case 255 /* DefaultClause */: + case 257 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 256 /* HeritageClause */: + case 258 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 257 /* CatchClause */: + case 259 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 260 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; + // Enum + case 263 /* EnumMember */: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); // Top-level nodes - case 262 /* SourceFile */: + case 264 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; - case 295 /* PartiallyEmittedExpression */: + // Transformation nodes + case 298 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; default: - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_1 = edgeTraversalPath; _i < edgeTraversalPath_1.length; _i++) { - var edge = edgeTraversalPath_1[_i]; - var value = node[edge.name]; - if (value !== undefined) { - result = ts.isArray(value) - ? reduceNodes(value, cbNodes, result) - : cbNode(result, value); - } - } - } break; } return result; } ts.reduceEachChild = reduceEachChild; - function visitNode(node, visitor, test, optional, lift, parenthesize, parentNode) { + /** + * Visits a Node using the supplied visitor, possibly returning a new Node in its place. + * + * @param node The Node to visit. + * @param visitor The callback used to visit the Node. + * @param test A callback to execute to verify the Node is valid. + * @param optional An optional value indicating whether the Node is itself optional. + * @param lift An optional callback to execute to lift a NodeArray into a valid Node. + */ + function visitNode(node, visitor, test, optional, lift) { if (node === undefined || visitor === undefined) { return node; } @@ -44855,15 +46077,21 @@ var ts; else { visitedNode = visited; } - if (parenthesize !== undefined) { - visitedNode = parenthesize(visitedNode, parentNode); - } Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); return visitedNode; } ts.visitNode = visitNode; - function visitNodes(nodes, visitor, test, start, count, parenthesize, parentNode) { + /** + * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. + * + * @param nodes The NodeArray to visit. + * @param visitor The callback used to visit a Node. + * @param test A node test to execute for each node. + * @param start An optional value indicating the starting offset at which to start visiting. + * @param count An optional value indicating the maximum number of nodes to visit. + */ + function visitNodes(nodes, visitor, test, start, count) { if (nodes === undefined) { return undefined; } @@ -44880,8 +46108,7 @@ var ts; // If we are not visiting all of the original nodes, we must always create a new array. // Since this is a fragment of a node array, we do not copy over the previous location // and will only copy over `hasTrailingComma` if we are including the last element. - updated = ts.createNodeArray([], /*location*/ undefined, - /*hasTrailingComma*/ nodes.hasTrailingComma && start + count === length); + updated = ts.createNodeArray([], /*hasTrailingComma*/ nodes.hasTrailingComma && start + count === length); } // Visit each original node. for (var i = 0; i < count; i++) { @@ -44891,27 +46118,22 @@ var ts; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { // Ensure we have a copy of `nodes`, up to the current index. - updated = ts.createNodeArray(nodes.slice(0, i), /*location*/ nodes, nodes.hasTrailingComma); + updated = ts.createNodeArray(nodes.slice(0, i), nodes.hasTrailingComma); + ts.setTextRange(updated, nodes); } if (visited) { if (ts.isArray(visited)) { for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) { var visitedNode = visited_1[_i]; - visitedNode = parenthesize - ? parenthesize(visitedNode, parentNode) - : visitedNode; Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); updated.push(visitedNode); } } else { - var visitedNode = parenthesize - ? parenthesize(visited, parentNode) - : visited; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); - updated.push(visitedNode); + Debug.assertNode(visited, test); + aggregateTransformFlags(visited); + updated.push(visited); } } } @@ -44927,10 +46149,10 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); - return ts.createNodeArray(ts.concatenate(statements, declarations), statements); + return ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements); } ts.visitLexicalEnvironment = visitLexicalEnvironment; /** @@ -44962,219 +46184,223 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 140 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 141 /* LastToken */)) { return node; } // We do not yet support types. - if ((kind >= 156 /* TypePredicate */ && kind <= 171 /* LiteralType */)) { + if ((kind >= 157 /* TypePredicate */ && kind <= 172 /* LiteralType */)) { return node; } switch (node.kind) { - case 204 /* SemicolonClassElement */: - case 207 /* EmptyStatement */: - case 198 /* OmittedExpression */: - case 223 /* DebuggerStatement */: + case 205 /* SemicolonClassElement */: + case 208 /* EmptyStatement */: + case 199 /* OmittedExpression */: + case 224 /* DebuggerStatement */: // No need to visit nodes with no children. return node; // Names - case 142 /* ComputedPropertyName */: + case 142 /* QualifiedName */: + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); + case 143 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 144 /* Parameter */: + case 145 /* Parameter */: return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), node.dotDotDotToken, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); + case 146 /* Decorator */: + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type member - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 150 /* Constructor */: + case 151 /* Constructor */: return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); // Binding patterns - case 172 /* ObjectBindingPattern */: + case 173 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 173 /* ArrayBindingPattern */: + case 174 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 174 /* BindingElement */: + case 175 /* BindingElement */: return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, /*optional*/ true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Expression - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 183 /* ParenthesizedExpression */: + case 183 /* TypeAssertionExpression */: + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 184 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 187 /* TypeOfExpression */: + case 188 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 201 /* AsExpression */: + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); + case 202 /* NonNullExpression */: + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 203 /* TemplateSpan */: + case 204 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 205 /* Block */: + case 206 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* IfStatement */: + case 210 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, /*optional*/ true, liftToBlock)); - case 210 /* DoStatement */: + case 211 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 215 /* ContinueStatement */: + case 216 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 216 /* BreakStatement */: + case 217 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 218 /* WithStatement */: + case 219 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 221 /* ThrowStatement */: + case 222 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 222 /* TryStatement */: + case 223 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, /*optional*/ true), visitNode(node.finallyBlock, visitor, ts.isBlock, /*optional*/ true)); - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 225 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 233 /* CaseBlock */: + case 231 /* EnumDeclaration */: + return ts.updateEnumDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNodes(node.members, visitor, ts.isEnumMember)); + case 232 /* ModuleDeclaration */: + return ts.updateModuleDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); + case 233 /* ModuleBlock */: + return ts.updateModuleBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 234 /* CaseBlock */: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 236 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + return ts.updateImportEqualsDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); + case 237 /* ImportDeclaration */: return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 237 /* ImportClause */: + case 238 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true)); - case 238 /* NamespaceImport */: + case 239 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 239 /* NamedImports */: + case 240 /* NamedImports */: return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 240 /* ImportSpecifier */: + case 241 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, /*optional*/ true)); - case 243 /* NamedExports */: + case 244 /* NamedExports */: return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 244 /* ExportSpecifier */: + case 245 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); + // Module references + case 247 /* ExternalModuleReference */: + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 247 /* JsxElement */: + case 248 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 248 /* JsxSelfClosingElement */: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 249 /* JsxOpeningElement */: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 250 /* JsxClosingElement */: + case 253 /* JsxAttributes */: + return ts.updateJsxAttributes(node, visitNodes(node.properties, visitor, ts.isJsxAttributeLike)); + case 249 /* JsxSelfClosingElement */: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 250 /* JsxOpeningElement */: + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 251 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 251 /* JsxAttribute */: + case 252 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 252 /* JsxSpreadAttribute */: + case 254 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 253 /* JsxExpression */: + case 255 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 254 /* CaseClause */: + case 256 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 255 /* DefaultClause */: + case 257 /* DefaultClause */: return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 256 /* HeritageClause */: + case 258 /* HeritageClause */: return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 260 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + // Enum + case 263 /* EnumMember */: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Top-level nodes - case 262 /* SourceFile */: + case 264 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 295 /* PartiallyEmittedExpression */: + case 298 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: - var updated = void 0; - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_2 = edgeTraversalPath; _i < edgeTraversalPath_2.length; _i++) { - var edge = edgeTraversalPath_2[_i]; - var value = node[edge.name]; - if (value !== undefined) { - var visited = ts.isArray(value) - ? visitNodes(value, visitor, edge.test, 0, value.length, edge.parenthesize, node) - : visitNode(value, visitor, edge.test, edge.optional, edge.lift, edge.parenthesize, node); - if (updated !== undefined || visited !== value) { - if (updated === undefined) { - updated = ts.getMutableClone(node); - } - if (visited !== value) { - updated[edge.name] = visited; - } - } - } - } - } - return updated ? ts.updateNode(updated, node) : node; + return node; } - // return node; } ts.visitEachChild = visitEachChild; function mergeLexicalEnvironment(statements, declarations) { @@ -45182,19 +46408,19 @@ var ts; return statements; } return ts.isNodeArray(statements) - ? ts.createNodeArray(ts.concatenate(statements, declarations), statements) + ? ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements) : ts.addRange(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; function mergeFunctionBodyLexicalEnvironment(body, declarations) { if (body && declarations !== undefined && declarations.length > 0) { if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.createNodeArray(ts.concatenate(body.statements, declarations), body.statements)); + return ts.updateBlock(body, ts.setTextRange(ts.createNodeArray(ts.concatenate(body.statements, declarations)), body.statements)); } else { - return ts.createBlock(ts.createNodeArray([ts.createReturn(body, /*location*/ body)].concat(declarations), body), - /*location*/ body, - /*multiLine*/ true); + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray([ts.setTextRange(ts.createReturn(body), body)].concat(declarations)), body), + /*multiLine*/ true), + /*location*/ body); } } return body; @@ -45264,7 +46490,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 199 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 200 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -45317,7 +46543,6 @@ var ts; } } })(Debug = ts.Debug || (ts.Debug = {})); - var _a; })(ts || (ts = {})); /// /// @@ -45407,7 +46632,7 @@ var ts; ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression); var expression = createAssignmentCallback ? createAssignmentCallback(target, value, location) - : ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value, location); + : ts.setTextRange(ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location); expression.original = original; emitExpression(expression); } @@ -45456,11 +46681,12 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_30 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_30, - /*type*/ undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name, + /*type*/ undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value); variable.original = original; - if (ts.isIdentifier(name_30)) { + ts.setTextRange(variable, location); + if (ts.isIdentifier(name)) { ts.setEmitFlags(variable, 64 /* NoNestedSourceMaps */); } ts.aggregateTransformFlags(variable); @@ -45664,8 +46890,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_31 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_31); + var name = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name); } } /** @@ -45687,7 +46913,7 @@ var ts; var temp = ts.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { flattenContext.context.hoistVariableDeclaration(temp); - flattenContext.emitExpression(ts.createAssignment(temp, value, location)); + flattenContext.emitExpression(ts.setTextRange(ts.createAssignment(temp, value), location)); } else { flattenContext.emitBindingOrAssignment(temp, value, location, /*original*/ undefined); @@ -45740,7 +46966,10 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), undefined, [value, ts.createArrayLiteral(propertyNames, location)]); + return ts.createCall(ts.getHelperName("__rest"), undefined, [ + value, + ts.setTextRange(ts.createArrayLiteral(propertyNames), location) + ]); } })(ts || (ts = {})); /// @@ -45775,8 +47004,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(177 /* PropertyAccessExpression */); - context.enableSubstitution(178 /* ElementAccessExpression */); + context.enableSubstitution(178 /* PropertyAccessExpression */); + context.enableSubstitution(179 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -45840,15 +47069,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 262 /* SourceFile */: - case 233 /* CaseBlock */: - case 232 /* ModuleBlock */: - case 205 /* Block */: + case 264 /* SourceFile */: + case 234 /* CaseBlock */: + case 233 /* ModuleBlock */: + case 206 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 227 /* ClassDeclaration */: - case 226 /* FunctionDeclaration */: + case 228 /* ClassDeclaration */: + case 227 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -45895,13 +47124,13 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return visitImportDeclaration(node); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return visitExportAssignment(node); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -45921,11 +47150,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 242 /* ExportDeclaration */ || - node.kind === 236 /* ImportDeclaration */ || - node.kind === 237 /* ImportClause */ || - (node.kind === 235 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 246 /* ExternalModuleReference */)) { + if (node.kind === 243 /* ExportDeclaration */ || + node.kind === 237 /* ImportDeclaration */ || + node.kind === 238 /* ImportClause */ || + (node.kind === 236 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 247 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -45955,19 +47184,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 150 /* Constructor */: + case 151 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 147 /* PropertyDeclaration */: - case 155 /* IndexSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 149 /* MethodDeclaration */: + case 148 /* PropertyDeclaration */: + case 156 /* IndexSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 150 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 204 /* SemicolonClassElement */: + case 205 /* SemicolonClassElement */: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -46007,47 +47236,47 @@ var ts; case 123 /* DeclareKeyword */: case 130 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 162 /* ArrayType */: - case 163 /* TupleType */: - case 161 /* TypeLiteral */: - case 156 /* TypePredicate */: - case 143 /* TypeParameter */: + case 163 /* ArrayType */: + case 164 /* TupleType */: + case 162 /* TypeLiteral */: + case 157 /* TypePredicate */: + case 144 /* TypeParameter */: case 118 /* AnyKeyword */: case 121 /* BooleanKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 129 /* NeverKeyword */: case 104 /* VoidKeyword */: - case 135 /* SymbolKeyword */: - case 159 /* ConstructorType */: - case 158 /* FunctionType */: - case 160 /* TypeQuery */: - case 157 /* TypeReference */: - case 164 /* UnionType */: - case 165 /* IntersectionType */: - case 166 /* ParenthesizedType */: - case 167 /* ThisType */: - case 168 /* TypeOperator */: - case 169 /* IndexedAccessType */: - case 170 /* MappedType */: - case 171 /* LiteralType */: + case 136 /* SymbolKeyword */: + case 160 /* ConstructorType */: + case 159 /* FunctionType */: + case 161 /* TypeQuery */: + case 158 /* TypeReference */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: + case 167 /* ParenthesizedType */: + case 168 /* ThisType */: + case 169 /* TypeOperator */: + case 170 /* IndexedAccessType */: + case 171 /* MappedType */: + case 172 /* LiteralType */: // TypeScript type nodes are elided. - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: // TypeScript index signatures are elided. - case 145 /* Decorator */: + case 146 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: // TypeScript property declarations are elided. return undefined; - case 150 /* Constructor */: + case 151 /* Constructor */: return visitConstructor(node); - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -46058,7 +47287,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -46069,35 +47298,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 256 /* HeritageClause */: + case 258 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 144 /* Parameter */: + case 145 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -46107,33 +47336,33 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return visitCallExpression(node); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return visitNewExpression(node); - case 201 /* NonNullExpression */: + case 202 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -46238,13 +47467,14 @@ var ts; // } var classDeclaration = ts.createClassDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); - var emitFlags = ts.getEmitFlags(node); + /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause)); // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. + var emitFlags = ts.getEmitFlags(node); if (hasStaticProperties) { emitFlags |= 32 /* NoTrailingSourceMap */; } + ts.setTextRange(classDeclaration, node); ts.setOriginalNode(classDeclaration, node); ts.setEmitFlags(classDeclaration, emitFlags); return classDeclaration; @@ -46352,12 +47582,18 @@ var ts; // } var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, hasExtendsClause); - var classExpression = ts.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members, location); + var classExpression = ts.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); + ts.setTextRange(classExpression, location); // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference // or decoratedClassAlias if the class contain self-reference. - var statement = ts.createLetStatement(declName, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression, location); + var statement = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declName, + /*type*/ undefined, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression) + ], 1 /* Let */)); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, location); ts.setCommentRange(statement, node); return statement; } @@ -46374,10 +47610,11 @@ var ts; var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84 /* ExtendsKeyword */; })); - var classExpression = ts.setOriginalNode(ts.createClassExpression( + var classExpression = ts.createClassExpression( /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, heritageClauses, members, - /*location*/ node), node); + /*typeParameters*/ undefined, heritageClauses, members); + ts.setOriginalNode(classExpression, node); + ts.setTextRange(classExpression, node); if (staticProperties.length > 0) { var expressions = []; var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -46409,7 +47646,7 @@ var ts; members.push(constructor); } ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); - return ts.createNodeArray(members, /*location*/ node.members); + return ts.setTextRange(ts.createNodeArray(members), /*location*/ node.members); } /** * Transforms (or creates) a constructor for a class. @@ -46434,10 +47671,9 @@ var ts; // constructor(${parameters}) { // ${body} // } - return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor( + return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor( /*decorators*/ undefined, - /*modifiers*/ undefined, parameters, body, - /*location*/ constructor || node), constructor)); + /*modifiers*/ undefined, parameters, body), constructor || node), constructor)); } /** * Transforms (or creates) the parameters for the constructor of a class with @@ -46520,10 +47756,10 @@ var ts; } // End the lexical environment. ts.addRange(statements, endLexicalEnvironment()); - return ts.createBlock(ts.createNodeArray(statements, + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ constructor ? constructor.body.statements : node.members), - /*location*/ constructor ? constructor.body : undefined, - /*multiLine*/ true); + /*multiLine*/ true), + /*location*/ constructor ? constructor.body : undefined); } /** * Adds super call and preceding prologue directives into the list of statements. @@ -46541,7 +47777,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -46578,9 +47814,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536 /* NoComments */); - return ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), propertyName, - /*location*/ node.name), localName), - /*location*/ ts.moveRangePos(node, -1))); + return ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1))); } /** * Gets all property declarations with initializers on either the static or instance side of a class. @@ -46614,7 +47848,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 147 /* PropertyDeclaration */ + return member.kind === 148 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } @@ -46749,12 +47983,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -46907,7 +48141,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 147 /* PropertyDeclaration */ + ? member.kind === 148 /* PropertyDeclaration */ ? ts.createVoidZero() : ts.createNull() : undefined; @@ -47013,7 +48247,7 @@ var ts; (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(35 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true))); + decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); } } } @@ -47026,10 +48260,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */ - || kind === 147 /* PropertyDeclaration */; + return kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */ + || kind === 148 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -47039,7 +48273,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 149 /* MethodDeclaration */; + return node.kind === 150 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -47050,12 +48284,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return true; } return false; @@ -47067,15 +48301,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 147 /* PropertyDeclaration */: - case 144 /* Parameter */: - case 151 /* GetAccessor */: + case 148 /* PropertyDeclaration */: + case 145 /* Parameter */: + case 152 /* GetAccessor */: return serializeTypeNode(node.type); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 149 /* MethodDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 150 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -47112,7 +48346,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 151 /* GetAccessor */) { + if (container && node.kind === 152 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -47158,24 +48392,24 @@ var ts; } switch (node.kind) { case 104 /* VoidKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 94 /* NullKeyword */: case 129 /* NeverKeyword */: return ts.createVoidZero(); - case 166 /* ParenthesizedType */: + case 167 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return ts.createIdentifier("Function"); - case 162 /* ArrayType */: - case 163 /* TupleType */: + case 163 /* ArrayType */: + case 164 /* TupleType */: return ts.createIdentifier("Array"); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: case 121 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: return ts.createIdentifier("String"); - case 171 /* LiteralType */: + case 172 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -47191,22 +48425,22 @@ var ts; break; case 132 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return serializeTypeReferenceNode(node); - case 165 /* IntersectionType */: - case 164 /* UnionType */: + case 166 /* IntersectionType */: + case 165 /* UnionType */: return serializeUnionOrIntersectionType(node); - case 160 /* TypeQuery */: - case 168 /* TypeOperator */: - case 169 /* IndexedAccessType */: - case 170 /* MappedType */: - case 161 /* TypeLiteral */: + case 161 /* TypeQuery */: + case 169 /* TypeOperator */: + case 170 /* IndexedAccessType */: + case 171 /* MappedType */: + case 162 /* TypeLiteral */: case 118 /* AnyKeyword */: - case 167 /* ThisType */: + case 168 /* ThisType */: break; default: ts.Debug.failBadSyntaxKind(node); @@ -47294,15 +48528,15 @@ var ts; case 70 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. - var name_32 = ts.getMutableClone(node); - name_32.flags &= ~8 /* Synthesized */; - name_32.original = undefined; - name_32.parent = currentScope; + var name = ts.getMutableClone(node); + name.flags &= ~8 /* Synthesized */; + name.original = undefined; + name.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_32), ts.createLiteral("undefined")), name_32); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } - return name_32; - case 141 /* QualifiedName */: + return name; + case 142 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -47370,7 +48604,7 @@ var ts; hoistVariableDeclaration(generatedName); expression = ts.createAssignment(generatedName, expression); } - return ts.setOriginalNode(ts.createComputedPropertyName(expression, /*location*/ name), name); + return ts.updateComputedPropertyName(name, expression); } else { return name; @@ -47388,7 +48622,7 @@ var ts; function visitHeritageClause(node) { if (node.token === 84 /* ExtendsKeyword */) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(84 /* ExtendsKeyword */, types, node); + return ts.setTextRange(ts.createHeritageClause(84 /* ExtendsKeyword */, types), node); } return undefined; } @@ -47401,9 +48635,8 @@ var ts; * @param node The ExpressionWithTypeArguments to transform. */ function visitExpressionWithTypeArguments(node) { - var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); - return ts.createExpressionWithTypeArguments( - /*typeArguments*/ undefined, expression, node); + return ts.updateExpressionWithTypeArguments(node, + /*typeArguments*/ undefined, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); } /** * Determines whether to emit a function-like declaration. We should not emit the @@ -47573,11 +48806,11 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), /*questionToken*/ undefined, - /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), - /*location*/ ts.moveRangePastModifiers(node)); + /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. ts.setOriginalNode(parameter, node); + ts.setTextRange(parameter, ts.moveRangePastModifiers(node)); ts.setCommentRange(parameter, node); ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); ts.setEmitFlags(parameter.name, 32 /* NoTrailingSourceMap */); @@ -47596,8 +48829,7 @@ var ts; // elide statement if there are no initialized variables. return undefined; } - return ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), - /*location*/ node); + return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -47610,7 +48842,7 @@ var ts; /*needsValue*/ false, createNamespaceExportExpression); } else { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), /*location*/ node); } } @@ -47724,9 +48956,9 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, transformEnumBody(node, containerName)), - /*typeArguments*/ undefined, [moduleArg]), - /*location*/ node); + /*typeArguments*/ undefined, [moduleArg])); ts.setOriginalNode(enumStatement, node); + ts.setTextRange(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); // Add a DeclarationMarker for the enum to preserve trailing comments and mark @@ -47747,8 +48979,7 @@ var ts; ts.addRange(statements, ts.map(node.members, transformEnumMember)); ts.addRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceLocalName; - return ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), - /*location*/ undefined, + return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); } /** @@ -47761,9 +48992,7 @@ var ts; // we pass false as 'generateNameForComputedPropertyName' for a backward compatibility purposes // old emitter always generate 'expression' part of the name as-is. var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); - return ts.createStatement(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name, - /*location*/ member), - /*location*/ member); + return ts.setTextRange(ts.createStatement(ts.setTextRange(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name), member)), member); } /** * Transforms the value of an enum member. @@ -47816,8 +49045,8 @@ var ts; if (!currentScopeFirstDeclarationsOfName) { currentScopeFirstDeclarationsOfName = ts.createMap(); } - if (!(name in currentScopeFirstDeclarationsOfName)) { - currentScopeFirstDeclarationsOfName[name] = node; + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } } @@ -47827,9 +49056,9 @@ var ts; */ function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_33 = node.symbol && node.symbol.name; - if (name_33) { - return currentScopeFirstDeclarationsOfName[name_33] === node; + var name = node.symbol && node.symbol.name; + if (name) { + return currentScopeFirstDeclarationsOfName.get(name) === node; } } return false; @@ -47846,7 +49075,7 @@ var ts; recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 230 /* EnumDeclaration */) { + if (node.kind === 231 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -47938,9 +49167,9 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, transformModuleBody(node, containerName)), - /*typeArguments*/ undefined, [moduleArg]), - /*location*/ node); + /*typeArguments*/ undefined, [moduleArg])); ts.setOriginalNode(moduleStatement, node); + ts.setTextRange(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); // Add a DeclarationMarker for the namespace to preserve trailing comments and mark @@ -47965,7 +49194,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 232 /* ModuleBlock */) { + if (body.kind === 233 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -47987,10 +49216,10 @@ var ts; currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; - var block = ts.createBlock(ts.createNodeArray(statements, + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ statementsLocation), - /*location*/ blockLocation, /*multiLine*/ true); + ts.setTextRange(block, blockLocation); // namespace hello.hi.world { // function foo() {} // @@ -48011,13 +49240,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 232 /* ModuleBlock */) { + if (body.kind !== 233 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 231 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 232 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -48058,7 +49287,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 238 /* NamespaceImport */) { + if (node.kind === 239 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -48165,10 +49394,10 @@ var ts; if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; - return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ + return ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.setOriginalNode(ts.createVariableDeclaration(node.name, /*type*/ undefined, moduleReference), node) - ]), node), node); + ])), node), node); } else { // exports.${name} = ${moduleReference}; @@ -48213,7 +49442,7 @@ var ts; * Creates a statement for the provided expression. This is used in calls to `map`. */ function expressionToStatement(expression) { - return ts.createStatement(expression, /*location*/ undefined); + return ts.createStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), ts.getLocalName(node)); @@ -48223,10 +49452,10 @@ var ts; statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue), location); + return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue, location); + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); } function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) { return ts.getNamespaceMemberName(currentNamespaceContainerName, name, /*allowComments*/ false, /*allowSourceMaps*/ true); @@ -48254,7 +49483,7 @@ var ts; function getClassAliasIfNeeded(node) { if (resolver.getNodeCheckFlags(node) & 8388608 /* ClassWithConstructorReference */) { enableSubstitutionForClassAliases(); - var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); + var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.unescapeIdentifier(node.name.text) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; hoistVariableDeclaration(classAlias); return classAlias; @@ -48281,7 +49510,7 @@ var ts; // substitute class names inside of a class declaration. context.enableSubstitution(70 /* Identifier */); // Keep track of class aliases. - classAliases = ts.createMap(); + classAliases = []; } } function enableSubstitutionForNamespaceExports() { @@ -48290,25 +49519,25 @@ var ts; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. context.enableSubstitution(70 /* Identifier */); - context.enableSubstitution(259 /* ShorthandPropertyAssignment */); + context.enableSubstitution(261 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(231 /* ModuleDeclaration */); + context.enableEmitNotification(232 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 231 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 232 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 230 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 231 /* EnumDeclaration */; } /** * Hook for node emit. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2 /* NamespaceExports */; @@ -48316,18 +49545,18 @@ var ts; if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; } /** * Hooks node substitutions. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -48337,16 +49566,16 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2 /* NamespaceExports */) { - var name_34 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_34); + var name = node.name; + var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { // A shorthand property with an assignment initializer is probably part of a // destructuring assignment if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_34, initializer, /*location*/ node); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); } - return ts.createPropertyAssignment(name_34, exportedName, /*location*/ node); + return ts.setTextRange(ts.createPropertyAssignment(name, exportedName), node); } } return node; @@ -48355,9 +49584,9 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -48395,11 +49624,12 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 262 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 231 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 230 /* EnumDeclaration */); + if (container && container.kind !== 264 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 232 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 231 /* EnumDeclaration */); if (substitute) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, /*location*/ node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), + /*location*/ node); } } } @@ -48446,11 +49676,11 @@ var ts; }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(paramHelper); - return ts.createCall(ts.getHelperName("__param"), + return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression - ], location); + ]), location); } var metadataHelper = { name: "typescript:metadata", @@ -48475,7 +49705,7 @@ var ts; function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) { context.requestEmitHelper(decorateHelper); var argumentsArray = []; - argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, /*location*/ undefined, /*multiLine*/ true)); + argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, /*multiLine*/ true)); argumentsArray.push(target); if (memberName) { argumentsArray.push(memberName); @@ -48483,7 +49713,8 @@ var ts; argumentsArray.push(descriptor); } } - return ts.createCall(ts.getHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray, location); + return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), + /*typeArguments*/ undefined, argumentsArray), location); } })(ts || (ts = {})); /// @@ -48513,37 +49744,37 @@ var ts; return node; } switch (node.kind) { - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return visitForOfStatement(node); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return visitForStatement(node); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return visitVoidExpression(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return visitConstructorDeclaration(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: return visitGetAccessorDeclaration(node); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return visitFunctionExpression(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return visitArrowFunction(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return visitParameter(node); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return visitExpressionStatement(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); default: return ts.visitEachChild(node, visitor, context); @@ -48552,9 +49783,9 @@ var ts; function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; - for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { - var e = elements_3[_i]; - if (e.kind === 260 /* SpreadAssignment */) { + for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { + var e = elements_4[_i]; + if (e.kind === 262 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -48566,7 +49797,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 258 /* PropertyAssignment */) { + if (e.kind === 260 /* PropertyAssignment */) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -48588,7 +49819,7 @@ var ts; // If the first element is a spread element, then the first argument to __assign is {}: // { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2) var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 176 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 177 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -48651,26 +49882,26 @@ var ts; /*skipInitializer*/ true); if (ts.some(declarations)) { var statement = ts.createVariableStatement( - /*modifiers*/ undefined, ts.updateVariableDeclarationList(initializer, declarations), - /*location*/ initializer); + /*modifiers*/ undefined, ts.updateVariableDeclarationList(initializer, declarations)); + ts.setTextRange(statement, initializer); leadingStatements = ts.append(leadingStatements, statement); } } else if (ts.isAssignmentPattern(initializer)) { temp = ts.createTempVariable(/*recordTempVariable*/ undefined); - var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.createAssignment(initializer, temp, /*location*/ node.initializer)), visitor, context, 1 /* ObjectRest */); - leadingStatements = ts.append(leadingStatements, ts.createStatement(expression, /*location*/ node.initializer)); + var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.setTextRange(ts.createAssignment(initializer, temp), node.initializer)), visitor, context, 1 /* ObjectRest */); + leadingStatements = ts.append(leadingStatements, ts.setTextRange(ts.createStatement(expression), node.initializer)); } } if (temp) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var statement = ts.visitNode(node.statement, visitor, ts.isStatement); var block = ts.isBlock(statement) - ? ts.updateBlock(statement, ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements), statement.statements)) - : ts.createBlock(ts.append(leadingStatements, statement), statement, /*multiLine*/ true); - return ts.updateForOf(node, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, /*type*/ undefined, /*initializer*/ undefined, node.initializer) - ], node.initializer, 1 /* Let */), expression, block); + ? ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements)), statement.statements)) + : ts.setTextRange(ts.createBlock(ts.append(leadingStatements, statement), /*multiLine*/ true), statement); + return ts.updateForOf(node, ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer) + ], 1 /* Let */), node.initializer), expression, block); } return ts.visitEachChild(node, visitor, context); } @@ -48742,7 +49973,7 @@ var ts; var trailingStatements = endLexicalEnvironment(); if (ts.some(leadingStatements) || ts.some(trailingStatements)) { var block = ts.convertToFunctionBody(body, /*multiLine*/ true); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements)), block.statements)); } return body; } @@ -48755,6 +49986,10 @@ var ts; text: "\n var __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };" }; function createAssignHelper(context, attributesSegments) { + if (context.getCompilerOptions().target >= 2 /* ES2015 */) { + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), + /*typeArguments*/ undefined, attributesSegments); + } context.requestEmitHelper(assignHelper); return ts.createCall(ts.getHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); @@ -48796,11 +50031,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 247 /* JsxElement */: + case 248 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 248 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 253 /* JsxExpression */: + case 255 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -48810,11 +50045,11 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 253 /* JsxExpression */: + case 255 /* JsxExpression */: return visitJsxExpression(node); - case 247 /* JsxElement */: + case 248 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 248 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); default: ts.Debug.failBadSyntaxKind(node); @@ -48830,7 +50065,7 @@ var ts; function visitJsxOpeningLikeElement(node, children, isChild, location) { var tagName = getTagName(node); var objectProperties; - var attrs = node.attributes; + var attrs = node.attributes.properties; if (attrs.length === 0) { // When there are no attributes, React wants "null" objectProperties = ts.createNull(); @@ -48869,15 +50104,15 @@ var ts; } function transformJsxAttributeInitializer(node) { if (node === undefined) { - return ts.createLiteral(true); + return ts.createTrue(); } else if (node.kind === 9 /* StringLiteral */) { var decoded = tryDecodeEntities(node.text); - return decoded ? ts.createLiteral(decoded, /*location*/ node) : node; + return decoded ? ts.setTextRange(ts.createLiteral(decoded), node) : node; } - else if (node.kind === 253 /* JsxExpression */) { + else if (node.kind === 255 /* JsxExpression */) { if (node.expression === undefined) { - return ts.createLiteral(true); + return ts.createTrue(); } return visitJsxExpression(node); } @@ -48886,54 +50121,61 @@ var ts; } } function visitJsxText(node) { - var text = ts.getTextOfNode(node, /*includeTrivia*/ true); - var parts; + var fixed = fixupWhitespaceAndDecodeEntities(ts.getTextOfNode(node, /*includeTrivia*/ true)); + return fixed === undefined ? undefined : ts.createLiteral(fixed); + } + /** + * 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 + * See also https://www.w3.org/TR/html4/struct/text.html#h-9.1 and https://www.w3.org/TR/CSS2/text.html#white-space-model + * + * An equivalent algorithm would be: + * - If there is only one line, return it. + * - If there is only whitespace (but multiple lines), return `undefined`. + * - Split the text into lines. + * - 'trimRight' the first line, 'trimLeft' the last line, 'trim' middle lines. + * - Decode entities on each line (individually). + * - Remove empty lines and join the rest with " ". + */ + function fixupWhitespaceAndDecodeEntities(text) { + var acc; + // First non-whitespace character on this line. var firstNonWhitespace = 0; + // Last non-whitespace character on this line. 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 + // These initial values are special because the first line is: + // firstNonWhitespace = 0 to indicate that we want leading whitsepace, + // but lastNonWhitespace = -1 as a special flag to indicate that we *don't* include the line if it's all whitespace. 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); - if (!parts) { - parts = []; - } - // We do not escape the string here as that is handled by the printer - // when it emits the literal. We do, however, need to decode JSX entities. - parts.push(ts.createLiteral(decodeEntities(part))); + // If we've seen any non-whitespace characters on this line, add the 'trim' of the line. + // (lastNonWhitespace === -1 is a special flag to detect whether the first line is all whitespace.) + if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) { + acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); } + // Reset firstNonWhitespace for the next line. + // Don't bother to reset lastNonWhitespace because we ignore it if firstNonWhitespace = -1. firstNonWhitespace = -1; } - else if (!ts.isWhiteSpace(c)) { + else if (!ts.isWhiteSpaceSingleLine(c)) { lastNonWhitespace = i; if (firstNonWhitespace === -1) { firstNonWhitespace = i; } } } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - if (!parts) { - parts = []; - } - // We do not escape the string here as that is handled by the printer - // when it emits the literal. We do, however, need to decode JSX entities. - parts.push(ts.createLiteral(decodeEntities(part))); - } - if (parts) { - return ts.reduceLeft(parts, aggregateJsxTextParts); - } - return undefined; + return firstNonWhitespace !== -1 + ? addLineOfJsxText(acc, text.substr(firstNonWhitespace)) + : acc; } - /** - * Aggregates two expressions by interpolating them with a whitespace literal. - */ - function aggregateJsxTextParts(left, right) { - return ts.createAdd(ts.createAdd(left, ts.createLiteral(" ")), right); + function addLineOfJsxText(acc, trimmedLine) { + // We do not escape the string here as that is handled by the printer + // when it emits the literal. We do, however, need to decode JSX entities. + var decoded = decodeEntities(trimmedLine); + return acc === undefined ? decoded : acc + " " + decoded; } /** * Replace entities like " ", "{", and "�" with the characters they encode. @@ -48948,7 +50190,7 @@ var ts; return String.fromCharCode(parseInt(hex, 16)); } else { - var ch = entities[word]; + var ch = entities.get(word); // If this is not a valid entity, then just use `match` (replace it with itself, i.e. don't replace) return ch ? String.fromCharCode(ch) : match; } @@ -48960,16 +50202,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 247 /* JsxElement */) { + if (node.kind === 248 /* JsxElement */) { return getTagName(node.openingElement); } else { - var name_35 = node.tagName; - if (ts.isIdentifier(name_35) && ts.isIntrinsicJsxName(name_35.text)) { - return ts.createLiteral(name_35.text); + var name = node.tagName; + if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.text)) { + return ts.createLiteral(name.text); } else { - return ts.createExpressionFromEntityName(name_35); + return ts.createExpressionFromEntityName(name); } } } @@ -48992,7 +50234,7 @@ var ts; } } ts.transformJsx = transformJsx; - var entities = ts.createMap({ + var entities = ts.createMapFromTemplate({ "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, @@ -49300,19 +50542,19 @@ var ts; case 119 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: // ES2017 'await' expressions must be transformed for targets < ES2017. return visitAwaitExpression(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: // ES2017 method declarations may be 'async' return visitMethodDeclaration(node); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: // ES2017 function declarations may be 'async' return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: // ES2017 function expressions may be 'async' return visitFunctionExpression(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: // ES2017 arrow functions may be 'async' return visitArrowFunction(node); default: @@ -49327,9 +50569,8 @@ var ts; * @param node The node to visit. */ function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield( - /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression), - /*location*/ node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createYield( + /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); } /** * Visits a MethodDeclaration node. @@ -49402,7 +50643,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 185 /* ArrowFunction */; + var isArrowFunction = node.kind === 186 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current @@ -49414,7 +50655,8 @@ var ts; var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(statements, /*location*/ node.body, /*multiLine*/ true); + var block = ts.createBlock(statements, /*multiLine*/ true); + ts.setTextRange(block, node.body); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. if (languageVersion >= 2 /* ES2015 */) { @@ -49434,7 +50676,7 @@ var ts; var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(block.statements, declarations), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); } return expression; } @@ -49447,7 +50689,7 @@ var ts; startLexicalEnvironment(); var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); var declarations = endLexicalEnvironment(); - return ts.updateBlock(visited, ts.createNodeArray(ts.concatenate(visited.statements, declarations), visited.statements)); + return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); } } function getPromiseConstructor(type) { @@ -49466,24 +50708,24 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(179 /* CallExpression */); - context.enableSubstitution(177 /* PropertyAccessExpression */); - context.enableSubstitution(178 /* ElementAccessExpression */); + context.enableSubstitution(180 /* CallExpression */); + context.enableSubstitution(178 /* PropertyAccessExpression */); + context.enableSubstitution(179 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(227 /* ClassDeclaration */); - context.enableEmitNotification(149 /* MethodDeclaration */); - context.enableEmitNotification(151 /* GetAccessor */); - context.enableEmitNotification(152 /* SetAccessor */); - context.enableEmitNotification(150 /* Constructor */); + context.enableEmitNotification(228 /* ClassDeclaration */); + context.enableEmitNotification(150 /* MethodDeclaration */); + context.enableEmitNotification(152 /* GetAccessor */); + context.enableEmitNotification(153 /* SetAccessor */); + context.enableEmitNotification(151 /* Constructor */); } } function substituteExpression(node) { switch (node.kind) { - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) { return substituteCallExpression(node); } @@ -49527,53 +50769,53 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 227 /* ClassDeclaration */ - || kind === 150 /* Constructor */ - || kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */; + return kind === 228 /* ClassDeclaration */ + || kind === 151 /* Constructor */ + || kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */; } /** * Hook for node emit. * + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { var savedCurrentSuperContainer = currentSuperContainer; currentSuperContainer = node; - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSuperContainer = savedCurrentSuperContainer; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } /** * Hooks node substitutions. * + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */) { return substituteExpression(node); } return node; } function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { if (flags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression]), "value", location); + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } else { - return ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression], location); + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), location); } } function getSuperContainerAsyncMethodFlags() { @@ -49636,7 +50878,7 @@ var ts; return node; } switch (node.kind) { - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -49661,25 +50903,21 @@ var ts; // Transforms `a[x] **= b` into `(_a = a)[_x = x] = Math.pow(_a[_x], b)` var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, /*location*/ left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, /*location*/ left.argumentExpression), - /*location*/ left); - value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, - /*location*/ left); + target = ts.setTextRange(ts.createElementAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(ts.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left); + value = ts.setTextRange(ts.createElementAccess(expressionTemp, argumentExpressionTemp), left); } else if (ts.isPropertyAccessExpression(left)) { // Transforms `a.x **= b` into `(_a = a).x = Math.pow(_a.x, b)` var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, /*location*/ left.expression), left.name, - /*location*/ left); - value = ts.createPropertyAccess(expressionTemp, left.name, - /*location*/ left); + target = ts.setTextRange(ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), left.name), left); + value = ts.setTextRange(ts.createPropertyAccess(expressionTemp, left.name), left); } else { // Transforms `a **= b` into `a = Math.pow(a, b)` target = left; value = left; } - return ts.createAssignment(target, ts.createMathPow(value, right, /*location*/ node), /*location*/ node); + return ts.setTextRange(ts.createAssignment(target, ts.createMathPow(value, right, /*location*/ node)), node); } function visitExponentiationExpression(node) { // Transforms `a ** b` into `Math.pow(a, b)` @@ -49869,7 +51107,7 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ - && node.kind === 217 /* ReturnStatement */ + && node.kind === 218 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { @@ -49902,91 +51140,91 @@ var ts; switch (node.kind) { case 114 /* StaticKeyword */: return undefined; // elide static keyword - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return visitClassDeclaration(node); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return visitClassExpression(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return visitParameter(node); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return visitArrowFunction(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return visitFunctionExpression(node); - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return visitVariableDeclaration(node); case 70 /* Identifier */: return visitIdentifier(node); - case 225 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: return visitSwitchStatement(node); - case 233 /* CaseBlock */: + case 234 /* CaseBlock */: return visitCaseBlock(node); - case 205 /* Block */: + case 206 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 216 /* BreakStatement */: - case 215 /* ContinueStatement */: + case 217 /* BreakStatement */: + case 216 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return visitLabeledStatement(node); - case 210 /* DoStatement */: - case 211 /* WhileStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return visitExpressionStatement(node); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return visitCatchClause(node); - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return visitCallExpression(node); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return visitNewExpression(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 12 /* NoSubstitutionTemplateLiteral */: case 13 /* TemplateHead */: case 14 /* TemplateMiddle */: case 15 /* TemplateTail */: return visitTemplateLiteral(node); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return visitTemplateExpression(node); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return visitYieldExpression(node); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return visitSpreadElement(node); case 96 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 98 /* ThisKeyword */: return visitThisKeyword(node); - case 202 /* MetaProperty */: + case 203 /* MetaProperty */: return visitMetaProperty(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return visitAccessorDeclaration(node); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return visitVariableStatement(node); - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -50001,7 +51239,7 @@ var ts; ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } function visitSwitchStatement(node) { if (convertedLoopState !== undefined) { @@ -50058,7 +51296,7 @@ var ts; if (ts.isGeneratedIdentifier(node)) { return node; } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + if (node.text !== "arguments" || !resolver.isArgumentsLocalBinding(node)) { return node; } return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); @@ -50069,13 +51307,13 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 216 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; - var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + var jump = node.kind === 217 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 216 /* BreakStatement */) { + if (node.kind === 217 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -50086,7 +51324,7 @@ var ts; } } else { - if (node.kind === 216 /* BreakStatement */) { + if (node.kind === 217 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -50134,8 +51372,9 @@ var ts; /*type*/ undefined, transformClassLikeDeclarationToExpression(node)); ts.setOriginalNode(variable, node); var statements = []; - var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([variable]), /*location*/ node); + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([variable])); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, node); ts.startOnNewLine(statement); statements.push(statement); // Add an `export default` statement for default exports (for `--target es5 --module es6`) @@ -50253,7 +51492,7 @@ var ts; ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); statements.push(statement); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); ts.setEmitFlags(block, 1536 /* NoComments */); return block; } @@ -50266,7 +51505,7 @@ var ts; */ function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node)), + statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node))), /*location*/ extendsClauseElement)); } } @@ -50288,8 +51527,8 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, ts.getDeclarationName(node), /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), - /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), - /*location*/ constructor || node); + /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); + ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); } @@ -50366,10 +51605,10 @@ var ts; if (constructor) { prependCaptureNewTargetIfNeeded(statements, constructor, /*copyOnWrite*/ false); } - var block = ts.createBlock(ts.createNodeArray(statements, + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ constructor ? constructor.body.statements : node.members), - /*location*/ constructor ? constructor.body : node, /*multiLine*/ true); + ts.setTextRange(block, constructor ? constructor.body : node); if (!constructor) { ts.setEmitFlags(block, 1536 /* NoComments */); } @@ -50382,17 +51621,17 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 217 /* ReturnStatement */) { + if (statement.kind === 218 /* ReturnStatement */) { return true; } - else if (statement.kind === 209 /* IfStatement */) { + else if (statement.kind === 210 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 205 /* Block */) { + else if (statement.kind === 206 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -50450,7 +51689,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -50460,8 +51699,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 192 /* BinaryExpression */ - || superCallExpression.left.kind !== 179 /* CallExpression */) { + if (superCallExpression.kind !== 193 /* BinaryExpression */ + || superCallExpression.left.kind !== 180 /* CallExpression */) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } // Shift comments from the original super call to the return statement. @@ -50496,25 +51735,25 @@ var ts; else if (ts.isBindingPattern(node.name)) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. - return ts.setOriginalNode(ts.createParameter( + return ts.setOriginalNode(ts.setTextRange(ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, ts.getGeneratedNameForNode(node), /*questionToken*/ undefined, /*type*/ undefined, - /*initializer*/ undefined, + /*initializer*/ undefined), /*location*/ node), /*original*/ node); } else if (node.initializer) { // Initializers are elided - return ts.setOriginalNode(ts.createParameter( + return ts.setOriginalNode(ts.setTextRange(ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, node.name, /*questionToken*/ undefined, /*type*/ undefined, - /*initializer*/ undefined, + /*initializer*/ undefined), /*location*/ node), /*original*/ node); } @@ -50544,17 +51783,17 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_36 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; // A rest parameter cannot have a binding pattern or an initializer, // so let's just ignore it. if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_36)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_36, initializer); + if (ts.isBindingPattern(name)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_36, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer); } } } @@ -50589,13 +51828,11 @@ var ts; */ function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer)), - /*location*/ parameter)) - ], /*location*/ parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */), - /*elseStatement*/ undefined, - /*location*/ parameter); + var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([ + ts.createStatement(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer))), parameter)) + ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */)); statement.startsOnNewLine = true; + ts.setTextRange(statement, parameter); ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 524288 /* CustomPrologue */); statements.push(statement); } @@ -50632,22 +51869,21 @@ var ts; var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); // var param = []; - statements.push(ts.setEmitFlags(ts.createVariableStatement( + statements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, /*type*/ undefined, ts.createArrayLiteral([])) - ]), + ])), /*location*/ parameter), 524288 /* CustomPrologue */)); // for (var _i = restIndex; _i < arguments.length; _i++) { // param[_i - restIndex] = arguments[_i]; // } - var forStatement = ts.createFor(ts.createVariableDeclarationList([ + var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) - ], /*location*/ parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), - /*location*/ parameter), ts.createPostfixIncrement(temp, /*location*/ parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 + ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ + ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp - : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), + : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), /*location*/ parameter)) ])); ts.setEmitFlags(forStatement, 524288 /* CustomPrologue */); @@ -50661,7 +51897,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 185 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 186 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -50671,8 +51907,9 @@ var ts; /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("_this", /*type*/ undefined, initializer) - ]), originalStatement); + ])); ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 524288 /* CustomPrologue */); + ts.setTextRange(captureThisStatement, originalStatement); ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } @@ -50680,22 +51917,22 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return statements; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 150 /* Constructor */: + case 151 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 92 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); @@ -50727,20 +51964,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 204 /* SemicolonClassElement */: + case 205 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 150 /* Constructor */: + case 151 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -50755,7 +51992,7 @@ var ts; * @param member The SemicolonClassElement node. */ function transformSemicolonClassElementToStatement(member) { - return ts.createEmptyStatement(/*location*/ member); + return ts.setTextRange(ts.createEmptyStatement(), member); } /** * Transforms a MethodDeclaration into a statement for a class body function. @@ -50771,7 +52008,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), + var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); @@ -50789,12 +52026,12 @@ var ts; * @param accessors The set of related get/set accessors. */ function transformAccessorsToStatement(receiver, accessors, container) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false), - /*location*/ ts.getSourceMapRange(accessors.firstAccessor)); + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } /** @@ -50831,12 +52068,12 @@ var ts; ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } - properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); + properties.push(ts.createPropertyAssignment("enumerable", ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue())); var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ target, propertyName, - ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true) + ts.createObjectLiteral(properties, /*multiLine*/ true) ]); if (startsOnNewLine) { call.startsOnNewLine = true; @@ -50861,7 +52098,8 @@ var ts; /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformFunctionBody(node), node); + /*type*/ undefined, transformFunctionBody(node)); + ts.setTextRange(func, node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8 /* CapturesThis */); exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); @@ -50931,15 +52169,15 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 227 /* FunctionDeclaration */ || node.kind === 185 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); convertedLoopState = savedConvertedLoopState; - return ts.setOriginalNode(ts.createFunctionExpression( + return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, /*typeParameters*/ undefined, parameters, - /*type*/ undefined, body, location), + /*type*/ undefined, body), location), /*original*/ node); } /** @@ -50977,7 +52215,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 185 /* ArrowFunction */); + ts.Debug.assert(node.kind === 186 /* ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -50993,7 +52231,8 @@ var ts; } } var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, /*location*/ body); + var returnStatement = ts.createReturn(expression); + ts.setTextRange(returnStatement, body); ts.setEmitFlags(returnStatement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1024 /* NoTrailingComments */); statements.push(returnStatement); // To align with the source map emit for the old emitter, we set a custom @@ -51007,7 +52246,8 @@ var ts; if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), multiLine); + ts.setTextRange(block, node.body); if (!multiLine && singleLine) { ts.setEmitFlags(block, 1 /* SingleLine */); } @@ -51019,7 +52259,7 @@ var ts; } function visitFunctionBodyDownLevel(node) { var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); - return ts.updateBlock(updated, ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, /*copyOnWrite*/ true), + return ts.updateBlock(updated, ts.setTextRange(ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, /*copyOnWrite*/ true)), /*location*/ updated.statements)); } function visitBlock(node, isFunctionBody) { @@ -51042,9 +52282,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -51060,9 +52300,9 @@ var ts; // If we are here it is most likely because our expression is a destructuring assignment. if (!needsDestructuringValue) { switch (node.expression.kind) { - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -51103,7 +52343,7 @@ var ts; } } if (assignments) { - updated = ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); }), node); + updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); })), node); } else { // none of declarations has initializer - the entire variable statement can be deleted @@ -51129,8 +52369,9 @@ var ts; var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ ? visitVariableDeclarationInLetDeclarationList : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); + var declarationList = ts.createVariableDeclarationList(declarations); ts.setOriginalNode(declarationList, node); + ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); if (node.transformFlags & 8388608 /* ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) @@ -51245,10 +52486,10 @@ var ts; return updated; } function recordLabel(node) { - convertedLoopState.labels[node.label.text] = node.label.text; + convertedLoopState.labels.set(node.label.text, node.label.text); } function resetLabel(node) { - convertedLoopState.labels[node.label.text] = undefined; + convertedLoopState.labels.set(node.label.text, undefined); } function visitLabeledStatement(node) { if (convertedLoopState && !convertedLoopState.labels) { @@ -51308,7 +52549,7 @@ var ts; // we don't want to emit a temporary variable for the RHS, just use it directly. var counter = ts.createLoopVariable(); var rhsReference = expression.kind === 70 /* Identifier */ - ? ts.createUniqueName(expression.text) + ? ts.createUniqueName(ts.unescapeIdentifier(expression.text)) : ts.createTempVariable(/*recordTempVariable*/ undefined); var elementAccess = ts.createElementAccess(rhsReference, counter); // Initialize LHS @@ -51322,8 +52563,9 @@ var ts; // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, elementAccess); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ initializer); + var declarationList = ts.createVariableDeclarationList(declarations); ts.setOriginalNode(declarationList, initializer); + ts.setTextRange(declarationList, initializer); // Adjust the source map range for the first declaration to align with the old // emitter. var firstDeclaration = declarations[0]; @@ -51335,12 +52577,11 @@ var ts; else { // The following call does not include the initializer, so we have // to emit it separately. - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.setOriginalNode(ts.createVariableDeclarationList([ + statements.push(ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), /*type*/ undefined, ts.createElementAccess(rhsReference, counter)) - ], /*location*/ ts.moveRangePos(initializer, -1)), initializer), - /*location*/ ts.moveRangeEnd(initializer, -1))); + ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); } } else { @@ -51355,7 +52596,7 @@ var ts; // Currently there is not way to check that assignment is binary expression of destructing assignment // so we have to cast never type to binaryExpression assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, /*location*/ ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createStatement(assignment), ts.moveRangeEnd(initializer, -1))); } } var bodyLocation; @@ -51364,7 +52605,7 @@ var ts; ts.addRange(statements, convertedLoopBodyStatements); } else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -51378,29 +52619,28 @@ var ts; ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression)); // The old emitter does not emit source maps for the block. // We add the location to preserve comments. - var body = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), - /*location*/ bodyLocation); + var body = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ statementsLocation)); + ts.setTextRange(body, bodyLocation); ts.setEmitFlags(body, 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); - var forStatement = ts.createFor(ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) - ], /*location*/ node.expression), 1048576 /* NoHoisting */), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), - /*location*/ node.expression), ts.createPostfixIncrement(counter, /*location*/ node.expression), body, - /*location*/ node); + var forStatement = ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)), + ts.setTextRange(ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression), node.expression) + ]), node.expression), 1048576 /* NoHoisting */), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), body); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); + ts.setTextRange(forStatement, node); return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 210 /* DoStatement */: - case 211 /* WhileStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -51423,7 +52663,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 142 /* ComputedPropertyName */) { + if (property.name.kind === 143 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -51437,8 +52677,7 @@ var ts; var temp = ts.createTempVariable(hoistVariableDeclaration); // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, node.multiLine), 32768 /* Indented */)); + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 32768 /* Indented */)); if (node.multiLine) { assignment.startsOnNewLine = true; } @@ -51496,11 +52735,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 225 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 226 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -51547,13 +52786,13 @@ var ts; copyOutParameters(loopOutParameters, 1 /* ToOutParameter */, statements_4); } ts.addRange(statements_4, lexicalEnvironment); - loopBody = ts.createBlock(statements_4, /*location*/ undefined, /*multiline*/ true); + loopBody = ts.createBlock(statements_4, /*multiline*/ true); } if (ts.isBlock(loopBody)) { loopBody.multiLine = true; } else { - loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); + loopBody = ts.createBlock([loopBody], /*multiline*/ true); } var isAsyncBlockContainingAwait = hierarchyFacts & 4 /* AsyncFunctionBody */ && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; @@ -51647,9 +52886,7 @@ var ts; // visit childnodes to transform initializer/condition/incrementor parts clone_4 = ts.visitEachChild(clone_4, visitor, context); // set loop statement - clone_4.statement = ts.createBlock(convertedLoopBodyStatements, - /*location*/ undefined, - /*multiline*/ true); + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, /*multiline*/ true); // reset and re-aggregate the transform flags clone_4.transformFlags = 0; ts.aggregateTransformFlags(clone_4); @@ -51718,26 +52955,25 @@ var ts; if (!state.labeledNonLocalBreaks) { state.labeledNonLocalBreaks = ts.createMap(); } - state.labeledNonLocalBreaks[labelText] = labelMarker; + state.labeledNonLocalBreaks.set(labelText, labelMarker); } else { if (!state.labeledNonLocalContinues) { state.labeledNonLocalContinues = ts.createMap(); } - state.labeledNonLocalContinues[labelText] = labelMarker; + state.labeledNonLocalContinues.set(labelText, labelMarker); } } function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { if (!table) { return; } - for (var labelText in table) { - var labelMarker = table[labelText]; + table.forEach(function (labelMarker, labelText) { var statements = []; // if there are no outer converted loop or outer label in question is located inside outer converted loop // then emit labeled break\continue // otherwise propagate pair 'label -> marker' to outer converted loop and emit 'return labelMarker' so outer loop can later decide what to do - if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) { var label = ts.createIdentifier(labelText); statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); } @@ -51746,7 +52982,7 @@ var ts; statements.push(ts.createReturn(loopResultName)); } caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); - } + }); } function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { var name = decl.name; @@ -51761,7 +52997,7 @@ var ts; else { loopParameters.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); if (resolver.getNodeCheckFlags(decl) & 2097152 /* NeedsLoopOutParameter */) { - var outParamName = ts.createUniqueName("out_" + name.text); + var outParamName = ts.createUniqueName("out_" + ts.unescapeIdentifier(name.text)); loopOutParameters.push({ originalName: name, outParamName: outParamName }); } } @@ -51781,20 +53017,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -51811,8 +53047,8 @@ var ts; * @param receiver The receiver for the assignment. */ function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), - /*location*/ property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -51826,8 +53062,8 @@ var ts; * @param receiver The receiver for the assignment. */ function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), - /*location*/ property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -51842,8 +53078,8 @@ var ts; */ function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined, container), - /*location*/ method); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined, container)); + ts.setTextRange(expression, method); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -51855,10 +53091,12 @@ var ts; var updated; if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var newVariableDeclaration = ts.createVariableDeclaration(temp); + ts.setTextRange(newVariableDeclaration, node.variableDeclaration); var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); - var list = ts.createVariableDeclarationList(vars, /*location*/ node.variableDeclaration, /*flags*/ node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); + var list = ts.createVariableDeclarationList(vars); + ts.setTextRange(list, node.variableDeclaration); + var destructure = ts.createVariableStatement(/*modifiers*/ undefined, list); updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); } else { @@ -51884,7 +53122,7 @@ var ts; ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); - return ts.createPropertyAssignment(node.name, functionExpression, + return ts.setTextRange(ts.createPropertyAssignment(node.name, functionExpression), /*location*/ node); } /** @@ -51908,7 +53146,7 @@ var ts; * @param node A ShorthandPropertyAssignment node. */ function visitShorthandPropertyAssignment(node) { - return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), + return ts.setTextRange(ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name)), /*location*/ node); } function visitComputedPropertyName(node) { @@ -52040,7 +53278,7 @@ var ts; })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 175 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 176 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -52056,8 +53294,7 @@ var ts; return ts.map(chunk, visitExpressionOfSpread); } function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { - return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, /*location*/ undefined, hasTrailingComma), visitor, ts.isExpression), - /*location*/ undefined, multiLine); + return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -52076,7 +53313,7 @@ var ts; * @param node A template literal. */ function visitTemplateLiteral(node) { - return ts.createLiteral(node.text, /*location*/ node); + return ts.setTextRange(ts.createLiteral(node.text), node); } /** * Visits a TaggedTemplateExpression node. @@ -52136,7 +53373,7 @@ var ts; // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's // and LineTerminatorSequences are normalized to for both TV and TRV. text = text.replace(/\r\n?/g, "\n"); - return ts.createLiteral(text, /*location*/ node); + return ts.setTextRange(ts.createLiteral(text), node); } /** * Visits a TemplateExpression node. @@ -52158,7 +53395,8 @@ var ts; // "abc" + (1 << 2) + "" var expression = ts.reduceLeft(expressions, ts.createAdd); if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); + expression.pos = node.pos; + expression.end = node.end; } return expression; } @@ -52241,19 +53479,21 @@ var ts; /** * Called by the printer just before a node is printed. * + * @param hint A hint as to the intended usage of the node. * @param node The node to be printed. + * @param emitCallback The callback used to emit the node. */ - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ : 65 /* FunctionIncludes */); - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); return; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } /** * Enables a more costly code path for substitutions when we determine a source file @@ -52273,24 +53513,24 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; context.enableSubstitution(98 /* ThisKeyword */); - context.enableEmitNotification(150 /* Constructor */); - context.enableEmitNotification(149 /* MethodDeclaration */); - context.enableEmitNotification(151 /* GetAccessor */); - context.enableEmitNotification(152 /* SetAccessor */); - context.enableEmitNotification(185 /* ArrowFunction */); - context.enableEmitNotification(184 /* FunctionExpression */); - context.enableEmitNotification(226 /* FunctionDeclaration */); + context.enableEmitNotification(151 /* Constructor */); + context.enableEmitNotification(150 /* MethodDeclaration */); + context.enableEmitNotification(152 /* GetAccessor */); + context.enableEmitNotification(153 /* SetAccessor */); + context.enableEmitNotification(186 /* ArrowFunction */); + context.enableEmitNotification(185 /* FunctionExpression */); + context.enableEmitNotification(227 /* FunctionDeclaration */); } } /** * Hooks node substitutions. * - * @param emitContext The context for the emitter. + * @param hint The context for the emitter. * @param node The node to substitute. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -52321,10 +53561,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 174 /* BindingElement */: - case 227 /* ClassDeclaration */: - case 230 /* EnumDeclaration */: - case 224 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 225 /* VariableDeclaration */: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -52366,7 +53606,7 @@ var ts; function substituteThisKeyword(node) { if (enabledSubstitutions & 1 /* CapturedThis */ && hierarchyFacts & 16 /* CapturesThis */) { - return ts.createIdentifier("_this", /*location*/ node); + return ts.setTextRange(ts.createIdentifier("_this"), node); } return node; } @@ -52382,11 +53622,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 208 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 209 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 179 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 180 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -52394,7 +53634,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 196 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 197 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -52419,6 +53659,118 @@ var ts; })(ts || (ts = {})); /// /// +/*@internal*/ +var ts; +(function (ts) { + /** + * Transforms ES5 syntax into ES3 syntax. + * + * @param context Context and state information for the transformation. + */ + function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + // enable emit notification only if using --jsx preserve or react-native + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(250 /* JsxOpeningElement */); + context.enableEmitNotification(251 /* JsxClosingElement */); + context.enableEmitNotification(249 /* JsxSelfClosingElement */); + noSubstitution = []; + } + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(178 /* PropertyAccessExpression */); + context.enableSubstitution(260 /* PropertyAssignment */); + return transformSourceFile; + /** + * Transforms an ES5 source file to ES3. + * + * @param node A SourceFile + */ + function transformSourceFile(node) { + return node; + } + /** + * Called by the printer just before a node is printed. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to emit. + * @param emitCallback A callback used to emit the node. + */ + function onEmitNode(hint, node, emitCallback) { + switch (node.kind) { + case 250 /* JsxOpeningElement */: + case 251 /* JsxClosingElement */: + case 249 /* JsxSelfClosingElement */: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(hint, node, emitCallback); + } + /** + * Hooks node substitutions. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to substitute. + */ + function onSubstituteNode(hint, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(hint, node); + } + node = previousOnSubstituteNode(hint, node); + if (ts.isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); + } + else if (ts.isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); + } + return node; + } + /** + * Substitutes a PropertyAccessExpression whose name is a reserved word. + * + * @param node A PropertyAccessExpression + */ + function substitutePropertyAccessExpression(node) { + var literalName = trySubstituteReservedName(node.name); + if (literalName) { + return ts.setTextRange(ts.createElementAccess(node.expression, literalName), node); + } + return node; + } + /** + * Substitutes a PropertyAssignment whose name is a reserved word. + * + * @param node A PropertyAssignment + */ + function substitutePropertyAssignment(node) { + var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return ts.updatePropertyAssignment(node, literalName, node.initializer); + } + return node; + } + /** + * If an identifier name is a reserved word, returns a string literal for the name. + * + * @param name An Identifier + */ + function trySubstituteReservedName(name) { + var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); + if (token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */) { + return ts.setTextRange(ts.createLiteral(name), name); + } + return undefined; + } + } + ts.transformES5 = transformES5; +})(ts || (ts = {})); +/// +/// // Transforms generator functions into a compatible ES5 representation with similar runtime // semantics. This is accomplished by first transforming the body of each generator // function into an intermediate representation that is the compiled into a JavaScript @@ -52589,13 +53941,15 @@ var ts; Instruction[Instruction["Catch"] = 6] = "Catch"; Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; })(Instruction || (Instruction = {})); - var instructionNames = ts.createMap((_a = {}, - _a[2 /* Return */] = "return", - _a[3 /* Break */] = "break", - _a[4 /* Yield */] = "yield", - _a[5 /* YieldStar */] = "yield*", - _a[7 /* Endfinally */] = "endfinally", - _a)); + function getInstructionName(instruction) { + switch (instruction) { + case 2 /* Return */: return "return"; + case 3 /* Break */: return "break"; + case 4 /* Yield */: return "yield"; + case 5 /* YieldStar */: return "yield*"; + case 7 /* Endfinally */: return "endfinally"; + } + } function transformGenerators(context) { var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); @@ -52687,13 +54041,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 210 /* DoStatement */: + case 211 /* DoStatement */: return visitDoStatement(node); - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: return visitWhileStatement(node); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: return visitSwitchStatement(node); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -52706,24 +54060,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return visitFunctionExpression(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return visitAccessorDeclaration(node); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return visitVariableStatement(node); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return visitForStatement(node); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return visitForInStatement(node); - case 216 /* BreakStatement */: + case 217 /* BreakStatement */: return visitBreakStatement(node); - case 215 /* ContinueStatement */: + case 216 /* ContinueStatement */: return visitContinueStatement(node); - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -52744,21 +54098,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitBinaryExpression(node); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return visitConditionalExpression(node); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return visitYieldExpression(node); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return visitCallExpression(node); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -52771,9 +54125,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -52792,11 +54146,11 @@ var ts; function visitFunctionDeclaration(node) { // Currently, we only support generators that were originally async functions. if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { - node = ts.setOriginalNode(ts.createFunctionDeclaration( + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration( /*decorators*/ undefined, node.modifiers, /*asteriskToken*/ undefined, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformGeneratorFunctionBody(node.body), + /*type*/ undefined, transformGeneratorFunctionBody(node.body)), /*location*/ node), node); } else { @@ -52830,11 +54184,11 @@ var ts; function visitFunctionExpression(node) { // Currently, we only support generators that were originally async functions. if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { - node = ts.setOriginalNode(ts.createFunctionExpression( + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformGeneratorFunctionBody(node.body), + /*type*/ undefined, transformGeneratorFunctionBody(node.body)), /*location*/ node), node); } else { @@ -52922,7 +54276,7 @@ var ts; operationArguments = savedOperationArguments; operationLocations = savedOperationLocations; state = savedState; - return ts.createBlock(statements, /*location*/ body, body.multiLine); + return ts.setTextRange(ts.createBlock(statements, body.multiLine), body); } /** * Visits a variable statement. @@ -53001,7 +54355,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -53013,7 +54367,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -53032,7 +54386,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 57 /* EqualsToken */, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.setTextRange(ts.createAssignment(target, ts.setTextRange(ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -53243,14 +54597,13 @@ var ts; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, /*location*/ undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, location, multiLine); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { emitAssignment(temp, hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, /*location*/ undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, - /*location*/ undefined, multiLine)); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); hasAssignedTemp = true; leadingElement = undefined; expressions = []; @@ -53281,8 +54634,7 @@ var ts; var multiLine = node.multiLine; var numInitialProperties = countInitialNodesWithoutYield(properties); var temp = declareLocal(); - emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, multiLine)); + emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine)); var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties); expressions.push(multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); return ts.inlineExpressions(expressions); @@ -53356,10 +54708,9 @@ var ts; // .mark resumeLabel // new (_b.apply(_a, _c.concat([%sent%, 2]))); var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, + return ts.setOriginalNode(ts.setTextRange(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, /*leadingElement*/ ts.createVoidZero())), - /*typeArguments*/ undefined, [], - /*location*/ node), node); + /*typeArguments*/ undefined, []), node), node); } return ts.visitEachChild(node, visitor, context); } @@ -53388,35 +54739,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 205 /* Block */: + case 206 /* Block */: return transformAndEmitBlock(node); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 209 /* IfStatement */: + case 210 /* IfStatement */: return transformAndEmitIfStatement(node); - case 210 /* DoStatement */: + case 211 /* DoStatement */: return transformAndEmitDoStatement(node); - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return transformAndEmitForStatement(node); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 215 /* ContinueStatement */: + case 216 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 216 /* BreakStatement */: + case 217 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 218 /* WithStatement */: + case 219 /* WithStatement */: return transformAndEmitWithStatement(node); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 221 /* ThrowStatement */: + case 222 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 222 /* TryStatement */: + case 223 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); @@ -53436,9 +54787,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - var name_37 = ts.getSynthesizedClone(variable.name); - ts.setCommentRange(name_37, variable.name); - hoistVariableDeclaration(name_37); + var name = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name, variable.name); + hoistVariableDeclaration(name); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -53604,8 +54955,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression), - /*location*/ initializer)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -53615,8 +54965,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression), - /*location*/ node.incrementor)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -53838,7 +55187,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 255 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 257 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -53851,7 +55200,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 254 /* CaseClause */) { + if (clause.kind === 256 /* CaseClause */) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -53993,9 +55342,9 @@ var ts; } return -1; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */) { return substituteExpression(node); } return node; @@ -54007,14 +55356,14 @@ var ts; return node; } function substituteExpressionIdentifier(node) { - if (renamedCatchVariables && ts.hasProperty(renamedCatchVariables, node.text)) { + if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { var original = ts.getOriginalNode(node); if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_38 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_38) { - var clone_7 = ts.getMutableClone(name_38); + var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; + if (name) { + var clone_7 = ts.getMutableClone(name); ts.setSourceMapRange(clone_7, node); ts.setCommentRange(clone_7, node); return clone_7; @@ -54158,10 +55507,10 @@ var ts; var name = declareLocal(text); if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = ts.createMap(); + renamedCatchVariableDeclarations = []; context.enableSubstitution(70 /* Identifier */); } - renamedCatchVariables[text] = true; + renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; var exception = peekBlock(); ts.Debug.assert(exception.state < 1 /* Catch */); @@ -54432,7 +55781,7 @@ var ts; */ function createInstruction(instruction) { var literal = ts.createLiteral(instruction); - literal.trailingComment = instructionNames[instruction]; + literal.trailingComment = getInstructionName(instruction); return literal; } /** @@ -54443,10 +55792,10 @@ var ts; */ function createInlineBreak(label, location) { ts.Debug.assert(label > 0, "Invalid label: " + label); - return ts.createReturn(ts.createArrayLiteral([ + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), location); + ])), location); } /** * Creates a statement that can be used indicate a Return operation. @@ -54455,15 +55804,16 @@ var ts; * @param location An optional source map location for the statement. */ function createInlineReturn(expression, location) { - return ts.createReturn(ts.createArrayLiteral(expression + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)]), location); + : [createInstruction(2 /* Return */)])), location); } /** * Creates an expression that can be used to resume from a Yield operation. */ function createGeneratorResume(location) { - return ts.createCall(ts.createPropertyAccess(state, "sent"), /*typeArguments*/ undefined, [], location); + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(state, "sent"), + /*typeArguments*/ undefined, []), location); } /** * Emits an empty instruction. @@ -54609,7 +55959,6 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, ts.createBlock(buildResult, - /*location*/ undefined, /*multiLine*/ buildResult.length > 0)), 262144 /* ReuseTempVariableScope */)); } /** @@ -54880,7 +56229,7 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeAssign(left, right, operationLocation) { - writeStatement(ts.createStatement(ts.createAssignment(left, right), operationLocation)); + writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); } /** * Writes a Throw operation to the current label's statement list. @@ -54891,7 +56240,7 @@ var ts; function writeThrow(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createThrow(expression, operationLocation)); + writeStatement(ts.setTextRange(ts.createThrow(expression), operationLocation)); } /** * Writes a Return operation to the current label's statement list. @@ -54902,9 +56251,9 @@ var ts; function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)]), operationLocation), 384 /* NoTokenSourceMaps */)); + : [createInstruction(2 /* Return */)])), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -54914,10 +56263,10 @@ var ts; */ function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -54927,10 +56276,10 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -54940,10 +56289,10 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -54953,9 +56302,9 @@ var ts; */ function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)]), operationLocation), 384 /* NoTokenSourceMaps */)); + : [createInstruction(4 /* Yield */)])), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -54965,10 +56314,10 @@ var ts; */ function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(5 /* YieldStar */), expression - ]), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -55051,186 +56400,903 @@ var ts; priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; - var _a; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - /** - * Transforms ES5 syntax into ES3 syntax. - * - * @param context Context and state information for the transformation. - */ - function transformES5(context) { - var compilerOptions = context.getCompilerOptions(); - // enable emit notification only if using --jsx preserve - var previousOnEmitNode; - var noSubstitution; - if (compilerOptions.jsx === 1 /* Preserve */) { - previousOnEmitNode = context.onEmitNode; - context.onEmitNode = onEmitNode; - context.enableEmitNotification(249 /* JsxOpeningElement */); - context.enableEmitNotification(250 /* JsxClosingElement */); - context.enableEmitNotification(248 /* JsxSelfClosingElement */); - noSubstitution = []; - } - var previousOnSubstituteNode = context.onSubstituteNode; - context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(177 /* PropertyAccessExpression */); - context.enableSubstitution(258 /* PropertyAssignment */); - return transformSourceFile; - /** - * Transforms an ES5 source file to ES3. - * - * @param node A SourceFile - */ - function transformSourceFile(node) { - return node; - } - /** - * Called by the printer just before a node is printed. - * - * @param node The node to be printed. - */ - function onEmitNode(emitContext, node, emitCallback) { - switch (node.kind) { - case 249 /* JsxOpeningElement */: - case 250 /* JsxClosingElement */: - case 248 /* JsxSelfClosingElement */: - var tagName = node.tagName; - noSubstitution[ts.getOriginalNodeId(tagName)] = true; - break; - } - previousOnEmitNode(emitContext, node, emitCallback); - } - /** - * Hooks node substitutions. - * - * @param emitContext The context for the emitter. - * @param node The node to substitute. - */ - function onSubstituteNode(emitContext, node) { - if (node.id && noSubstitution && noSubstitution[node.id]) { - return previousOnSubstituteNode(emitContext, node); - } - node = previousOnSubstituteNode(emitContext, node); - if (ts.isPropertyAccessExpression(node)) { - return substitutePropertyAccessExpression(node); - } - else if (ts.isPropertyAssignment(node)) { - return substitutePropertyAssignment(node); - } - return node; - } - /** - * Substitutes a PropertyAccessExpression whose name is a reserved word. - * - * @param node A PropertyAccessExpression - */ - function substitutePropertyAccessExpression(node) { - var literalName = trySubstituteReservedName(node.name); - if (literalName) { - return ts.createElementAccess(node.expression, literalName, /*location*/ node); - } - return node; - } - /** - * Substitutes a PropertyAssignment whose name is a reserved word. - * - * @param node A PropertyAssignment - */ - function substitutePropertyAssignment(node) { - var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); - if (literalName) { - return ts.updatePropertyAssignment(node, literalName, node.initializer); - } - return node; - } - /** - * If an identifier name is a reserved word, returns a string literal for the name. - * - * @param name An Identifier - */ - function trySubstituteReservedName(name) { - var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); - if (token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */) { - return ts.createLiteral(name, /*location*/ name); - } - return undefined; - } - } - ts.transformES5 = transformES5; })(ts || (ts = {})); /// /// /*@internal*/ var ts; (function (ts) { - function transformES2015Module(context) { + function transformModule(context) { + function getTransformModuleDelegate(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.AMD: return transformAMDModule; + case ts.ModuleKind.UMD: return transformUMDModule; + default: return transformCommonJSModule; + } + } + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var compilerOptions = context.getCompilerOptions(); - var previousOnEmitNode = context.onEmitNode; + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var moduleKind = ts.getEmitModuleKind(compilerOptions); var previousOnSubstituteNode = context.onSubstituteNode; - context.onEmitNode = onEmitNode; + var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(262 /* SourceFile */); - context.enableSubstitution(70 /* Identifier */); - var currentSourceFile; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(193 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(191 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(192 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(261 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(264 /* SourceFile */); // Restore state when substituting nodes in a file. + var moduleInfoMap = []; // The ExternalModuleInfo for each file. + var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. + var currentSourceFile; // The current file. + var currentModuleInfo; // The ExternalModuleInfo for the current file. + var noSubstitution; // Set of nodes for which substitution rules should be ignored. return transformSourceFile; + /** + * Transforms the module aspects of a SourceFile. + * + * @param node The SourceFile node. + */ function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { + if (ts.isDeclarationFile(node) + || !(ts.isExternalModule(node) + || compilerOptions.isolatedModules)) { return node; } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements); - ts.append(statements, ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + currentSourceFile = node; + currentModuleInfo = ts.collectExternalModuleInfo(node, resolver, compilerOptions); + moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo; + // Perform the transformation. + var transformModule = getTransformModuleDelegate(moduleKind); + var updated = transformModule(node); + currentSourceFile = undefined; + currentModuleInfo = undefined; + return ts.aggregateTransformFlags(updated); + } + /** + * Transforms a SourceFile into a CommonJS module. + * + * @param node The SourceFile node. + */ + function transformCommonJSModule(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + ts.addRange(statements, endLexicalEnvironment()); + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); + var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); + if (currentModuleInfo.hasExportStarsToExportValues) { + ts.addEmitHelper(updated, exportStarHelper); + } + return updated; + } + /** + * Transforms a SourceFile into an AMD module. + * + * @param node The SourceFile node. + */ + function transformAMDModule(node) { + var define = ts.createIdentifier("define"); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + // An AMD define function has the following shape: + // + // define(id?, dependencies?, factory); + // + // This has the shape of the following: + // + // define(name, ["module1", "module2"], function (module1Alias) { ... } + // + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // + // import "module" + // + // or + // + // /// + // + // we need to add modules without alias names to the end of the dependencies list + var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + // Create an updated SourceFile: + // + // define(moduleName?, ["module1", "module2"], function ... + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ + ts.createStatement(ts.createCall(define, + /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + // Add the dependency array argument: + // + // ["require", "exports", module1", "module2", ...] + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + // Add the module body function argument: + // + // function (require, exports, module1, module2) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ]))) + ]), + /*location*/ node.statements)); + } + /** + * Transforms a SourceFile into a UMD module. + * + * @param node The SourceFile node. + */ + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "factory")], + /*type*/ undefined, ts.setTextRange(ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement( + /*modifiers*/ undefined, [ + ts.createVariableDeclaration("v", + /*type*/ undefined, ts.createCall(ts.createIdentifier("factory"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), + /*typeArguments*/ undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], + /*multiLine*/ true), + /*location*/ undefined)); + // Create an updated SourceFile: + // + // (function (factory) { + // if (typeof module === "object" && typeof module.exports === "object") { + // var v = factory(require, exports); + // if (v !== undefined) module.exports = v; + // } + // else if (typeof define === 'function' && define.amd) { + // define(["require", "exports"], factory); + // } + // })(function ...) + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, + /*typeArguments*/ undefined, [ + // Add the module body function argument: + // + // function (require, exports) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ])) + ]), + /*location*/ node.statements)); + } + /** + * Collect the additional asynchronous dependencies for the module. + * + * @param node The source file. + * @param includeNonAmdDependencies A value indicating whether to include non-AMD dependencies. + */ + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + // names of modules with corresponding parameter in the factory function + var aliasedModuleNames = []; + // names of modules with no corresponding parameters in factory function + var unaliasedModuleNames = []; + // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding + // module names in aliasedModuleNames. + var importAliasNames = []; + // Fill in amd-dependency tags + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, amdDependency.name)); } else { - return ts.visitEachChild(node, visitor, context); + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); } } - return node; + for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { + var importNode = _c[_b]; + // Find the name of the external module + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + // Find the name of the module alias, if there is one + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + // Set emitFlags on the name of the classDeclaration + // This is so that when printer will not substitute the identifier + ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; } - function visitor(node) { + /** + * Transforms a SourceFile into an AMD or UMD module body. + * + * @param node The SourceFile node. + */ + function transformAsynchronousModuleBody(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } + // Visit each statement of the module body. + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + // End the lexical environment for the module body + // and merge any new lexical declarations. + ts.addRange(statements, endLexicalEnvironment()); + // Append the 'export =' statement if provided. + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); + var body = ts.createBlock(statements, /*multiLine*/ true); + if (currentModuleInfo.hasExportStarsToExportValues) { + // If we have any `export * from ...` declarations + // we need to inform the emitter to add the __export helper. + ts.addEmitHelper(body, exportStarHelper); + } + return body; + } + /** + * Adds the down-level representation of `export=` to the statement list if one exists + * in the source file. + * + * @param statements The Statement list to modify. + * @param emitAsReturn A value indicating whether to emit the `export=` statement as a + * return statement. + */ + function addExportEqualsIfNeeded(statements, emitAsReturn) { + if (currentModuleInfo.exportEquals) { + if (emitAsReturn) { + var statement = ts.createReturn(currentModuleInfo.exportEquals.expression); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + statements.push(statement); + } + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression)); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 1536 /* NoComments */); + statements.push(statement); + } + } + } + // + // Top-Level Source Element Visitors + // + /** + * Visits a node at the top level of the source file. + * + * @param node The node to visit. + */ + function sourceElementVisitor(node) { switch (node.kind) { - case 235 /* ImportEqualsDeclaration */: - // Elide `import=` as it is not legal with --module ES6 - return undefined; - case 241 /* ExportAssignment */: + case 237 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 236 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 243 /* ExportDeclaration */: + return visitExportDeclaration(node); + case 242 /* ExportAssignment */: return visitExportAssignment(node); + case 207 /* VariableStatement */: + return visitVariableStatement(node); + case 227 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 228 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 299 /* MergeDeclarationMarker */: + return visitMergeDeclarationMarker(node); + case 300 /* EndOfDeclarationMarker */: + return visitEndOfDeclarationMarker(node); + default: + // This visitor does not descend into the tree, as export/import statements + // are only transformed at the top level of a file. + return node; + } + } + /** + * Visits an ImportDeclaration node. + * + * @param node The node to visit. + */ + function visitImportDeclaration(node) { + var statements; + var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); + if (moduleKind !== ts.ModuleKind.AMD) { + if (!node.importClause) { + // import "mod"; + return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); + } + else { + var variables = []; + if (namespaceDeclaration && !ts.isDefaultImport(node)) { + // import * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, createRequireCall(node))); + } + else { + // import d from "mod"; + // import { x, y } from "mod"; + // import d, { x, y } from "mod"; + // import d, * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), + /*type*/ undefined, createRequireCall(node))); + if (namespaceDeclaration && ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node))); + } + } + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList(variables, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), + /*location*/ node)); + } + } + else if (namespaceDeclaration && ts.isDefaultImport(node)) { + // import d, * as n from "mod"; + statements = ts.append(statements, ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node)), + /*location*/ node) + ], languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Creates a `require()` call to import an external module. + * + * @param importNode The declararation to import. + */ + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (moduleName) { + args.push(moduleName); + } + return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); + } + /** + * Visits an ImportEqualsDeclaration node. + * + * @param node The node to visit. + */ + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; + if (moduleKind !== ts.ModuleKind.AMD) { + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(node.name, createRequireCall(node))), node)); + } + else { + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), + /*type*/ undefined, createRequireCall(node)) + ], + /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node)); + } + } + else { + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); + } + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportEqualsDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits an ExportDeclaration node. + * + * @param The node to visit. + */ + function visitExportDeclaration(node) { + if (!node.moduleSpecifier) { + // Elide export declarations with no module specifier as they are handled + // elsewhere. + return undefined; + } + var generatedName = ts.getGeneratedNameForNode(node); + if (node.exportClause) { + var statements = []; + // export { x, y } from "mod"; + if (moduleKind !== ts.ModuleKind.AMD) { + statements.push(ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(generatedName, + /*type*/ undefined, createRequireCall(node)) + ])), + /*location*/ node)); + } + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); + } + return ts.singleOrMany(statements); + } + else { + // export * from "mod"; + return ts.setTextRange(ts.createStatement(ts.createCall(ts.createIdentifier("__export"), + /*typeArguments*/ undefined, [ + moduleKind !== ts.ModuleKind.AMD + ? createRequireCall(node) + : generatedName + ])), node); + } + } + /** + * Visits an ExportAssignment node. + * + * @param node The node to visit. + */ + function visitExportAssignment(node) { + if (node.isExportEquals) { + return undefined; + } + var statements; + var original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); + } + else { + statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); + } + return ts.singleOrMany(statements); + } + /** + * Visits a FunctionDeclaration node. + * + * @param node The node to visit. + */ + function visitFunctionDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + /*typeParameters*/ undefined, node.parameters, + /*type*/ undefined, node.body), + /*location*/ node), + /*original*/ node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits a ClassDeclaration node. + * + * @param node The node to visit. + */ + function visitClassDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createClassDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + /*typeParameters*/ undefined, node.heritageClauses, node.members), node), node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits a VariableStatement node. + * + * @param node The node to visit. + */ + function visitVariableStatement(node) { + var statements; + var variables; + var expressions; + if (ts.hasModifier(node, 1 /* Export */)) { + var modifiers = void 0; + // If we're exporting these variables, then these just become assignments to 'exports.x'. + // We only want to emit assignments for variables with initializers. + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { + if (!modifiers) { + modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + } + variables = ts.append(variables, variable); + } + else if (variable.initializer) { + expressions = ts.append(expressions, transformInitializedVariable(variable)); + } + } + if (variables) { + statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); + } + if (expressions) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + } + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); + } + else { + statements = appendExportsOfVariableStatement(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Transforms an exported variable with an initializer into an expression. + * + * @param node The node to transform. + */ + function transformInitializedVariable(node) { + if (ts.isBindingPattern(node.name)) { + return ts.flattenDestructuringAssignment(node, + /*visitor*/ undefined, context, 0 /* All */, + /*needsValue*/ false, createExportExpression); + } + else { + return ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name), + /*location*/ node.name), node.initializer); + } + } + /** + * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged + * and transformed declaration. + * + * @param node The node to visit. + */ + function visitMergeDeclarationMarker(node) { + // For an EnumDeclaration or ModuleDeclaration that merges with a preceeding + // declaration we do not emit a leading variable declaration. To preserve the + // begin/end semantics of the declararation and to properly handle exports + // we wrapped the leading variable declaration in a `MergeDeclarationMarker`. + // + // To balance the declaration, add the exports of the elided variable + // statement. + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207 /* VariableStatement */) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } return node; } - function visitExportAssignment(node) { - // Elide `export=` as it is not legal with --module ES6 - return node.isExportEquals ? undefined : node; + /** + * Determines whether a node has an associated EndOfDeclarationMarker. + * + * @param node The node to test. + */ + function hasAssociatedEndOfDeclarationMarker(node) { + return (ts.getEmitFlags(node) & 2097152 /* HasEndOfDeclarationMarker */) !== 0; + } + /** + * Visits a DeclarationMarker used as a placeholder for the end of a transformed + * declaration. + * + * @param node The node to visit. + */ + function visitEndOfDeclarationMarker(node) { + // For some transformations we emit an `EndOfDeclarationMarker` to mark the actual + // end of the transformed declaration. We use this marker to emit any deferred exports + // of the declaration. + var id = ts.getOriginalNodeId(node); + var statements = deferredExports[id]; + if (statements) { + delete deferredExports[id]; + return ts.append(statements, node); + } + return node; + } + /** + * Appends the exports of an ImportDeclaration to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfImportDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + var importClause = decl.importClause; + if (!importClause) { + return statements; + } + if (importClause.name) { + statements = appendExportsOfDeclaration(statements, importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + switch (namedBindings.kind) { + case 239 /* NamespaceImport */: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 240 /* NamedImports */: + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var importBinding = _a[_i]; + statements = appendExportsOfDeclaration(statements, importBinding); + } + break; + } + } + return statements; + } + /** + * Appends the exports of an ImportEqualsDeclaration to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfImportEqualsDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + return appendExportsOfDeclaration(statements, decl); + } + /** + * Appends the exports of a VariableStatement to a statement list, returning the statement + * list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param node The VariableStatement whose exports are to be recorded. + */ + function appendExportsOfVariableStatement(statements, node) { + if (currentModuleInfo.exportEquals) { + return statements; + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + statements = appendExportsOfBindingElement(statements, decl); + } + return statements; + } + /** + * Appends the exports of a VariableDeclaration or BindingElement to a statement list, + * returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfBindingElement(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + statements = appendExportsOfBindingElement(statements, element); + } + } + } + else if (!ts.isGeneratedIdentifier(decl.name)) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + /** + * Appends the exports of a ClassDeclaration or FunctionDeclaration to a statement list, + * returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfHoistedDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.hasModifier(decl, 1 /* Export */)) { + var exportName = ts.hasModifier(decl, 512 /* Default */) ? ts.createIdentifier("default") : decl.name; + statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), /*location*/ decl); + } + if (decl.name) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + /** + * Appends the exports of a declaration to a statement list, returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration to export. + */ + function appendExportsOfDeclaration(statements, decl) { + var name = ts.getDeclarationName(decl); + var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(name.text); + if (exportSpecifiers) { + for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { + var exportSpecifier = exportSpecifiers_1[_i]; + statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name); + } + } + return statements; + } + /** + * Appends the down-level representation of an export to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param exportName The name of the export. + * @param expression The expression to export. + * @param location The location to use for source maps and comments for the export. + * @param allowComments Whether to allow comments on the export. + */ + function appendExportStatement(statements, exportName, expression, location, allowComments) { + statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); + return statements; + } + function createUnderscoreUnderscoreESModule() { + var statement; + if (languageVersion === 0 /* ES3 */) { + statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true))); + } + else { + statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ])); + } + ts.setEmitFlags(statement, 524288 /* CustomPrologue */); + return statement; + } + /** + * Creates a call to the current file's export function to export a value. + * + * @param name The bound name of the export. + * @param value The exported value. + * @param location The location to use for source maps and comments for the export. + * @param allowComments An optional value indicating whether to emit comments for the statement. + */ + function createExportStatement(name, value, location, allowComments) { + var statement = ts.setTextRange(ts.createStatement(createExportExpression(name, value)), location); + ts.startOnNewLine(statement); + if (!allowComments) { + ts.setEmitFlags(statement, 1536 /* NoComments */); + } + return statement; + } + /** + * Creates a call to the current file's export function to export a value. + * + * @param name The bound name of the export. + * @param value The exported value. + * @param location The location to use for source maps and comments for the export. + */ + function createExportExpression(name, value, location) { + return ts.setTextRange(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location); + } + // + // Modifier Visitors + // + /** + * Visit nodes to elide module-specific modifiers. + * + * @param node The node to visit. + */ + function modifierVisitor(node) { + // Elide module-specific modifiers. + switch (node.kind) { + case 83 /* ExportKeyword */: + case 78 /* DefaultKeyword */: + return undefined; + } + return node; } // // Emit Notification // /** - * Hook for node emit. + * Hook for node emit notifications. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(emitContext, node, emitCallback) { - if (ts.isSourceFile(node)) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264 /* SourceFile */) { currentSourceFile = node; - previousOnEmitNode(emitContext, node, emitCallback); + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; + noSubstitution = []; + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; + currentModuleInfo = undefined; + noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } // @@ -55239,27 +57305,188 @@ var ts; /** * Hooks node substitutions. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (ts.isIdentifier(node) && emitContext === 1 /* Expression */) { - return substituteExpressionIdentifier(node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (node.id && noSubstitution[node.id]) { + return node; + } + if (hint === 1 /* Expression */) { + return substituteExpression(node); + } + else if (ts.isShorthandPropertyAssignment(node)) { + return substituteShorthandPropertyAssignment(node); } return node; } + /** + * Substitution for a ShorthandPropertyAssignment whose declaration name is an imported + * or exported symbol. + * + * @param node The node to substitute. + */ + function substituteShorthandPropertyAssignment(node) { + var name = node.name; + var exportedOrImportedName = substituteExpressionIdentifier(name); + if (exportedOrImportedName !== name) { + // A shorthand property with an assignment initializer is probably part of a + // destructuring assignment + if (node.objectAssignmentInitializer) { + var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); + } + return ts.setTextRange(ts.createPropertyAssignment(name, exportedOrImportedName), node); + } + return node; + } + /** + * Substitution for an Expression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 193 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 192 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + return substituteUnaryExpression(node); + } + return node; + } + /** + * Substitution for an Identifier expression that may contain an imported or exported + * symbol. + * + * @param node The node to substitute. + */ function substituteExpressionIdentifier(node) { if (ts.getEmitFlags(node) & 4096 /* HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return ts.createPropertyAccess(externalHelpersModuleName, node); } + return node; + } + if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); + if (exportContainer && exportContainer.kind === 264 /* SourceFile */) { + return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), + /*location*/ node); + } + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts.isImportClause(importDeclaration)) { + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), + /*location*/ node); + } + else if (ts.isImportSpecifier(importDeclaration)) { + var name = importDeclaration.propertyName || importDeclaration.name; + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name)), + /*location*/ node); + } + } } return node; } + /** + * Substitution for a BinaryExpression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteBinaryExpression(node) { + // When we see an assignment expression whose left-hand side is an exported symbol, + // we should ensure all exports of that symbol are updated with the correct value. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + // - We do not substitute identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only substitute identifiers that are exported at the top level. + if (ts.isAssignmentOperator(node.operatorToken.kind) + && ts.isIdentifier(node.left) + && !ts.isGeneratedIdentifier(node.left) + && !ts.isLocalName(node.left) + && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + // For each additional export of the declaration, apply an export assignment. + var expression = node; + for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { + var exportName = exportedNames_1[_i]; + // Mark the node to prevent triggering this rule again. + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression, /*location*/ node); + } + return expression; + } + } + return node; + } + /** + * Substitution for a UnaryExpression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteUnaryExpression(node) { + // When we see a prefix or postfix increment expression whose operand is an exported + // symbol, we should ensure all exports of that symbol are updated with the correct + // value. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + // - We do not substitute identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only substitute identifiers that are exported at the top level. + if ((node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var expression = node.kind === 192 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1)), + /*location*/ node) + : node; + for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { + var exportName = exportedNames_2[_i]; + // Mark the node to prevent triggering this rule again. + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression); + } + return expression; + } + } + return node; + } + /** + * Gets the additional exports of a name. + * + * @param name The name. + */ + function getExports(name) { + if (!ts.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) { + return currentModuleInfo + && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; + } + } + } } - ts.transformES2015Module = transformES2015Module; + ts.transformModule = transformModule; + // emit output for the __export helper function + var exportStarHelper = { + name: "typescript:export-star", + scoped: true, + text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" + }; })(ts || (ts = {})); /// /// @@ -55276,14 +57503,14 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(262 /* SourceFile */); // Restore state when substituting nodes in a file. - var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. - var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. - var exportFunctionsMap = ts.createMap(); // The export function associated with a source file. - var noSubstitutionMap = ts.createMap(); // Set of nodes for which substitution rules should be ignored for each file. + context.enableSubstitution(193 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(191 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(192 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(264 /* SourceFile */); // Restore state when substituting nodes in a file. + var moduleInfoMap = []; // The ExternalModuleInfo for each file. + var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. + var exportFunctionsMap = []; // The export function associated with a source file. + var noSubstitutionMap = []; // Set of nodes for which substitution rules should be ignored for each file. var currentSourceFile; // The current file. var moduleInfo; // ExternalModuleInfo for the current file. var exportFunction; // The export function for the current file. @@ -55322,7 +57549,8 @@ var ts; moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); // Make sure that the name of the 'exports' function does not conflict with // existing identifiers. - exportFunction = exportFunctionsMap[id] = ts.createUniqueName("exports"); + exportFunction = ts.createUniqueName("exports"); + exportFunctionsMap[id] = exportFunction; contextObject = ts.createUniqueName("context"); // Add the body of the module. var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); @@ -55341,12 +57569,12 @@ var ts; // So the helper will be emit at the correct position instead of at the top of the source-file var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); - var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.createNodeArray([ + var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ], node.statements)), 1024 /* NoTrailingComments */); + ]), node.statements)), 1024 /* NoTrailingComments */); if (!(compilerOptions.outFile || compilerOptions.out)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -55374,13 +57602,13 @@ var ts; var externalImport = externalImports[i]; var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { // deduplicate/group entries in dependency list by the dependency name - var groupIndex = groupIndices[text]; dependencyGroups[groupIndex].externalImports.push(externalImport); } else { - groupIndices[text] = dependencyGroups.length; + groupIndices.set(text, dependencyGroups.length); dependencyGroups.push({ name: externalModuleName, externalImports: [externalImport] @@ -55464,7 +57692,7 @@ var ts; // - Temporary variables will appear at the top rather than at the bottom of the file ts.addRange(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + var moduleObject = ts.createObjectLiteral([ ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), ts.createPropertyAssignment("execute", ts.createFunctionExpression( /*modifiers*/ undefined, @@ -55472,12 +57700,11 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, ts.createBlock(executeStatements, - /*location*/ undefined, - /*multiLine*/ true))) - ]), - /*multiLine*/ true))); - return ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); + /*type*/ undefined, ts.createBlock(executeStatements, /*multiLine*/ true))) + ]); + moduleObject.multiLine = true; + statements.push(ts.createReturn(moduleObject)); + return ts.createBlock(statements, /*multiLine*/ true); } /** * Adds an exportStar function to a statement list if it is needed for the file. @@ -55493,13 +57720,13 @@ var ts; // to support this we store names of local/indirect exported entries in a set. // this set is used to filter names brought by star expors. // local names set should only be added if we have anything exported - if (!moduleInfo.exportedNames && ts.isEmpty(moduleInfo.exportSpecifiers)) { + if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) { // no exported declarations (export var ...) or export specifiers (export {x}) // check if we have any non star export declarations. var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 242 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 243 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -55519,12 +57746,12 @@ var ts; continue; } // write name of exported declaration, i.e 'export var x...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createTrue())); } } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 242 /* ExportDeclaration */) { + if (externalImport.kind !== 243 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -55535,14 +57762,14 @@ var ts; for (var _f = 0, _g = exportDecl.exportClause.elements; _f < _g.length; _f++) { var element = _g[_f]; // write name of indirectly exported entry, i.e. 'export {x} from ...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createTrue())); } } var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); statements.push(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(exportedNamesStorageRef, - /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true)) + /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*multiline*/ true)) ]))); var exportStarFunction = createExportStarFunction(exportedNamesStorageRef); statements.push(exportStarFunction); @@ -55583,9 +57810,7 @@ var ts; ])), ts.createStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [exports])) - ], - /*location*/ undefined, - /*multiline*/ true)); + ], /*multiline*/ true)); } /** * Creates an array setter callbacks for each dependency group. @@ -55605,19 +57830,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // fall-through - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -55634,7 +57859,7 @@ var ts; properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); } statements.push(ts.createStatement(ts.createCall(exportFunction, - /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)]))); + /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*multiline*/ true)]))); } else { // export * from 'foo' @@ -55653,9 +57878,9 @@ var ts; /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], - /*type*/ undefined, ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true))); + /*type*/ undefined, ts.createBlock(statements, /*multiLine*/ true))); } - return ts.createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); + return ts.createArrayLiteral(setters, /*multiLine*/ true); } // // Top-level Source Element Visitors @@ -55667,15 +57892,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return visitImportDeclaration(node); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -55776,11 +58001,9 @@ var ts; var name = ts.getLocalName(node); hoistVariableDeclaration(name); // Rewrite the class declaration into an assignment of a class expression. - statements = ts.append(statements, ts.createStatement(ts.createAssignment(name, ts.createClassExpression( + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement), - /*location*/ node)), - /*location*/ node)); + /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts.getOriginalNodeId(node); @@ -55815,7 +58038,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), /*location*/ node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -55853,7 +58076,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 1048576 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 262 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 264 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -55900,8 +58123,8 @@ var ts; function createVariableAssignment(name, value, location, isExportedDeclaration) { hoistVariableDeclaration(ts.getSynthesizedClone(name)); return isExportedDeclaration - ? createExportExpression(name, preventSubstitution(ts.createAssignment(name, value, location))) - : preventSubstitution(ts.createAssignment(name, value, location)); + ? createExportExpression(name, preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location))) + : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } /** * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged @@ -55917,7 +58140,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -55973,10 +58196,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 238 /* NamespaceImport */: + case 239 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 239 /* NamedImports */: + case 240 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -56094,10 +58317,10 @@ var ts; return statements; } var name = ts.getDeclarationName(decl); - var exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + var exportSpecifiers = moduleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { - for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { - var exportSpecifier = exportSpecifiers_1[_i]; + for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { + var exportSpecifier = exportSpecifiers_2[_i]; if (exportSpecifier.name.text !== excludeName) { statements = appendExportStatement(statements, exportSpecifier.name, name); } @@ -56155,43 +58378,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return visitClassDeclaration(node); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return visitForStatement(node); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return visitForInStatement(node); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return visitForOfStatement(node); - case 210 /* DoStatement */: + case 211 /* DoStatement */: return visitDoStatement(node); - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: return visitWhileStatement(node); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return visitLabeledStatement(node); - case 218 /* WithStatement */: + case 219 /* WithStatement */: return visitWithStatement(node); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: return visitSwitchStatement(node); - case 233 /* CaseBlock */: + case 234 /* CaseBlock */: return visitCaseBlock(node); - case 254 /* CaseClause */: + case 256 /* CaseClause */: return visitCaseClause(node); - case 255 /* DefaultClause */: + case 257 /* DefaultClause */: return visitDefaultClause(node); - case 222 /* TryStatement */: + case 223 /* TryStatement */: return visitTryStatement(node); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return visitCatchClause(node); - case 205 /* Block */: + case 206 /* Block */: return visitBlock(node); - case 296 /* MergeDeclarationMarker */: + case 299 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 297 /* EndOfDeclarationMarker */: + case 300 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -56371,7 +58594,7 @@ var ts; */ function destructuringVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 192 /* BinaryExpression */) { + && node.kind === 193 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (node.transformFlags & 2048 /* ContainsDestructuringAssignment */) { @@ -56419,7 +58642,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 262 /* SourceFile */; + return container !== undefined && container.kind === 264 /* SourceFile */; } else { return false; @@ -56447,12 +58670,12 @@ var ts; /** * Hook for node emit notifications. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. - * @param emit A callback used to emit the node in the printer. + * @param emitCallback A callback used to emit the node in the printer. */ - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 262 /* SourceFile */) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -56461,14 +58684,14 @@ var ts; if (noSubstitution) { delete noSubstitutionMap[id]; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } // @@ -56477,15 +58700,15 @@ var ts; /** * Hooks node substitutions. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); if (isSubstitutionPrevented(node)) { return node; } - if (emitContext === 1 /* Expression */) { + if (hint === 1 /* Expression */) { return substituteExpression(node); } return node; @@ -56499,10 +58722,10 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return substituteBinaryExpression(node); - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -56530,1119 +58753,11 @@ var ts; var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), /*location*/ node); } else if (ts.isImportSpecifier(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name), - /*location*/ node); - } - } - } - return node; - } - /** - * Substitution for a BinaryExpression that may contain an imported or exported symbol. - * - * @param node The node to substitute. - */ - function substituteBinaryExpression(node) { - // When we see an assignment expression whose left-hand side is an exported symbol, - // we should ensure all exports of that symbol are updated with the correct value. - // - // - We do not substitute generated identifiers for any reason. - // - We do not substitute identifiers tagged with the LocalName flag. - // - We do not substitute identifiers that were originally the name of an enum or - // namespace due to how they are transformed in TypeScript. - // - We only substitute identifiers that are exported at the top level. - if (ts.isAssignmentOperator(node.operatorToken.kind) - && ts.isIdentifier(node.left) - && !ts.isGeneratedIdentifier(node.left) - && !ts.isLocalName(node.left) - && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { - var exportedNames = getExports(node.left); - if (exportedNames) { - // For each additional export of the declaration, apply an export assignment. - var expression = node; - for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { - var exportName = exportedNames_1[_i]; - expression = createExportExpression(exportName, preventSubstitution(expression)); - } - return expression; - } - } - return node; - } - /** - * Substitution for a UnaryExpression that may contain an imported or exported symbol. - * - * @param node The node to substitute. - */ - function substituteUnaryExpression(node) { - // When we see a prefix or postfix increment expression whose operand is an exported - // symbol, we should ensure all exports of that symbol are updated with the correct - // value. - // - // - We do not substitute generated identifiers for any reason. - // - We do not substitute identifiers tagged with the LocalName flag. - // - We do not substitute identifiers that were originally the name of an enum or - // namespace due to how they are transformed in TypeScript. - // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) - && ts.isIdentifier(node.operand) - && !ts.isGeneratedIdentifier(node.operand) - && !ts.isLocalName(node.operand) - && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { - var exportedNames = getExports(node.operand); - if (exportedNames) { - var expression = node.kind === 191 /* PostfixUnaryExpression */ - ? ts.createPrefix(node.operator, node.operand, - /*location*/ node) - : node; - for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { - var exportName = exportedNames_2[_i]; - expression = createExportExpression(exportName, preventSubstitution(expression)); - } - if (node.kind === 191 /* PostfixUnaryExpression */) { - expression = node.operator === 42 /* PlusPlusToken */ - ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) - : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); - } - return expression; - } - } - return node; - } - /** - * Gets the exports of a name. - * - * @param name The name. - */ - function getExports(name) { - var exportedNames; - if (!ts.isGeneratedIdentifier(name)) { - var valueDeclaration = resolver.getReferencedImportDeclaration(name) - || resolver.getReferencedValueDeclaration(name); - if (valueDeclaration) { - var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 262 /* SourceFile */) { - exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); - } - exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); - } - } - return exportedNames; - } - /** - * Prevent substitution of a node for this transformer. - * - * @param node The node which should not be substituted. - */ - function preventSubstitution(node) { - if (noSubstitution === undefined) - noSubstitution = ts.createMap(); - noSubstitution[ts.getNodeId(node)] = true; - return node; - } - /** - * Determines whether a node should not be substituted. - * - * @param node The node to test. - */ - function isSubstitutionPrevented(node) { - return noSubstitution && node.id && noSubstitution[node.id]; - } - } - ts.transformSystemModule = transformSystemModule; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var moduleKind = ts.getEmitModuleKind(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(259 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(262 /* SourceFile */); // Restore state when substituting nodes in a file. - var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. - var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. - var currentSourceFile; // The current file. - var currentModuleInfo; // The ExternalModuleInfo for the current file. - var noSubstitution; // Set of nodes for which substitution rules should be ignored. - return transformSourceFile; - /** - * Transforms the module aspects of a SourceFile. - * - * @param node The SourceFile node. - */ - function transformSourceFile(node) { - if (ts.isDeclarationFile(node) - || !(ts.isExternalModule(node) - || compilerOptions.isolatedModules)) { - return node; - } - currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); - // Perform the transformation. - var transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule(node); - currentSourceFile = undefined; - currentModuleInfo = undefined; - return ts.aggregateTransformFlags(updated); - } - /** - * Transforms a SourceFile into a CommonJS module. - * - * @param node The SourceFile node. - */ - function transformCommonJSModule(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); - ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); - var updated = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); - if (currentModuleInfo.hasExportStarsToExportValues) { - ts.addEmitHelper(updated, exportStarHelper); - } - return updated; - } - /** - * Transforms a SourceFile into an AMD module. - * - * @param node The SourceFile node. - */ - function transformAMDModule(node) { - var define = ts.createIdentifier("define"); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - // An AMD define function has the following shape: - // - // define(id?, dependencies?, factory); - // - // This has the shape of the following: - // - // define(name, ["module1", "module2"], function (module1Alias) { ... } - // - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // - // import "module" - // - // or - // - // /// - // - // we need to add modules without alias names to the end of the dependencies list - var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - // Create an updated SourceFile: - // - // define(moduleName?, ["module1", "module2"], function ... - return ts.updateSourceFileNode(node, ts.createNodeArray([ - ts.createStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - // Add the dependency array argument: - // - // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - // Add the module body function argument: - // - // function (require, exports, module1, module2) ... - ts.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), - ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), - /*type*/ undefined, transformAsynchronousModuleBody(node)) - ]))) - ], - /*location*/ node.statements)); - } - /** - * Transforms a SourceFile into a UMD module. - * - * @param node The SourceFile node. - */ - function transformUMDModule(node) { - var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - var umdHeader = ts.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "factory")], - /*type*/ undefined, ts.createBlock([ - ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ - ts.createVariableStatement( - /*modifiers*/ undefined, [ - ts.createVariableDeclaration("v", - /*type*/ undefined, ts.createCall(ts.createIdentifier("factory"), - /*typeArguments*/ undefined, [ - ts.createIdentifier("require"), - ts.createIdentifier("exports") - ])) - ]), - ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) - ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("define"), - /*typeArguments*/ undefined, [ - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - ts.createIdentifier("factory") - ])) - ]))) - ], - /*location*/ undefined, - /*multiLine*/ true)); - // Create an updated SourceFile: - // - // (function (factory) { - // if (typeof module === "object" && typeof module.exports === "object") { - // var v = factory(require, exports); - // if (v !== undefined) module.exports = v; - // } - // else if (typeof define === 'function' && define.amd) { - // define(["require", "exports"], factory); - // } - // })(function ...) - return ts.updateSourceFileNode(node, ts.createNodeArray([ - ts.createStatement(ts.createCall(umdHeader, - /*typeArguments*/ undefined, [ - // Add the module body function argument: - // - // function (require, exports) ... - ts.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), - ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), - /*type*/ undefined, transformAsynchronousModuleBody(node)) - ])) - ], - /*location*/ node.statements)); - } - /** - * Collect the additional asynchronous dependencies for the module. - * - * @param node The source file. - * @param includeNonAmdDependencies A value indicating whether to include non-AMD dependencies. - */ - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - // names of modules with corresponding parameter in the factory function - var aliasedModuleNames = []; - // names of modules with no corresponding parameters in factory function - var unaliasedModuleNames = []; - // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding - // module names in aliasedModuleNames. - var importAliasNames = []; - // Fill in amd-dependency tags - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { - var importNode = _c[_b]; - // Find the name of the external module - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - // Find the name of the module alias, if there is one - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - // Set emitFlags on the name of the classDeclaration - // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - /** - * Transforms a SourceFile into an AMD or UMD module body. - * - * @param node The SourceFile node. - */ - function transformAsynchronousModuleBody(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - // Visit each statement of the module body. - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); - ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - // End the lexical environment for the module body - // and merge any new lexical declarations. - ts.addRange(statements, endLexicalEnvironment()); - // Append the 'export =' statement if provided. - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); - var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); - if (currentModuleInfo.hasExportStarsToExportValues) { - // If we have any `export * from ...` declarations - // we need to inform the emitter to add the __export helper. - ts.addEmitHelper(body, exportStarHelper); - } - return body; - } - /** - * Adds the down-level representation of `export=` to the statement list if one exists - * in the source file. - * - * @param statements The Statement list to modify. - * @param emitAsReturn A value indicating whether to emit the `export=` statement as a - * return statement. - */ - function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (currentModuleInfo.exportEquals) { - if (emitAsReturn) { - var statement = ts.createReturn(currentModuleInfo.exportEquals.expression, - /*location*/ currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression), - /*location*/ currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536 /* NoComments */); - statements.push(statement); - } - } - } - // - // Top-Level Source Element Visitors - // - /** - * Visits a node at the top level of the source file. - * - * @param node The node to visit. - */ - function sourceElementVisitor(node) { - switch (node.kind) { - case 236 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 235 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 242 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 241 /* ExportAssignment */: - return visitExportAssignment(node); - case 206 /* VariableStatement */: - return visitVariableStatement(node); - case 226 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 227 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 296 /* MergeDeclarationMarker */: - return visitMergeDeclarationMarker(node); - case 297 /* EndOfDeclarationMarker */: - return visitEndOfDeclarationMarker(node); - default: - // This visitor does not descend into the tree, as export/import statements - // are only transformed at the top level of a file. - return node; - } - } - /** - * Visits an ImportDeclaration node. - * - * @param node The node to visit. - */ - function visitImportDeclaration(node) { - var statements; - var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (moduleKind !== ts.ModuleKind.AMD) { - if (!node.importClause) { - // import "mod"; - return ts.createStatement(createRequireCall(node), /*location*/ node); - } - else { - var variables = []; - if (namespaceDeclaration && !ts.isDefaultImport(node)) { - // import * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, createRequireCall(node))); - } - else { - // import d from "mod"; - // import { x, y } from "mod"; - // import d, { x, y } from "mod"; - // import d, * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), - /*type*/ undefined, createRequireCall(node))); - if (namespaceDeclaration && ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node))); - } - } - statements = ts.append(statements, ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList(variables, - /*location*/ undefined, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), - /*location*/ node)); - } - } - else if (namespaceDeclaration && ts.isDefaultImport(node)) { - // import d, * as n from "mod"; - statements = ts.append(statements, ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node), - /*location*/ node) - ], - /*location*/ undefined, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfImportDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Creates a `require()` call to import an external module. - * - * @param importNode The declararation to import. - */ - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (moduleName) { - args.push(moduleName); - } - return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); - } - /** - * Visits an ImportEqualsDeclaration node. - * - * @param node The node to visit. - */ - function visitImportEqualsDeclaration(node) { - ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); - var statements; - if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(node.name, createRequireCall(node)), - /*location*/ node)); - } - else { - statements = ts.append(statements, ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), - /*type*/ undefined, createRequireCall(node)) - ], - /*location*/ undefined, - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), - /*location*/ node)); - } - } - else { - if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node)), - /*location*/ node)); - } - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfImportEqualsDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Visits an ExportDeclaration node. - * - * @param The node to visit. - */ - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - // Elide export declarations with no module specifier as they are handled - // elsewhere. - return undefined; - } - var generatedName = ts.getGeneratedNameForNode(node); - if (node.exportClause) { - var statements = []; - // export { x, y } from "mod"; - if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(generatedName, - /*type*/ undefined, createRequireCall(node)) - ]), - /*location*/ node)); - } - for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { - var specifier = _a[_i]; - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue), - /*location*/ specifier)); - } - return ts.singleOrMany(statements); - } - else { - // export * from "mod"; - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), - /*typeArguments*/ undefined, [ - moduleKind !== ts.ModuleKind.AMD - ? createRequireCall(node) - : generatedName - ]), - /*location*/ node); - } - } - /** - * Visits an ExportAssignment node. - * - * @param node The node to visit. - */ - function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; - } - var statements; - var original = node.original; - if (original && hasAssociatedEndOfDeclarationMarker(original)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); - } - else { - statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); - } - return ts.singleOrMany(statements); - } - /** - * Visits a FunctionDeclaration node. - * - * @param node The node to visit. - */ - function visitFunctionDeclaration(node) { - var statements; - if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createFunctionDeclaration( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), - /*typeParameters*/ undefined, node.parameters, - /*type*/ undefined, node.body, - /*location*/ node), - /*original*/ node)); - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfHoistedDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Visits a ClassDeclaration node. - * - * @param node The node to visit. - */ - function visitClassDeclaration(node) { - var statements; - if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createClassDeclaration( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), - /*typeParameters*/ undefined, node.heritageClauses, node.members, - /*location*/ node), - /*original*/ node)); - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfHoistedDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Visits a VariableStatement node. - * - * @param node The node to visit. - */ - function visitVariableStatement(node) { - var statements; - var variables; - var expressions; - if (ts.hasModifier(node, 1 /* Export */)) { - var modifiers = void 0; - // If we're exporting these variables, then these just become assignments to 'exports.x'. - // We only want to emit assignments for variables with initializers. - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { - if (!modifiers) { - modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); - } - variables = ts.append(variables, variable); - } - else if (variable.initializer) { - expressions = ts.append(expressions, transformInitializedVariable(variable)); - } - } - if (variables) { - statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); - } - if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), /*location*/ node)); - } - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); - } - else { - statements = appendExportsOfVariableStatement(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Transforms an exported variable with an initializer into an expression. - * - * @param node The node to transform. - */ - function transformInitializedVariable(node) { - if (ts.isBindingPattern(node.name)) { - return ts.flattenDestructuringAssignment(node, - /*visitor*/ undefined, context, 0 /* All */, - /*needsValue*/ false, createExportExpression); - } - else { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name, - /*location*/ node.name), node.initializer); - } - } - /** - * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged - * and transformed declaration. - * - * @param node The node to visit. - */ - function visitMergeDeclarationMarker(node) { - // For an EnumDeclaration or ModuleDeclaration that merges with a preceeding - // declaration we do not emit a leading variable declaration. To preserve the - // begin/end semantics of the declararation and to properly handle exports - // we wrapped the leading variable declaration in a `MergeDeclarationMarker`. - // - // To balance the declaration, add the exports of the elided variable - // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206 /* VariableStatement */) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); - } - return node; - } - /** - * Determines whether a node has an associated EndOfDeclarationMarker. - * - * @param node The node to test. - */ - function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 2097152 /* HasEndOfDeclarationMarker */) !== 0; - } - /** - * Visits a DeclarationMarker used as a placeholder for the end of a transformed - * declaration. - * - * @param node The node to visit. - */ - function visitEndOfDeclarationMarker(node) { - // For some transformations we emit an `EndOfDeclarationMarker` to mark the actual - // end of the transformed declaration. We use this marker to emit any deferred exports - // of the declaration. - var id = ts.getOriginalNodeId(node); - var statements = deferredExports[id]; - if (statements) { - delete deferredExports[id]; - return ts.append(statements, node); - } - return node; - } - /** - * Appends the exports of an ImportDeclaration to a statement list, returning the - * statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration whose exports are to be recorded. - */ - function appendExportsOfImportDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - var importClause = decl.importClause; - if (!importClause) { - return statements; - } - if (importClause.name) { - statements = appendExportsOfDeclaration(statements, importClause); - } - var namedBindings = importClause.namedBindings; - if (namedBindings) { - switch (namedBindings.kind) { - case 238 /* NamespaceImport */: - statements = appendExportsOfDeclaration(statements, namedBindings); - break; - case 239 /* NamedImports */: - for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { - var importBinding = _a[_i]; - statements = appendExportsOfDeclaration(statements, importBinding); - } - break; - } - } - return statements; - } - /** - * Appends the exports of an ImportEqualsDeclaration to a statement list, returning the - * statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration whose exports are to be recorded. - */ - function appendExportsOfImportEqualsDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - return appendExportsOfDeclaration(statements, decl); - } - /** - * Appends the exports of a VariableStatement to a statement list, returning the statement - * list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param node The VariableStatement whose exports are to be recorded. - */ - function appendExportsOfVariableStatement(statements, node) { - if (currentModuleInfo.exportEquals) { - return statements; - } - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - statements = appendExportsOfBindingElement(statements, decl); - } - return statements; - } - /** - * Appends the exports of a VariableDeclaration or BindingElement to a statement list, - * returning the statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration whose exports are to be recorded. - */ - function appendExportsOfBindingElement(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - if (ts.isBindingPattern(decl.name)) { - for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - statements = appendExportsOfBindingElement(statements, element); - } - } - } - else if (!ts.isGeneratedIdentifier(decl.name)) { - statements = appendExportsOfDeclaration(statements, decl); - } - return statements; - } - /** - * Appends the exports of a ClassDeclaration or FunctionDeclaration to a statement list, - * returning the statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration whose exports are to be recorded. - */ - function appendExportsOfHoistedDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - if (ts.hasModifier(decl, 1 /* Export */)) { - var exportName = ts.hasModifier(decl, 512 /* Default */) ? ts.createIdentifier("default") : decl.name; - statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), /*location*/ decl); - } - if (decl.name) { - statements = appendExportsOfDeclaration(statements, decl); - } - return statements; - } - /** - * Appends the exports of a declaration to a statement list, returning the statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration to export. - */ - function appendExportsOfDeclaration(statements, decl) { - var name = ts.getDeclarationName(decl); - var exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; - if (exportSpecifiers) { - for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { - var exportSpecifier = exportSpecifiers_2[_i]; - statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name); - } - } - return statements; - } - /** - * Appends the down-level representation of an export to a statement list, returning the - * statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param exportName The name of the export. - * @param expression The expression to export. - * @param location The location to use for source maps and comments for the export. - * @param allowComments Whether to allow comments on the export. - */ - function appendExportStatement(statements, exportName, expression, location, allowComments) { - if (exportName.text === "default") { - var sourceFile = ts.getOriginalNode(currentSourceFile, ts.isSourceFile); - if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 0 /* ES3 */) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements = ts.append(statements, ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), - /*typeArguments*/ undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } - statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); - return statements; - } - /** - * Creates a call to the current file's export function to export a value. - * - * @param name The bound name of the export. - * @param value The exported value. - * @param location The location to use for source maps and comments for the export. - * @param allowComments An optional value indicating whether to emit comments for the statement. - */ - function createExportStatement(name, value, location, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value), location); - ts.startOnNewLine(statement); - if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); - } - return statement; - } - /** - * Creates a call to the current file's export function to export a value. - * - * @param name The bound name of the export. - * @param value The exported value. - * @param location The location to use for source maps and comments for the export. - */ - function createExportExpression(name, value, location) { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value, location); - } - // - // Modifier Visitors - // - /** - * Visit nodes to elide module-specific modifiers. - * - * @param node The node to visit. - */ - function modifierVisitor(node) { - // Elide module-specific modifiers. - switch (node.kind) { - case 83 /* ExportKeyword */: - case 78 /* DefaultKeyword */: - return undefined; - } - return node; - } - // - // Emit Notification - // - /** - * Hook for node emit notifications. - * - * @param emitContext A context hint for the emitter. - * @param node The node to emit. - * @param emit A callback used to emit the node in the printer. - */ - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 262 /* SourceFile */) { - currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; - noSubstitution = ts.createMap(); - previousOnEmitNode(emitContext, node, emitCallback); - currentSourceFile = undefined; - currentModuleInfo = undefined; - noSubstitution = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - // - // Substitutions - // - /** - * Hooks node substitutions. - * - * @param emitContext A context hint for the emitter. - * @param node The node to substitute. - */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (node.id && noSubstitution[node.id]) { - return node; - } - if (emitContext === 1 /* Expression */) { - return substituteExpression(node); - } - else if (ts.isShorthandPropertyAssignment(node)) { - return substituteShorthandPropertyAssignment(node); - } - return node; - } - /** - * Substitution for a ShorthandPropertyAssignment whose declaration name is an imported - * or exported symbol. - * - * @param node The node to substitute. - */ - function substituteShorthandPropertyAssignment(node) { - var name = node.name; - var exportedOrImportedName = substituteExpressionIdentifier(name); - if (exportedOrImportedName !== name) { - // A shorthand property with an assignment initializer is probably part of a - // destructuring assignment - if (node.objectAssignmentInitializer) { - var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, /*location*/ node); - } - return ts.createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); - } - return node; - } - /** - * Substitution for an Expression that may contain an imported or exported symbol. - * - * @param node The node to substitute. - */ - function substituteExpression(node) { - switch (node.kind) { - case 70 /* Identifier */: - return substituteExpressionIdentifier(node); - case 192 /* BinaryExpression */: - return substituteBinaryExpression(node); - case 191 /* PostfixUnaryExpression */: - case 190 /* PrefixUnaryExpression */: - return substituteUnaryExpression(node); - } - return node; - } - /** - * Substitution for an Identifier expression that may contain an imported or exported - * symbol. - * - * @param node The node to substitute. - */ - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } - return node; - } - if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { - var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 262 /* SourceFile */) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), - /*location*/ node); - } - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), - /*location*/ node); - } - else if (ts.isImportSpecifier(importDeclaration)) { - var name_39 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_39), + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name)), /*location*/ node); } } @@ -57674,9 +58789,7 @@ var ts; var expression = node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { var exportName = exportedNames_3[_i]; - // Mark the node to prevent triggering this rule again. - noSubstitution[ts.getNodeId(expression)] = true; - expression = createExportExpression(exportName, expression, /*location*/ node); + expression = createExportExpression(exportName, preventSubstitution(expression)); } return expression; } @@ -57705,15 +58818,17 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 191 /* PostfixUnaryExpression */ - ? ts.createBinary(node.operand, ts.createToken(node.operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1), - /*location*/ node) + var expression = node.kind === 192 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { var exportName = exportedNames_4[_i]; - // Mark the node to prevent triggering this rule again. - noSubstitution[ts.getNodeId(expression)] = true; - expression = createExportExpression(exportName, expression); + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + if (node.kind === 192 /* PostfixUnaryExpression */) { + expression = node.operator === 42 /* PlusPlusToken */ + ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) + : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } return expression; } @@ -57721,29 +58836,144 @@ var ts; return node; } /** - * Gets the additional exports of a name. + * Gets the exports of a name. * * @param name The name. */ function getExports(name) { + var exportedNames; if (!ts.isGeneratedIdentifier(name)) { var valueDeclaration = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { - return currentModuleInfo - && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; + var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); + if (exportContainer && exportContainer.kind === 264 /* SourceFile */) { + exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); + } + exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); } } + return exportedNames; + } + /** + * Prevent substitution of a node for this transformer. + * + * @param node The node which should not be substituted. + */ + function preventSubstitution(node) { + if (noSubstitution === undefined) + noSubstitution = []; + noSubstitution[ts.getNodeId(node)] = true; + return node; + } + /** + * Determines whether a node should not be substituted. + * + * @param node The node to test. + */ + function isSubstitutionPrevented(node) { + return noSubstitution && node.id && noSubstitution[node.id]; } - var _a; } - ts.transformModule = transformModule; - // emit output for the __export helper function - var exportStarHelper = { - name: "typescript:export-star", - scoped: true, - text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" - }; + ts.transformSystemModule = transformSystemModule; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformES2015Module(context) { + var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.enableEmitNotification(264 /* SourceFile */); + context.enableSubstitution(70 /* Identifier */); + var currentSourceFile; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); + if (externalHelpersModuleName) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements); + ts.append(statements, ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); + } + else { + return ts.visitEachChild(node, visitor, context); + } + } + return node; + } + function visitor(node) { + switch (node.kind) { + case 236 /* ImportEqualsDeclaration */: + // Elide `import=` as it is not legal with --module ES6 + return undefined; + case 242 /* ExportAssignment */: + return visitExportAssignment(node); + } + return node; + } + function visitExportAssignment(node) { + // Elide `export=` as it is not legal with --module ES6 + return node.isExportEquals ? undefined : node; + } + // + // Emit Notification + // + /** + * Hook for node emit. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. + */ + function onEmitNode(hint, node, emitCallback) { + if (ts.isSourceFile(node)) { + currentSourceFile = node; + previousOnEmitNode(hint, node, emitCallback); + currentSourceFile = undefined; + } + else { + previousOnEmitNode(hint, node, emitCallback); + } + } + // + // Substitutions + // + /** + * Hooks node substitutions. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to substitute. + */ + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (ts.isIdentifier(node) && hint === 1 /* Expression */) { + return substituteExpressionIdentifier(node); + } + return node; + } + function substituteExpressionIdentifier(node) { + if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); + if (externalHelpersModuleName) { + return ts.createPropertyAccess(externalHelpersModuleName, node); + } + } + return node; + } + } + ts.transformES2015Module = transformES2015Module; })(ts || (ts = {})); /// /// @@ -57760,14 +58990,16 @@ var ts; /* @internal */ var ts; (function (ts) { - var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, - _a[ts.ModuleKind.System] = ts.transformSystemModule, - _a[ts.ModuleKind.AMD] = ts.transformModule, - _a[ts.ModuleKind.CommonJS] = ts.transformModule, - _a[ts.ModuleKind.UMD] = ts.transformModule, - _a[ts.ModuleKind.None] = ts.transformModule, - _a)); + function getModuleTransformer(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.ES2015: + return ts.transformES2015Module; + case ts.ModuleKind.System: + return ts.transformSystemModule; + default: + return ts.transformModule; + } + } var SyntaxKindFeatureFlags; (function (SyntaxKindFeatureFlags) { SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; @@ -57795,7 +59027,7 @@ var ts; transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); + transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. if (languageVersion < 1 /* ES5 */) { @@ -57813,7 +59045,7 @@ var ts; * @param transforms An array of Transformers. */ function transformFiles(resolver, host, sourceFiles, transformers) { - var enabledSyntaxKindFeatures = new Array(298 /* Count */); + var enabledSyntaxKindFeatures = new Array(301 /* Count */); var lexicalEnvironmentDisabled = false; var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; @@ -57836,19 +59068,22 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, - onSubstituteNode: function (_emitContext, node) { return node; }, + onSubstituteNode: function (_, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, + onEmitNode: function (hint, node, callback) { return callback(hint, node); }, enableEmitNotification: enableEmitNotification, isEmitNotificationEnabled: isEmitNotificationEnabled }; + ts.performance.mark("beforeTransform"); // Chain together and initialize each transformer. var transformation = ts.chain.apply(void 0, transformers)(context); // Transform each source file. var transformed = ts.map(sourceFiles, transformSourceFile); // Disable modification of the lexical environment. lexicalEnvironmentDisabled = true; + ts.performance.mark("afterTransform"); + ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { transformed: transformed, emitNodeWithSubstitution: emitNodeWithSubstitution, @@ -57881,20 +59116,16 @@ var ts; /** * Emits a node with possible substitution. * - * @param emitContext The current emit context. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emitCallback The callback used to emit the node or its substitute. */ - function emitNodeWithSubstitution(emitContext, node, emitCallback) { + function emitNodeWithSubstitution(hint, node, emitCallback) { if (node) { if (isSubstitutionEnabled(node)) { - var substitute = context.onSubstituteNode(emitContext, node); - if (substitute && substitute !== node) { - emitCallback(emitContext, substitute); - return; - } + node = context.onSubstituteNode(hint, node) || node; } - emitCallback(emitContext, node); + emitCallback(hint, node); } } /** @@ -57914,17 +59145,17 @@ var ts; /** * Emits a node with possible emit notification. * - * @param emitContext The current emit context. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emitCallback The callback used to emit the node. */ - function emitNodeWithNotification(emitContext, node, emitCallback) { + function emitNodeWithNotification(hint, node, emitCallback) { if (node) { if (isEmitNotificationEnabled(node)) { - context.onEmitNode(emitContext, node, emitCallback); + context.onEmitNode(hint, node, emitCallback); } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } } @@ -58028,7 +59259,6 @@ var ts; } } ts.transformFiles = transformFiles; - var _a; })(ts || (ts = {})); /// /* @internal */ @@ -58073,10 +59303,9 @@ var ts; * * @param filePath The path to the generated output file. * @param sourceMapFilePath The path to the output source map file. - * @param sourceFiles The input source files for the program. - * @param isBundledEmit A value indicating whether the generated output file is a bundle. + * @param sourceFileOrBundle The input source file or bundle for the program. */ - function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { + function initialize(filePath, sourceMapFilePath, sourceFileOrBundle) { if (disabled) { return; } @@ -58112,11 +59341,10 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (!isBundledEmit) { - ts.Debug.assert(sourceFiles.length === 1); + if (sourceFileOrBundle.kind === 264 /* SourceFile */) { // For modules or multiple emit files the mapRoot will have directory structure like the sources // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFiles[0], host, sourceMapDir)); + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { // The relative paths are relative to the common directory @@ -58239,31 +59467,32 @@ var ts; /** * Emits a node with possible leading and trailing source maps. * + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emitCallback The callback used to emit the node. */ - function emitNodeWithSourceMap(emitContext, node, emitCallback) { + function emitNodeWithSourceMap(hint, node, emitCallback) { if (disabled) { - return emitCallback(emitContext, node); + return emitCallback(hint, node); } if (node) { var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 294 /* NotEmittedStatement */ + if (node.kind !== 297 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); } if (emitFlags & 64 /* NoNestedSourceMaps */) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } - if (node.kind !== 294 /* NotEmittedStatement */ + if (node.kind !== 297 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -58398,11 +59627,10 @@ var ts; /* @internal */ var ts; (function (ts) { - function createCommentWriter(host, writer, sourceMap) { - var compilerOptions = host.getCompilerOptions(); - var extendedDiagnostics = compilerOptions.extendedDiagnostics; - var newLine = host.getNewLine(); - var emitPos = sourceMap.emitPos; + function createCommentWriter(printerOptions, emitPos) { + var extendedDiagnostics = printerOptions.extendedDiagnostics; + var newLine = ts.getNewLineCharacter(printerOptions); + var writer; var containerPos = -1; var containerEnd = -1; var declarationListContainerEnd = -1; @@ -58411,17 +59639,19 @@ var ts; var currentLineMap; var detachedCommentsInfo; var hasWrittenComment = false; - var disabled = compilerOptions.removeComments; + var disabled = printerOptions.removeComments; return { reset: reset, + setWriter: setWriter, setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, + emitLeadingCommentsOfPosition: emitLeadingCommentsOfPosition, }; - function emitNodeWithComments(emitContext, node, emitCallback) { + function emitNodeWithComments(hint, node, emitCallback) { if (disabled) { - emitCallback(emitContext, node); + emitCallback(hint, node); return; } if (node) { @@ -58431,18 +59661,18 @@ var ts; // Both pos and end are synthesized, so just emit the node without comments. if (emitFlags & 2048 /* NoNestedComments */) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } else { if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 294 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 297 /* NotEmittedStatement */; var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; // Emit leading comments if the position is not synthesized and the node @@ -58461,7 +59691,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 225 /* VariableDeclarationList */) { + if (node.kind === 226 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -58470,11 +59700,11 @@ var ts; } if (emitFlags & 2048 /* NoNestedComments */) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } if (extendedDiagnostics) { ts.performance.mark("beginEmitNodeWithComment"); @@ -58557,9 +59787,11 @@ var ts; hasWrittenComment = true; } // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -58567,6 +59799,12 @@ var ts; writer.write(" "); } } + function emitLeadingCommentsOfPosition(pos) { + if (disabled || pos === -1) { + return; + } + emitLeadingComments(pos, /*isEmittedNode*/ true); + } function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } @@ -58575,9 +59813,11 @@ var ts; if (!writer.isAtStartOfLine()) { writer.write(" "); } - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -58596,9 +59836,11 @@ var ts; } function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -58629,6 +59871,9 @@ var ts; currentLineMap = undefined; detachedCommentsInfo = undefined; } + function setWriter(output) { + writer = output; + } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; currentText = currentSourceFile.text; @@ -58661,9 +59906,11 @@ var ts; } } function writeComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); } /** * Determine if the given comment is a triple-slash @@ -58692,15 +59939,17 @@ var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, targetSourceFile) { var declarationDiagnostics = ts.createDiagnosticCollection(); - ts.forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); + ts.forEachEmittedFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); - function getDeclarationDiagnosticsFromFile(_a, sources, isBundledEmit) { + function getDeclarationDiagnosticsFromFile(_a, sourceFileOrBundle) { var declarationFilePath = _a.declarationFilePath; - emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit, /*emitOnlyDtsFiles*/ false); + emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sourceFileOrBundle, /*emitOnlyDtsFiles*/ false); } } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles) { + function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles) { + var sourceFiles = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var isBundledEmit = sourceFileOrBundle.kind === 265 /* Bundle */; var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -58774,7 +60023,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 236 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 237 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -58800,9 +60049,9 @@ var ts; } }); if (usedTypeDirectiveReferences) { - for (var directive in usedTypeDirectiveReferences) { + ts.forEachKey(usedTypeDirectiveReferences, function (directive) { referencesOutput += "/// " + newLine; - } + }); } return { reportedDeclarationError: reportedDeclarationError, @@ -58827,6 +60076,7 @@ var ts; var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; writer.reportInaccessibleThisError = reportInaccessibleThisError; + writer.reportIllegalExtends = reportIllegalExtends; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -58849,10 +60099,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 224 /* VariableDeclaration */) { + if (declaration.kind === 225 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 239 /* NamedImports */ || declaration.kind === 240 /* ImportSpecifier */ || declaration.kind === 237 /* ImportClause */) { + else if (declaration.kind === 240 /* NamedImports */ || declaration.kind === 241 /* ImportSpecifier */ || declaration.kind === 238 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -58870,7 +60120,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 236 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 237 /* 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; @@ -58880,12 +60130,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 231 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 232 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 231 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 232 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -58904,8 +60154,8 @@ var ts; } for (var _i = 0, typeReferenceDirectives_1 = typeReferenceDirectives; _i < typeReferenceDirectives_1.length; _i++) { var directive = typeReferenceDirectives_1[_i]; - if (!(directive in usedTypeDirectiveReferences)) { - usedTypeDirectiveReferences[directive] = directive; + if (!usedTypeDirectiveReferences.has(directive)) { + usedTypeDirectiveReferences.set(directive, directive); } } } @@ -58934,6 +60184,12 @@ var ts; handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); } + function reportIllegalExtends() { + if (errorNameNode) { + reportedDeclarationError = true; + emitterDiagnostics.add(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced, ts.declarationNameToString(errorNameNode))); + } + } function reportInaccessibleThisError() { if (errorNameNode) { reportedDeclarationError = true; @@ -58943,13 +60199,19 @@ var ts; function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); - if (type) { + // use the checker's type, not the declared type, + // for non-optional initialized parameters that aren't a parameter property + var shouldUseResolverType = declaration.kind === 145 /* Parameter */ && + resolver.isRequiredInitializedParameter(declaration); + if (type && !shouldUseResolverType) { // Write the type emitType(type); } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); + var format = 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */ | + (shouldUseResolverType ? 4096 /* AddUndefined */ : 0); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer); errorNameNode = undefined; } } @@ -59003,49 +60265,50 @@ var ts; function emitType(type) { switch (type.kind) { case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 133 /* ObjectKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 94 /* NullKeyword */: case 129 /* NeverKeyword */: - case 167 /* ThisType */: - case 171 /* LiteralType */: + case 168 /* ThisType */: + case 172 /* LiteralType */: return writeTextOfNode(currentText, type); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return emitTypeReference(type); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return emitTypeQuery(type); - case 162 /* ArrayType */: + case 163 /* ArrayType */: return emitArrayType(type); - case 163 /* TupleType */: + case 164 /* TupleType */: return emitTupleType(type); - case 164 /* UnionType */: + case 165 /* UnionType */: return emitUnionType(type); - case 165 /* IntersectionType */: + case 166 /* IntersectionType */: return emitIntersectionType(type); - case 166 /* ParenthesizedType */: + case 167 /* ParenthesizedType */: return emitParenType(type); - case 168 /* TypeOperator */: + case 169 /* TypeOperator */: return emitTypeOperator(type); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return emitIndexedAccessType(type); - case 170 /* MappedType */: + case 171 /* MappedType */: return emitMappedType(type); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 161 /* TypeLiteral */: + case 162 /* TypeLiteral */: return emitTypeLiteral(type); case 70 /* Identifier */: return emitEntityName(type); - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: return emitEntityName(type); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -59053,8 +60316,8 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 141 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 141 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 142 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 142 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); @@ -59063,14 +60326,14 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 235 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 236 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 177 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 178 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -59179,15 +60442,15 @@ var ts; // do not need to keep track of created temp names. function getExportDefaultTempVariableName() { var baseName = "_default"; - if (!(baseName in currentIdentifiers)) { + if (!currentIdentifiers.has(baseName)) { return baseName; } var count = 0; while (true) { count++; - var name_40 = baseName + "_" + count; - if (!(name_40 in currentIdentifiers)) { - return name_40; + var name = baseName + "_" + count; + if (!currentIdentifiers.has(name)) { + return name; } } } @@ -59234,10 +60497,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 235 /* ImportEqualsDeclaration */ || - (node.parent.kind === 262 /* SourceFile */ && isCurrentFileExternalModule)) { + else if (node.kind === 236 /* ImportEqualsDeclaration */ || + (node.parent.kind === 264 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 262 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 264 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -59247,7 +60510,7 @@ var ts; }); } else { - if (node.kind === 236 /* ImportDeclaration */) { + if (node.kind === 237 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -59265,23 +60528,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return writeVariableStatement(node); - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return writeClassDeclaration(node); - case 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -59289,7 +60552,7 @@ var ts; } function emitModuleElementDeclarationFlags(node) { // If the node is parented in the current source file we need to emit export declare or just export - if (node.parent.kind === 262 /* SourceFile */) { + if (node.parent.kind === 264 /* SourceFile */) { var modifiers = ts.getModifierFlags(node); // If the node is exported if (modifiers & 1 /* Export */) { @@ -59298,7 +60561,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 228 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 229 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -59350,7 +60613,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 238 /* NamespaceImport */) { + if (namedBindings.kind === 239 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -59374,7 +60637,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 238 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 239 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -59395,13 +60658,13 @@ var ts; // the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered // external modules since they are indistinguishable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' // so compiler will treat them as external modules. - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 231 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 232 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 235 /* ImportEqualsDeclaration */) { + if (parent.kind === 236 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 231 /* ModuleDeclaration */) { + else if (parent.kind === 232 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -59471,7 +60734,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 232 /* ModuleBlock */) { + while (node.body && node.body.kind !== 233 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -59541,7 +60804,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 149 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 150 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -59552,53 +60815,70 @@ 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 === 158 /* FunctionType */ || - node.parent.kind === 159 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 161 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 149 /* MethodDeclaration */ || - node.parent.kind === 148 /* MethodSignature */ || - node.parent.kind === 158 /* FunctionType */ || - node.parent.kind === 159 /* ConstructorType */ || - node.parent.kind === 153 /* CallSignature */ || - node.parent.kind === 154 /* ConstructSignature */); + if (node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 162 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 150 /* MethodDeclaration */ || + node.parent.kind === 149 /* MethodSignature */ || + node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + node.parent.kind === 154 /* CallSignature */ || + node.parent.kind === 155 /* ConstructSignature */); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } + if (node.default && !isPrivateMethodTypeParameter(node)) { + write(" = "); + if (node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 162 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 150 /* MethodDeclaration */ || + node.parent.kind === 149 /* MethodSignature */ || + node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + node.parent.kind === 154 /* CallSignature */ || + node.parent.kind === 155 /* ConstructSignature */); + emitType(node.default); + } + else { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.default, getTypeParameterConstraintVisibilityError); + } + } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 153 /* CallSignature */: + case 154 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* 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 === 227 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 228 /* 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 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -59617,7 +60897,7 @@ var ts; write(">"); } } - function emitHeritageClause(typeReferences, isImplementsList) { + function emitHeritageClause(className, typeReferences, isImplementsList) { if (typeReferences) { write(isImplementsList ? " implements " : " extends "); emitCommaList(typeReferences, emitTypeOfTypeReference); @@ -59631,20 +60911,22 @@ var ts; } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; + errorNameNode = className; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); + errorNameNode = undefined; } function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 227 /* ClassDeclaration */) { + if (node.parent.parent.kind === 228 /* 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 : - ts.Diagnostics.Extends_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; } else { // interface is inaccessible - diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; + diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; } return { diagnosticMessage: diagnosticMessage, @@ -59676,9 +60958,10 @@ var ts; emitTypeParameters(node.typeParameters); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); + node.name; + emitHeritageClause(node.name, [baseTypeNode], /*isImplementsList*/ false); } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); + emitHeritageClause(node.name, ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); write(" {"); writeLine(); increaseIndent(); @@ -59699,7 +60982,7 @@ var ts; emitTypeParameters(node.typeParameters); var interfaceExtendsTypes = ts.filter(ts.getInterfaceBaseTypeNodes(node), function (base) { return ts.isEntityNameExpression(base.expression); }); if (interfaceExtendsTypes && interfaceExtendsTypes.length) { - emitHeritageClause(interfaceExtendsTypes, /*isImplementsList*/ false); + emitHeritageClause(node.name, interfaceExtendsTypes, /*isImplementsList*/ false); } write(" {"); writeLine(); @@ -59723,7 +61006,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 !== 224 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 225 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -59734,11 +61017,11 @@ var ts; writeTextOfNode(currentText, node.name); // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor // we don't want to emit property declaration with "?" - if ((node.kind === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */ || - (node.kind === 144 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */ || + (node.kind === 145 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */) && node.parent.kind === 161 /* TypeLiteral */) { + if ((node.kind === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */) && node.parent.kind === 162 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -59751,14 +61034,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 224 /* VariableDeclaration */) { + if (node.kind === 225 /* VariableDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */) { + else if (node.kind === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -59767,7 +61050,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 === 227 /* ClassDeclaration */) { + else if (node.parent.kind === 228 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -59799,7 +61082,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 198 /* OmittedExpression */) { + if (element.kind !== 199 /* OmittedExpression */) { elements.push(element); } } @@ -59869,7 +61152,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 === 151 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 152 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -59882,7 +61165,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 151 /* GetAccessor */ + return accessor.kind === 152 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -59891,7 +61174,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 152 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 153 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? @@ -59941,17 +61224,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 226 /* FunctionDeclaration */) { + if (node.kind === 227 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 149 /* MethodDeclaration */ || node.kind === 150 /* Constructor */) { + else if (node.kind === 150 /* MethodDeclaration */ || node.kind === 151 /* Constructor */) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 226 /* FunctionDeclaration */) { + if (node.kind === 227 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 150 /* Constructor */) { + else if (node.kind === 151 /* Constructor */) { write("constructor"); } else { @@ -59971,17 +61254,17 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 155 /* IndexSignature */) { + if (node.kind === 156 /* IndexSignature */) { // Index signature can have readonly modifier emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { // Construct signature or constructor type write new Signature - if (node.kind === 154 /* ConstructSignature */ || node.kind === 159 /* ConstructorType */) { + if (node.kind === 155 /* ConstructSignature */ || node.kind === 160 /* ConstructorType */) { write("new "); } - else if (node.kind === 158 /* FunctionType */) { + else if (node.kind === 159 /* FunctionType */) { var currentOutput = writer.getText(); // Do not generate incorrect type when function type with type parameters is type argument // This could happen if user used space between two '<' making it error free @@ -59996,22 +61279,22 @@ var ts; } // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 155 /* IndexSignature */) { + if (node.kind === 156 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 158 /* FunctionType */ || node.kind === 159 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 161 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 159 /* FunctionType */ || node.kind === 160 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 162 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 150 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { + else if (node.kind !== 151 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -60025,26 +61308,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.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 153 /* CallSignature */: + case 154 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.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 155 /* IndexSignature */: + case 156 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.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 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -60052,7 +61335,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 === 227 /* ClassDeclaration */) { + else if (node.parent.kind === 228 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -60066,7 +61349,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -60101,9 +61384,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 158 /* FunctionType */ || - node.parent.kind === 159 /* ConstructorType */ || - node.parent.parent.kind === 161 /* TypeLiteral */) { + if (node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + node.parent.parent.kind === 162 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8 /* Private */)) { @@ -60119,29 +61402,29 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 150 /* Constructor */: + case 151 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.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 153 /* CallSignature */: + case 154 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.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 155 /* IndexSignature */: + case 156 /* IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -60149,7 +61432,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 === 227 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 228 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -60162,7 +61445,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 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -60174,12 +61457,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 === 172 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 173 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 173 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 174 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -60190,7 +61473,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 198 /* OmittedExpression */) { + if (bindingElement.kind === 199 /* 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) @@ -60199,7 +61482,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 174 /* BindingElement */) { + else if (bindingElement.kind === 175 /* 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" @@ -60238,40 +61521,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 226 /* FunctionDeclaration */: - case 231 /* ModuleDeclaration */: - case 235 /* ImportEqualsDeclaration */: - case 228 /* InterfaceDeclaration */: - case 227 /* ClassDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 230 /* EnumDeclaration */: + case 227 /* FunctionDeclaration */: + case 232 /* ModuleDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 229 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 231 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return emitExportDeclaration(node); - case 150 /* Constructor */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 151 /* Constructor */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: return writeFunctionDeclaration(node); - case 154 /* ConstructSignature */: - case 153 /* CallSignature */: - case 155 /* IndexSignature */: + case 155 /* ConstructSignature */: + case 154 /* CallSignature */: + case 156 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return emitAccessorDeclaration(node); - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return emitPropertyDeclaration(node); - case 261 /* EnumMember */: + case 263 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return emitExportAssignment(node); - case 262 /* SourceFile */: + case 264 /* SourceFile */: return emitSourceFile(node); } } @@ -60289,7 +61572,7 @@ var ts; } else { // Get the declaration file path - ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(declarationFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, @@ -60297,8 +61580,9 @@ var ts; referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, sourceFileOrBundle) { // Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path + var isBundledEmit = sourceFileOrBundle.kind === 265 /* Bundle */; if (isBundledEmit && !addBundledFileReference) { return; } @@ -60309,10 +61593,11 @@ var ts; } } /* @internal */ - function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { - var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles); + function writeDeclarationFile(declarationFilePath, sourceFileOrBundle, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { + var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { + var sourceFiles = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; var declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); ts.writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); @@ -60335,63 +61620,56 @@ var ts; } ts.writeDeclarationFile = writeDeclarationFile; })(ts || (ts = {})); -/// +/// /// -/// -/// +/// +/// /// -/* @internal */ var ts; (function (ts) { - // Flags enum to track count of temp variables and a few dedicated names - var TempFlags; - (function (TempFlags) { - TempFlags[TempFlags["Auto"] = 0] = "Auto"; - TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; - TempFlags[TempFlags["_i"] = 268435456] = "_i"; - })(TempFlags || (TempFlags = {})); - var id = function (s) { return s; }; - var nullTransformers = [function (_) { return id; }]; + var delimiters = createDelimiterMap(); + var brackets = createBracketsMap(); + /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { - var delimiters = createDelimiterMap(); - var brackets = createBracketsMap(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = emitOnlyDtsFiles ? nullTransformers : ts.getTransformers(compilerOptions); + var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); - var write = writer.write, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var sourceMap = ts.createSourceMapWriter(host, writer); - var emitNodeWithSourceMap = sourceMap.emitNodeWithSourceMap, emitTokenWithSourceMap = sourceMap.emitTokenWithSourceMap; - var comments = ts.createCommentWriter(host, writer, sourceMap); - var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition; - var nodeIdToGeneratedName; - var autoGeneratedIdToGeneratedName; - var generatedNameSet; - var tempFlags; var currentSourceFile; - var currentText; - var currentFileIdentifiers; var bundledHelpers; var isOwnFileEmit; var emitSkipped = false; var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); // Transform the source files - ts.performance.mark("beforeTransform"); - var _a = ts.transformFiles(resolver, host, sourceFiles, transformers), transformed = _a.transformed, emitNodeWithSubstitution = _a.emitNodeWithSubstitution, emitNodeWithNotification = _a.emitNodeWithNotification; - ts.performance.measure("transformTime", "beforeTransform"); + var transform = ts.transformFiles(resolver, host, sourceFiles, transformers); + // Create a printer to print the nodes + var printer = createPrinter(compilerOptions, { + // resolver hooks + hasGlobalName: resolver.hasGlobalName, + // transform hooks + onEmitNode: transform.emitNodeWithNotification, + onSubstituteNode: transform.emitNodeWithSubstitution, + // sourcemap hooks + onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, + onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, + onEmitSourceMapOfPosition: sourceMap.emitPos, + // emitter hooks + onEmitHelpers: emitHelpers, + onSetSourceFile: setSourceFile, + }); // Emit each output file ts.performance.mark("beforePrint"); - ts.forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); // Clean up emit nodes on parse tree - for (var _b = 0, sourceFiles_4 = sourceFiles; _b < sourceFiles_4.length; _b++) { - var sourceFile = sourceFiles_4[_b]; + for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { + var sourceFile = sourceFiles_2[_a]; ts.disposeEmitNodes(sourceFile); } return { @@ -60400,18 +61678,19 @@ var ts; emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList }; - function emitFile(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, isBundledEmit) { + function emitSourceFileOrBundle(_a, sourceFileOrBundle) { + var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath; // Make sure not to write js file and source map file if any of them cannot be written if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { if (!emitOnlyDtsFiles) { - printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle); } } else { emitSkipped = true; } if (declarationFilePath) { - emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; + emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFileOrBundle(sourceFileOrBundle), host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; } if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { @@ -60425,26 +61704,24 @@ var ts; } } } - function printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit) { - sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); - nodeIdToGeneratedName = []; - autoGeneratedIdToGeneratedName = []; - generatedNameSet = ts.createMap(); - bundledHelpers = isBundledEmit ? ts.createMap() : undefined; - isOwnFileEmit = !isBundledEmit; - // Emit helpers from all the files - if (isBundledEmit && moduleKind) { - for (var _a = 0, sourceFiles_5 = sourceFiles; _a < sourceFiles_5.length; _a++) { - var sourceFile = sourceFiles_5[_a]; - emitHelpers(sourceFile, /*isBundle*/ true); - } + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle) { + var bundle = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 264 /* SourceFile */ ? sourceFileOrBundle : undefined; + var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; + sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFileOrBundle); + if (bundle) { + bundledHelpers = ts.createMap(); + isOwnFileEmit = false; + printer.writeBundle(bundle, writer); } - // Print each transformed source file. - ts.forEach(sourceFiles, printSourceFile); - writeLine(); + else { + isOwnFileEmit = true; + printer.writeFile(sourceFile, writer); + } + writer.writeLine(); var sourceMappingURL = sourceMap.getSourceMappingURL(); if (sourceMappingURL) { - write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Sometimes tools can sometimes see this line as a source mapping url comment + writer.write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Sometimes tools can sometimes see this line as a source mapping url comment } // Write the source map if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) { @@ -60458,138 +61735,237 @@ var ts; ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles); // Reset state sourceMap.reset(); - comments.reset(); writer.reset(); - tempFlags = 0 /* Auto */; currentSourceFile = undefined; - currentText = undefined; + bundledHelpers = undefined; isOwnFileEmit = false; } - function printSourceFile(node) { + function setSourceFile(node) { currentSourceFile = node; - currentText = node.text; - currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); - comments.setSourceFile(node); - pipelineEmitWithNotification(0 /* SourceFile */, node); } - /** - * Emits a node. - */ - function emit(node) { - pipelineEmitWithNotification(3 /* Unspecified */, node); + function emitHelpers(node, writeLines) { + var helpersEmitted = false; + var bundle = node.kind === 265 /* Bundle */ ? node : undefined; + if (bundle && moduleKind === ts.ModuleKind.None) { + return; + } + var numNodes = bundle ? bundle.sourceFiles.length : 1; + for (var i = 0; i < numNodes; i++) { + var currentNode = bundle ? bundle.sourceFiles[i] : node; + var sourceFile = ts.isSourceFile(currentNode) ? currentNode : currentSourceFile; + var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = ts.isSourceFile(currentNode) && !isOwnFileEmit; + var helpers = ts.getEmitHelpers(currentNode); + if (helpers) { + for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { + var helper = _b[_a]; + if (!helper.scoped) { + // Skip the helper if it can be skipped and the noEmitHelpers compiler + // option is set, or if it can be imported and the importHelpers compiler + // option is set. + if (shouldSkip) + continue; + // Skip the helper if it can be bundled but hasn't already been emitted and we + // are emitting a bundled module. + if (shouldBundle) { + if (bundledHelpers.get(helper.name)) { + continue; + } + bundledHelpers.set(helper.name, true); + } + } + else if (bundle) { + // Skip the helper if it is scoped and we are emitting bundled helpers + continue; + } + writeLines(helper.text); + helpersEmitted = true; + } + } + } + return helpersEmitted; + } + } + ts.emitFiles = emitFiles; + function createPrinter(printerOptions, handlers) { + if (printerOptions === void 0) { printerOptions = {}; } + if (handlers === void 0) { handlers = {}; } + var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, onSubstituteNode = handlers.onSubstituteNode; + var newLine = ts.getNewLineCharacter(printerOptions); + var languageVersion = ts.getEmitScriptTarget(printerOptions); + var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); + var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; + var currentSourceFile; + var nodeIdToGeneratedName; // Map of generated names for specific nodes. + var autoGeneratedIdToGeneratedName; // Map of generated names for temp and loop variables. + var generatedNames; // Set of names generated by the NameGenerator. + var tempFlagsStack; // Stack of enclosing name generation scopes. + var tempFlags; // TempFlags for the current name generation scope. + var writer; + var ownWriter; + reset(); + return { + // public API + printNode: printNode, + printFile: printFile, + printBundle: printBundle, + // internal API + writeNode: writeNode, + writeFile: writeFile, + writeBundle: writeBundle + }; + function printNode(hint, node, sourceFile) { + switch (hint) { + case 0 /* SourceFile */: + ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); + break; + case 2 /* IdentifierName */: + ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); + break; + case 1 /* Expression */: + ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); + break; + } + switch (node.kind) { + case 264 /* SourceFile */: return printFile(node); + case 265 /* Bundle */: return printBundle(node); + } + writeNode(hint, node, sourceFile, beginPrint()); + return endPrint(); + } + function printBundle(bundle) { + writeBundle(bundle, beginPrint()); + return endPrint(); + } + function printFile(sourceFile) { + writeFile(sourceFile, beginPrint()); + return endPrint(); + } + function writeNode(hint, node, sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(hint, node, sourceFile); + reset(); + writer = previousWriter; + } + function writeBundle(bundle, output) { + var previousWriter = writer; + setWriter(output); + emitHelpersIndirect(bundle); + for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + print(0 /* SourceFile */, sourceFile, sourceFile); + } + reset(); + writer = previousWriter; + } + function writeFile(sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(0 /* SourceFile */, sourceFile, sourceFile); + reset(); + writer = previousWriter; + } + function beginPrint() { + return ownWriter || (ownWriter = ts.createTextWriter(newLine)); + } + function endPrint() { + var text = ownWriter.getText(); + ownWriter.reset(); + return text; + } + function print(hint, node, sourceFile) { + setSourceFile(sourceFile); + pipelineEmitWithNotification(hint, node); + } + function setSourceFile(sourceFile) { + currentSourceFile = sourceFile; + comments.setSourceFile(sourceFile); + if (onSetSourceFile) { + onSetSourceFile(sourceFile); + } + } + function setWriter(output) { + writer = output; + comments.setWriter(output); + } + function reset() { + nodeIdToGeneratedName = []; + autoGeneratedIdToGeneratedName = []; + generatedNames = ts.createMap(); + tempFlagsStack = []; + tempFlags = 0 /* Auto */; + comments.reset(); + setWriter(/*output*/ undefined); + } + function emit(node, hint) { + if (hint === void 0) { hint = 3 /* Unspecified */; } + pipelineEmitWithNotification(hint, node); } - /** - * Emits an IdentifierName. - */ function emitIdentifierName(node) { pipelineEmitWithNotification(2 /* IdentifierName */, node); } - /** - * Emits an expression node. - */ function emitExpression(node) { pipelineEmitWithNotification(1 /* Expression */, node); } - /** - * Emits a node with possible notification. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called from printSourceFile, emit, emitExpression, or - * emitIdentifierName. - */ - function pipelineEmitWithNotification(emitContext, node) { - emitNodeWithNotification(emitContext, node, pipelineEmitWithComments); + function pipelineEmitWithNotification(hint, node) { + if (onEmitNode) { + onEmitNode(hint, node, pipelineEmitWithComments); + } + else { + pipelineEmitWithComments(hint, node); + } } - /** - * Emits a node with comments. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithNotification. - */ - function pipelineEmitWithComments(emitContext, node) { - // Do not emit comments for SourceFile - if (emitContext === 0 /* SourceFile */) { - pipelineEmitWithSourceMap(emitContext, node); + function pipelineEmitWithComments(hint, node) { + if (emitNodeWithComments && hint !== 0 /* SourceFile */) { + emitNodeWithComments(hint, node, pipelineEmitWithSourceMap); + } + else { + pipelineEmitWithSourceMap(hint, node); + } + } + function pipelineEmitWithSourceMap(hint, node) { + if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */) { + onEmitSourceMapOfNode(hint, node, pipelineEmitWithSubstitution); + } + else { + pipelineEmitWithSubstitution(hint, node); + } + } + function pipelineEmitWithSubstitution(hint, node) { + if (onSubstituteNode) { + onSubstituteNode(hint, node, pipelineEmitWithHint); + } + else { + pipelineEmitWithHint(hint, node); + } + } + function pipelineEmitWithHint(hint, node) { + switch (hint) { + case 0 /* SourceFile */: return pipelineEmitSourceFile(node); + case 2 /* IdentifierName */: return pipelineEmitIdentifierName(node); + case 1 /* Expression */: return pipelineEmitExpression(node); + case 3 /* Unspecified */: return pipelineEmitUnspecified(node); + } + } + function pipelineEmitSourceFile(node) { + ts.Debug.assertNode(node, ts.isSourceFile); + emitSourceFile(node); + } + function pipelineEmitIdentifierName(node) { + ts.Debug.assertNode(node, ts.isIdentifier); + emitIdentifier(node); + } + function pipelineEmitUnspecified(node) { + var kind = node.kind; + // Reserved words + // Strict mode reserved words + // Contextual keywords + if (ts.isKeyword(kind)) { + writeTokenText(kind); return; } - emitNodeWithComments(emitContext, node, pipelineEmitWithSourceMap); - } - /** - * Emits a node with source maps. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithComments. - */ - function pipelineEmitWithSourceMap(emitContext, node) { - // Do not emit source mappings for SourceFile or IdentifierName - if (emitContext === 0 /* SourceFile */ - || emitContext === 2 /* IdentifierName */) { - pipelineEmitWithSubstitution(emitContext, node); - return; - } - emitNodeWithSourceMap(emitContext, node, pipelineEmitWithSubstitution); - } - /** - * Emits a node with possible substitution. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithSourceMap or - * pipelineEmitInUnspecifiedContext (when picking a more specific context). - */ - function pipelineEmitWithSubstitution(emitContext, node) { - emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext); - } - /** - * Emits a node. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithSubstitution. - */ - function pipelineEmitForContext(emitContext, node) { - switch (emitContext) { - case 0 /* SourceFile */: return pipelineEmitInSourceFileContext(node); - case 2 /* IdentifierName */: return pipelineEmitInIdentifierNameContext(node); - case 3 /* Unspecified */: return pipelineEmitInUnspecifiedContext(node); - case 1 /* Expression */: return pipelineEmitInExpressionContext(node); - } - } - /** - * Emits a node in the SourceFile EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInSourceFileContext(node) { - var kind = node.kind; - switch (kind) { - // Top-level nodes - case 262 /* SourceFile */: - return emitSourceFile(node); - } - } - /** - * Emits a node in the IdentifierName EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInIdentifierNameContext(node) { - var kind = node.kind; - switch (kind) { - // Identifiers - case 70 /* Identifier */: - return emitIdentifier(node); - } - } - /** - * Emits a node in the Unspecified EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInUnspecifiedContext(node) { - var kind = node.kind; switch (kind) { // Pseudo-literals case 13 /* TemplateHead */: @@ -60599,239 +61975,204 @@ var ts; // Identifiers case 70 /* Identifier */: return emitIdentifier(node); - // Reserved words - case 75 /* ConstKeyword */: - case 78 /* DefaultKeyword */: - case 83 /* ExportKeyword */: - case 104 /* VoidKeyword */: - // Strict mode reserved words - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 113 /* PublicKeyword */: - case 114 /* StaticKeyword */: - // Contextual keywords - case 116 /* AbstractKeyword */: - case 117 /* AsKeyword */: - case 118 /* AnyKeyword */: - case 119 /* AsyncKeyword */: - case 120 /* AwaitKeyword */: - case 121 /* BooleanKeyword */: - case 122 /* ConstructorKeyword */: - case 123 /* DeclareKeyword */: - case 124 /* GetKeyword */: - case 125 /* IsKeyword */: - case 127 /* ModuleKeyword */: - case 128 /* NamespaceKeyword */: - case 129 /* NeverKeyword */: - case 130 /* ReadonlyKeyword */: - case 131 /* RequireKeyword */: - case 132 /* NumberKeyword */: - case 133 /* SetKeyword */: - case 134 /* StringKeyword */: - case 135 /* SymbolKeyword */: - case 136 /* TypeKeyword */: - case 137 /* UndefinedKeyword */: - case 138 /* FromKeyword */: - case 139 /* GlobalKeyword */: - case 140 /* OfKeyword */: - writeTokenText(kind); - return; // Parse tree nodes // Names - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: return emitQualifiedName(node); - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return emitTypeParameter(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return emitParameter(node); - case 145 /* Decorator */: + case 146 /* Decorator */: return emitDecorator(node); // Type members - case 146 /* PropertySignature */: + case 147 /* PropertySignature */: return emitPropertySignature(node); - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 148 /* MethodSignature */: + case 149 /* MethodSignature */: return emitMethodSignature(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return emitConstructor(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return emitAccessorDeclaration(node); - case 153 /* CallSignature */: + case 154 /* CallSignature */: return emitCallSignature(node); - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: return emitConstructSignature(node); - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: return emitIndexSignature(node); // Types - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return emitTypePredicate(node); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return emitTypeReference(node); - case 158 /* FunctionType */: + case 159 /* FunctionType */: return emitFunctionType(node); - case 159 /* ConstructorType */: + case 160 /* ConstructorType */: return emitConstructorType(node); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return emitTypeQuery(node); - case 161 /* TypeLiteral */: + case 162 /* TypeLiteral */: return emitTypeLiteral(node); - case 162 /* ArrayType */: + case 163 /* ArrayType */: return emitArrayType(node); - case 163 /* TupleType */: + case 164 /* TupleType */: return emitTupleType(node); - case 164 /* UnionType */: + case 165 /* UnionType */: return emitUnionType(node); - case 165 /* IntersectionType */: + case 166 /* IntersectionType */: return emitIntersectionType(node); - case 166 /* ParenthesizedType */: + case 167 /* ParenthesizedType */: return emitParenthesizedType(node); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 167 /* ThisType */: + case 168 /* ThisType */: return emitThisType(); - case 168 /* TypeOperator */: + case 169 /* TypeOperator */: return emitTypeOperator(node); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 170 /* MappedType */: + case 171 /* MappedType */: return emitMappedType(node); - case 171 /* LiteralType */: + case 172 /* LiteralType */: return emitLiteralType(node); // Binding patterns - case 172 /* ObjectBindingPattern */: + case 173 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 173 /* ArrayBindingPattern */: + case 174 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 174 /* BindingElement */: + case 175 /* BindingElement */: return emitBindingElement(node); // Misc - case 203 /* TemplateSpan */: + case 204 /* TemplateSpan */: return emitTemplateSpan(node); - case 204 /* SemicolonClassElement */: + case 205 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 205 /* Block */: + case 206 /* Block */: return emitBlock(node); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return emitVariableStatement(node); - case 207 /* EmptyStatement */: + case 208 /* EmptyStatement */: return emitEmptyStatement(); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return emitExpressionStatement(node); - case 209 /* IfStatement */: + case 210 /* IfStatement */: return emitIfStatement(node); - case 210 /* DoStatement */: + case 211 /* DoStatement */: return emitDoStatement(node); - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: return emitWhileStatement(node); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return emitForStatement(node); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return emitForInStatement(node); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return emitForOfStatement(node); - case 215 /* ContinueStatement */: + case 216 /* ContinueStatement */: return emitContinueStatement(node); - case 216 /* BreakStatement */: + case 217 /* BreakStatement */: return emitBreakStatement(node); - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: return emitReturnStatement(node); - case 218 /* WithStatement */: + case 219 /* WithStatement */: return emitWithStatement(node); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: return emitSwitchStatement(node); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return emitLabeledStatement(node); - case 221 /* ThrowStatement */: + case 222 /* ThrowStatement */: return emitThrowStatement(node); - case 222 /* TryStatement */: + case 223 /* TryStatement */: return emitTryStatement(node); - case 223 /* DebuggerStatement */: + case 224 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 225 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return emitClassDeclaration(node); - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 232 /* ModuleBlock */: + case 233 /* ModuleBlock */: return emitModuleBlock(node); - case 233 /* CaseBlock */: + case 234 /* CaseBlock */: return emitCaseBlock(node); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return emitImportDeclaration(node); - case 237 /* ImportClause */: + case 238 /* ImportClause */: return emitImportClause(node); - case 238 /* NamespaceImport */: + case 239 /* NamespaceImport */: return emitNamespaceImport(node); - case 239 /* NamedImports */: + case 240 /* NamedImports */: return emitNamedImports(node); - case 240 /* ImportSpecifier */: + case 241 /* ImportSpecifier */: return emitImportSpecifier(node); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return emitExportAssignment(node); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return emitExportDeclaration(node); - case 243 /* NamedExports */: + case 244 /* NamedExports */: return emitNamedExports(node); - case 244 /* ExportSpecifier */: + case 245 /* ExportSpecifier */: return emitExportSpecifier(node); - case 245 /* MissingDeclaration */: + case 246 /* MissingDeclaration */: return; // Module references - case 246 /* ExternalModuleReference */: + case 247 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 249 /* JsxOpeningElement */: + case 250 /* JsxOpeningElement */: return emitJsxOpeningElement(node); - case 250 /* JsxClosingElement */: + case 251 /* JsxClosingElement */: return emitJsxClosingElement(node); - case 251 /* JsxAttribute */: + case 252 /* JsxAttribute */: return emitJsxAttribute(node); - case 252 /* JsxSpreadAttribute */: + case 253 /* JsxAttributes */: + return emitJsxAttributes(node); + case 254 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 253 /* JsxExpression */: + case 255 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 254 /* CaseClause */: + case 256 /* CaseClause */: return emitCaseClause(node); - case 255 /* DefaultClause */: + case 257 /* DefaultClause */: return emitDefaultClause(node); - case 256 /* HeritageClause */: + case 258 /* HeritageClause */: return emitHeritageClause(node); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 260 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 261 /* EnumMember */: + case 263 /* EnumMember */: return emitEnumMember(node); } // If the node is an expression, try to emit it as an expression with @@ -60840,13 +62181,7 @@ var ts; return pipelineEmitWithSubstitution(1 /* Expression */, node); } } - /** - * Emits a node in the Expression EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInExpressionContext(node) { + function pipelineEmitExpression(node) { var kind = node.kind; switch (kind) { // Literals @@ -60868,70 +62203,83 @@ var ts; writeTokenText(kind); return; // Expressions - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return emitCallExpression(node); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return emitNewExpression(node); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 182 /* TypeAssertionExpression */: + case 183 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return emitFunctionExpression(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return emitArrowFunction(node); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return emitDeleteExpression(node); - case 187 /* TypeOfExpression */: + case 188 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return emitVoidExpression(node); - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: return emitAwaitExpression(node); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return emitBinaryExpression(node); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return emitConditionalExpression(node); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return emitTemplateExpression(node); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return emitYieldExpression(node); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return emitSpreadExpression(node); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return emitClassExpression(node); - case 198 /* OmittedExpression */: + case 199 /* OmittedExpression */: return; - case 200 /* AsExpression */: + case 201 /* AsExpression */: return emitAsExpression(node); - case 201 /* NonNullExpression */: + case 202 /* NonNullExpression */: return emitNonNullExpression(node); - case 202 /* MetaProperty */: + case 203 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 247 /* JsxElement */: + case 248 /* JsxElement */: return emitJsxElement(node); - case 248 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes - case 295 /* PartiallyEmittedExpression */: + case 298 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); } } + function emitBodyIndirect(node, elements, emitCallback) { + if (emitBodyWithDetachedComments) { + emitBodyWithDetachedComments(node, elements, emitCallback); + } + else { + emitCallback(node); + } + } + function emitHelpersIndirect(node) { + if (onEmitHelpers) { + onEmitHelpers(node, writeLines); + } + } // // Literals/Pseudo-literals // @@ -60950,7 +62298,7 @@ var ts; // SyntaxKind.TemplateTail function emitLiteral(node) { var text = getLiteralTextOfNode(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) + if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } @@ -61049,7 +62397,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 151 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 152 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -61152,17 +62500,13 @@ var ts; write("{"); writeLine(); increaseIndent(); - if (node.readonlyToken) { - write("readonly "); - } + writeIfPresent(node.readonlyToken, "readonly "); write("["); emit(node.typeParameter.name); write(" in "); emit(node.typeParameter.constraint); write("]"); - if (node.questionToken) { - write("?"); - } + writeIfPresent(node.questionToken, "?"); write(": "); emit(node.type); write(";"); @@ -61240,7 +62584,7 @@ var ts; var indentAfterDot = false; if (!(ts.getEmitFlags(node) & 65536 /* NoIndentation */)) { var dotRangeStart = node.expression.end; - var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; + var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; var dotToken = { kind: 22 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); @@ -61257,9 +62601,11 @@ var ts; // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal function needsDotDotForPropertyAccess(expression) { if (expression.kind === 8 /* NumericLiteral */) { - // check if numeric literal was originally written with a dot + // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(22 /* DotToken */)) < 0; + return ts.getNumericLiteralFlags(text, /*hint*/ 15 /* All */) === 0 /* None */ + && !expression.isOctalLiteral + && text.indexOf(ts.tokenToString(22 /* DotToken */)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer @@ -61267,7 +62613,7 @@ var ts; // isFinite handles cases when constantValue is undefined return isFinite(constantValue) && Math.floor(constantValue) === constantValue - && compilerOptions.removeComments; + && printerOptions.removeComments; } } function emitElementAccessExpression(node) { @@ -61293,11 +62639,9 @@ var ts; emitExpression(node.template); } function emitTypeAssertionExpression(node) { - if (node.type) { - write("<"); - emit(node.type); - write(">"); - } + write("<"); + emit(node.type); + write(">"); emitExpression(node.expression); } function emitParenthesizedExpression(node) { @@ -61356,7 +62700,7 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 190 /* PrefixUnaryExpression */ + return operand.kind === 191 /* PrefixUnaryExpression */ && ((node.operator === 36 /* PlusToken */ && (operand.operator === 36 /* PlusToken */ || operand.operator === 42 /* PlusPlusToken */)) || (node.operator === 37 /* MinusToken */ && (operand.operator === 37 /* MinusToken */ || operand.operator === 43 /* MinusMinusToken */))); } @@ -61446,6 +62790,10 @@ var ts; else { writeToken(16 /* OpenBraceToken */, node.pos, /*contextNode*/ node); emitBlockStatements(node); + // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); writeToken(17 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } } @@ -61479,7 +62827,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 209 /* IfStatement */) { + if (node.elseStatement.kind === 210 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -61541,7 +62889,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 225 /* VariableDeclarationList */) { + if (node.kind === 226 /* VariableDeclarationList */) { emit(node); } else { @@ -61641,11 +62989,10 @@ var ts; emitBlockFunctionBody(body); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); emitSignatureHead(node); emitBlockFunctionBody(body); - tempFlags = savedTempFlags; + popNameGenerationScope(); } if (indentedFlag) { decreaseIndent(); @@ -61700,9 +63047,10 @@ var ts; function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) + var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine - : emitBlockFunctionBodyWorker); + : emitBlockFunctionBodyWorker; + emitBodyIndirect(body, body.statements, emitBlockFunctionBody); decreaseIndent(); writeToken(17 /* CloseBraceToken */, body.statements.end, body); } @@ -61712,8 +63060,9 @@ var ts; function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) { // Emit all the prologue directives (like "use strict"). var statementOffset = emitPrologueDirectives(body.statements, /*startWithNewLine*/ true); - var helpersEmitted = emitHelpers(body); - if (statementOffset === 0 && !helpersEmitted && emitBlockFunctionBodyOnSingleLine) { + var pos = writer.getTextPos(); + emitHelpersIndirect(body); + if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); emitList(body, body.statements, 384 /* SingleLineFunctionBodyStatements */); increaseIndent(); @@ -61736,15 +63085,14 @@ var ts; } emitTypeParameters(node, node.typeParameters); emitList(node, node.heritageClauses, 256 /* ClassHeritageClauses */); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 65 /* ClassMembers */); write("}"); + popNameGenerationScope(); if (indentedFlag) { decreaseIndent(); } - tempFlags = savedTempFlags; } function emitInterfaceDeclaration(node) { emitDecorators(node, node.decorators); @@ -61771,19 +63119,18 @@ var ts; emitModifiers(node, node.modifiers); write("enum "); emit(node.name); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 81 /* EnumMembers */); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 231 /* ModuleDeclaration */) { + while (body.kind === 232 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -61796,13 +63143,12 @@ var ts; write("{ }"); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write("{"); increaseIndent(); emitBlockStatements(node); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } } function emitCaseBlock(node) { @@ -61910,14 +63256,20 @@ var ts; write("<"); emitJsxTagName(node.tagName); write(" "); - emitList(node, node.attributes, 131328 /* JsxElementAttributes */); + // We are checking here so we won't re-enter the emiting pipeline and emit extra sourcemap + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write("/>"); } function emitJsxOpeningElement(node) { write("<"); emitJsxTagName(node.tagName); - writeIfAny(node.attributes, " "); - emitList(node, node.attributes, 131328 /* JsxElementAttributes */); + writeIfAny(node.attributes.properties, " "); + // We are checking here so we won't re-enter the emitting pipeline and emit extra sourcemap + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write(">"); } function emitJsxText(node) { @@ -61928,6 +63280,9 @@ var ts; emitJsxTagName(node.tagName); write(">"); } + function emitJsxAttributes(node) { + emitList(node, node.properties, 131328 /* JsxElementAttributes */); + } function emitJsxAttribute(node) { emit(node.name); emitWithPrefix("=", node.initializer); @@ -61990,7 +63345,6 @@ var ts; emitList(node, node.types, 272 /* HeritageClauseTypes */); } function emitCatchClause(node) { - writeLine(); var openParenPos = writeToken(73 /* CatchKeyword */, node.pos); write(" "); writeToken(18 /* OpenParenToken */, openParenPos); @@ -62013,7 +63367,7 @@ var ts; // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { + if (emitTrailingCommentsOfPosition && (ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -62045,16 +63399,15 @@ var ts; function emitSourceFile(node) { writeLine(); emitShebang(); - emitBodyWithDetachedComments(node, node.statements, emitSourceFileWorker); + emitBodyIndirect(node, node.statements, emitSourceFileWorker); } function emitSourceFileWorker(node) { var statements = node.statements; var statementOffset = emitPrologueDirectives(statements); - var savedTempFlags = tempFlags; - tempFlags = 0; - emitHelpers(node); + pushNameGenerationScope(); + emitHelpersIndirect(node); emitList(node, statements, 1 /* MultiLine */, statementOffset); - tempFlags = savedTempFlags; + popNameGenerationScope(); } // Transformation nodes function emitPartiallyEmittedExpression(node) { @@ -62079,76 +63432,11 @@ var ts; } return statements.length; } - function emitHelpers(node, isBundle) { - var sourceFile = ts.isSourceFile(node) ? node : currentSourceFile; - var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); - var shouldBundle = ts.isSourceFile(node) && !isOwnFileEmit; - var helpersEmitted = false; - var helpers = ts.getEmitHelpers(node); - if (helpers) { - for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { - var helper = _b[_a]; - if (!helper.scoped) { - // Skip the helper if it can be skipped and the noEmitHelpers compiler - // option is set, or if it can be imported and the importHelpers compiler - // option is set. - if (shouldSkip) - continue; - // Skip the helper if it can be bundled but hasn't already been emitted and we - // are emitting a bundled module. - if (shouldBundle) { - if (bundledHelpers[helper.name]) { - continue; - } - bundledHelpers[helper.name] = true; - } - } - else if (isBundle) { - // Skip the helper if it is scoped and we are emitting bundled helpers - continue; - } - writeLines(helper.text); - helpersEmitted = true; - } - } - if (helpersEmitted) { - writeLine(); - } - return helpersEmitted; - } - function writeLines(text) { - var lines = text.split(/\r\n?|\n/g); - var indentation = guessIndentation(lines); - for (var i = 0; i < lines.length; i++) { - var line = indentation ? lines[i].slice(indentation) : lines[i]; - if (line.length) { - if (i > 0) { - writeLine(); - } - write(line); - } - } - } - function guessIndentation(lines) { - var indentation; - for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { - var line = lines_1[_a]; - for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { - if (!ts.isWhiteSpace(line.charCodeAt(i))) { - if (indentation === undefined || i < indentation) { - indentation = i; - break; - } - } - } - } - return indentation; - } // // Helpers // function emitShebang() { - var shebang = ts.getShebang(currentText); + var shebang = ts.getShebang(currentSourceFile.text); if (shebang) { write(shebang); writeLine(); @@ -62268,6 +63556,15 @@ var ts; var child = children[start + i]; // Write the delimiter if this is not the first node. if (previousSibling) { + // i.e + // function commentedParameters( + // /* Parameter a */ + // a + // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline + // , + if (delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } write(delimiter); // Write either a line terminator or whitespace to separate the elements. if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { @@ -62284,14 +63581,16 @@ var ts; write(" "); } } + // Emit this child. if (shouldEmitInterveningComments) { - var commentRange = ts.getCommentRange(child); - emitTrailingCommentsOfPosition(commentRange.pos); + if (emitTrailingCommentsOfPosition) { + var commentRange = ts.getCommentRange(child); + emitTrailingCommentsOfPosition(commentRange.pos); + } } else { shouldEmitInterveningComments = mayEmitInterveningComments; } - // Emit this child. emit(child); if (shouldDecreaseIndentAfterEmit) { decreaseIndent(); @@ -62304,6 +63603,15 @@ var ts; if (format & 16 /* CommaDelimited */ && hasTrailingComma) { write(","); } + // Emit any trailing comment of the last element in the list + // i.e + // var array = [... + // 2 + // /* end of element 2 */ + // ]; + if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } // Decrease the indent, if requested. if (format & 64 /* Indented */) { decreaseIndent(); @@ -62320,6 +63628,38 @@ var ts; write(getClosingBracket(format)); } } + function write(s) { + writer.write(s); + } + function writeLine() { + writer.writeLine(); + } + function increaseIndent() { + writer.increaseIndent(); + } + function decreaseIndent() { + writer.decreaseIndent(); + } + function writeIfAny(nodes, text) { + if (ts.some(nodes)) { + write(text); + } + } + function writeIfPresent(node, text) { + if (node) { + write(text); + } + } + function writeToken(token, pos, contextNode) { + return onEmitSourceMapOfToken + ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) + : writeTokenText(token, pos); + } + function writeTokenText(token, pos) { + var tokenString = ts.tokenToString(token); + write(tokenString); + return pos < 0 ? pos : pos + tokenString.length; + } function writeLineOrSpace(node) { if (ts.getEmitFlags(node) & 1 /* SingleLine */) { write(" "); @@ -62328,23 +63668,32 @@ var ts; writeLine(); } } - function writeIfAny(nodes, text) { - if (nodes && nodes.length > 0) { - write(text); + function writeLines(text) { + var lines = text.split(/\r\n?|\n/g); + var indentation = guessIndentation(lines); + for (var i = 0; i < lines.length; i++) { + var line = indentation ? lines[i].slice(indentation) : lines[i]; + if (line.length) { + writeLine(); + write(line); + writeLine(); + } } } - function writeIfPresent(node, text) { - if (node !== undefined) { - write(text); + function guessIndentation(lines) { + var indentation; + for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { + var line = lines_1[_a]; + for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { + if (!ts.isWhiteSpace(line.charCodeAt(i))) { + if (indentation === undefined || i < indentation) { + indentation = i; + break; + } + } + } } - } - function writeToken(token, pos, contextNode) { - return emitTokenWithSourceMap(contextNode, token, pos, writeTokenText); - } - function writeTokenText(token, pos) { - var tokenString = ts.tokenToString(token); - write(tokenString); - return pos < 0 ? pos : pos + tokenString.length; + return indentation; } function increaseIndentIf(value, valueToWriteWhenNotIndenting) { if (value) { @@ -62455,15 +63804,23 @@ var ts; && !ts.nodeIsSynthesized(node2) && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } + function isSingleLineEmptyBlock(block) { + return !block.multiLine + && isEmptyBlock(block); + } + function isEmptyBlock(block) { + return block.statements.length === 0 + && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + } function skipSynthesizedParentheses(node) { - while (node.kind === 183 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 184 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; } function getTextOfNode(node, includeTrivia) { if (ts.isGeneratedIdentifier(node)) { - return getGeneratedIdentifier(node); + return generateName(node); } else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { return ts.unescapeIdentifier(node.text); @@ -62488,24 +63845,58 @@ var ts; } return ts.getLiteralText(node, currentSourceFile, languageVersion); } - function isSingleLineEmptyBlock(block) { - return !block.multiLine - && isEmptyBlock(block); + /** + * Push a new name generation scope. + */ + function pushNameGenerationScope() { + tempFlagsStack.push(tempFlags); + tempFlags = 0; } - function isEmptyBlock(block) { - return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + /** + * Pop the current name generation scope. + */ + function popNameGenerationScope() { + tempFlags = tempFlagsStack.pop(); } + /** + * Generate the text for a generated identifier. + */ + function generateName(name) { + if (name.autoGenerateKind === 4 /* Node */) { + // Node names generate unique names based on their original node + // and are cached based on that node's id. + var node = getNodeForGeneratedName(name); + return generateNameCached(node); + } + else { + // Auto, Loop, and Unique names are cached based on their unique + // autoGenerateId. + var autoGenerateId = name.autoGenerateId; + return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(makeName(name))); + } + } + function generateNameCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + } + /** + * Returns a value indicating whether a name is unique globally, within the current file, + * or within the NameGenerator. + */ function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentFileIdentifiers, name) && - !ts.hasProperty(generatedNameSet, name); + return !(hasGlobalName && hasGlobalName(name)) + && !currentSourceFile.identifiers.has(name) + && !generatedNames.has(name); } + /** + * Returns a value indicating whether a name is unique within a container. + */ function isUniqueLocalName(name, container) { for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { + if (node.locals) { + var local = node.locals.get(name); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { + if (local && local.flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { return false; } } @@ -62513,16 +63904,16 @@ var ts; return true; } /** - * Return the next available name in the pattern _a ... _z, _0, _1, ... - * TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name. - * Note that names generated by makeTempVariableName and makeUniqueName will never conflict. - */ + * Return the next available name in the pattern _a ... _z, _0, _1, ... + * TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name. + * Note that names generated by makeTempVariableName and makeUniqueName will never conflict. + */ function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_41 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_41)) { + var name = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name)) { tempFlags |= flags; - return name_41; + return name; } } while (true) { @@ -62530,19 +63921,21 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_42 = count < 26 + var name = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_42)) { - return name_42; + if (isUniqueName(name)) { + return name; } } } } - // Generate a name that is unique within the current file and doesn't conflict with any names - // in global scope. The name is formed by adding an '_n' suffix to the specified base name, - // where n is a positive integer. Note that names generated by makeTempVariableName and - // makeUniqueName are guaranteed to never conflict. + /** + * Generate a name that is unique within the current file and doesn't conflict with any names + * in global scope. The name is formed by adding an '_n' suffix to the specified base name, + * where n is a positive integer. Note that names generated by makeTempVariableName and + * makeUniqueName are guaranteed to never conflict. + */ function makeUniqueName(baseName) { // Find the first unique 'name_n', where n is a positive number if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { @@ -62552,58 +63945,69 @@ var ts; while (true) { var generatedName = baseName + i; if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; + generatedNames.set(generatedName, generatedName); + return generatedName; } i++; } } + /** + * Generates a unique name for a ModuleDeclaration or EnumDeclaration. + */ function generateNameForModuleOrEnum(node) { var name = getTextOfNode(node.name); // Use module/enum name itself if it is unique, otherwise make a unique variation return isUniqueLocalName(name, node) ? name : makeUniqueName(name); } + /** + * Generates a unique name for an ImportDeclaration or ExportDeclaration. + */ function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); var baseName = expr.kind === 9 /* StringLiteral */ ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; return makeUniqueName(baseName); } + /** + * Generates a unique name for a default export. + */ function generateNameForExportDefault() { return makeUniqueName("default"); } + /** + * Generates a unique name for a class expression. + */ function generateNameForClassExpression() { return makeUniqueName("class"); } function generateNameForMethodOrAccessor(node) { if (ts.isIdentifier(node.name)) { - return generateNameForNodeCached(node.name); + return generateNameCached(node.name); } return makeTempVariableName(0 /* Auto */); } /** * Generates a unique name from a node. - * - * @param node A node. */ function generateNameForNode(node) { switch (node.kind) { case 70 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 231 /* ModuleDeclaration */: - case 230 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: + case 231 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 236 /* ImportDeclaration */: - case 242 /* ExportDeclaration */: + case 237 /* ImportDeclaration */: + case 243 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 226 /* FunctionDeclaration */: - case 227 /* ClassDeclaration */: - case 241 /* ExportAssignment */: + case 227 /* FunctionDeclaration */: + case 228 /* ClassDeclaration */: + case 242 /* ExportAssignment */: return generateNameForExportDefault(); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return generateNameForClassExpression(); - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); @@ -62611,24 +64015,20 @@ var ts; } /** * Generates a unique identifier for a node. - * - * @param name A generated name. */ - function generateName(name) { + function makeName(name) { switch (name.autoGenerateKind) { case 1 /* Auto */: return makeTempVariableName(0 /* Auto */); case 2 /* Loop */: return makeTempVariableName(268435456 /* _i */); case 3 /* Unique */: - return makeUniqueName(name.text); + return makeUniqueName(ts.unescapeIdentifier(name.text)); } ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } /** * Gets the node from which a name should be generated. - * - * @param name A generated name wrapper. */ function getNodeForGeneratedName(name) { var autoGenerateId = name.autoGenerateId; @@ -62648,56 +64048,40 @@ var ts; // otherwise, return the original node for the source; return node; } - function generateNameForNodeCached(node) { - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); - } - /** - * Gets the generated identifier text from a generated identifier. - * - * @param name The generated identifier. - */ - function getGeneratedIdentifier(name) { - if (name.autoGenerateKind === 4 /* Node */) { - // Generated names generate unique names based on their original node - // and are cached based on that node's id - var node = getNodeForGeneratedName(name); - return generateNameForNodeCached(node); - } - else { - // Auto, Loop, and Unique names are cached based on their unique - // autoGenerateId. - var autoGenerateId = name.autoGenerateId; - return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(generateName(name))); - } - } - function createDelimiterMap() { - var delimiters = []; - delimiters[0 /* None */] = ""; - delimiters[16 /* CommaDelimited */] = ","; - delimiters[4 /* BarDelimited */] = " |"; - delimiters[8 /* AmpersandDelimited */] = " &"; - return delimiters; - } - function getDelimiter(format) { - return delimiters[format & 28 /* DelimitersMask */]; - } - function createBracketsMap() { - var brackets = []; - brackets[512 /* Braces */] = ["{", "}"]; - brackets[1024 /* Parenthesis */] = ["(", ")"]; - brackets[2048 /* AngleBrackets */] = ["<", ">"]; - brackets[4096 /* SquareBrackets */] = ["[", "]"]; - return brackets; - } - function getOpeningBracket(format) { - return brackets[format & 7680 /* BracketsMask */][0]; - } - function getClosingBracket(format) { - return brackets[format & 7680 /* BracketsMask */][1]; - } } - ts.emitFiles = emitFiles; + ts.createPrinter = createPrinter; + function createDelimiterMap() { + var delimiters = []; + delimiters[0 /* None */] = ""; + delimiters[16 /* CommaDelimited */] = ","; + delimiters[4 /* BarDelimited */] = " |"; + delimiters[8 /* AmpersandDelimited */] = " &"; + return delimiters; + } + function getDelimiter(format) { + return delimiters[format & 28 /* DelimitersMask */]; + } + function createBracketsMap() { + var brackets = []; + brackets[512 /* Braces */] = ["{", "}"]; + brackets[1024 /* Parenthesis */] = ["(", ")"]; + brackets[2048 /* AngleBrackets */] = ["<", ">"]; + brackets[4096 /* SquareBrackets */] = ["[", "]"]; + return brackets; + } + function getOpeningBracket(format) { + return brackets[format & 7680 /* BracketsMask */][0]; + } + function getClosingBracket(format) { + return brackets[format & 7680 /* BracketsMask */][1]; + } + // Flags enum to track count of temp variables and a few dedicated names + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); var ListFormat; (function (ListFormat) { ListFormat[ListFormat["None"] = 0] = "None"; @@ -62862,11 +64246,11 @@ var ts; return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; } function directoryExists(directoryPath) { - if (directoryPath in existingDirectories) { + if (existingDirectories.has(directoryPath)) { return true; } if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; + existingDirectories.set(directoryPath, true); return true; } return false; @@ -62885,10 +64269,11 @@ var ts; } var hash = ts.sys.createHash(data); var mtimeBefore = ts.sys.getModifiedTime(fileName); - if (mtimeBefore && fileName in outputFingerprints) { - var fingerprint = outputFingerprints[fileName]; + if (mtimeBefore) { + var fingerprint = outputFingerprints.get(fileName); // If output has not been changed, and the file has no external modification - if (fingerprint.byteOrderMark === writeByteOrderMark && + if (fingerprint && + fingerprint.byteOrderMark === writeByteOrderMark && fingerprint.hash === hash && fingerprint.mtime.getTime() === mtimeBefore.getTime()) { return; @@ -62896,11 +64281,11 @@ var ts; } ts.sys.writeFile(fileName, data, writeByteOrderMark); var mtimeAfter = ts.sys.getModifiedTime(fileName); - outputFingerprints[fileName] = { + outputFingerprints.set(fileName, { hash: hash, byteOrderMark: writeByteOrderMark, mtime: mtimeAfter - }; + }); } function writeFile(fileName, data, writeByteOrderMark, onError) { try { @@ -62999,10 +64384,14 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_43 = names_1[_i]; - var result = name_43 in cache - ? cache[name_43] - : cache[name_43] = loader(name_43, containingFile); + var name = names_1[_i]; + var result = void 0; + if (cache.has(name)) { + result = cache.get(name); + } + else { + cache.set(name, result = loader(name, containingFile)); + } resolutions.push(result); } return resolutions; @@ -63135,7 +64524,7 @@ var ts; return program; function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -63159,7 +64548,7 @@ var ts; classifiableNames = ts.createMap(); for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { var sourceFile = files_2[_i]; - ts.copyProperties(sourceFile.classifiableNames, classifiableNames); + ts.copyEntries(sourceFile.classifiableNames, classifiableNames); } } return classifiableNames; @@ -63395,7 +64784,7 @@ var ts; }; } function isSourceFileFromExternalLibrary(file) { - return sourceFilesFoundSearchingNodeModules[file.path]; + return sourceFilesFoundSearchingNodeModules.get(file.path); } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); @@ -63540,23 +64929,23 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 144 /* Parameter */: - case 147 /* PropertyDeclaration */: + case 145 /* Parameter */: + case 148 /* PropertyDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // Pass through - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 226 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 226 /* FunctionDeclaration */: - case 224 /* VariableDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 225 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -63564,35 +64953,35 @@ var ts; } } switch (node.kind) { - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 256 /* HeritageClause */: + case 258 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 107 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 182 /* TypeAssertionExpression */: + case 183 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; @@ -63607,29 +64996,29 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 227 /* ClassDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 226 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 226 /* FunctionDeclaration */: + case 228 /* ClassDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // pass through - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 206 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 207 /* VariableStatement */); } break; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { @@ -63641,16 +65030,16 @@ var ts; return; } break; - case 144 /* Parameter */: + case 145 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 199 /* ExpressionWithTypeArguments */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 200 /* ExpressionWithTypeArguments */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -63747,11 +65136,10 @@ var ts; && (options.isolatedModules || isExternalModuleFile) && !file.isDeclarationFile) { // synthesize 'import "tslib"' declaration - var externalHelpersModuleReference = ts.createSynthesizedNode(9 /* StringLiteral */); - externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(236 /* ImportDeclaration */); - importDecl.parent = file; + var externalHelpersModuleReference = ts.createLiteral(ts.externalHelpersModuleNameText); + var importDecl = ts.createImportDeclaration(undefined, undefined, undefined); externalHelpersModuleReference.parent = importDecl; + importDecl.parent = file; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -63767,9 +65155,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 236 /* ImportDeclaration */: - case 235 /* ImportEqualsDeclaration */: - case 242 /* ExportDeclaration */: + case 237 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 243 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -63784,7 +65172,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2 /* Ambient */) || ts.isDeclarationFile(file))) { var moduleName = node.name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -63884,18 +65272,18 @@ var ts; } // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { - sourceFilesFoundSearchingNodeModules[file_1.path] = false; + if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth == 0) { + sourceFilesFoundSearchingNodeModules.set(file_1.path, false); if (!options.noResolve) { processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } - else if (file_1 && modulesWithElidedImports[file_1.path]) { + else if (file_1 && modulesWithElidedImports.get(file_1.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } } @@ -63912,7 +65300,7 @@ var ts; }); filesByName.set(path, file); if (file) { - sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0); + sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; if (host.useCaseSensitiveFileNames()) { // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case @@ -63961,7 +65349,7 @@ var ts; } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { // If we already found this library as a primary reference - nothing to do - var previousResolution = resolvedTypeReferenceDirectives[typeReferenceDirective]; + var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { return; } @@ -63995,7 +65383,7 @@ var ts; fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { - resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective; + resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); } } function createDiagnostic(refFile, refPos, refEnd, message) { @@ -64044,7 +65432,7 @@ var ts; // This may still end up being an untyped module -- the file won't be included but imports will be allowed. var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { - modulesWithElidedImports[file.path] = true; + modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = ts.toPath(resolvedFileName, currentDirectory, getCanonicalFileName); @@ -64063,8 +65451,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var file = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var file = sourceFiles_3[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -64075,8 +65463,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -64235,7 +65623,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { + ts.forEachEmittedFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -64367,12 +65755,13 @@ var ts; }, { name: "jsx", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "preserve": 1 /* Preserve */, + "react-native": 3 /* ReactNative */, "react": 2 /* React */ }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, }, { name: "reactNamespace", @@ -64402,7 +65791,7 @@ var ts; { name: "module", shortName: "m", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "none": ts.ModuleKind.None, "commonjs": ts.ModuleKind.CommonJS, "amd": ts.ModuleKind.AMD, @@ -64416,7 +65805,7 @@ var ts; }, { name: "newLine", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "crlf": 0 /* CarriageReturnLineFeed */, "lf": 1 /* LineFeed */ }), @@ -64514,8 +65903,8 @@ var ts; shortName: "p", type: "string", isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY + description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY }, { name: "removeComments", @@ -64565,7 +65954,7 @@ var ts; { name: "target", shortName: "t", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "es3": 0 /* ES3 */, "es5": 1 /* ES5 */, "es6": 2 /* ES2015 */, @@ -64602,7 +65991,7 @@ var ts; }, { name: "moduleResolution", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "node": ts.ModuleResolutionKind.NodeJs, "classic": ts.ModuleResolutionKind.Classic, }), @@ -64711,7 +66100,7 @@ var ts; type: "list", element: { name: "lib", - type: ts.createMap({ + type: ts.createMapFromTemplate({ // JavaScript only "es5": "lib.es5.d.ts", "es6": "lib.es2015.d.ts", @@ -64760,6 +66149,16 @@ var ts; name: "alwaysStrict", type: "boolean", description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + }, + { + // A list of plugins to load in the language service + name: "plugins", + type: "list", + isTSConfigOnly: true, + element: { + name: "plugin", + type: "object" + } } ]; /* @internal */ @@ -64822,9 +66221,9 @@ var ts; var optionNameMap = ts.createMap(); var shortOptionNames = ts.createMap(); ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; + optionNameMap.set(option.name.toLowerCase(), option); if (option.shortName) { - shortOptionNames[option.shortName] = option.name; + shortOptionNames.set(option.shortName, option.name); } }); optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; @@ -64833,7 +66232,7 @@ var ts; ts.getOptionNameMap = getOptionNameMap; /* @internal */ function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -64885,11 +66284,12 @@ var ts; else if (s.charCodeAt(0) === 45 /* minus */) { s = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1).toLowerCase(); // Try to translate short option names to their full equivalents. - if (s in shortOptionNames) { - s = shortOptionNames[s]; + var short = shortOptionNames.get(s); + if (short !== undefined) { + s = short; } - if (s in optionNameMap) { - var opt = optionNameMap[s]; + var opt = optionNameMap.get(s); + if (opt) { if (opt.isTSConfigOnly) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } @@ -65037,21 +66437,20 @@ var ts; } function getNameOfCompilerOptionValue(value, customTypeMap) { // There is a typeMap associated with this command-line option so use it to map value back to its name - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { return key; } - } - return undefined; + }); } function serializeCompilerOptions(options) { - var result = ts.createMap(); + var result = {}; var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_44 in options) { - if (ts.hasProperty(options, name_44)) { + for (var name in options) { + if (ts.hasProperty(options, name)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - switch (name_44) { + switch (name) { case "init": case "watch": case "version": @@ -65059,14 +66458,14 @@ var ts; case "project": break; default: - var value = options[name_44]; - var optionDefinition = optionsNameMap[name_44.toLowerCase()]; + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { // There is no map associated with this compiler option then use the value as-is // This is the case if the value is expect to be string, number, boolean or list of string - result[name_44] = value; + result[name] = value; } else { if (optionDefinition.type === "list") { @@ -65075,11 +66474,11 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_44] = convertedValue; + result[name] = convertedValue; } else { // There is a typeMap associated with this command-line option so use it to map value back to its name - result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -65305,8 +66704,8 @@ var ts; } var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; + var opt = optionNameMap.get(id); + if (opt) { defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); } else { @@ -65340,8 +66739,9 @@ var ts; } function convertJsonOptionOfCustomType(opt, value, errors) { var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; + var val = opt.type.get(key); + if (val !== undefined) { + return val; } else { errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); @@ -65465,7 +66865,7 @@ var ts; for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { var fileName = fileNames_1[_i]; var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; + literalFileMap.set(keyMapper(file), file); } } if (include && include.length > 0) { @@ -65486,14 +66886,13 @@ var ts; // same directory, we should remove it. removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; + if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) { + wildcardFileMap.set(key, file); } } } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); + var literalFiles = ts.arrayFrom(literalFileMap.values()); + var wildcardFiles = ts.arrayFrom(wildcardFileMap.values()); return { fileNames: literalFiles.concat(wildcardFiles), wildcardDirectories: wildcardDirectories @@ -65501,8 +66900,8 @@ var ts; } function validateSpecs(specs, errors, allowTrailingRecursion) { var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + var spec = specs_1[_i]; if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); } @@ -65536,7 +66935,7 @@ var ts; // /a/b/a?z - Watch /a/b directly to catch any new file matching a?z var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); + var wildcardDirectories = {}; if (include !== undefined) { var recursiveKeys = []; for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { @@ -65558,14 +66957,16 @@ var ts; } } // Remove any subpaths under an existing recursively watched directory. - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; + for (var key in wildcardDirectories) + if (ts.hasProperty(wildcardDirectories, key)) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } } } - } + ; } return wildcardDirectories; } @@ -65592,11 +66993,11 @@ var ts; */ function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); + var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions); for (var i = 0 /* Highest */; i < adjustedExtensionPriority; i++) { var higherPriorityExtension = extensions[i]; var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { return true; } } @@ -65612,23 +67013,13 @@ var ts; */ function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions); for (var i = nextExtensionPriority; i < extensions.length; i++) { var lowerPriorityExtension = extensions[i]; var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; + wildcardFiles.delete(lowerPriorityPath); } } - /** - * Adds a file to an array of files. - * - * @param output The output array. - * @param file The file path. - */ - function addFileToOutput(output, file) { - output.push(file); - return output; - } /** * Gets a case sensitive key. * @@ -65811,6 +67202,10 @@ var ts; ScriptElementKind.letElement = "let"; ScriptElementKind.directory = "directory"; ScriptElementKind.externalModuleName = "external module name"; + /** + * + **/ + ScriptElementKind.jsxAttribute = "JSX attribute"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { @@ -65896,33 +67291,34 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 144 /* Parameter */: - case 224 /* VariableDeclaration */: - case 174 /* BindingElement */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 258 /* PropertyAssignment */: - case 259 /* ShorthandPropertyAssignment */: - case 261 /* EnumMember */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 257 /* CatchClause */: + case 145 /* Parameter */: + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 260 /* PropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: + case 263 /* EnumMember */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 259 /* CatchClause */: + case 252 /* JsxAttribute */: return 1 /* Value */; - case 143 /* TypeParameter */: - case 228 /* InterfaceDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 161 /* TypeLiteral */: + case 144 /* TypeParameter */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 162 /* TypeLiteral */: return 2 /* Type */; - case 227 /* ClassDeclaration */: - case 230 /* EnumDeclaration */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -65932,22 +67328,25 @@ var ts; else { return 4 /* Namespace */; } - case 239 /* NamedImports */: - case 240 /* ImportSpecifier */: - case 235 /* ImportEqualsDeclaration */: - case 236 /* ImportDeclaration */: - case 241 /* ExportAssignment */: - case 242 /* ExportDeclaration */: + case 240 /* NamedImports */: + case 241 /* ImportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportDeclaration */: + case 242 /* ExportAssignment */: + case 243 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 262 /* SourceFile */: + case 264 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 241 /* ExportAssignment */) { + if (node.kind === 264 /* SourceFile */) { + return 1 /* Value */; + } + else if (node.parent.kind === 242 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -65972,15 +67371,15 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 141 /* QualifiedName */ && + if (node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 235 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 236 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function isInRightSideOfImport(node) { - while (node.parent.kind === 141 /* QualifiedName */) { + while (node.parent.kind === 142 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -65991,27 +67390,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 141 /* QualifiedName */) { - while (root.parent && root.parent.kind === 141 /* QualifiedName */) { + if (root.parent.kind === 142 /* QualifiedName */) { + while (root.parent && root.parent.kind === 142 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 157 /* TypeReference */ && !isLastClause; + return root.parent.kind === 158 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 177 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 177 /* PropertyAccessExpression */) { + if (root.parent.kind === 178 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 178 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 199 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 256 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 200 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 258 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 227 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || - (decl.kind === 228 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); + return (decl.kind === 228 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || + (decl.kind === 229 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); } return false; } @@ -66019,17 +67418,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 157 /* TypeReference */ || - (node.parent.kind === 199 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 158 /* TypeReference */ || + (node.parent.kind === 200 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 98 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || - node.kind === 167 /* ThisType */; + node.kind === 168 /* ThisType */; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 179 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 180 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 180 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 181 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -66042,7 +67441,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 220 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 221 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -66052,13 +67451,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 /* Identifier */ && - (node.parent.kind === 216 /* BreakStatement */ || node.parent.kind === 215 /* ContinueStatement */) && + (node.parent.kind === 217 /* BreakStatement */ || node.parent.kind === 216 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 /* Identifier */ && - node.parent.kind === 220 /* LabeledStatement */ && + node.parent.kind === 221 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -66066,15 +67465,15 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 177 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 231 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 232 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -66085,19 +67484,19 @@ var ts; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 258 /* PropertyAssignment */: - case 261 /* EnumMember */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 231 /* ModuleDeclaration */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 260 /* PropertyAssignment */: + case 263 /* EnumMember */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 232 /* ModuleDeclaration */: return node.parent.name === node; - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: return true; } } @@ -66146,17 +67545,17 @@ var ts; return undefined; } switch (node.kind) { - case 262 /* SourceFile */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 230 /* EnumDeclaration */: - case 231 /* ModuleDeclaration */: + case 264 /* SourceFile */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: return node; } } @@ -66164,46 +67563,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 262 /* SourceFile */: + case 264 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: return ts.ScriptElementKind.classElement; - case 228 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; - case 229 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; - case 230 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; - case 224 /* VariableDeclaration */: + case 229 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 230 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 231 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 225 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 174 /* BindingElement */: + case 175 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 185 /* ArrowFunction */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: return ts.ScriptElementKind.functionElement; - case 151 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; - case 152 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 152 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; + case 153 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: return ts.ScriptElementKind.memberFunctionElement; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return ts.ScriptElementKind.memberVariableElement; - case 155 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; - case 154 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; - case 153 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; - case 150 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; - case 143 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; - case 261 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; - case 144 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 235 /* ImportEqualsDeclaration */: - case 240 /* ImportSpecifier */: - case 237 /* ImportClause */: - case 244 /* ExportSpecifier */: - case 238 /* NamespaceImport */: + case 156 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; + case 155 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; + case 154 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; + case 151 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; + case 144 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; + case 263 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 145 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 236 /* ImportEqualsDeclaration */: + case 241 /* ImportSpecifier */: + case 238 /* ImportClause */: + case 245 /* ExportSpecifier */: + case 239 /* NamespaceImport */: return ts.ScriptElementKind.alias; - case 286 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -66218,7 +67617,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 171 /* LiteralType */ ? node.parent : node; + var searchNode = node.parent.kind === 172 /* LiteralType */ ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32 /* StringLiteral */) { return type; @@ -66233,7 +67632,7 @@ var ts; return true; case 70 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 144 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 145 /* Parameter */; default: return false; } @@ -66278,42 +67677,42 @@ var ts; return false; } switch (n.kind) { - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 230 /* EnumDeclaration */: - case 176 /* ObjectLiteralExpression */: - case 172 /* ObjectBindingPattern */: - case 161 /* TypeLiteral */: - case 205 /* Block */: - case 232 /* ModuleBlock */: - case 233 /* CaseBlock */: - case 239 /* NamedImports */: - case 243 /* NamedExports */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 177 /* ObjectLiteralExpression */: + case 173 /* ObjectBindingPattern */: + case 162 /* TypeLiteral */: + case 206 /* Block */: + case 233 /* ModuleBlock */: + case 234 /* CaseBlock */: + case 240 /* NamedImports */: + case 244 /* NamedExports */: return nodeEndsWith(n, 17 /* CloseBraceToken */, sourceFile); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 180 /* NewExpression */: + case 181 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 179 /* CallExpression */: - case 183 /* ParenthesizedExpression */: - case 166 /* ParenthesizedType */: + case 180 /* CallExpression */: + case 184 /* ParenthesizedExpression */: + case 167 /* ParenthesizedType */: return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 154 /* ConstructSignature */: - case 153 /* CallSignature */: - case 185 /* ArrowFunction */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 155 /* ConstructSignature */: + case 154 /* CallSignature */: + case 186 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -66323,67 +67722,67 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 19 /* CloseParenToken */, sourceFile); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 209 /* IfStatement */: + case 210 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24 /* SemicolonToken */); - case 175 /* ArrayLiteralExpression */: - case 173 /* ArrayBindingPattern */: - case 178 /* ElementAccessExpression */: - case 142 /* ComputedPropertyName */: - case 163 /* TupleType */: + case 176 /* ArrayLiteralExpression */: + case 174 /* ArrayBindingPattern */: + case 179 /* ElementAccessExpression */: + case 143 /* ComputedPropertyName */: + case 164 /* TupleType */: return nodeEndsWith(n, 21 /* CloseBracketToken */, sourceFile); - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); - case 254 /* CaseClause */: - case 255 /* DefaultClause */: + case 256 /* CaseClause */: + case 257 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 211 /* WhileStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 212 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 210 /* DoStatement */: + case 211 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 105 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 187 /* TypeOfExpression */: - case 186 /* DeleteExpression */: - case 188 /* VoidExpression */: - case 195 /* YieldExpression */: - case 196 /* SpreadElement */: + case 188 /* TypeOfExpression */: + case 187 /* DeleteExpression */: + case 189 /* VoidExpression */: + case 196 /* YieldExpression */: + case 197 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 203 /* TemplateSpan */: + case 204 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 242 /* ExportDeclaration */: - case 236 /* ImportDeclaration */: + case 243 /* ExportDeclaration */: + case 237 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -66439,7 +67838,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 === 293 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 296 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -66611,7 +68010,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 262 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 264 /* 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. @@ -66670,17 +68069,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 253 /* JsxExpression */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 255 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 253 /* JsxExpression */) { + if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 255 /* JsxExpression */) { return true; } //
|
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 250 /* JsxClosingElement */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 251 /* JsxClosingElement */) { return true; } return false; @@ -66792,17 +68191,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 157 /* TypeReference */ || node.kind === 179 /* CallExpression */) { + if (node.kind === 158 /* TypeReference */ || node.kind === 180 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 227 /* ClassDeclaration */ || node.kind === 228 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 228 /* ClassDeclaration */ || node.kind === 229 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 140 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 141 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -66861,18 +68260,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 175 /* ArrayLiteralExpression */ || - node.kind === 176 /* ObjectLiteralExpression */) { + if (node.kind === 176 /* ArrayLiteralExpression */ || + node.kind === 177 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 192 /* BinaryExpression */ && + if (node.parent.kind === 193 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 57 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 214 /* ForOfStatement */ && + if (node.parent.kind === 215 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -66880,7 +68279,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 258 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 260 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -66908,12 +68307,32 @@ var ts; } } ts.isInNonReferenceComment = isInNonReferenceComment; + function createTextSpanFromNode(node, sourceFile) { + return ts.createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); + } + ts.createTextSpanFromNode = createTextSpanFromNode; + function isTypeKeyword(kind) { + switch (kind) { + case 118 /* AnyKeyword */: + case 121 /* BooleanKeyword */: + case 129 /* NeverKeyword */: + case 132 /* NumberKeyword */: + case 133 /* ObjectKeyword */: + case 135 /* StringKeyword */: + case 136 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + return true; + default: + return false; + } + } + ts.isTypeKeyword = isTypeKeyword; })(ts || (ts = {})); // Display-part writer helpers /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 144 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 145 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -66937,7 +68356,8 @@ var ts; decreaseIndent: function () { indent--; }, clear: resetWriter, trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop }; function writeIndent() { if (lineStart) { @@ -67094,7 +68514,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location) && - location.parent.kind === 142 /* ComputedPropertyName */) { + location.parent.kind === 143 /* ComputedPropertyName */) { return location.text; } // Try to get the local symbol if we're dealing with an 'export default' @@ -67106,7 +68526,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 240 /* ImportSpecifier */ || location.parent.kind === 244 /* ExportSpecifier */) && + (location.parent.kind === 241 /* ImportSpecifier */ || location.parent.kind === 245 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -67226,7 +68646,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 124 /* GetKeyword */ || - keyword2 === 133 /* SetKeyword */ || + keyword2 === 134 /* SetKeyword */ || keyword2 === 122 /* ConstructorKeyword */ || keyword2 === 114 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". @@ -67385,10 +68805,10 @@ var ts; angleBracketStack--; } else if (token === 118 /* AnyKeyword */ || - token === 134 /* StringKeyword */ || + token === 135 /* StringKeyword */ || token === 132 /* NumberKeyword */ || token === 121 /* BooleanKeyword */ || - token === 135 /* SymbolKeyword */) { + token === 136 /* 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, @@ -67560,7 +68980,7 @@ var ts; } } function isKeyword(token) { - return token >= 71 /* FirstKeyword */ && token <= 140 /* LastKeyword */; + return token >= 71 /* FirstKeyword */ && token <= 141 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -67617,10 +69037,10 @@ var ts; // 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 231 /* ModuleDeclaration */: - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 226 /* FunctionDeclaration */: + case 232 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 227 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -67671,7 +69091,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 231 /* ModuleDeclaration */ && + return declaration.kind === 232 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -67686,7 +69106,7 @@ var ts; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run // in a third of the time it would normally take. - if (classifiableNames[identifier.text]) { + if (classifiableNames.get(identifier.text)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var type = classifySymbol(symbol, ts.getMeaningFromLocation(node)); @@ -67835,16 +69255,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 282 /* JSDocParameterTag */: + case 285 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 285 /* JSDocTemplateTag */: + case 288 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 284 /* JSDocTypeTag */: + case 287 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 283 /* JSDocReturnTag */: + case 286 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -67931,22 +69351,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 249 /* JsxOpeningElement */: + case 250 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 250 /* JsxClosingElement */: + case 251 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 248 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 251 /* JsxAttribute */: + case 252 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -67974,17 +69394,17 @@ var ts; if (token) { if (tokenKind === 57 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 224 /* VariableDeclaration */ || - token.parent.kind === 147 /* PropertyDeclaration */ || - token.parent.kind === 144 /* Parameter */ || - token.parent.kind === 251 /* JsxAttribute */) { + if (token.parent.kind === 225 /* VariableDeclaration */ || + token.parent.kind === 148 /* PropertyDeclaration */ || + token.parent.kind === 145 /* Parameter */ || + token.parent.kind === 252 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 192 /* BinaryExpression */ || - token.parent.kind === 190 /* PrefixUnaryExpression */ || - token.parent.kind === 191 /* PostfixUnaryExpression */ || - token.parent.kind === 193 /* ConditionalExpression */) { + if (token.parent.kind === 193 /* BinaryExpression */ || + token.parent.kind === 191 /* PrefixUnaryExpression */ || + token.parent.kind === 192 /* PostfixUnaryExpression */ || + token.parent.kind === 194 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -67994,7 +69414,7 @@ var ts; return 4 /* numericLiteral */; } else if (tokenKind === 9 /* StringLiteral */) { - return token.parent.kind === 251 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 252 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 11 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -68010,32 +69430,32 @@ var ts; else if (tokenKind === 70 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 144 /* Parameter */: + case 145 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -68064,7 +69484,6 @@ var ts; } ts.getEncodedSyntacticClassifications = getEncodedSyntacticClassifications; })(ts || (ts = {})); -/// /* @internal */ var ts; (function (ts) { @@ -68072,10 +69491,10 @@ var ts; (function (Completions) { function getCompletionsAtPosition(host, typeChecker, log, compilerOptions, sourceFile, position) { if (ts.isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position); + return getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); } if (ts.isInString(sourceFile, position)) { - return getStringLiteralCompletionEntries(sourceFile, position); + return getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log); } var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (!completionData) { @@ -68088,13 +69507,13 @@ var ts; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true); - ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target)); } else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 /* JSX */ && - location.parent && location.parent.kind === 250 /* JsxClosingElement */) { + location.parent && location.parent.kind === 251 /* JsxClosingElement */) { // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. // For example: @@ -68111,632 +69530,642 @@ var ts; return undefined; } } - getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true); + getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); } // Add keywords if this is not a member completion list if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { - var entries = []; - var nameTable = ts.getNameTable(sourceFile); - for (var name_45 in nameTable) { - // Skip identifiers produced only from the current location - if (nameTable[name_45] === position) { - continue; + } + Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames, target) { + var entries = []; + var nameTable = ts.getNameTable(sourceFile); + nameTable.forEach(function (pos, name) { + // Skip identifiers produced only from the current location + if (pos === position) { + return; + } + if (!uniqueNames.get(name)) { + uniqueNames.set(name, name); + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name), target, /*performCharacterChecks*/ true); + if (displayName) { + var entry = { + name: displayName, + kind: ts.ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } - if (!uniqueNames[name_45]) { - uniqueNames[name_45] = name_45; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_45), compilerOptions.target, /*performCharacterChecks*/ true); - if (displayName) { - var entry = { - name: displayName, - kind: ts.ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; + } + }); + return entries; + } + function createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target) { + // 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(typeChecker, symbol, target, performCharacterChecks, location); + if (!displayName) { + return undefined; + } + // TODO(drosen): Right now we just permit *all* semantic meanings when calling + // 'getSymbolKind' which is permissible given that it is backwards compatible; but + // really we should consider passing the meaning for the node so that we don't report + // that a suggestion for a value is an interface. We COULD also just do what + // 'getSymbolModifiers' does, which is to use the first declaration. + // Use a 'sortText' of 0' so that all symbol completion entries come before any other + // entries (like JavaScript identifier entries). + return { + name: displayName, + kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), + kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), + sortText: "0", + }; + } + function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks, typeChecker, target, log) { + var start = ts.timestamp(); + var uniqueNames = ts.createMap(); + if (symbols) { + for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { + var symbol = symbols_4[_i]; + var entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + if (entry) { + var id = ts.escapeIdentifier(entry.name); + if (!uniqueNames.get(id)) { entries.push(entry); + uniqueNames.set(id, id); } } } - return entries; } - function createCompletionEntry(symbol, location, performCharacterChecks) { - // 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(typeChecker, symbol, compilerOptions.target, performCharacterChecks, location); - if (!displayName) { - return undefined; + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); + return uniqueNames; + } + function getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log) { + var node = ts.findPrecedingToken(position, sourceFile); + if (!node || node.kind !== 9 /* StringLiteral */) { + return undefined; + } + if (node.parent.kind === 260 /* PropertyAssignment */ && + node.parent.parent.kind === 177 /* ObjectLiteralExpression */ && + node.parent.name === node) { + // Get quoted name of properties of the object literal expression + // i.e. interface ConfigFiles { + // 'jspm:dev': string + // } + // let files: ConfigFiles = { + // '/*completion position*/' + // } + // + // function foo(c: ConfigFiles) {} + // foo({ + // '/*completion position*/' + // }); + return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent, typeChecker, compilerOptions.target, log); + } + else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { + // Get all names of properties on the expression + // i.e. interface A { + // 'prop1': string + // } + // let a: A; + // a['/*completion position*/'] + return getStringLiteralCompletionEntriesFromElementAccess(node.parent, typeChecker, compilerOptions.target, log); + } + else if (node.parent.kind === 237 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + // Get all known external module names or complete a path to a module + // i.e. import * as ns from "/*completion position*/"; + // import x = require("/*completion position*/"); + // var y = require("/*completion position*/"); + return getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); + } + else if (isEqualityExpression(node.parent)) { + // Get completions from the type of the other operand + // i.e. switch (a) { + // case '/*completion position*/' + // } + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.left === node ? node.parent.right : node.parent.left), typeChecker); + } + else if (ts.isCaseOrDefaultClause(node.parent)) { + // Get completions from the type of the switch expression + // i.e. x === '/*completion position' + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.parent.parent.expression), typeChecker); + } + else { + var argumentInfo = ts.SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); + if (argumentInfo) { + // Get string literal completions from specialized signatures of the target + // i.e. declare function f(a: 'A'); + // f("/*completion position*/") + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker); } - // TODO(drosen): Right now we just permit *all* semantic meanings when calling - // 'getSymbolKind' which is permissible given that it is backwards compatible; but - // really we should consider passing the meaning for the node so that we don't report - // that a suggestion for a value is an interface. We COULD also just do what - // 'getSymbolModifiers' does, which is to use the first declaration. - // Use a 'sortText' of 0' so that all symbol completion entries come before any other - // entries (like JavaScript identifier entries). - return { - name: displayName, - kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0", - }; + // Get completion for string literal from string literal type + // i.e. var x: "hi" | "hello" = "/*completion position*/" + return getStringLiteralCompletionEntriesFromType(typeChecker.getContextualType(node), typeChecker); } - function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { - var start = ts.timestamp(); - var uniqueNames = ts.createMap(); - if (symbols) { - for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { - var symbol = symbols_4[_i]; - var entry = createCompletionEntry(symbol, location, performCharacterChecks); - if (entry) { - var id = ts.escapeIdentifier(entry.name); - if (!uniqueNames[id]) { - entries.push(entry); - uniqueNames[id] = id; + } + function getStringLiteralCompletionEntriesFromPropertyAssignment(element, typeChecker, target, log) { + var type = typeChecker.getContextualType(element.parent); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + } + } + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker) { + var candidates = []; + var entries = []; + typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); + for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { + var candidate = candidates_3[_i]; + addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries, typeChecker); + } + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; + } + return undefined; + } + function getStringLiteralCompletionEntriesFromElementAccess(node, typeChecker, target, log) { + var type = typeChecker.getTypeAtLocation(node.expression); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + } + return undefined; + } + function getStringLiteralCompletionEntriesFromType(type, typeChecker) { + if (type) { + var entries = []; + addStringLiteralCompletionsFromType(type, entries, typeChecker); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; + } + } + return undefined; + } + function addStringLiteralCompletionsFromType(type, result, typeChecker) { + if (type && type.flags & 16384 /* TypeParameter */) { + type = typeChecker.getApparentType(type); + } + if (!type) { + return; + } + if (type.flags & 65536 /* Union */) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + addStringLiteralCompletionsFromType(t, result, typeChecker); + } + } + else if (type.flags & 32 /* StringLiteral */) { + result.push({ + name: type.text, + kindModifiers: ts.ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.variableElement, + sortText: "0" + }); + } + } + function getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker) { + var literalValue = ts.normalizeSlashes(node.text); + var scriptPath = node.getSourceFile().path; + var scriptDirectory = ts.getDirectoryPath(scriptPath); + var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); + var entries; + if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { + var extensions = ts.getSupportedExtensions(compilerOptions); + if (compilerOptions.rootDirs) { + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, span, compilerOptions, host, scriptPath); + } + else { + entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, span, host, scriptPath); + } + } + else { + // Check for node modules + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); + } + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: entries + }; + } + /** + * Takes a script path and returns paths for all potential folders that could be merged with its + * containing folder via the "rootDirs" compiler option + */ + function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { + // Make all paths absolute/normalized if they are not already + rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); + // Determine the path to the directory containing the script relative to the root directory it is contained within + var relativeDirectory; + for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { + var rootDirectory = rootDirs_1[_i]; + if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + break; + } + } + // Now find a path for each potential directory that is to be merged with the one containing the script + return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); + } + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, compilerOptions, host, exclude) { + var basePath = compilerOptions.project || host.getCurrentDirectory(); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + var result = []; + for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { + var baseDirectory = baseDirectories_1[_i]; + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); + } + return result; + } + /** + * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. + */ + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, host, exclude, result) { + if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); + /** + * Remove the basename from the path. Note that we don't use the basename to filter completions; + * the client is responsible for refining completions. + */ + fragment = ts.getDirectoryPath(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; + } + fragment = ts.ensureTrailingDirectorySeparator(fragment); + var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); + var baseDirectory = ts.getDirectoryPath(absolutePath); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + if (tryDirectoryExists(host, baseDirectory)) { + // Enumerate the available files if possible + var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + if (files) { + /** + * Multiple file entries might map to the same truncated name once we remove extensions + * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: + * + * both foo.ts and foo.tsx become foo + */ + var foundFiles = ts.createMap(); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var filePath = files_3[_i]; + filePath = ts.normalizePath(filePath); + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + continue; + } + var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + if (!foundFiles.get(foundFileName)) { + foundFiles.set(foundFileName, true); + } + } + ts.forEachKey(foundFiles, function (foundFile) { + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); + }); + } + // If possible, get folder completion as well + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { + var directory = directories_2[_a]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); + } + } + } + return result; + } + /** + * Check all of the declared modules and those in node modules. Possible sources of modules: + * Modules that are found by the type checker + * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) + * Modules from node_modules (i.e. those listed in package.json) + * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions + */ + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span, compilerOptions, host, typeChecker) { + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var result; + if (baseUrl) { + var fileExtensions = ts.getSupportedExtensions(compilerOptions); + var projectDir = compilerOptions.project || host.getCurrentDirectory(); + var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); + result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, /*includeExtensions*/ false, span, host); + if (paths) { + for (var path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { + var pattern = _a[_i]; + for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { + var match = _c[_b]; + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + else if (ts.startsWith(path, fragment)) { + var entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); + } } } } } - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); - return uniqueNames; } - function getStringLiteralCompletionEntries(sourceFile, position) { - var node = ts.findPrecedingToken(position, sourceFile); - if (!node || node.kind !== 9 /* StringLiteral */) { - return undefined; + else { + result = []; + } + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); + for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { + var moduleName = _e[_d]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + return result; + } + function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { + if (host.readDirectory) { + var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; + if (parsed) { + // The prefix has two effective parts: the directory path and the base component after the filepath that is not a + // full directory component. For example: directory/path/of/prefix/base* + var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); + var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); + var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; + // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call + var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; + var normalizedSuffix = ts.normalizePath(parsed.suffix); + var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); + var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + // If we have a suffix, then we need to read the directory all the way down. We could create a glob + // that encodes the suffix, but we would have to escape the character "?" which readDirectory + // doesn't support. For now, this is safer but slower + var includeGlob = normalizedSuffix ? "**/*" : "./*"; + var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); + if (matches) { + var result = []; + // Trim away prefix and suffix + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; + var normalizedMatch = ts.normalizePath(match); + if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { + continue; + } + var start = completePrefix.length; + var length_5 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); + } + return result; + } } - if (node.parent.kind === 258 /* PropertyAssignment */ && - node.parent.parent.kind === 176 /* ObjectLiteralExpression */ && - node.parent.name === node) { - // Get quoted name of properties of the object literal expression - // i.e. interface ConfigFiles { - // 'jspm:dev': string - // } - // let files: ConfigFiles = { - // '/*completion position*/' - // } - // - // function foo(c: ConfigFiles) {} - // foo({ - // '/*completion position*/' - // }); - return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); + } + return undefined; + } + function enumeratePotentialNonRelativeModules(fragment, scriptPath, options, typeChecker, host) { + // Check If this is a nested module + var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; + var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; + // Get modules that the type checker picked up + var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); + var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); + // Nested modules of the form "module-name/sub" need to be adjusted to only return the string + // after the last '/' that appears in the fragment because that's where the replacement span + // starts + if (isNestedModule) { + var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { + if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { + return moduleName.substr(moduleNameWithSeperator_1.length); + } + return moduleName; + }); + } + if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { + for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { + var visibleModule = _a[_i]; + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.moduleName); + } + else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { + var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, /*exclude*/ undefined, /*include*/ ["./*"]); + if (nestedFiles) { + for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { + var f = nestedFiles_1[_b]; + f = ts.normalizePath(f); + var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + } + } + } } - else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { - // Get all names of properties on the expression - // i.e. interface A { - // 'prop1': string - // } - // let a: A; - // a['/*completion position*/'] - return getStringLiteralCompletionEntriesFromElementAccess(node.parent); - } - else if (node.parent.kind === 236 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { - // Get all known external module names or complete a path to a module - // i.e. import * as ns from "/*completion position*/"; - // import x = require("/*completion position*/"); - // var y = require("/*completion position*/"); - return getStringLiteralCompletionEntriesFromModuleNames(node); + } + return ts.deduplicate(nonRelativeModules); + } + function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { + var token = ts.getTokenAtPosition(sourceFile, position); + if (!token) { + return undefined; + } + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + if (!commentRanges || !commentRanges.length) { + return undefined; + } + var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); + if (!range) { + return undefined; + } + var completionInfo = { + /** + * We don't want the editor to offer any other completions, such as snippets, inside a comment. + */ + isGlobalCompletion: false, + isMemberCompletion: false, + /** + * The user may type in a path that doesn't yet exist, creating a "new identifier" + * with respect to the collection of identifiers the server is aware of. + */ + isNewIdentifierLocation: true, + entries: [] + }; + var text = sourceFile.text.substr(range.pos, position - range.pos); + var match = tripleSlashDirectiveFragmentRegex.exec(text); + if (match) { + var prefix = match[1]; + var kind = match[2]; + var toComplete = match[3]; + var scriptPath = ts.getDirectoryPath(sourceFile.path); + if (kind === "path") { + // Give completions for a relative path + var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, span_10, host, sourceFile.path); } else { - var argumentInfo = ts.SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); - if (argumentInfo) { - // Get string literal completions from specialized signatures of the target - // i.e. declare function f(a: 'A'); - // f("/*completion position*/") - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); - } - // Get completion for string literal from string literal type - // i.e. var x: "hi" | "hello" = "/*completion position*/" - return getStringLiteralCompletionEntriesFromContextualType(node); + // Give completions based on the typings available + var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); } } - function getStringLiteralCompletionEntriesFromPropertyAssignment(element) { - var type = typeChecker.getContextualType(element.parent); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + return completionInfo; + } + function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { + if (result === void 0) { result = []; } + // Check for typings specified in compiler options + if (options.types) { + for (var _i = 0, _a = options.types; _i < _a.length; _i++) { + var moduleName = _a[_i]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + } + else if (host.getDirectories) { + var typeRoots = void 0; + try { + // Wrap in try catch because getEffectiveTypeRoots touches the filesystem + typeRoots = ts.getEffectiveTypeRoots(options, host); + } + catch (e) { } + if (typeRoots) { + for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { + var root = typeRoots_2[_b]; + getCompletionEntriesFromDirectories(host, root, span, result); } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo) { - var candidates = []; - var entries = []; - typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); - for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { - var candidate = candidates_3[_i]; - if (candidate.parameters.length > argumentInfo.argumentIndex) { - var parameter = candidate.parameters[argumentInfo.argumentIndex]; - addStringLiteralCompletionsFromType(typeChecker.getTypeAtLocation(parameter.valueDeclaration), entries); + if (host.getDirectories) { + // Also get all @types typings installed in visible node_modules directories + for (var _c = 0, _d = findPackageJsons(scriptPath, host); _c < _d.length; _c++) { + var packageJson = _d[_c]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, typesDir, span, result); + } + } + return result; + } + function getCompletionEntriesFromDirectories(host, directory, span, result) { + if (host.getDirectories && tryDirectoryExists(host, directory)) { + var directories = tryGetDirectories(host, directory); + if (directories) { + for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { + var typeDirectory = directories_3[_i]; + typeDirectory = ts.normalizePath(typeDirectory); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); } } - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; - } - return undefined; } - function getStringLiteralCompletionEntriesFromElementAccess(node) { - var type = typeChecker.getTypeAtLocation(node.expression); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + function findPackageJsons(currentDir, host) { + var paths = []; + var currentConfigPath; + while (true) { + currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + currentDir = ts.getDirectoryPath(currentConfigPath); + var parent = ts.getDirectoryPath(currentDir); + if (currentDir === parent) { + break; } - } - return undefined; - } - function getStringLiteralCompletionEntriesFromContextualType(node) { - var type = typeChecker.getContextualType(node); - if (type) { - var entries_2 = []; - addStringLiteralCompletionsFromType(type, entries_2); - if (entries_2.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; - } - } - return undefined; - } - function addStringLiteralCompletionsFromType(type, result) { - if (type && type.flags & 16384 /* TypeParameter */) { - type = typeChecker.getApparentType(type); - } - if (!type) { - return; - } - if (type.flags & 65536 /* Union */) { - ts.forEach(type.types, function (t) { return addStringLiteralCompletionsFromType(t, result); }); + currentDir = parent; } else { - if (type.flags & 32 /* StringLiteral */) { + break; + } + } + return paths; + } + function enumerateNodeModulesVisibleToScript(host, scriptPath) { + var result = []; + if (host.readFile && host.fileExists) { + for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + var packageJson = _a[_i]; + var contents = tryReadingPackageJson(packageJson); + if (!contents) { + return; + } + var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); + var foundModuleNames = []; + // Provide completions for all non @types dependencies + for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { + var key = nodeModulesDependencyKeys_1[_b]; + addPotentialPackageNames(contents[key], foundModuleNames); + } + for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { + var moduleName = foundModuleNames_1[_c]; + var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); result.push({ - name: type.text, - kindModifiers: ts.ScriptElementKindModifier.none, - kind: ts.ScriptElementKind.variableElement, - sortText: "0" + moduleName: moduleName, + moduleDir: moduleDir }); } } } - function getStringLiteralCompletionEntriesFromModuleNames(node) { - var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; - var scriptDirectory = ts.getDirectoryPath(scriptPath); - var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); - var entries; - if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { - if (compilerOptions.rootDirs) { - entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ false, span, scriptPath); - } - else { - entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ false, span, scriptPath); - } + return result; + function tryReadingPackageJson(filePath) { + try { + var fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; } - else { - // Check for node modules - entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); - } - return { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: entries - }; - } - /** - * Takes a script path and returns paths for all potential folders that could be merged with its - * containing folder via the "rootDirs" compiler option - */ - function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { - // Make all paths absolute/normalized if they are not already - rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); - // Determine the path to the directory containing the script relative to the root directory it is contained within - var relativeDirectory; - for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { - var rootDirectory = rootDirs_1[_i]; - if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { - relativeDirectory = scriptPath.substr(rootDirectory.length); - break; - } - } - // Now find a path for each potential directory that is to be merged with the one containing the script - return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); - } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, exclude) { - var basePath = compilerOptions.project || host.getCurrentDirectory(); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); - var result = []; - for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { - var baseDirectory = baseDirectories_1[_i]; - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, exclude, result); - } - return result; - } - /** - * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. - */ - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, exclude, result) { - if (result === void 0) { result = []; } - if (fragment === undefined) { - fragment = ""; - } - fragment = ts.normalizeSlashes(fragment); - /** - * Remove the basename from the path. Note that we don't use the basename to filter completions; - * the client is responsible for refining completions. - */ - fragment = ts.getDirectoryPath(fragment); - if (fragment === "") { - fragment = "." + ts.directorySeparator; - } - fragment = ts.ensureTrailingDirectorySeparator(fragment); - var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); - var baseDirectory = ts.getDirectoryPath(absolutePath); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (tryDirectoryExists(host, baseDirectory)) { - // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); - if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - var foundFiles = ts.createMap(); - for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { - var filePath = files_3[_i]; - filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { - continue; - } - var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); - if (!foundFiles[foundFileName]) { - foundFiles[foundFileName] = true; - } - } - for (var foundFile in foundFiles) { - result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); - } - } - // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); - if (directories) { - for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { - var directory = directories_2[_a]; - var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); - } - } - } - return result; - } - /** - * Check all of the declared modules and those in node modules. Possible sources of modules: - * Modules that are found by the type checker - * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) - * Modules from node_modules (i.e. those listed in package.json) - * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions - */ - function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span) { - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var result; - if (baseUrl) { - var fileExtensions = ts.getSupportedExtensions(compilerOptions); - var projectDir = compilerOptions.project || host.getCurrentDirectory(); - var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, /*includeExtensions*/ false, span); - if (paths) { - for (var path in paths) { - if (paths.hasOwnProperty(path)) { - if (path === "*") { - if (paths[path]) { - for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { - var pattern = _a[_i]; - for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions); _b < _c.length; _b++) { - var match = _c[_b]; - result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - else if (ts.startsWith(path, fragment)) { - var entry = paths[path] && paths[path].length === 1 && paths[path][0]; - if (entry) { - result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - } - } - else { - result = []; - } - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions); _d < _e.length; _d++) { - var moduleName = _e[_d]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - return result; - } - function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions) { - if (host.readDirectory) { - var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; - if (parsed) { - // The prefix has two effective parts: the directory path and the base component after the filepath that is not a - // full directory component. For example: directory/path/of/prefix/base* - var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); - var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); - var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); - var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; - // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call - var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; - var normalizedSuffix = ts.normalizePath(parsed.suffix); - var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); - var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - // If we have a suffix, then we need to read the directory all the way down. We could create a glob - // that encodes the suffix, but we would have to escape the character "?" which readDirectory - // doesn't support. For now, this is safer but slower - var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); - if (matches) { - var result = []; - // Trim away prefix and suffix - for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { - var match = matches_1[_i]; - var normalizedMatch = ts.normalizePath(match); - if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { - continue; - } - var start = completePrefix.length; - var length_5 = normalizedMatch.length - start - normalizedSuffix.length; - result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); - } - return result; - } - } - } - return undefined; - } - function enumeratePotentialNonRelativeModules(fragment, scriptPath, options) { - // Check If this is a nested module - var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; - var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; - // Get modules that the type checker picked up - var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); - var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); - // Nested modules of the form "module-name/sub" need to be adjusted to only return the string - // after the last '/' that appears in the fragment because that's where the replacement span - // starts - if (isNestedModule) { - var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); - nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { - if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { - return moduleName.substr(moduleNameWithSeperator_1.length); - } - return moduleName; - }); - } - if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { - for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { - var visibleModule = _a[_i]; - if (!isNestedModule) { - nonRelativeModules.push(visibleModule.moduleName); - } - else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { - var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, /*exclude*/ undefined, /*include*/ ["./*"]); - if (nestedFiles) { - for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { - var f = nestedFiles_1[_b]; - f = ts.normalizePath(f); - var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); - nonRelativeModules.push(nestedModule); - } - } - } - } - } - return ts.deduplicate(nonRelativeModules); - } - function getTripleSlashReferenceCompletion(sourceFile, position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (!token) { + catch (e) { return undefined; } - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - if (!commentRanges || !commentRanges.length) { - return undefined; - } - var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); - if (!range) { - return undefined; - } - var completionInfo = { - /** - * We don't want the editor to offer any other completions, such as snippets, inside a comment. - */ - isGlobalCompletion: false, - isMemberCompletion: false, - /** - * The user may type in a path that doesn't yet exist, creating a "new identifier" - * with respect to the collection of identifiers the server is aware of. - */ - isNewIdentifierLocation: true, - entries: [] - }; - var text = sourceFile.text.substr(range.pos, position - range.pos); - var match = tripleSlashDirectiveFragmentRegex.exec(text); - if (match) { - var prefix = match[1]; - var kind = match[2]; - var toComplete = match[3]; - var scriptPath = ts.getDirectoryPath(sourceFile.path); - if (kind === "path") { - // Give completions for a relative path - var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, span_10, sourceFile.path); - } - else { - // Give completions based on the typings available - var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); - } - } - return completionInfo; } - function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { - if (result === void 0) { result = []; } - // Check for typings specified in compiler options - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - // Wrap in try catch because getEffectiveTypeRoots touches the filesystem - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch (e) { } - if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, root, span, result); + function addPotentialPackageNames(dependencies, result) { + if (dependencies) { + for (var dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { + result.push(dep); } } } - if (host.getDirectories) { - // Also get all @types typings installed in visible node_modules directories - for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { - var packageJson = _d[_c]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, typesDir, span, result); - } - } - return result; - } - function getCompletionEntriesFromDirectories(host, directory, span, result) { - if (host.getDirectories && tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { - var typeDirectory = directories_3[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - function findPackageJsons(currentDir) { - var paths = []; - var currentConfigPath; - while (true) { - currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_14 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_14) { - break; - } - currentDir = parent_14; - } - else { - break; - } - } - return paths; - } - function enumerateNodeModulesVisibleToScript(host, scriptPath) { - var result = []; - if (host.readFile && host.fileExists) { - for (var _i = 0, _a = findPackageJsons(scriptPath); _i < _a.length; _i++) { - var packageJson = _a[_i]; - var contents = tryReadingPackageJson(packageJson); - if (!contents) { - return; - } - var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); - var foundModuleNames = []; - // Provide completions for all non @types dependencies - for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { - var key = nodeModulesDependencyKeys_1[_b]; - addPotentialPackageNames(contents[key], foundModuleNames); - } - for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { - var moduleName = foundModuleNames_1[_c]; - var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName: moduleName, - moduleDir: moduleDir - }); - } - } - } - return result; - function tryReadingPackageJson(filePath) { - try { - var fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; - } - catch (e) { - return undefined; - } - } - function addPotentialPackageNames(dependencies, result) { - if (dependencies) { - for (var dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { - result.push(dep); - } - } - } - } - } - function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; - } - // Replace everything after the last directory seperator that appears - function getDirectoryFragmentTextSpan(text, textStart) { - var index = text.lastIndexOf(ts.directorySeparator); - var offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset }; - } - // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) - function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; - var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; - } - return false; - } - function normalizeAndPreserveTrailingSlash(path) { - return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); } } - Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function createCompletionEntryForModule(name, kind, replacementSpan) { + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; + } + // Replace everything after the last directory seperator that appears + function getDirectoryFragmentTextSpan(text, textStart) { + var index = text.lastIndexOf(ts.directorySeparator); + var offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset }; + } + // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) + function isPathRelativeToScript(path) { + if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; + var slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; + } + return false; + } + function normalizeAndPreserveTrailingSlash(path) { + return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); + } function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { // Compute all the completion symbols again. var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_3 = completionData.location; + var symbols = completionData.symbols, location_1 = completionData.location; // Find the symbol with the matching entry name. // 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(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_3) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_1) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_3, location_3, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), @@ -68764,12 +70193,12 @@ var ts; // Compute all the completion symbols again. var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_4 = completionData.location; + var symbols = completionData.symbols, location_2 = completionData.location; // Find the symbol with the matching entry name. // 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. - return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_4) === entryName ? s : undefined; }); + return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_2) === entryName ? s : undefined; }); } return undefined; } @@ -68800,9 +70229,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 284 /* JSDocTypeTag */: - case 282 /* JSDocParameterTag */: - case 283 /* JSDocReturnTag */: + case 287 /* JSDocTypeTag */: + case 285 /* JSDocParameterTag */: + case 286 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -68847,13 +70276,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_15 = contextToken.parent, kind = contextToken.kind; + var parent = contextToken.parent, kind = contextToken.kind; if (kind === 22 /* DotToken */) { - if (parent_15.kind === 177 /* PropertyAccessExpression */) { + if (parent.kind === 178 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_15.kind === 141 /* QualifiedName */) { + else if (parent.kind === 142 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -68864,13 +70293,27 @@ var ts; } } else if (sourceFile.languageVariant === 1 /* JSX */) { - if (kind === 26 /* LessThanToken */) { - isRightOfOpenTag = true; - location = contextToken; - } - else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 250 /* JsxClosingElement */) { - isStartingCloseTag = true; - location = contextToken; + switch (contextToken.parent.kind) { + case 251 /* JsxClosingElement */: + if (kind === 40 /* SlashToken */) { + isStartingCloseTag = true; + location = contextToken; + } + break; + case 193 /* BinaryExpression */: + if (!(contextToken.parent.left.flags & 32768 /* ThisNodeHasError */)) { + // It has a left-hand side, so we're not in an opening JSX tag. + break; + } + // fall through + case 249 /* JsxSelfClosingElement */: + case 248 /* JsxElement */: + case 250 /* JsxOpeningElement */: + if (kind === 26 /* LessThanToken */) { + isRightOfOpenTag = true; + location = contextToken; + } + break; } } } @@ -68917,7 +70360,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */ || node.kind === 177 /* PropertyAccessExpression */) { + if (node.kind === 70 /* Identifier */ || node.kind === 142 /* QualifiedName */ || node.kind === 178 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -68973,11 +70416,11 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 248 /* JsxSelfClosingElement */) || (jsxContainer.kind === 249 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 249 /* JsxSelfClosingElement */) || (jsxContainer.kind === 250 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element - attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + attrsType = typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); if (attrsType) { - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); + symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes.properties); isMemberCompletion = true; isNewIdentifierLocation = false; return true; @@ -69021,9 +70464,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 262 /* SourceFile */ || - scopeNode.kind === 194 /* TemplateExpression */ || - scopeNode.kind === 253 /* JsxExpression */ || + scopeNode.kind === 264 /* SourceFile */ || + scopeNode.kind === 195 /* TemplateExpression */ || + scopeNode.kind === 255 /* JsxExpression */ || ts.isStatement(scopeNode); } /// TODO filter meaning based on the current context @@ -69056,11 +70499,11 @@ var ts; return true; } if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 249 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 250 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 250 /* JsxClosingElement */ || contextToken.parent.kind === 248 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 247 /* JsxElement */; + if (contextToken.parent.kind === 251 /* JsxClosingElement */ || contextToken.parent.kind === 249 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 248 /* JsxElement */; } } return false; @@ -69070,40 +70513,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 25 /* CommaToken */: - return containingNodeKind === 179 /* CallExpression */ // func( a, | - || containingNodeKind === 150 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 180 /* NewExpression */ // new C(a, | - || containingNodeKind === 175 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 192 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 158 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 180 /* CallExpression */ // func( a, | + || containingNodeKind === 151 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 181 /* NewExpression */ // new C(a, | + || containingNodeKind === 176 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 193 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 159 /* FunctionType */; // var x: (s: string, list| case 18 /* OpenParenToken */: - return containingNodeKind === 179 /* CallExpression */ // func( | - || containingNodeKind === 150 /* Constructor */ // constructor( | - || containingNodeKind === 180 /* NewExpression */ // new C(a| - || containingNodeKind === 183 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 166 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 180 /* CallExpression */ // func( | + || containingNodeKind === 151 /* Constructor */ // constructor( | + || containingNodeKind === 181 /* NewExpression */ // new C(a| + || containingNodeKind === 184 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 167 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 20 /* OpenBracketToken */: - return containingNodeKind === 175 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 155 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 142 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + return containingNodeKind === 176 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 156 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 143 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 127 /* ModuleKeyword */: // module | case 128 /* NamespaceKeyword */: return true; case 22 /* DotToken */: - return containingNodeKind === 231 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 232 /* ModuleDeclaration */; // module A.| case 16 /* OpenBraceToken */: - return containingNodeKind === 227 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 228 /* ClassDeclaration */; // class A{ | case 57 /* EqualsToken */: - return containingNodeKind === 224 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 192 /* BinaryExpression */; // x = a| + return containingNodeKind === 225 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 193 /* BinaryExpression */; // x = a| case 13 /* TemplateHead */: - return containingNodeKind === 194 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 195 /* TemplateExpression */; // `aa ${| case 14 /* TemplateMiddle */: - return containingNodeKind === 203 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 204 /* TemplateSpan */; // `aa ${10} dd ${| case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: - return containingNodeKind === 147 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 148 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -69146,7 +70589,7 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 176 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 177 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; @@ -69156,7 +70599,7 @@ var ts; typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 172 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 173 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -69167,11 +70610,11 @@ var ts; // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 144 /* Parameter */) { + if (!canGetType && rootDeclaration.kind === 145 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 149 /* MethodDeclaration */ || rootDeclaration.parent.kind === 152 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 150 /* MethodDeclaration */ || rootDeclaration.parent.kind === 153 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -69213,9 +70656,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 239 /* NamedImports */ ? - 236 /* ImportDeclaration */ : - 242 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 240 /* NamedImports */ ? + 237 /* ImportDeclaration */ : + 243 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -69223,12 +70666,13 @@ var ts; } isMemberCompletion = true; isNewIdentifierLocation = false; - var exports; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); + if (!moduleSpecifierSymbol) { + symbols = ts.emptyArray; + return true; } - symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : ts.emptyArray; + var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); + symbols = filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements); return true; } /** @@ -69240,9 +70684,9 @@ var ts; switch (contextToken.kind) { case 16 /* OpenBraceToken */: // const x = { | case 25 /* CommaToken */: - var parent_16 = contextToken.parent; - if (parent_16 && (parent_16.kind === 176 /* ObjectLiteralExpression */ || parent_16.kind === 172 /* ObjectBindingPattern */)) { - return parent_16; + var parent = contextToken.parent; + if (parent && (parent.kind === 177 /* ObjectLiteralExpression */ || parent.kind === 173 /* ObjectBindingPattern */)) { + return parent; } break; } @@ -69259,8 +70703,8 @@ var ts; case 16 /* OpenBraceToken */: // import { | case 25 /* CommaToken */: switch (contextToken.parent.kind) { - case 239 /* NamedImports */: - case 243 /* NamedExports */: + case 240 /* NamedImports */: + case 244 /* NamedExports */: return contextToken.parent; } } @@ -69269,37 +70713,54 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_17 = contextToken.parent; + var parent = contextToken.parent; switch (contextToken.kind) { case 27 /* LessThanSlashToken */: case 40 /* SlashToken */: case 70 /* Identifier */: - case 251 /* JsxAttribute */: - case 252 /* JsxSpreadAttribute */: - if (parent_17 && (parent_17.kind === 248 /* JsxSelfClosingElement */ || parent_17.kind === 249 /* JsxOpeningElement */)) { - return parent_17; + case 253 /* JsxAttributes */: + case 252 /* JsxAttribute */: + case 254 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 249 /* JsxSelfClosingElement */ || parent.kind === 250 /* JsxOpeningElement */)) { + return parent; } - else if (parent_17.kind === 251 /* JsxAttribute */) { - return parent_17.parent; + else if (parent.kind === 252 /* JsxAttribute */) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + return parent.parent.parent; } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_17 && ((parent_17.kind === 251 /* JsxAttribute */) || (parent_17.kind === 252 /* JsxSpreadAttribute */))) { - return parent_17.parent; + if (parent && ((parent.kind === 252 /* JsxAttribute */) || (parent.kind === 254 /* JsxSpreadAttribute */))) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + return parent.parent.parent; } break; case 17 /* CloseBraceToken */: - if (parent_17 && - parent_17.kind === 253 /* JsxExpression */ && - parent_17.parent && - (parent_17.parent.kind === 251 /* JsxAttribute */)) { - return parent_17.parent.parent; + if (parent && + parent.kind === 255 /* JsxExpression */ && + parent.parent && parent.parent.kind === 252 /* JsxAttribute */) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + // each JsxAttribute can have initializer as JsxExpression + return parent.parent.parent.parent; } - if (parent_17 && parent_17.kind === 252 /* JsxSpreadAttribute */) { - return parent_17.parent; + if (parent && parent.kind === 254 /* JsxSpreadAttribute */) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + return parent.parent.parent; } break; } @@ -69308,16 +70769,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 226 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: return true; } return false; @@ -69329,66 +70790,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25 /* CommaToken */: - return containingNodeKind === 224 /* VariableDeclaration */ || - containingNodeKind === 225 /* VariableDeclarationList */ || - containingNodeKind === 206 /* VariableStatement */ || - containingNodeKind === 230 /* EnumDeclaration */ || + return containingNodeKind === 225 /* VariableDeclaration */ || + containingNodeKind === 226 /* VariableDeclarationList */ || + containingNodeKind === 207 /* VariableStatement */ || + containingNodeKind === 231 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 227 /* ClassDeclaration */ || - containingNodeKind === 197 /* ClassExpression */ || - containingNodeKind === 228 /* InterfaceDeclaration */ || - containingNodeKind === 173 /* ArrayBindingPattern */ || - containingNodeKind === 229 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 228 /* ClassDeclaration */ || + containingNodeKind === 198 /* ClassExpression */ || + containingNodeKind === 229 /* InterfaceDeclaration */ || + containingNodeKind === 174 /* ArrayBindingPattern */ || + containingNodeKind === 230 /* TypeAliasDeclaration */; // type Map, K, | case 22 /* DotToken */: - return containingNodeKind === 173 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 174 /* ArrayBindingPattern */; // var [.| case 55 /* ColonToken */: - return containingNodeKind === 174 /* BindingElement */; // var {x :html| + return containingNodeKind === 175 /* BindingElement */; // var {x :html| case 20 /* OpenBracketToken */: - return containingNodeKind === 173 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 174 /* ArrayBindingPattern */; // var [x| case 18 /* OpenParenToken */: - return containingNodeKind === 257 /* CatchClause */ || + return containingNodeKind === 259 /* CatchClause */ || isFunction(containingNodeKind); case 16 /* OpenBraceToken */: - return containingNodeKind === 230 /* EnumDeclaration */ || - containingNodeKind === 228 /* InterfaceDeclaration */ || - containingNodeKind === 161 /* TypeLiteral */; // const x : { | + return containingNodeKind === 231 /* EnumDeclaration */ || + containingNodeKind === 229 /* InterfaceDeclaration */ || + containingNodeKind === 162 /* TypeLiteral */; // const x : { | case 24 /* SemicolonToken */: - return containingNodeKind === 146 /* PropertySignature */ && + return containingNodeKind === 147 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 228 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 161 /* TypeLiteral */); // const x : { a; | + (contextToken.parent.parent.kind === 229 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 162 /* TypeLiteral */); // const x : { a; | case 26 /* LessThanToken */: - return containingNodeKind === 227 /* ClassDeclaration */ || - containingNodeKind === 197 /* ClassExpression */ || - containingNodeKind === 228 /* InterfaceDeclaration */ || - containingNodeKind === 229 /* TypeAliasDeclaration */ || + return containingNodeKind === 228 /* ClassDeclaration */ || + containingNodeKind === 198 /* ClassExpression */ || + containingNodeKind === 229 /* InterfaceDeclaration */ || + containingNodeKind === 230 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); case 114 /* StaticKeyword */: - return containingNodeKind === 147 /* PropertyDeclaration */; + return containingNodeKind === 148 /* PropertyDeclaration */; case 23 /* DotDotDotToken */: - return containingNodeKind === 144 /* Parameter */ || + return containingNodeKind === 145 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 173 /* ArrayBindingPattern */); // var [...z| + contextToken.parent.parent.kind === 174 /* ArrayBindingPattern */); // var [...z| case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: - return containingNodeKind === 144 /* Parameter */; + return containingNodeKind === 145 /* Parameter */; case 117 /* AsKeyword */: - return containingNodeKind === 240 /* ImportSpecifier */ || - containingNodeKind === 244 /* ExportSpecifier */ || - containingNodeKind === 238 /* NamespaceImport */; + return containingNodeKind === 241 /* ImportSpecifier */ || + containingNodeKind === 245 /* ExportSpecifier */ || + containingNodeKind === 239 /* NamespaceImport */; case 74 /* ClassKeyword */: case 82 /* EnumKeyword */: case 108 /* InterfaceKeyword */: case 88 /* FunctionKeyword */: case 103 /* VarKeyword */: case 124 /* GetKeyword */: - case 133 /* SetKeyword */: + case 134 /* SetKeyword */: case 90 /* ImportKeyword */: case 109 /* LetKeyword */: case 75 /* ConstKeyword */: case 115 /* YieldKeyword */: - case 136 /* TypeKeyword */: + case 137 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -69436,13 +70897,13 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_46 = element.propertyName || element.name; - existingImportsOrExports[name_46.text] = true; + var name = element.propertyName || element.name; + existingImportsOrExports.set(name.text, true); } - if (!ts.someProperties(existingImportsOrExports)) { + if (existingImportsOrExports.size === 0) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); } - return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports[e.name]; }); + return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports.get(e.name); }); } /** * Filters out completion suggestions for named imports or exports. @@ -69458,12 +70919,12 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 258 /* PropertyAssignment */ && - m.kind !== 259 /* ShorthandPropertyAssignment */ && - m.kind !== 174 /* BindingElement */ && - m.kind !== 149 /* MethodDeclaration */ && - m.kind !== 151 /* GetAccessor */ && - m.kind !== 152 /* SetAccessor */) { + if (m.kind !== 260 /* PropertyAssignment */ && + m.kind !== 261 /* ShorthandPropertyAssignment */ && + m.kind !== 175 /* BindingElement */ && + m.kind !== 150 /* MethodDeclaration */ && + m.kind !== 152 /* GetAccessor */ && + m.kind !== 153 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -69471,7 +70932,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 174 /* BindingElement */ && m.propertyName) { + if (m.kind === 175 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 70 /* Identifier */) { existingName = m.propertyName.text; @@ -69483,9 +70944,9 @@ var ts; // things like '__proto__' are not filtered out. existingName = m.name.text; } - existingMemberNames[existingName] = true; + existingMemberNames.set(existingName, true); } - return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames[m.name]; }); + return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames.get(m.name); }); } /** * Filters out completion suggestions from 'symbols' according to existing JSX attributes. @@ -69501,11 +70962,11 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 251 /* JsxAttribute */) { - seenNames[attr.name.text] = true; + if (attr.kind === 252 /* JsxAttribute */) { + seenNames.set(attr.name.text, true); } } - return ts.filter(symbols, function (a) { return !seenNames[a.name]; }); + return ts.filter(symbols, function (a) { return !seenNames.get(a.name); }); } } /** @@ -69551,7 +71012,7 @@ var ts; } // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 71 /* FirstKeyword */; i <= 140 /* LastKeyword */; i++) { + for (var i = 71 /* FirstKeyword */; i <= 141 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -69603,6 +71064,15 @@ var ts; catch (e) { } return undefined; } + function isEqualityExpression(node) { + return ts.isBinaryExpression(node) && isEqualityOperatorKind(node.operatorToken.kind); + } + function isEqualityOperatorKind(kind) { + return kind == 31 /* EqualsEqualsToken */ || + kind === 32 /* ExclamationEqualsToken */ || + kind === 33 /* EqualsEqualsEqualsToken */ || + kind === 34 /* ExclamationEqualsEqualsToken */; + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -69612,534 +71082,519 @@ var ts; (function (DocumentHighlights) { function getDocumentHighlights(typeChecker, cancellationToken, sourceFile, position, sourceFilesToSearch) { var node = ts.getTouchingWord(sourceFile, position); + return node && (getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) || getSyntacticDocumentHighlights(node, sourceFile)); + } + DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + function getHighlightSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var end = node.getEnd(); + return { + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(start, end), + kind: ts.HighlightSpanKind.none + }; + } + function getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) { + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch); + return referencedSymbols && convertReferencedSymbols(referencedSymbols); + } + function convertReferencedSymbols(referencedSymbols) { + var fileNameToDocumentHighlights = ts.createMap(); + var result = []; + for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { + var referencedSymbol = referencedSymbols_1[_i]; + for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { + var referenceEntry = _b[_a]; + var fileName = referenceEntry.fileName; + var documentHighlights = fileNameToDocumentHighlights.get(fileName); + if (!documentHighlights) { + documentHighlights = { fileName: fileName, highlightSpans: [] }; + fileNameToDocumentHighlights.set(fileName, documentHighlights); + result.push(documentHighlights); + } + documentHighlights.highlightSpans.push({ + textSpan: referenceEntry.textSpan, + kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference + }); + } + } + return result; + } + function getSyntacticDocumentHighlights(node, sourceFile) { + var highlightSpans = getHighlightSpans(node, sourceFile); + if (!highlightSpans || highlightSpans.length === 0) { + return undefined; + } + return [{ fileName: sourceFile.fileName, highlightSpans: highlightSpans }]; + } + // returns true if 'node' is defined and has a matching 'kind'. + function hasKind(node, kind) { + return node !== undefined && node.kind === kind; + } + // Null-propagating 'parent' function. + function parent(node) { + return node && node.parent; + } + function getHighlightSpans(node, sourceFile) { if (!node) { return undefined; } - return getSemanticDocumentHighlights(node) || getSyntacticDocumentHighlights(node); - function getHighlightSpanForNode(node) { - var start = node.getStart(); - var end = node.getEnd(); - return { - fileName: sourceFile.fileName, - textSpan: ts.createTextSpanFromBounds(start, end), - kind: ts.HighlightSpanKind.none - }; + switch (node.kind) { + case 89 /* IfKeyword */: + case 81 /* ElseKeyword */: + if (hasKind(node.parent, 210 /* IfStatement */)) { + return getIfElseOccurrences(node.parent, sourceFile); + } + break; + case 95 /* ReturnKeyword */: + if (hasKind(node.parent, 218 /* ReturnStatement */)) { + return highlightSpans(getReturnOccurrences(node.parent)); + } + break; + case 99 /* ThrowKeyword */: + if (hasKind(node.parent, 222 /* ThrowStatement */)) { + return highlightSpans(getThrowOccurrences(node.parent)); + } + break; + case 101 /* TryKeyword */: + case 73 /* CatchKeyword */: + case 86 /* FinallyKeyword */: + var tryStatement = node.kind === 73 /* CatchKeyword */ ? parent(parent(node)) : parent(node); + if (hasKind(tryStatement, 223 /* TryStatement */)) { + return highlightSpans(getTryCatchFinallyOccurrences(tryStatement, sourceFile)); + } + break; + case 97 /* SwitchKeyword */: + if (hasKind(node.parent, 220 /* SwitchStatement */)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent)); + } + break; + case 72 /* CaseKeyword */: + case 78 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 220 /* SwitchStatement */)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent.parent.parent)); + } + break; + case 71 /* BreakKeyword */: + case 76 /* ContinueKeyword */: + if (hasKind(node.parent, 217 /* BreakStatement */) || hasKind(node.parent, 216 /* ContinueStatement */)) { + return highlightSpans(getBreakOrContinueStatementOccurrences(node.parent)); + } + break; + case 87 /* ForKeyword */: + if (hasKind(node.parent, 213 /* ForStatement */) || + hasKind(node.parent, 214 /* ForInStatement */) || + hasKind(node.parent, 215 /* ForOfStatement */)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case 105 /* WhileKeyword */: + case 80 /* DoKeyword */: + if (hasKind(node.parent, 212 /* WhileStatement */) || hasKind(node.parent, 211 /* DoStatement */)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case 122 /* ConstructorKeyword */: + if (hasKind(node.parent, 151 /* Constructor */)) { + return highlightSpans(getConstructorOccurrences(node.parent)); + } + break; + case 124 /* GetKeyword */: + case 134 /* SetKeyword */: + if (hasKind(node.parent, 152 /* GetAccessor */) || hasKind(node.parent, 153 /* SetAccessor */)) { + return highlightSpans(getGetAndSetOccurrences(node.parent)); + } + break; + default: + if (ts.isModifierKind(node.kind) && node.parent && + (ts.isDeclaration(node.parent) || node.parent.kind === 207 /* VariableStatement */)) { + return highlightSpans(getModifierOccurrences(node.kind, node.parent)); + } } - function getSemanticDocumentHighlights(node) { - if (node.kind === 70 /* Identifier */ || - node.kind === 98 /* ThisKeyword */ || - node.kind === 167 /* ThisType */ || - node.kind === 96 /* SuperKeyword */ || - node.kind === 9 /* StringLiteral */ || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/ false); - return convertReferencedSymbols(referencedSymbols); - } - return undefined; - function convertReferencedSymbols(referencedSymbols) { - if (!referencedSymbols) { - return undefined; - } - var fileNameToDocumentHighlights = ts.createMap(); - var result = []; - for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { - var referencedSymbol = referencedSymbols_1[_i]; - for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { - var referenceEntry = _b[_a]; - var fileName = referenceEntry.fileName; - var documentHighlights = fileNameToDocumentHighlights[fileName]; - if (!documentHighlights) { - documentHighlights = { fileName: fileName, highlightSpans: [] }; - fileNameToDocumentHighlights[fileName] = documentHighlights; - result.push(documentHighlights); - } - documentHighlights.highlightSpans.push({ - textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference - }); - } - } - return result; - } + function highlightSpans(nodes) { + return nodes && nodes.map(function (node) { return getHighlightSpanForNode(node, sourceFile); }); } - function getSyntacticDocumentHighlights(node) { - var fileName = sourceFile.fileName; - var highlightSpans = getHighlightSpans(node); - if (!highlightSpans || highlightSpans.length === 0) { - return undefined; + } + /** + * Aggregates all throw-statements within this node *without* crossing + * into function boundaries and try-blocks with catch-clauses. + */ + function aggregateOwnedThrowStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 222 /* ThrowStatement */) { + statementAccumulator.push(node); } - return [{ fileName: fileName, highlightSpans: highlightSpans }]; - // returns true if 'node' is defined and has a matching 'kind'. - function hasKind(node, kind) { - return node !== undefined && node.kind === kind; - } - // Null-propagating 'parent' function. - function parent(node) { - return node && node.parent; - } - function getHighlightSpans(node) { - if (node) { - switch (node.kind) { - case 89 /* IfKeyword */: - case 81 /* ElseKeyword */: - if (hasKind(node.parent, 209 /* IfStatement */)) { - return getIfElseOccurrences(node.parent); - } - break; - case 95 /* ReturnKeyword */: - if (hasKind(node.parent, 217 /* ReturnStatement */)) { - return getReturnOccurrences(node.parent); - } - break; - case 99 /* ThrowKeyword */: - if (hasKind(node.parent, 221 /* ThrowStatement */)) { - return getThrowOccurrences(node.parent); - } - break; - case 73 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 222 /* TryStatement */)) { - return getTryCatchFinallyOccurrences(node.parent.parent); - } - break; - case 101 /* TryKeyword */: - case 86 /* FinallyKeyword */: - if (hasKind(parent(node), 222 /* TryStatement */)) { - return getTryCatchFinallyOccurrences(node.parent); - } - break; - case 97 /* SwitchKeyword */: - if (hasKind(node.parent, 219 /* SwitchStatement */)) { - return getSwitchCaseDefaultOccurrences(node.parent); - } - break; - case 72 /* CaseKeyword */: - case 78 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 219 /* SwitchStatement */)) { - return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); - } - break; - case 71 /* BreakKeyword */: - case 76 /* ContinueKeyword */: - if (hasKind(node.parent, 216 /* BreakStatement */) || hasKind(node.parent, 215 /* ContinueStatement */)) { - return getBreakOrContinueStatementOccurrences(node.parent); - } - break; - case 87 /* ForKeyword */: - if (hasKind(node.parent, 212 /* ForStatement */) || - hasKind(node.parent, 213 /* ForInStatement */) || - hasKind(node.parent, 214 /* ForOfStatement */)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 105 /* WhileKeyword */: - case 80 /* DoKeyword */: - if (hasKind(node.parent, 211 /* WhileStatement */) || hasKind(node.parent, 210 /* DoStatement */)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 122 /* ConstructorKeyword */: - if (hasKind(node.parent, 150 /* Constructor */)) { - return getConstructorOccurrences(node.parent); - } - break; - case 124 /* GetKeyword */: - case 133 /* SetKeyword */: - if (hasKind(node.parent, 151 /* GetAccessor */) || hasKind(node.parent, 152 /* SetAccessor */)) { - return getGetAndSetOccurrences(node.parent); - } - break; - default: - if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 206 /* VariableStatement */)) { - return getModifierOccurrences(node.kind, node.parent); - } - } - } - return undefined; - } - /** - * Aggregates all throw-statements within this node *without* crossing - * into function boundaries and try-blocks with catch-clauses. - */ - function aggregateOwnedThrowStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 221 /* ThrowStatement */) { - statementAccumulator.push(node); - } - else if (node.kind === 222 /* TryStatement */) { - var tryStatement = node; - if (tryStatement.catchClause) { - aggregate(tryStatement.catchClause); - } - else { - // Exceptions thrown within a try block lacking a catch clause - // are "owned" in the current context. - aggregate(tryStatement.tryBlock); - } - if (tryStatement.finallyBlock) { - aggregate(tryStatement.finallyBlock); - } - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, aggregate); - } - } - } - /** - * For lack of a better name, this function takes a throw statement and returns the - * nearest ancestor that is a try-block (whose try statement has a catch clause), - * function-block, or source file. - */ - function getThrowStatementOwner(throwStatement) { - var child = throwStatement; - while (child.parent) { - var parent_18 = child.parent; - if (ts.isFunctionBlock(parent_18) || parent_18.kind === 262 /* SourceFile */) { - return parent_18; - } - // 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_18.kind === 222 /* TryStatement */) { - var tryStatement = parent_18; - if (tryStatement.tryBlock === child && tryStatement.catchClause) { - return child; - } - } - child = parent_18; - } - return undefined; - } - function aggregateAllBreakAndContinueStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 216 /* BreakStatement */ || node.kind === 215 /* ContinueStatement */) { - statementAccumulator.push(node); - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, aggregate); - } - } - } - function ownsBreakOrContinueStatement(owner, statement) { - var actualOwner = getBreakOrContinueOwner(statement); - return actualOwner && actualOwner === owner; - } - function getBreakOrContinueOwner(statement) { - for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { - switch (node_2.kind) { - case 219 /* SwitchStatement */: - if (statement.kind === 215 /* ContinueStatement */) { - continue; - } - // Fall through. - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 211 /* WhileStatement */: - case 210 /* DoStatement */: - if (!statement.label || isLabeledBy(node_2, statement.label.text)) { - return node_2; - } - break; - default: - // Don't cross function boundaries. - if (ts.isFunctionLike(node_2)) { - return undefined; - } - break; - } - } - return undefined; - } - function getModifierOccurrences(modifier, declaration) { - 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 === 227 /* ClassDeclaration */ || - container.kind === 197 /* ClassExpression */ || - (declaration.kind === 144 /* Parameter */ && hasKind(container, 150 /* Constructor */)))) { - return undefined; - } - } - else if (modifier === 114 /* StaticKeyword */) { - if (!(container.kind === 227 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */)) { - return undefined; - } - } - else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { - if (!(container.kind === 232 /* ModuleBlock */ || container.kind === 262 /* SourceFile */)) { - return undefined; - } - } - else if (modifier === 116 /* AbstractKeyword */) { - if (!(container.kind === 227 /* ClassDeclaration */ || declaration.kind === 227 /* ClassDeclaration */)) { - return undefined; - } + else if (node.kind === 223 /* TryStatement */) { + var tryStatement = node; + if (tryStatement.catchClause) { + aggregate(tryStatement.catchClause); } else { - // unsupported modifier - return undefined; - } - var keywords = []; - var modifierFlag = getFlagFromModifier(modifier); - var nodes; - switch (container.kind) { - case 232 /* ModuleBlock */: - case 262 /* SourceFile */: - // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 128 /* Abstract */) { - nodes = declaration.members.concat(declaration); - } - else { - nodes = container.statements; - } - break; - case 150 /* Constructor */: - nodes = container.parameters.concat(container.parent.members); - break; - case 227 /* ClassDeclaration */: - case 197 /* 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 & 28 /* AccessibilityModifier */) { - var constructor = ts.forEach(container.members, function (member) { - return member.kind === 150 /* Constructor */ && member; - }); - if (constructor) { - nodes = nodes.concat(constructor.parameters); - } - } - else if (modifierFlag & 128 /* Abstract */) { - nodes = nodes.concat(container); - } - break; - default: - ts.Debug.fail("Invalid container kind."); - } - ts.forEach(nodes, function (node) { - if (ts.getModifierFlags(node) & modifierFlag) { - ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - function getFlagFromModifier(modifier) { - switch (modifier) { - case 113 /* PublicKeyword */: - return 4 /* Public */; - case 111 /* PrivateKeyword */: - return 8 /* Private */; - case 112 /* ProtectedKeyword */: - return 16 /* Protected */; - case 114 /* StaticKeyword */: - return 32 /* Static */; - case 83 /* ExportKeyword */: - return 1 /* Export */; - case 123 /* DeclareKeyword */: - return 2 /* Ambient */; - case 116 /* AbstractKeyword */: - return 128 /* Abstract */; - default: - ts.Debug.fail(); - } - } - } - function pushKeywordIf(keywordList, token) { - var expected = []; - for (var _i = 2; _i < arguments.length; _i++) { - expected[_i - 2] = arguments[_i]; - } - if (token && ts.contains(expected, token.kind)) { - keywordList.push(token); - return true; - } - return false; - } - function getGetAndSetOccurrences(accessorDeclaration) { - var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 151 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 152 /* 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, 124 /* GetKeyword */, 133 /* SetKeyword */); }); - } - } - } - function getConstructorOccurrences(constructorDeclaration) { - var declarations = constructorDeclaration.symbol.getDeclarations(); - var keywords = []; - ts.forEach(declarations, function (declaration) { - ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 122 /* ConstructorKeyword */); - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getLoopBreakContinueOccurrences(loopNode) { - var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87 /* ForKeyword */, 105 /* WhileKeyword */, 80 /* DoKeyword */)) { - // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 210 /* DoStatement */) { - var loopTokens = loopNode.getChildren(); - for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { - break; - } - } - } - } - var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */, 76 /* ContinueKeyword */); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { - var owner = getBreakOrContinueOwner(breakOrContinueStatement); - if (owner) { - switch (owner.kind) { - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 210 /* DoStatement */: - case 211 /* WhileStatement */: - return getLoopBreakContinueOccurrences(owner); - case 219 /* SwitchStatement */: - return getSwitchCaseDefaultOccurrences(owner); - } - } - return undefined; - } - function getSwitchCaseDefaultOccurrences(switchStatement) { - var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 97 /* 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(), 72 /* CaseKeyword */, 78 /* DefaultKeyword */); - var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */); - } - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getTryCatchFinallyOccurrences(tryStatement) { - var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 101 /* TryKeyword */); - if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73 /* CatchKeyword */); + // Exceptions thrown within a try block lacking a catch clause + // are "owned" in the current context. + aggregate(tryStatement.tryBlock); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 86 /* FinallyKeyword */); + aggregate(tryStatement.finallyBlock); } - return ts.map(keywords, getHighlightSpanForNode); } - function getThrowOccurrences(throwStatement) { - var owner = getThrowStatementOwner(throwStatement); - if (!owner) { - return undefined; - } - var keywords = []; - ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* 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(), 95 /* ReturnKeyword */); - }); - } - return ts.map(keywords, getHighlightSpanForNode); - } - 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, 205 /* Block */))) { - return undefined; - } - var keywords = []; - ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); - }); - // Include 'throw' statements that do not occur within a try block. - ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* 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, 209 /* 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], 89 /* 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], 81 /* ElseKeyword */)) { - break; - } - } - if (!hasKind(ifStatement.elseStatement, 209 /* IfStatement */)) { - break; - } - ifStatement = ifStatement.elseStatement; - } - var result = []; - // 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 === 81 /* ElseKeyword */ && i < keywords.length - 1) { - var elseKeyword = keywords[i]; - var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. - var shouldCombindElseAndIf = true; - // Avoid recalculating getStart() by iterating backwards. - for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { - if (!ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { - shouldCombindElseAndIf = false; - break; - } - } - if (shouldCombindElseAndIf) { - result.push({ - fileName: fileName, - textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: ts.HighlightSpanKind.reference - }); - i++; // skip the next keyword - continue; - } - } - // Ordinary case: just highlight the keyword. - result.push(getHighlightSpanForNode(keywords[i])); - } - return result; + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); } } } - DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + /** + * For lack of a better name, this function takes a throw statement and returns the + * nearest ancestor that is a try-block (whose try statement has a catch clause), + * function-block, or source file. + */ + function getThrowStatementOwner(throwStatement) { + var child = throwStatement; + while (child.parent) { + var parent_2 = child.parent; + if (ts.isFunctionBlock(parent_2) || parent_2.kind === 264 /* SourceFile */) { + return parent_2; + } + // 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_2.kind === 223 /* TryStatement */) { + var tryStatement = parent_2; + if (tryStatement.tryBlock === child && tryStatement.catchClause) { + return child; + } + } + child = parent_2; + } + return undefined; + } + function aggregateAllBreakAndContinueStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 217 /* BreakStatement */ || node.kind === 216 /* ContinueStatement */) { + statementAccumulator.push(node); + } + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); + } + } + } + function ownsBreakOrContinueStatement(owner, statement) { + var actualOwner = getBreakOrContinueOwner(statement); + return actualOwner && actualOwner === owner; + } + function getBreakOrContinueOwner(statement) { + for (var node = statement.parent; node; node = node.parent) { + switch (node.kind) { + case 220 /* SwitchStatement */: + if (statement.kind === 216 /* ContinueStatement */) { + continue; + } + // Fall through. + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 212 /* WhileStatement */: + case 211 /* DoStatement */: + if (!statement.label || isLabeledBy(node, statement.label.text)) { + return node; + } + break; + default: + // Don't cross function boundaries. + if (ts.isFunctionLike(node)) { + return undefined; + } + break; + } + } + return undefined; + } + function getModifierOccurrences(modifier, declaration) { + 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 === 228 /* ClassDeclaration */ || + container.kind === 198 /* ClassExpression */ || + (declaration.kind === 145 /* Parameter */ && hasKind(container, 151 /* Constructor */)))) { + return undefined; + } + } + else if (modifier === 114 /* StaticKeyword */) { + if (!(container.kind === 228 /* ClassDeclaration */ || container.kind === 198 /* ClassExpression */)) { + return undefined; + } + } + else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { + if (!(container.kind === 233 /* ModuleBlock */ || container.kind === 264 /* SourceFile */)) { + return undefined; + } + } + else if (modifier === 116 /* AbstractKeyword */) { + if (!(container.kind === 228 /* ClassDeclaration */ || declaration.kind === 228 /* ClassDeclaration */)) { + return undefined; + } + } + else { + // unsupported modifier + return undefined; + } + var keywords = []; + var modifierFlag = getFlagFromModifier(modifier); + var nodes; + switch (container.kind) { + case 233 /* ModuleBlock */: + case 264 /* SourceFile */: + // Container is either a class declaration or the declaration is a classDeclaration + if (modifierFlag & 128 /* Abstract */) { + nodes = declaration.members.concat(declaration); + } + else { + nodes = container.statements; + } + break; + case 151 /* Constructor */: + nodes = container.parameters.concat(container.parent.members); + break; + case 228 /* ClassDeclaration */: + case 198 /* 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 & 28 /* AccessibilityModifier */) { + var constructor = ts.forEach(container.members, function (member) { + return member.kind === 151 /* Constructor */ && member; + }); + if (constructor) { + nodes = nodes.concat(constructor.parameters); + } + } + else if (modifierFlag & 128 /* Abstract */) { + nodes = nodes.concat(container); + } + break; + default: + ts.Debug.fail("Invalid container kind."); + } + ts.forEach(nodes, function (node) { + if (ts.getModifierFlags(node) & modifierFlag) { + ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); + } + }); + return keywords; + function getFlagFromModifier(modifier) { + switch (modifier) { + case 113 /* PublicKeyword */: + return 4 /* Public */; + case 111 /* PrivateKeyword */: + return 8 /* Private */; + case 112 /* ProtectedKeyword */: + return 16 /* Protected */; + case 114 /* StaticKeyword */: + return 32 /* Static */; + case 83 /* ExportKeyword */: + return 1 /* Export */; + case 123 /* DeclareKeyword */: + return 2 /* Ambient */; + case 116 /* AbstractKeyword */: + return 128 /* Abstract */; + default: + ts.Debug.fail(); + } + } + } + function pushKeywordIf(keywordList, token) { + var expected = []; + for (var _i = 2; _i < arguments.length; _i++) { + expected[_i - 2] = arguments[_i]; + } + if (token && ts.contains(expected, token.kind)) { + keywordList.push(token); + return true; + } + return false; + } + function getGetAndSetOccurrences(accessorDeclaration) { + var keywords = []; + tryPushAccessorKeyword(accessorDeclaration.symbol, 152 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 153 /* SetAccessor */); + return keywords; + function tryPushAccessorKeyword(accessorSymbol, accessorKind) { + var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); + if (accessor) { + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124 /* GetKeyword */, 134 /* SetKeyword */); }); + } + } + } + function getConstructorOccurrences(constructorDeclaration) { + var declarations = constructorDeclaration.symbol.getDeclarations(); + var keywords = []; + ts.forEach(declarations, function (declaration) { + ts.forEach(declaration.getChildren(), function (token) { + return pushKeywordIf(keywords, token, 122 /* ConstructorKeyword */); + }); + }); + return keywords; + } + function getLoopBreakContinueOccurrences(loopNode) { + var keywords = []; + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87 /* ForKeyword */, 105 /* WhileKeyword */, 80 /* DoKeyword */)) { + // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. + if (loopNode.kind === 211 /* DoStatement */) { + var loopTokens = loopNode.getChildren(); + for (var i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { + break; + } + } + } + } + var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(loopNode, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */, 76 /* ContinueKeyword */); + } + }); + return keywords; + } + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { + var owner = getBreakOrContinueOwner(breakOrContinueStatement); + if (owner) { + switch (owner.kind) { + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + return getLoopBreakContinueOccurrences(owner); + case 220 /* SwitchStatement */: + return getSwitchCaseDefaultOccurrences(owner); + } + } + return undefined; + } + function getSwitchCaseDefaultOccurrences(switchStatement) { + var keywords = []; + pushKeywordIf(keywords, switchStatement.getFirstToken(), 97 /* 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(), 72 /* CaseKeyword */, 78 /* DefaultKeyword */); + var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(switchStatement, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */); + } + }); + }); + return keywords; + } + function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { + var keywords = []; + pushKeywordIf(keywords, tryStatement.getFirstToken(), 101 /* TryKeyword */); + if (tryStatement.catchClause) { + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73 /* CatchKeyword */); + } + if (tryStatement.finallyBlock) { + var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 86 /* FinallyKeyword */); + } + return keywords; + } + function getThrowOccurrences(throwStatement) { + var owner = getThrowStatementOwner(throwStatement); + if (!owner) { + return undefined; + } + var keywords = []; + ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* 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(), 95 /* ReturnKeyword */); + }); + } + return keywords; + } + 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, 206 /* Block */))) { + return undefined; + } + var keywords = []; + ts.forEachReturnStatement(func.body, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); + }); + // Include 'throw' statements that do not occur within a try block. + ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* ThrowKeyword */); + }); + return keywords; + } + function getIfElseOccurrences(ifStatement, sourceFile) { + var keywords = []; + // Traverse upwards through all parent if-statements linked by their else-branches. + while (hasKind(ifStatement.parent, 210 /* 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], 89 /* 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], 81 /* ElseKeyword */)) { + break; + } + } + if (!hasKind(ifStatement.elseStatement, 210 /* IfStatement */)) { + break; + } + ifStatement = ifStatement.elseStatement; + } + var result = []; + // 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 === 81 /* ElseKeyword */ && i < keywords.length - 1) { + var elseKeyword = keywords[i]; + var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. + var shouldCombindElseAndIf = true; + // Avoid recalculating getStart() by iterating backwards. + for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { + if (!ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { + shouldCombindElseAndIf = false; + break; + } + } + if (shouldCombindElseAndIf) { + result.push({ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), + kind: ts.HighlightSpanKind.reference + }); + i++; // skip the next keyword + continue; + } + } + // Ordinary case: just highlight the keyword. + result.push(getHighlightSpanForNode(keywords[i], sourceFile)); + } + return result; + } /** * Whether or not a 'node' is preceded by a label of the given string. * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 220 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 221 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -70160,15 +71615,15 @@ var ts; return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + "|" + settings.allowJs + "|" + settings.baseUrl + "|" + JSON.stringify(settings.typeRoots) + "|" + JSON.stringify(settings.rootDirs) + "|" + JSON.stringify(settings.paths); } function getBucketForCompilationSettings(key, createIfMissing) { - var bucket = buckets[key]; + var bucket = buckets.get(key); if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(); + buckets.set(key, bucket = ts.createFileMap()); } return bucket; } function reportStats() { - var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { - var entries = buckets[name]; + var bucketInfoArray = ts.arrayFrom(buckets.keys()).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { + var entries = buckets.get(name); var sourceFiles = []; entries.forEachValue(function (key, entry) { sourceFiles.push({ @@ -70266,57 +71721,30 @@ var ts; (function (ts) { var FindAllReferences; (function (FindAllReferences) { - function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments) { + function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments, isForRename) { var node = ts.getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); - if (node === sourceFile) { - return undefined; - } - switch (node.kind) { - case 8 /* NumericLiteral */: - if (!ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - break; - } - // Fallthrough - case 70 /* Identifier */: - case 98 /* ThisKeyword */: - // case SyntaxKind.SuperKeyword: TODO:GH#9268 - case 122 /* ConstructorKeyword */: - case 9 /* StringLiteral */: - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, /*implementations*/ false); - } - return undefined; + return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename); } FindAllReferences.findReferencedSymbols = findReferencedSymbols; - function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, implementations) { + function convertReferences(referenceSymbols) { + return referenceSymbols && ts.flatMap(referenceSymbols, function (r) { return r.references; }); + } + FindAllReferences.convertReferences = convertReferences; + function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename, implementations) { if (!implementations) { - // Labels - if (ts.isLabelName(node)) { - if (ts.isJumpStatementTarget(node)) { - var labelDefinition = ts.getTargetLabel(node.parent, node.text); - // if we have a label definition, look within its statement for references, if not, then - // the label is undefined and we have no results.. - return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; - } - else { - // it is a label definition and not a target, search within the parent labeledStatement - return getLabelReferencesInNode(node.parent, node); - } - } - if (ts.isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles); - } - if (node.kind === 96 /* SuperKeyword */) { - return getReferencesForSuperKeyword(node); + var special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken); + if (special) { + return special; } } // `getSymbolAtLocation` normally returns the symbol of the class when given the constructor keyword, // so we have to specify that we want the constructor symbol. var symbol = typeChecker.getSymbolAtLocation(node); - if (!implementations && !symbol && node.kind === 9 /* StringLiteral */) { - return getReferencesForStringLiteral(node, sourceFiles); - } // Could not find a symbol e.g. unknown identifier if (!symbol) { + if (!implementations && node.kind === 9 /* StringLiteral */) { + return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); + } // Can't have references to something that we have no symbol for. return undefined; } @@ -70325,1040 +71753,1120 @@ var ts; if (!declarations || !declarations.length) { return undefined; } - var result; + var _a = followAliases(symbol, node, typeChecker, isForRename), aliasedSymbol = _a.symbol, shorthandModuleSymbol = _a.shorthandModuleSymbol; + symbol = aliasedSymbol; + // Build the set of symbols to search for, initially it has only the current symbol + var searchSymbols = populateSearchSymbolSet(symbol, node, typeChecker, implementations); + if (shorthandModuleSymbol) { + searchSymbols.push(shorthandModuleSymbol); + } // Compute the meaning from the location and the symbol it references var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), declarations); + var result = []; + // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. + var symbolToIndex = []; + var inheritsFromCache = ts.createMap(); // 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); - // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. - var symbolToIndex = []; if (scope) { - result = []; - getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + getRefs(scope, declaredName); } else { - var internedName = getInternedName(symbol, node); - for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { - var sourceFile = sourceFiles_8[_i]; + var isDefault = ts.isExportDefaultSymbol(symbol); + var internedName = isDefault ? symbol.valueDeclaration.localSymbol.name : getInternedName(symbol, node); + for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { + var sourceFile = sourceFiles_5[_i]; cancellationToken.throwIfCancellationRequested(); - var nameTable = ts.getNameTable(sourceFile); - if (nameTable[internedName] !== undefined) { - result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + var searchName = (isDefault ? getDefaultImportName(symbol, sourceFile, typeChecker) : undefined) || + (sourceFileHasName(sourceFile, internedName) ? declaredName : undefined); + if (searchName !== undefined) { + getRefs(sourceFile, searchName); } } } return result; - function getDefinition(symbol) { - var info = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node); - var name = ts.map(info.displayParts, function (p) { return p.text; }).join(""); - var declarations = symbol.declarations; - if (!declarations || declarations.length === 0) { - return undefined; - } - return { - containerKind: "", - containerName: "", - name: name, - kind: info.symbolKind, - fileName: declarations[0].getSourceFile().fileName, - textSpan: ts.createTextSpan(declarations[0].getStart(), 0), - displayParts: info.displayParts - }; + function getRefs(scope, searchName) { + getReferencesInNode(scope, symbol, searchName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache); } - function getAliasSymbolForPropertyNameSymbol(symbol, location) { - if (symbol.flags & 8388608 /* Alias */) { - // Default import get alias - var defaultImport = ts.getDeclarationOfKind(symbol, 237 /* ImportClause */); - if (defaultImport) { - return typeChecker.getAliasedSymbol(symbol); - } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 240 /* ImportSpecifier */ || - declaration.kind === 244 /* ExportSpecifier */) ? declaration : undefined; }); - if (importOrExportSpecifier && - // export { a } - (!importOrExportSpecifier.propertyName || - // export {a as class } where a is location - importOrExportSpecifier.propertyName === location)) { - // If Import specifier -> get alias - // else Export specifier -> get local target - return importOrExportSpecifier.kind === 240 /* ImportSpecifier */ ? - typeChecker.getAliasedSymbol(symbol) : - typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); - } + } + FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; + /** getReferencedSymbols for special node kinds. */ + function getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken) { + if (ts.isTypeKeyword(node.kind)) { + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + } + // Labels + if (ts.isLabelName(node)) { + if (ts.isJumpStatementTarget(node)) { + var labelDefinition = ts.getTargetLabel(node.parent, node.text); + // if we have a label definition, look within its statement for references, if not, then + // the label is undefined and we have no results.. + return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, cancellationToken); } + else { + // it is a label definition and not a target, search within the parent labeledStatement + return getLabelReferencesInNode(node.parent, node, cancellationToken); + } + } + if (ts.isThis(node)) { + return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); + } + if (node.kind === 96 /* SuperKeyword */) { + return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); + } + return undefined; + } + /** + * Follows aliases to get to the original declaration of a symbol. + * For a shorthand ambient module, we don't follow the alias to it, but we will need to add it to the set of search symbols. + */ + function followAliases(symbol, node, typeChecker, isForRename) { + while (true) { + // When renaming a default import, only rename in the current file + if (isForRename && isImportDefaultSymbol(symbol)) { + return { symbol: symbol }; + } + var aliasedSymbol = getAliasSymbolForPropertyNameSymbol(symbol, node, typeChecker); + // Don't follow alias if it goes to unknown symbol. This can happen if it points to an untyped module. + if (!aliasedSymbol || !aliasedSymbol.declarations) { + return { symbol: symbol }; + } + if (ts.isShorthandAmbientModuleSymbol(aliasedSymbol)) { + return { symbol: symbol, shorthandModuleSymbol: aliasedSymbol }; + } + symbol = aliasedSymbol; + } + } + function sourceFileHasName(sourceFile, name) { + return ts.getNameTable(sourceFile).get(name) !== undefined; + } + /** + * Given a symbol, see if any of the imports in a source file reference it. + * Only call this if `symbol` is a default export. + */ + function getDefaultImportName(symbol, sourceFile, checker) { + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var importSpecifier = _a[_i]; + var importDecl = importSpecifier.parent; + ts.Debug.assert(importDecl.moduleSpecifier === importSpecifier); + var defaultName = importDecl.importClause.name; + var defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName)); + if (symbol === defaultReferencedSymbol) { + return defaultName.text; + } + } + return undefined; + } + function getDefinition(symbol, node, typeChecker) { + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node), displayParts = _a.displayParts, symbolKind = _a.symbolKind; + var name = displayParts.map(function (p) { return p.text; }).join(""); + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { return undefined; } - function followAliasIfNecessary(symbol, location) { - return getAliasSymbolForPropertyNameSymbol(symbol, location) || symbol; - } - function getPropertySymbolOfDestructuringAssignment(location) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - typeChecker.getPropertySymbolOfDestructuringAssignment(location); - } - function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 174 /* BindingElement */); - return bindingElement && - bindingElement.parent.kind === 172 /* ObjectBindingPattern */ && - !bindingElement.propertyName; - } - function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 174 /* BindingElement */); - var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); - } + return { + containerKind: "", + containerName: "", + name: name, + kind: symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: ts.createTextSpan(declarations[0].getStart(), 0), + displayParts: displayParts + }; + } + function getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) { + if (!(symbol.flags & 8388608 /* Alias */)) { return undefined; } - function getInternedName(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 under the cursor. - if (ts.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); - symbol = localExportDefaultSymbol || symbol; - return ts.stripQuotes(symbol.name); + // Default import get alias + var defaultImport = ts.getDeclarationOfKind(symbol, 238 /* ImportClause */); + if (defaultImport) { + return typeChecker.getAliasedSymbol(symbol); } - /** - * 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 === 184 /* FunctionExpression */ || valueDeclaration.kind === 197 /* 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 (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); - if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 227 /* ClassDeclaration */); - } - } - // If the symbol is an import we would like to find it if we are looking for what it imports. - // So consider it visible outside its declaration scope. - if (symbol.flags & 8388608 /* Alias */) { - return undefined; - } - // If symbol is of object binding pattern element without property name we would want to - // look for property too and that could be anywhere - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - return undefined; - } - // 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 /* SyntheticProperty */)) { - return undefined; - } - var scope; - var declarations = symbol.getDeclarations(); - if (declarations) { - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; - var container = ts.getContainerNode(declaration); - if (!container) { - return undefined; - } - if (scope && scope !== container) { - // Different declarations have different containers, bail out - return undefined; - } - if (container.kind === 262 /* 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; - } - // The search scope is the container node - scope = container; - } - } - return scope; + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 241 /* ImportSpecifier */ || + declaration.kind === 245 /* ExportSpecifier */) ? declaration : undefined; }); + if (importOrExportSpecifier && + // export { a } + (!importOrExportSpecifier.propertyName || + // export {a as class } where a is location + importOrExportSpecifier.propertyName === location)) { + // If Import specifier -> get alias + // else Export specifier -> get local target + return importOrExportSpecifier.kind === 241 /* ImportSpecifier */ ? + typeChecker.getAliasedSymbol(symbol) : + typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } - function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { - var positions = []; - /// TODO: Cache symbol existence for files to save text search - // Also, need to make this work for unicode escapes. - // Be resilient in the face of a symbol with no name or zero length name - if (!symbolName || !symbolName.length) { - return positions; + } + function followAliasIfNecessary(symbol, location, typeChecker) { + return getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) || symbol; + } + function getPropertySymbolOfDestructuringAssignment(location, typeChecker) { + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && + typeChecker.getPropertySymbolOfDestructuringAssignment(location); + } + function isObjectBindingPatternElementWithoutPropertyName(symbol) { + var bindingElement = ts.getDeclarationOfKind(symbol, 175 /* BindingElement */); + return bindingElement && + bindingElement.parent.kind === 173 /* ObjectBindingPattern */ && + !bindingElement.propertyName; + } + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker) { + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + var bindingElement = ts.getDeclarationOfKind(symbol, 175 /* BindingElement */); + var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); + return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + } + return undefined; + } + function getInternedName(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 under the cursor. + if (ts.isImportOrExportSpecifierName(location)) { + return location.text; + } + 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 === 185 /* FunctionExpression */ || valueDeclaration.kind === 198 /* 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 (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); + if (privateDeclaration) { + return ts.getAncestor(privateDeclaration, 228 /* ClassDeclaration */); } - var text = sourceFile.text; - var sourceLength = text.length; - var symbolNameLength = symbolName.length; - var position = text.indexOf(symbolName, start); - while (position >= 0) { - cancellationToken.throwIfCancellationRequested(); - // If we are past the end, stop looking - if (position > end) - break; - // We found a match. Make sure it's not part of a larger word (i.e. the char - // before and after it have to be a non-identifier char). - var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5 /* Latest */))) { - // Found a real match. Keep searching. - positions.push(position); + } + // If the symbol is an import we would like to find it if we are looking for what it imports. + // So consider it visible outside its declaration scope. + if (symbol.flags & 8388608 /* Alias */) { + return undefined; + } + // If symbol is of object binding pattern element without property name we would want to + // look for property too and that could be anywhere + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + return undefined; + } + // 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 & 134217728 /* Transient */ && symbol.checkFlags & 2 /* SyntheticProperty */)) { + return undefined; + } + var scope; + var declarations = symbol.getDeclarations(); + if (declarations) { + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; + var container = ts.getContainerNode(declaration); + if (!container) { + return undefined; } - position = text.indexOf(symbolName, position + symbolNameLength + 1); + if (scope && scope !== container) { + // Different declarations have different containers, bail out + return undefined; + } + if (container.kind === 264 /* 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; + } + // The search scope is the container node + scope = container; } + } + return scope; + } + function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end, cancellationToken) { + var positions = []; + /// TODO: Cache symbol existence for files to save text search + // Also, need to make this work for unicode escapes. + // Be resilient in the face of a symbol with no name or zero length name + if (!symbolName || !symbolName.length) { return positions; } - function getLabelReferencesInNode(container, targetLabel) { - var references = []; - var sourceFile = container.getSourceFile(); - var labelName = targetLabel.text; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.getWidth() !== labelName.length) { - return; - } - // Only pick labels that are either the target label, or have a target that is the target label - if (node === targetLabel || - (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ts.ScriptElementKind.label, - name: labelName, - textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()), - displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] - }; - return [{ definition: definition, references: references }]; + var text = sourceFile.text; + var sourceLength = text.length; + var symbolNameLength = symbolName.length; + var position = text.indexOf(symbolName, start); + while (position >= 0) { + cancellationToken.throwIfCancellationRequested(); + // If we are past the end, stop looking + if (position > end) + break; + // We found a match. Make sure it's not part of a larger word (i.e. the char + // before and after it have to be a non-identifier char). + var endPosition = position + symbolNameLength; + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5 /* Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5 /* Latest */))) { + // Found a real match. Keep searching. + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); } - function isValidReferencePosition(node, searchSymbolName) { - if (node) { - // Compare the length so we filter out strict superstrings of the symbol we are looking for - switch (node.kind) { - case 70 /* Identifier */: - return node.getWidth() === searchSymbolName.length; - case 9 /* StringLiteral */: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - // For string literals we have two additional chars for the quotes - return node.getWidth() === searchSymbolName.length + 2; + return positions; + } + function getLabelReferencesInNode(container, targetLabel, cancellationToken) { + var references = []; + var sourceFile = container.getSourceFile(); + var labelName = targetLabel.text; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { + return; + } + // Only pick labels that are either the target label, or have a target that is the target label + if (node === targetLabel || + (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { + references.push(getReferenceEntryFromNode(node)); + } + }); + var definition = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ts.ScriptElementKind.label, + name: labelName, + textSpan: ts.createTextSpanFromNode(targetLabel, sourceFile), + displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] + }; + return [{ definition: definition, references: references }]; + } + function isValidReferencePosition(node, searchSymbolName) { + // Compare the length so we filter out strict superstrings of the symbol we are looking for + switch (node && node.kind) { + case 70 /* Identifier */: + return node.getWidth() === searchSymbolName.length; + case 9 /* StringLiteral */: + return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + // For string literals we have two additional chars for the quotes + node.getWidth() === searchSymbolName.length + 2; + case 8 /* NumericLiteral */: + return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; + default: + return false; + } + } + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + var name = ts.tokenToString(keywordKind); + var references = []; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var sourceFile = sourceFiles_6[_i]; + cancellationToken.throwIfCancellationRequested(); + addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); + } + if (!references.length) + return undefined; + var definition = { + containerKind: "", + containerName: "", + fileName: references[0].fileName, + kind: ts.ScriptElementKind.keyword, + name: name, + textSpan: references[0].textSpan, + displayParts: [{ text: name, kind: ts.ScriptElementKind.keyword }] + }; + return [{ definition: definition, references: references }]; + } + function addReferencesForKeywordInFile(sourceFile, kind, searchText, cancellationToken, references) { + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { + var position = possiblePositions_1[_i]; + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (referenceLocation.kind === kind) { + references.push({ + textSpan: ts.createTextSpanFromNode(referenceLocation), + fileName: sourceFile.fileName, + isWriteAccess: false, + isDefinition: false, + }); + } + } + } + /** Search within node "container" for references for a search value, where the search value is defined as a + * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). + * searchLocation: a node where the search value + */ + function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache) { + var sourceFile = container.getSourceFile(); + var start = findInComments ? container.getFullStart() : container.getStart(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); + var parents = getParentSymbolsOfPropertyAccess(); + for (var _i = 0, possiblePositions_2 = possiblePositions; _i < possiblePositions_2.length; _i++) { + var position = possiblePositions_2[_i]; + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (!isValidReferencePosition(referenceLocation, searchText)) { + // This wasn't the start of a token. Check to see if it might be a + // match in a comment or string if that's what the caller is asking + // for. + if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { + // In the case where we're looking inside comments/strings, we don't have + // an actual definition. So just use 'undefined' here. Features like + // 'Rename' won't care (as they ignore the definitions), and features like + // 'FindReferences' will just filter out these results. + result.push({ + definition: undefined, + references: [{ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpan(position, searchText.length), + isWriteAccess: false, + isDefinition: false + }] + }); + } + continue; + } + if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { + continue; + } + var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); + if (referenceSymbol) { + var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); + var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, + /*searchLocationIsConstructor*/ searchLocation.kind === 122 /* ConstructorKeyword */, parents, inheritsFromCache, typeChecker); + if (relatedSymbol) { + addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); + } + else if (!(referenceSymbol.flags & 134217728 /* Transient */) && ts.contains(searchSymbols, shorthandValueSymbol)) { + addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); + } + else if (searchLocation.kind === 122 /* ConstructorKeyword */) { + findAdditionalConstructorReferences(referenceSymbol, referenceLocation); + } + } + } + return; + /* If we are just looking for implementations and this is a property access expression, we need to get the + * symbol of the local type of the symbol the property is being accessed on. This is because our search + * symbol may have a different parent symbol if the local type's symbol does not declare the property + * being accessed (i.e. it is declared in some parent class or interface) + */ + function getParentSymbolsOfPropertyAccess() { + if (implementations) { + var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); + if (propertyAccessExpression) { + var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); + if (localParentType) { + if (localParentType.symbol && localParentType.symbol.flags & (32 /* Class */ | 64 /* Interface */) && localParentType.symbol !== searchSymbol.parent) { + return [localParentType.symbol]; } - break; - case 8 /* NumericLiteral */: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return node.getWidth() === searchSymbolName.length; + else if (localParentType.flags & 196608 /* UnionOrIntersection */) { + return getSymbolsForClassAndInterfaceComponents(localParentType); } - break; + } + } + } + } + /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ + function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { + ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); + var referenceClass = referenceLocation.parent; + if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { + ts.Debug.assert(referenceClass.name === referenceLocation); + // This is the class declaration containing the constructor. + addReferences(findOwnConstructorCalls(searchSymbol, sourceFile)); + } + else { + // If this class appears in `extends C`, then the extending class' "super" calls are references. + var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); + if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation, typeChecker) === searchSymbol) { + addReferences(superConstructorAccesses(classExtending)); + } + } + } + function addReferences(references) { + if (references.length) { + var referencedSymbol = getReferencedSymbol(searchSymbol); + ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); + } + } + function getReferencedSymbol(symbol) { + var symbolId = ts.getSymbolId(symbol); + var index = symbolToIndex[symbolId]; + if (index === undefined) { + index = result.length; + symbolToIndex[symbolId] = index; + result.push({ + definition: getDefinition(symbol, searchLocation, typeChecker), + references: [] + }); + } + return result[index]; + } + function addReferenceToRelatedSymbol(node, relatedSymbol) { + var references = getReferencedSymbol(relatedSymbol).references; + if (implementations) { + getImplementationReferenceEntryForNode(node, references, typeChecker); + } + else { + references.push(getReferenceEntryFromNode(node)); + } + } + } + function getPropertyAccessExpressionFromRightHandSide(node) { + return ts.isRightSideOfPropertyAccess(node) && node.parent; + } + /** `classSymbol` is the class where the constructor was defined. + * Reference the constructor and all calls to `new this()`. + */ + function findOwnConstructorCalls(classSymbol, sourceFile) { + var result = []; + for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var ctrKeyword = ts.findChildOfKind(decl, 122 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 151 /* Constructor */ && !!ctrKeyword); + result.push(ctrKeyword); + } + classSymbol.exports.forEach(function (member) { + var decl = member.valueDeclaration; + if (decl && decl.kind === 150 /* MethodDeclaration */) { + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 98 /* ThisKeyword */, function (thisKeyword) { + if (ts.isNewExpressionTarget(thisKeyword)) { + result.push(thisKeyword); + } + }); + } + } + }); + return result; + } + /** Find references to `super` in the constructor of an extending class. */ + function superConstructorAccesses(cls) { + var symbol = cls.symbol; + var ctr = symbol.members.get("__constructor"); + if (!ctr) { + return []; + } + var result = []; + for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.Debug.assert(decl.kind === 151 /* Constructor */); + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 96 /* SuperKeyword */, function (node) { + if (ts.isCallExpressionTarget(node)) { + result.push(node); + } + }); + } + } + ; + return result; + } + function getImplementationReferenceEntryForNode(refNode, result, typeChecker) { + // Check if we found a function/propertyAssignment/method with an implementation or initializer + if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { + result.push(getReferenceEntryFromNode(refNode.parent)); + } + else if (refNode.kind === 70 /* Identifier */) { + if (refNode.parent.kind === 261 /* ShorthandPropertyAssignment */) { + // Go ahead and dereference the shorthand assignment by going to its definition + getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + } + // Check if the node is within an extends or implements clause + var containingClass = getContainingClassIfInHeritageClause(refNode); + if (containingClass) { + result.push(getReferenceEntryFromNode(containingClass)); + return; + } + // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface + var containingTypeReference = getContainingTypeReference(refNode); + if (containingTypeReference) { + var parent = containingTypeReference.parent; + if (ts.isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent.initializer)); + } + else if (ts.isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { + if (parent.body.kind === 206 /* Block */) { + ts.forEachReturnStatement(parent.body, function (returnStatement) { + if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { + maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); + } + }); + } + else if (isImplementationExpression(parent.body)) { + maybeAdd(getReferenceEntryFromNode(parent.body)); + } + } + else if (ts.isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { + maybeAdd(getReferenceEntryFromNode(parent.expression)); + } + } + } + // Type nodes can contain multiple references to the same type. For example: + // let x: Foo & (Foo & Bar) = ... + // Because we are returning the implementation locations and not the identifier locations, + // duplicate entries would be returned here as each of the type references is part of + // the same implementation. For that reason, check before we add a new entry + function maybeAdd(a) { + if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { + result.push(a); + } + } + } + function getSymbolsForClassAndInterfaceComponents(type, result) { + if (result === void 0) { result = []; } + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var componentType = _a[_i]; + if (componentType.symbol && componentType.symbol.getFlags() & (32 /* Class */ | 64 /* Interface */)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & 196608 /* UnionOrIntersection */) { + getSymbolsForClassAndInterfaceComponents(componentType, result); + } + } + return result; + } + function getContainingTypeReference(node) { + var topLevelTypeReference = undefined; + while (node) { + if (ts.isTypeNode(node)) { + topLevelTypeReference = node; + } + node = node.parent; + } + return topLevelTypeReference; + } + function getContainingClassIfInHeritageClause(node) { + if (node && node.parent) { + if (node.kind === 200 /* ExpressionWithTypeArguments */ + && node.parent.kind === 258 /* HeritageClause */ + && ts.isClassLike(node.parent.parent)) { + return node.parent.parent; + } + else if (node.kind === 70 /* Identifier */ || node.kind === 178 /* PropertyAccessExpression */) { + return getContainingClassIfInHeritageClause(node.parent); + } + } + return undefined; + } + /** + * Returns true if this is an expression that can be considered an implementation + */ + function isImplementationExpression(node) { + switch (node.kind) { + case 184 /* ParenthesizedExpression */: + return isImplementationExpression(node.expression); + case 186 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 177 /* ObjectLiteralExpression */: + case 198 /* ClassExpression */: + case 176 /* ArrayLiteralExpression */: + return true; + default: + return false; + } + } + /** + * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol + * is an interface, determines if some ancestor of the child symbol extends or inherits from it. + * Also takes in a cache of previous results which makes this slightly more efficient and is + * necessary to avoid potential loops like so: + * class A extends B { } + * class B extends A { } + * + * We traverse the AST rather than using the type checker because users are typically only interested + * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling + * implementations of types that share a common ancestor with the type whose implementation we are + * searching for need to be filtered out of the results. The type checker doesn't let us make the + * distinction between structurally compatible implementations and explicit implementations, so we + * must use the AST. + * + * @param child A class or interface Symbol + * @param parent Another class or interface Symbol + * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results + */ + function explicitlyInheritsFrom(child, parent, cachedResults, typeChecker) { + var parentIsInterface = parent.getFlags() & 64 /* Interface */; + return searchHierarchy(child); + function searchHierarchy(symbol) { + if (symbol === parent) { + return true; + } + var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); + var cached = cachedResults.get(key); + if (cached !== undefined) { + return cached; + } + // Set the key so that we don't infinitely recurse + cachedResults.set(key, false); + var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + if (parentIsInterface) { + var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { + var typeReference = interfaceReferences_1[_i]; + if (searchTypeReference(typeReference)) { + return true; + } + } + } + } + return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + } + else if (declaration.kind === 229 /* InterfaceDeclaration */) { + if (parentIsInterface) { + return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); + } + } + return false; + }); + cachedResults.set(key, inherits); + return inherits; + } + function searchTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); } } return false; } - /** Search within node "container" for references for a search value, where the search value is defined as a - * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). - * searchLocation: a node where the search value - */ - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { - var sourceFile = container.getSourceFile(); - var start = findInComments ? container.getFullStart() : container.getStart(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd()); - var parents = getParentSymbolsOfPropertyAccess(); - var inheritsFromCache = ts.createMap(); - if (possiblePositions.length) { - // Build the set of symbols to search for, initially it has only the current symbol - var searchSymbols_1 = populateSearchSymbolSet(searchSymbol, searchLocation); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { - // This wasn't the start of a token. Check to see if it might be a - // match in a comment or string if that's what the caller is asking - // for. - if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || - (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { - // In the case where we're looking inside comments/strings, we don't have - // an actual definition. So just use 'undefined' here. Features like - // 'Rename' won't care (as they ignore the definitions), and features like - // 'FindReferences' will just filter out these results. - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: ts.createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); - } - return; - } - if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { - return; - } - var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, - /*searchLocationIsConstructor*/ searchLocation.kind === 122 /* ConstructorKeyword */, parents, inheritsFromCache); - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); - } - else if (!(referenceSymbol.flags & 67108864 /* Transient */) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); - } - else if (searchLocation.kind === 122 /* ConstructorKeyword */) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); - } - } - }); - } - return; - /* If we are just looking for implementations and this is a property access expression, we need to get the - * symbol of the local type of the symbol the property is being accessed on. This is because our search - * symbol may have a different parent symbol if the local type's symbol does not declare the property - * being accessed (i.e. it is declared in some parent class or interface) - */ - function getParentSymbolsOfPropertyAccess() { - if (implementations) { - var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); - if (propertyAccessExpression) { - var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); - if (localParentType) { - if (localParentType.symbol && localParentType.symbol.flags & (32 /* Class */ | 64 /* Interface */) && localParentType.symbol !== searchSymbol.parent) { - return [localParentType.symbol]; - } - else if (localParentType.flags & 196608 /* UnionOrIntersection */) { - return getSymbolsForClassAndInterfaceComponents(localParentType); - } - } - } - } - } - function getPropertyAccessExpressionFromRightHandSide(node) { - return ts.isRightSideOfPropertyAccess(node) && node.parent; - } - /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ - function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { - ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); - var referenceClass = referenceLocation.parent; - if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { - ts.Debug.assert(referenceClass.name === referenceLocation); - // This is the class declaration containing the constructor. - addReferences(findOwnConstructorCalls(searchSymbol)); - } - else { - // If this class appears in `extends C`, then the extending class' "super" calls are references. - var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); - if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) { - addReferences(superConstructorAccesses(classExtending)); - } - } - } - function addReferences(references) { - if (references.length) { - var referencedSymbol = getReferencedSymbol(searchSymbol); - ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); - } - } - /** `classSymbol` is the class where the constructor was defined. - * Reference the constructor and all calls to `new this()`. - */ - function findOwnConstructorCalls(classSymbol) { - var result = []; - for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 150 /* Constructor */); - var ctrKeyword = decl.getChildAt(0); - ts.Debug.assert(ctrKeyword.kind === 122 /* ConstructorKeyword */); - result.push(ctrKeyword); - } - ts.forEachProperty(classSymbol.exports, function (member) { - var decl = member.valueDeclaration; - if (decl && decl.kind === 149 /* MethodDeclaration */) { - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 98 /* ThisKeyword */, function (thisKeyword) { - if (ts.isNewExpressionTarget(thisKeyword)) { - result.push(thisKeyword); - } - }); - } - } - }); - return result; - } - /** Find references to `super` in the constructor of an extending class. */ - function superConstructorAccesses(cls) { - var symbol = cls.symbol; - var ctr = symbol.members["__constructor"]; - if (!ctr) { - return []; - } - var result = []; - for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 150 /* Constructor */); - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 96 /* SuperKeyword */, function (node) { - if (ts.isCallExpressionTarget(node)) { - result.push(node); - } - }); - } - } - ; - return result; - } - function getReferencedSymbol(symbol) { - var symbolId = ts.getSymbolId(symbol); - var index = symbolToIndex[symbolId]; - if (index === undefined) { - index = result.length; - symbolToIndex[symbolId] = index; - result.push({ - definition: getDefinition(symbol), - references: [] - }); - } - return result[index]; - } - function addReferenceToRelatedSymbol(node, relatedSymbol) { - var references = getReferencedSymbol(relatedSymbol).references; - if (implementations) { - getImplementationReferenceEntryForNode(node, references); - } - else { - references.push(getReferenceEntryFromNode(node)); - } - } - } - function getImplementationReferenceEntryForNode(refNode, result) { - // Check if we found a function/propertyAssignment/method with an implementation or initializer - if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); - } - else if (refNode.kind === 70 /* Identifier */) { - if (refNode.parent.kind === 259 /* ShorthandPropertyAssignment */) { - // Go ahead and dereference the shorthand assignment by going to its definition - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); - } - // Check if the node is within an extends or implements clause - var containingClass = getContainingClassIfInHeritageClause(refNode); - if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); - return; - } - // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface - var containingTypeReference = getContainingTypeReference(refNode); - if (containingTypeReference) { - var parent_19 = containingTypeReference.parent; - if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_19.initializer)); - } - else if (ts.isFunctionLike(parent_19) && parent_19.type === containingTypeReference && parent_19.body) { - if (parent_19.body.kind === 205 /* Block */) { - ts.forEachReturnStatement(parent_19.body, function (returnStatement) { - if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); - } - }); - } - else if (isImplementationExpression(parent_19.body)) { - maybeAdd(getReferenceEntryFromNode(parent_19.body)); - } - } - else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_19.expression)); - } - } - } - // Type nodes can contain multiple references to the same type. For example: - // let x: Foo & (Foo & Bar) = ... - // Because we are returning the implementation locations and not the identifier locations, - // duplicate entries would be returned here as each of the type references is part of - // the same implementation. For that reason, check before we add a new entry - function maybeAdd(a) { - if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { - result.push(a); - } - } - } - function getSymbolsForClassAndInterfaceComponents(type, result) { - if (result === void 0) { result = []; } - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var componentType = _a[_i]; - if (componentType.symbol && componentType.symbol.getFlags() & (32 /* Class */ | 64 /* Interface */)) { - result.push(componentType.symbol); - } - if (componentType.getFlags() & 196608 /* UnionOrIntersection */) { - getSymbolsForClassAndInterfaceComponents(componentType, result); - } - } - return result; - } - function getContainingTypeReference(node) { - var topLevelTypeReference = undefined; - while (node) { - if (ts.isTypeNode(node)) { - topLevelTypeReference = node; - } - node = node.parent; - } - return topLevelTypeReference; - } - function getContainingClassIfInHeritageClause(node) { - if (node && node.parent) { - if (node.kind === 199 /* ExpressionWithTypeArguments */ - && node.parent.kind === 256 /* HeritageClause */ - && ts.isClassLike(node.parent.parent)) { - return node.parent.parent; - } - else if (node.kind === 70 /* Identifier */ || node.kind === 177 /* PropertyAccessExpression */) { - return getContainingClassIfInHeritageClause(node.parent); - } - } + } + function getReferencesForSuperKeyword(superKeyword, typeChecker, cancellationToken) { + var searchSpaceNode = ts.getSuperContainer(superKeyword, /*stopOnFunctions*/ false); + if (!searchSpaceNode) { return undefined; } - /** - * Returns true if this is an expression that can be considered an implementation - */ - function isImplementationExpression(node) { - // Unwrap parentheses - if (node.kind === 183 /* ParenthesizedExpression */) { - return isImplementationExpression(node.expression); - } - return node.kind === 185 /* ArrowFunction */ || - node.kind === 184 /* FunctionExpression */ || - node.kind === 176 /* ObjectLiteralExpression */ || - node.kind === 197 /* ClassExpression */ || - node.kind === 175 /* ArrayLiteralExpression */; - } - /** - * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol - * is an interface, determines if some ancestor of the child symbol extends or inherits from it. - * Also takes in a cache of previous results which makes this slightly more efficient and is - * necessary to avoid potential loops like so: - * class A extends B { } - * class B extends A { } - * - * We traverse the AST rather than using the type checker because users are typically only interested - * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling - * implementations of types that share a common ancestor with the type whose implementation we are - * searching for need to be filtered out of the results. The type checker doesn't let us make the - * distinction between structurally compatible implementations and explicit implementations, so we - * must use the AST. - * - * @param child A class or interface Symbol - * @param parent Another class or interface Symbol - * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results - */ - function explicitlyInheritsFrom(child, parent, cachedResults) { - var parentIsInterface = parent.getFlags() & 64 /* Interface */; - return searchHierarchy(child); - function searchHierarchy(symbol) { - if (symbol === parent) { - return true; - } - var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); - if (key in cachedResults) { - return cachedResults[key]; - } - // Set the key so that we don't infinitely recurse - cachedResults[key] = false; - var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - if (parentIsInterface) { - var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); - if (interfaceReferences) { - for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { - var typeReference = interfaceReferences_1[_i]; - if (searchTypeReference(typeReference)) { - return true; - } - } - } - } - return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - } - else if (declaration.kind === 228 /* InterfaceDeclaration */) { - if (parentIsInterface) { - return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); - } - } - return false; - }); - cachedResults[key] = inherits; - return inherits; - } - function searchTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type && type.symbol) { - return searchHierarchy(type.symbol); - } - } - return false; - } - } - function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, /*stopOnFunctions*/ false); - if (!searchSpaceNode) { + // Whether 'super' occurs in a static context within a class. + var staticFlag = 32 /* Static */; + switch (searchSpaceNode.kind) { + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + default: return undefined; + } + var references = []; + var sourceFile = searchSpaceNode.getSourceFile(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + for (var _i = 0, possiblePositions_3 = possiblePositions; _i < possiblePositions_3.length; _i++) { + var position = possiblePositions_3[_i]; + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 96 /* SuperKeyword */) { + continue; } - // Whether 'super' occurs in a static context within a class. - var staticFlag = 32 /* Static */; - switch (searchSpaceNode.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); + // If we have a 'super' container, we must have an enclosing class. + // Now make sure the owning class is the same as the search-space + // and has the same static qualifier as the original 'super's owner. + if (container && (32 /* Static */ & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(getReferenceEntryFromNode(node)); + } + } + var definition = getDefinition(searchSpaceNode.symbol, superKeyword, typeChecker); + return [{ definition: definition, references: references }]; + } + function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, typeChecker, cancellationToken) { + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); + // Whether 'this' occurs in a static context within a class. + var staticFlag = 32 /* Static */; + switch (searchSpaceNode.kind) { + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; - default: + } + // fall through + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + case 264 /* SourceFile */: + if (ts.isExternalModule(searchSpaceNode)) { return undefined; - } - var references = []; + } + // Fall through + case 227 /* FunctionDeclaration */: + case 185 /* 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. + default: + return undefined; + } + var references = []; + var possiblePositions; + if (searchSpaceNode.kind === 264 /* SourceFile */) { + ts.forEach(sourceFiles, function (sourceFile) { + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { var sourceFile = searchSpaceNode.getSourceFile(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); + var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: thisOrSuperKeyword.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: "this", + textSpan: ts.createTextSpanFromNode(thisOrSuperKeyword), + displayParts: displayParts + }, + references: references + }]; + function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 96 /* SuperKeyword */) { + if (!node || !ts.isThis(node)) { return; } - var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); - // If we have a 'super' container, we must have an enclosing class. - // Now make sure the owning class is the same as the search-space - // and has the same static qualifier as the original 'super's owner. - if (container && (32 /* Static */ & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); + var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); + switch (searchSpaceNode.kind) { + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + if (searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 198 /* ClassExpression */: + case 228 /* 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 && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 264 /* SourceFile */: + if (container.kind === 264 /* SourceFile */ && !ts.isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); + } + break; } }); - var definition = getDefinition(searchSpaceNode.symbol); - return [{ definition: definition, references: references }]; } - function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); - // Whether 'this' occurs in a static context within a class. - var staticFlag = 32 /* Static */; - switch (searchSpaceNode.kind) { - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - if (ts.isObjectLiteralMethod(searchSpaceNode)) { - break; + } + function getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (!type) { + // nothing to do here. moving on + return undefined; + } + var references = []; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); + } + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: type.text, + textSpan: ts.createTextSpanFromNode(node), + displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] + }, + references: references + }]; + function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { + for (var _i = 0, possiblePositions_4 = possiblePositions; _i < possiblePositions_4.length; _i++) { + var position = possiblePositions_4[_i]; + cancellationToken.throwIfCancellationRequested(); + var node_2 = ts.getTouchingWord(sourceFile, position); + if (!node_2 || node_2.kind !== 9 /* StringLiteral */) { + return; + } + var type_2 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + if (type_2 === searchType) { + references.push(getReferenceEntryFromNode(node_2)); + } + } + } + } + function populateSearchSymbolSet(symbol, location, typeChecker, implementations) { + // The search set contains at least the current symbol + var result = [symbol]; + // If the location is name of property symbol from object literal destructuring pattern + // Search the property symbol + // for ( { property: p2 } of elems) { } + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 261 /* ShorthandPropertyAssignment */) { + var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, typeChecker); + if (propertySymbol) { + result.push(propertySymbol); + } + } + // If the location is in a context sensitive location (i.e. in an object literal) try + // to get a contextual type for it, and add the property symbol from the contextual + // type to the search set + if (containingObjectLiteralElement) { + ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (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 + * property name and variable declaration of the identifier. + * Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service + * should show both 'name' in 'obj' and 'name' in variable declaration + * const name = "Foo"; + * const obj = { name }; + * In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment + * so that when matching with potential reference symbol, both symbols from property declaration and variable declaration + * will be included correctly. + */ + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } + } + // If the symbol.valueDeclaration is a property parameter declaration, + // we should include both parameter declaration symbol and property declaration symbol + // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. + // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 145 /* Parameter */ && + ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + ts.addRange(result, typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); + } + // If this is symbol of binding element without propertyName declaration in Object binding pattern + // Include the property in the search + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker); + if (bindingElementPropertySymbol) { + result.push(bindingElementPropertySymbol); + } + // If this is a union property, add all the symbols from all its source symbols in all unioned types. + // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list + for (var _i = 0, _a = typeChecker.getRootSymbols(symbol); _i < _a.length; _i++) { + var rootSymbol = _a[_i]; + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap(), typeChecker); + } + } + return result; + } + /** + * Find symbol of the given property-name and add the symbol to the given result array + * @param symbol a symbol to start searching for the given propertyName + * @param propertyName a name of property to search for + * @param result an array of symbol of found property symbols + * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. + * The value of previousIterationSymbol is undefined when the function is first called. + */ + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, typeChecker) { + if (!symbol) { + return; + } + // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited + // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. + // For example: + // interface C extends C { + // /*findRef*/propName: string; + // } + // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, + // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, + // the function will add any found symbol of the property-name, then its sub-routine will call + // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already + // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. + if (previousIterationSymbolsCache.has(symbol.name)) { + return; + } + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === 229 /* InterfaceDeclaration */) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); + } + }); + } + return; + function getPropertySymbolFromTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type) { + var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); + if (propertySymbol) { + result.push.apply(result, typeChecker.getRootSymbols(propertySymbol)); } - // fall through - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class - break; - case 262 /* SourceFile */: - if (ts.isExternalModule(searchSpaceNode)) { + // Visit the typeReference as well to see if it directly or indirectly use that property + previousIterationSymbolsCache.set(symbol.name, symbol); + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, typeChecker); + } + } + } + } + function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker) { + if (ts.contains(searchSymbols, referenceSymbol)) { + // If we are searching for constructor uses, they must be 'new' expressions. + return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) ? referenceSymbol : undefined; + } + // If the reference symbol is an alias, check if what it is aliasing is one of the search + // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. + var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation, typeChecker); + if (aliasSymbol) { + return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker); + } + // If the reference location is in an object literal, try to get the contextual type for the + // object literal, lookup the property symbol in the contextual type, and use this symbol to + // compare to our searchSymbol + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { + return ts.find(typeChecker.getRootSymbols(contextualSymbol), function (symbol) { return ts.contains(searchSymbols, symbol); }); + }); + if (contextualSymbol) { + return contextualSymbol; + } + // If the reference location is the name of property from object literal destructuring pattern + // Get the property symbol from the object literal's type and look if thats the search symbol + // In below eg. get 'property' from type of elems iterating type + // for ( { property: p2 } of elems) { } + var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, typeChecker); + if (propertySymbol && ts.contains(searchSymbols, propertySymbol)) { + return propertySymbol; + } + } + // If the reference location is the binding element and doesn't have property name + // then include the binding element in the related symbols + // let { a } : { a }; + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, typeChecker); + if (bindingElementPropertySymbol && ts.contains(searchSymbols, bindingElementPropertySymbol)) { + return bindingElementPropertySymbol; + } + // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) + // Or a union property, use its underlying unioned symbols + return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { + // if it is in the list, then we are done + if (ts.contains(searchSymbols, rootSymbol)) { + return rootSymbol; + } + // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the + // parent symbol + if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + // Parents will only be defined if implementations is true + if (parents) { + if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache, typeChecker); })) { return undefined; } - // Fall through - case 226 /* FunctionDeclaration */: - case 184 /* 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. - default: - return undefined; - } - var references = []; - var possiblePositions; - if (searchSpaceNode.kind === 262 /* SourceFile */) { - ts.forEach(sourceFiles, function (sourceFile) { - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); - }); - } - else { - var sourceFile = searchSpaceNode.getSourceFile(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); - } - var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: "this", - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: displayParts - }, - references: references - }]; - function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || !ts.isThis(node)) { - return; - } - var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); - switch (searchSpaceNode.kind) { - case 184 /* FunctionExpression */: - case 226 /* FunctionDeclaration */: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 197 /* ClassExpression */: - case 227 /* 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 && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 262 /* SourceFile */: - if (container.kind === 262 /* SourceFile */ && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); - } - } - function getReferencesForStringLiteral(node, sourceFiles) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (!type) { - // nothing to do here. moving on - return undefined; - } - var references = []; - for (var _i = 0, sourceFiles_9 = sourceFiles; _i < sourceFiles_9.length; _i++) { - var sourceFile = sourceFiles_9[_i]; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd()); - getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); - } - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: type.text, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] - }, - references: references - }]; - function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { - for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { - var position = possiblePositions_1[_i]; - cancellationToken.throwIfCancellationRequested(); - var node_3 = ts.getTouchingWord(sourceFile, position); - if (!node_3 || node_3.kind !== 9 /* StringLiteral */) { - return; - } - var type_1 = ts.getStringLiteralTypeForNode(node_3, typeChecker); - if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_3)); - } } + var result = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap(), typeChecker); + return ts.find(result, function (symbol) { return ts.contains(searchSymbols, symbol); }); } - } - function populateSearchSymbolSet(symbol, location) { - // The search set contains at least the current symbol - var result = [symbol]; - // If the location is name of property symbol from object literal destructuring pattern - // Search the property symbol - // for ( { property: p2 } of elems) { } - var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 259 /* ShorthandPropertyAssignment */) { - var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); - if (propertySymbol) { - result.push(propertySymbol); - } - } - // If the symbol is an alias, add what it aliases to the list - // import {a} from "mod"; - // export {a} - // If the symbol is an alias to default declaration, add what it aliases to the list - // declare "mod" { export default class B { } } - // import B from "mod"; - //// For export specifiers, the exported name can be referring to a local symbol, e.g.: - //// import {a} from "mod"; - //// export {a as somethingElse} - //// We want the *local* declaration of 'a' as declared in the import, - //// *not* as declared within "mod" (or farther) - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(symbol, location); - if (aliasSymbol) { - result = result.concat(populateSearchSymbolSet(aliasSymbol, location)); - } - // If the location is in a context sensitive location (i.e. in an object literal) try - // to get a contextual type for it, and add the property symbol from the contextual - // type to the search set - if (containingObjectLiteralElement) { - ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (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 - * property name and variable declaration of the identifier. - * Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service - * should show both 'name' in 'obj' and 'name' in variable declaration - * const name = "Foo"; - * const obj = { name }; - * In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment - * so that when matching with potential reference symbol, both symbols from property declaration and variable declaration - * will be included correctly. - */ - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); - } - } - // If the symbol.valueDeclaration is a property parameter declaration, - // we should include both parameter declaration symbol and property declaration symbol - // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. - // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 144 /* Parameter */ && - ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { - result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); - } - // If this is symbol of binding element without propertyName declaration in Object binding pattern - // Include the property in the search - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol); - if (bindingElementPropertySymbol) { - result.push(bindingElementPropertySymbol); - } - // If this is a union property, add all the symbols from all its source symbols in all unioned types. - // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list - ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap()); - } - }); - return result; - } - /** - * Find symbol of the given property-name and add the symbol to the given result array - * @param symbol a symbol to start searching for the given propertyName - * @param propertyName a name of property to search for - * @param result an array of symbol of found property symbols - * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. - * The value of previousIterationSymbol is undefined when the function is first called. - */ - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache) { - if (!symbol) { - return; - } - // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited - // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. - // For example: - // interface C extends C { - // /*findRef*/propName: string; - // } - // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, - // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, - // the function will add any found symbol of the property-name, then its sub-routine will call - // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already - // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. - if (symbol.name in previousIterationSymbolsCache) { - return; - } - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === 228 /* InterfaceDeclaration */) { - ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); - } - }); - } - return; - function getPropertySymbolFromTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type) { - var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); - if (propertySymbol) { - result.push.apply(result, typeChecker.getRootSymbols(propertySymbol)); - } - // Visit the typeReference as well to see if it directly or indirectly use that property - previousIterationSymbolsCache[symbol.name] = symbol; - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); - } - } - } - } - function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache) { - if (ts.contains(searchSymbols, referenceSymbol)) { - // If we are searching for constructor uses, they must be 'new' expressions. - return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) && referenceSymbol; - } - // If the reference symbol is an alias, check if what it is aliasing is one of the search - // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); - if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache); - } - // If the reference location is in an object literal, try to get the contextual type for the - // object literal, lookup the property symbol in the contextual type, and use this symbol to - // compare to our searchSymbol - var containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); - if (containingObjectLiteralElement) { - var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (contextualSymbol) { - return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - }); - if (contextualSymbol) { - return contextualSymbol; - } - // If the reference location is the name of property from object literal destructuring pattern - // Get the property symbol from the object literal's type and look if thats the search symbol - // In below eg. get 'property' from type of elems iterating type - // for ( { property: p2 } of elems) { } - var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation); - if (propertySymbol && searchSymbols.indexOf(propertySymbol) >= 0) { - return propertySymbol; - } - } - // If the reference location is the binding element and doesn't have property name - // then include the binding element in the related symbols - // let { a } : { a }; - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol); - if (bindingElementPropertySymbol && searchSymbols.indexOf(bindingElementPropertySymbol) >= 0) { - return bindingElementPropertySymbol; - } - // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) - // Or a union property, use its underlying unioned symbols - return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { - // if it is in the list, then we are done - if (searchSymbols.indexOf(rootSymbol) >= 0) { - return rootSymbol; - } - // Finally, try all properties with the same name in any type the containing type extended or implemented, and - // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the - // parent symbol - if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - // Parents will only be defined if implementations is true - if (parents) { - if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache); })) { - return undefined; - } - } - var result_4 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_4, /*previousIterationSymbolsCache*/ ts.createMap()); - return ts.forEach(result_4, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - } - return undefined; - }); - } - function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 142 /* ComputedPropertyName */) { - var nameExpression = node.name.expression; - // treat computed property names where expression is string/numeric literal as just string/numeric literal - if (ts.isStringOrNumericLiteral(nameExpression)) { - return nameExpression.text; - } - return undefined; - } - return node.name.text; - } - function getPropertySymbolsFromContextualType(node) { - var objectLiteral = node.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - var name = getNameFromObjectLiteralElement(node); - if (name && contextualType) { - var result_5 = []; - var symbol_2 = contextualType.getProperty(name); - if (symbol_2) { - result_5.push(symbol_2); - } - if (contextualType.flags & 65536 /* Union */) { - ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name); - if (symbol) { - result_5.push(symbol); - } - }); - } - return result_5; + return undefined; + }); + } + function getNameFromObjectLiteralElement(node) { + if (node.name.kind === 143 /* ComputedPropertyName */) { + var nameExpression = node.name.expression; + // treat computed property names where expression is string/numeric literal as just string/numeric literal + if (ts.isStringOrNumericLiteral(nameExpression)) { + return nameExpression.text; } return undefined; } - /** Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations - * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class - * then we need to widen the search to include type positions as well. - * On the contrary, if we are searching for "Bar" in type position and we trace bar to an interface, and an uninstantiated - * module, we want to keep the search limited to only types, as the two declarations (interface and uninstantiated module) - * do not intersect in any of the three spaces. - */ - function getIntersectingMeaningFromDeclarations(meaning, declarations) { - if (declarations) { - var lastIterationMeaning = void 0; - do { - // The result is order-sensitive, for instance if initialMeaning === Namespace, and declarations = [class, instantiated module] - // we need to consider both as they initialMeaning intersects with the module in the namespace space, and the module - // intersects with the class in the value space. - // To achieve that we will keep iterating until the result stabilizes. - // Remember the last meaning - lastIterationMeaning = meaning; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; - var declarationMeaning = ts.getMeaningFromDeclaration(declaration); - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; - } - } - } while (meaning !== lastIterationMeaning); + return node.name.text; + } + /** Gets all symbols for one property. Does not get symbols for every property. */ + function getPropertySymbolsFromContextualType(node, typeChecker) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + var result_4 = []; + var symbol = contextualType.getProperty(name); + if (symbol) { + result_4.push(symbol); } - return meaning; + if (contextualType.flags & 65536 /* Union */) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_4.push(symbol); + } + }); + } + return result_4; } + return undefined; } - FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; - function convertReferences(referenceSymbols) { - if (!referenceSymbols) { - return undefined; + /** + * Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations + * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class + * then we need to widen the search to include type positions as well. + * On the contrary, if we are searching for "Bar" in type position and we trace bar to an interface, and an uninstantiated + * module, we want to keep the search limited to only types, as the two declarations (interface and uninstantiated module) + * do not intersect in any of the three spaces. + */ + function getIntersectingMeaningFromDeclarations(meaning, declarations) { + if (declarations) { + var lastIterationMeaning = void 0; + do { + // The result is order-sensitive, for instance if initialMeaning === Namespace, and declarations = [class, instantiated module] + // we need to consider both as they initialMeaning intersects with the module in the namespace space, and the module + // intersects with the class in the value space. + // To achieve that we will keep iterating until the result stabilizes. + // Remember the last meaning + lastIterationMeaning = meaning; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + var declarationMeaning = ts.getMeaningFromDeclaration(declaration); + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } while (meaning !== lastIterationMeaning); } - var referenceEntries = []; - for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) { - var referenceSymbol = referenceSymbols_1[_i]; - ts.addRange(referenceEntries, referenceSymbol.references); - } - return referenceEntries; + return meaning; } - FindAllReferences.convertReferences = convertReferences; function isImplementation(node) { if (!node) { return false; @@ -71367,7 +72875,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 224 /* VariableDeclaration */) { + else if (node.kind === 225 /* VariableDeclaration */) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } @@ -71377,18 +72885,18 @@ var ts; } else { switch (node.kind) { - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 230 /* EnumDeclaration */: - case 231 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 231 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 206 /* VariableStatement */) { - ts.Debug.assert(node.parent.kind === 225 /* VariableDeclarationList */); + if (node.parent && node.parent.parent && node.parent.parent.kind === 207 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 226 /* VariableDeclarationList */); return node.parent.parent; } } @@ -71427,10 +72935,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 191 /* PostfixUnaryExpression */ || parent.kind === 190 /* PrefixUnaryExpression */) { + if (parent.kind === 192 /* PostfixUnaryExpression */ || parent.kind === 191 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 192 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 193 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 57 /* FirstAssignment */ <= operator && operator <= 69 /* LastAssignment */; } @@ -71445,33 +72953,6 @@ var ts; forEachDescendantOfKind(child, kind, action); }); } - /** - * Returns the containing object literal property declaration given a possible name node, e.g. "a" in x = { "a": 1 } - */ - function getContainingObjectLiteralElement(node) { - switch (node.kind) { - case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - if (node.parent.kind === 142 /* ComputedPropertyName */) { - return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; - } - // intential fall through - case 70 /* Identifier */: - return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; - } - return undefined; - } - function isObjectLiteralPropertyDeclaration(node) { - switch (node.kind) { - case 258 /* PropertyAssignment */: - case 259 /* ShorthandPropertyAssignment */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - return true; - } - return false; - } /** Get `C` given `N` if `N` is in the position `class C extends N` or `class C extends foo.N` where `N` is an identifier. */ function tryGetClassByExtendingIdentifier(node) { return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); @@ -71482,6 +72963,9 @@ var ts; } return false; } + function isImportDefaultSymbol(symbol) { + return symbol.declarations[0].kind === 238 /* ImportClause */; + } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); /* @internal */ @@ -71502,11 +72986,9 @@ var ts; // Type reference directives var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { - var referenceFile = program.getResolvedTypeReferenceDirectives()[typeReferenceDirective.fileName]; - if (referenceFile && referenceFile.resolvedFileName) { - return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; - } - return undefined; + var referenceFile = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); + return referenceFile && referenceFile.resolvedFileName && + [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; } var node = ts.getTouchingPropertyName(sourceFile, position); if (node === sourceFile) { @@ -71516,7 +72998,7 @@ var ts; if (ts.isJumpStatementTarget(node)) { var labelName = node.text; var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ts.ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, ts.ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } var typeChecker = program.getTypeChecker(); var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); @@ -71542,7 +73024,7 @@ var ts; // if (node.kind === 70 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 240 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 239 /* NamedImports */))) { + (declaration.kind === 241 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 240 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -71551,7 +73033,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 === 259 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 261 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -71562,6 +73044,37 @@ var ts; var shorthandContainerName_1 = typeChecker.symbolToString(symbol.parent, node); return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind_1, shorthandSymbolName_1, shorthandContainerName_1); }); } + if (ts.isJsxOpeningLikeElement(node.parent)) { + // If there are errors when trying to figure out stateless component function, just return the first declaration + // For example: + // declare function /*firstSource*/MainButton(buttonProps: ButtonProps): JSX.Element; + // declare function /*secondSource*/MainButton(linkProps: LinkProps): JSX.Element; + // declare function /*thirdSource*/MainButton(props: ButtonProps | LinkProps): JSX.Element; + // let opt =
; // Error - We get undefined for resolved signature indicating an error, then just return the first declaration + var _a = getSymbolInfo(typeChecker, symbol, node), symbolName = _a.symbolName, symbolKind = _a.symbolKind, containerName = _a.containerName; + return [createDefinitionInfo(symbol.valueDeclaration, symbolKind, symbolName, containerName)]; + } + // If the current location we want to find its definition is in an object literal, try to get the contextual type for the + // object literal, lookup the property symbol in the contextual type, and use this for goto-definition. + // For example + // interface Props{ + // /*first*/prop1: number + // prop2: boolean + // } + // function Foo(arg: Props) {} + // Foo( { pr/*1*/op1: 10, prop2: true }) + var element = ts.getContainingObjectLiteralElement(node); + if (element) { + if (typeChecker.getContextualType(element.parent)) { + var result = []; + var propertySymbols = ts.getPropertySymbolsFromContextualType(typeChecker, element); + for (var _i = 0, propertySymbols_1 = propertySymbols; _i < propertySymbols_1.length; _i++) { + var propertySymbol = propertySymbols_1[_i]; + result.push.apply(result, getDefinitionFromSymbol(typeChecker, propertySymbol, node)); + } + return result; + } + } return getDefinitionFromSymbol(typeChecker, symbol, node); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; @@ -71580,13 +73093,13 @@ var ts; return undefined; } if (type.flags & 65536 /* Union */ && !(type.flags & 16 /* Enum */)) { - var result_6 = []; + var result_5 = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(/*to*/ result_6, /*from*/ getDefinitionFromSymbol(typeChecker, t.symbol, node)); + ts.addRange(/*to*/ result_5, /*from*/ getDefinitionFromSymbol(typeChecker, t.symbol, node)); } }); - return result_6; + return result_5; } if (!type.symbol) { return undefined; @@ -71633,29 +73146,42 @@ var ts; function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { var declarations = []; var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 150 /* Constructor */) || - (!selectConstructors && (d.kind === 226 /* FunctionDeclaration */ || d.kind === 149 /* MethodDeclaration */ || d.kind === 148 /* MethodSignature */))) { + for (var _i = 0, signatureDeclarations_1 = signatureDeclarations; _i < signatureDeclarations_1.length; _i++) { + var d = signatureDeclarations_1[_i]; + if (selectConstructors ? d.kind === 151 /* Constructor */ : isSignatureDeclaration(d)) { declarations.push(d); if (d.body) definition = d; } - }); - if (definition) { - result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); - return true; } - else if (declarations.length) { - result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); + if (declarations.length) { + result.push(createDefinitionInfo(definition || ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); return true; } return false; } } + function isSignatureDeclaration(node) { + switch (node.kind) { + case 151 /* Constructor */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + return true; + default: + return false; + } + } + /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */ function createDefinitionInfo(node, symbolKind, symbolName, containerName) { + return createDefinitionInfoFromName(node.name || node, symbolKind, symbolName, containerName); + } + /** Creates a DefinitionInfo directly from the name of a declaration. */ + function createDefinitionInfoFromName(name, symbolKind, symbolName, containerName) { + var sourceFile = name.getSourceFile(); return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromNode(name, sourceFile), kind: symbolKind, name: symbolName, containerKind: undefined, @@ -71703,7 +73229,15 @@ var ts; } function tryGetSignatureDeclaration(typeChecker, node) { var callLike = getAncestorCallLikeExpression(node); - return callLike && typeChecker.getResolvedSignature(callLike).declaration; + var signature = callLike && typeChecker.getResolvedSignature(callLike); + if (signature) { + var decl = signature.declaration; + if (decl && isSignatureDeclaration(decl)) { + return decl; + } + } + // Don't go to a function type, go to the value having that type. + return undefined; } })(GoToDefinition = ts.GoToDefinition || (ts.GoToDefinition = {})); })(ts || (ts = {})); @@ -71715,7 +73249,7 @@ var ts; function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 259 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 261 /* ShorthandPropertyAssignment */) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -71728,7 +73262,7 @@ var ts; } else { // Perform "Find all References" and retrieve only those that are implementations - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/ true); + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ false, /*implementations*/ true); var result = ts.flatMap(referencedSymbols, function (symbol) { return ts.map(symbol.references, function (_a) { var textSpan = _a.textSpan, fileName = _a.fileName; @@ -71882,19 +73416,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 226 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 150 /* Constructor */: - case 227 /* ClassDeclaration */: - case 206 /* VariableStatement */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 151 /* Constructor */: + case 228 /* ClassDeclaration */: + case 207 /* VariableStatement */: break findOwner; - case 262 /* SourceFile */: + case 264 /* SourceFile */: return undefined; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - if (commentOwner.parent.kind === 231 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 232 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -71941,7 +73475,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 206 /* VariableStatement */) { + if (commentOwner.kind === 207 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -71959,17 +73493,17 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 183 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 184 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return rightHandSide.parameters; - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150 /* Constructor */) { + if (member.kind === 151 /* Constructor */) { return member.parameters; } } @@ -72027,7 +73561,7 @@ var ts; }); if (!safeList) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = result.config ? ts.createMap(result.config) : EmptySafeList; + safeList = result.config ? ts.createMapFromTemplate(result.config) : EmptySafeList; } var filesToWatch = []; // Directories to search for package.json, bower.json and other typing information @@ -72054,33 +73588,33 @@ var ts; if (unresolvedImports) { for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { var moduleId = unresolvedImports_1[_a]; - var typingName = moduleId in nodeCoreModules ? "node" : moduleId; - if (!(typingName in inferredTypings)) { - inferredTypings[typingName] = undefined; + var typingName = nodeCoreModules.has(moduleId) ? "node" : moduleId; + if (!inferredTypings.has(typingName)) { + inferredTypings.set(typingName, undefined); } } } // Add the cached typing locations for inferred typings that are already installed - for (var name_47 in packageNameToTypingLocation) { - if (name_47 in inferredTypings && !inferredTypings[name_47]) { - inferredTypings[name_47] = packageNameToTypingLocation[name_47]; + packageNameToTypingLocation.forEach(function (typingLocation, name) { + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined) { + inferredTypings.set(name, typingLocation); } - } + }); // Remove typings that the user has added to the exclude list for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { var excludeTypingName = exclude_1[_b]; - delete inferredTypings[excludeTypingName]; + inferredTypings.delete(excludeTypingName); } var newTypingNames = []; var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); + inferredTypings.forEach(function (inferred, typing) { + if (inferred !== undefined) { + cachedTypingPaths.push(inferred); } else { newTypingNames.push(typing); } - } + }); return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; /** * Merge a given list of typingNames to the inferredTypings map @@ -72091,8 +73625,8 @@ var ts; } for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { var typing = typingNames_1[_i]; - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; + if (!inferredTypings.has(typing)) { + inferredTypings.set(typing, undefined); } } } @@ -72131,7 +73665,7 @@ var ts; var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); if (safeList !== EmptySafeList) { - mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return safeList.has(f); })); } var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2 /* JSX */; }); if (hasJsxFile) { @@ -72174,7 +73708,7 @@ var ts; } if (packageJson.typings) { var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; + inferredTypings.set(packageJson.name, absolutePath); } else { typingNames.push(packageJson.name); @@ -72194,47 +73728,49 @@ var ts; function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; - // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - ts.forEach(sourceFiles, function (sourceFile) { + var _loop_4 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { - return; + return "continue"; } - var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_48 in nameToDeclarations) { - var declarations = nameToDeclarations[name_48]; + ts.forEachEntry(sourceFile.getNamedDeclarations(), function (declarations, name) { 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_48); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); if (!matches) { - continue; + return; // continue to next named declarations } - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { + var declaration = declarations_12[_i]; // It was a match! If the pattern has dots in it, then also see if the // declaration container matches as well. if (patternMatcher.patternContainsDots) { var containers = getContainers(declaration); if (!containers) { - return undefined; + return true; // Break out of named declarations and go to the next source file. } - matches = patternMatcher.getMatches(containers, name_48); + matches = patternMatcher.getMatches(containers, name); if (!matches) { - continue; + return; // continue to next named declarations } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_48, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } - } - }); + }); + }; + // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] + for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { + var sourceFile = sourceFiles_8[_i]; + _loop_4(sourceFile); + } // Remove imports when the imported declaration is already in the list and has the same name. rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 237 /* ImportClause */ || decl.kind === 240 /* ImportSpecifier */ || decl.kind === 235 /* ImportEqualsDeclaration */) { + if (decl.kind === 238 /* ImportClause */ || decl.kind === 241 /* ImportSpecifier */ || decl.kind === 236 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -72276,7 +73812,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 142 /* ComputedPropertyName */) { + else if (declaration.name.kind === 143 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ true); } else { @@ -72297,7 +73833,7 @@ var ts; } return true; } - if (expression.kind === 177 /* PropertyAccessExpression */) { + if (expression.kind === 178 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -72310,7 +73846,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 === 142 /* ComputedPropertyName */) { + if (declaration.name.kind === 143 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } @@ -72356,7 +73892,7 @@ var ts; matchKind: ts.PatternMatchKind[rawItem.matchKind], isCaseSensitive: rawItem.isCaseSensitive, fileName: rawItem.fileName, - textSpan: ts.createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), + textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: container && container.name ? container.name.text : "", containerKind: container && container.name ? ts.getNodeKind(container) : "" @@ -72463,7 +73999,7 @@ var ts; return; } switch (node.kind) { - case 150 /* Constructor */: + case 151 /* Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -72475,21 +74011,21 @@ var ts; } } break; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 149 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 237 /* ImportClause */: + case 238 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -72501,7 +74037,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 238 /* NamespaceImport */) { + if (namedBindings.kind === 239 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -72512,12 +74048,12 @@ var ts; } } break; - case 174 /* BindingElement */: - case 224 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 225 /* VariableDeclaration */: var decl = node; - var name_49 = decl.name; - if (ts.isBindingPattern(name_49)) { - addChildrenRecursively(name_49); + var name = decl.name; + if (ts.isBindingPattern(name)) { + addChildrenRecursively(name); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { // For `const x = function() {}`, just use the function node, not the const. @@ -72527,12 +74063,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 185 /* ArrowFunction */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -72542,9 +74078,9 @@ var ts; } endNode(); break; - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 228 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -72552,21 +74088,21 @@ var ts; } endNode(); break; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 244 /* ExportSpecifier */: - case 235 /* ImportEqualsDeclaration */: - case 155 /* IndexSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 229 /* TypeAliasDeclaration */: + case 245 /* ExportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 156 /* IndexSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 230 /* TypeAliasDeclaration */: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 286 /* JSDocTypedefTag */) { + if (tag.kind === 289 /* JSDocTypedefTag */) { addLeafNode(tag); } }); @@ -72584,9 +74120,9 @@ var ts; // Anonymous items are never merged. return true; } - var itemsWithSameName = nameToItems[name]; + var itemsWithSameName = nameToItems.get(name); if (!itemsWithSameName) { - nameToItems[name] = child; + nameToItems.set(name, child); return true; } if (itemsWithSameName instanceof Array) { @@ -72604,7 +74140,7 @@ var ts; if (tryMerge(itemWithSameName, child)) { return false; } - nameToItems[name] = [itemWithSameName, child]; + nameToItems.set(name, [itemWithSameName, child]); return true; } function tryMerge(a, b) { @@ -72617,14 +74153,14 @@ var ts; }); /** a and b have the same name, but they may not be mergeable. */ function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 231 /* ModuleDeclaration */ || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 232 /* ModuleDeclaration */ || areSameModule(a, b)); // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 231 /* ModuleDeclaration */) { + if (a.body.kind !== 232 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -72652,39 +74188,20 @@ var ts; function compareChildren(child1, child2) { var name1 = tryGetName(child1.node), name2 = tryGetName(child2.node); if (name1 && name2) { - var cmp = localeCompareFix(name1, name2); + var cmp = ts.compareStringsCaseInsensitive(name1, name2); return cmp !== 0 ? cmp : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } else { return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } } - // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". - var localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; - var localeCompareFix = localeCompareIsCorrect ? ts.collator.compare : function (a, b) { - // This isn't perfect, but it passes all of our tests. - for (var i = 0; i < Math.min(a.length, b.length); i++) { - var chA = a.charAt(i), chB = b.charAt(i); - if (chA === "\"" && chB === "'") { - return 1; - } - if (chA === "'" && chB === "\"") { - return -1; - } - var cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); - if (cmp !== 0) { - return cmp; - } - } - return a.length - b.length; - }; /** * This differs from getItemName because this is just used for sorting. * We only sort nodes by name that have a more-or-less "direct" name, as opposed to `new()` and the like. * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 231 /* ModuleDeclaration */) { + if (node.kind === 232 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -72692,18 +74209,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 197 /* ClassExpression */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 198 /* ClassExpression */: return getFunctionOrClassName(node); - case 286 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 231 /* ModuleDeclaration */) { + if (node.kind === 232 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -72714,16 +74231,16 @@ var ts; } } switch (node.kind) { - case 262 /* SourceFile */: + case 264 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 185 /* ArrowFunction */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -72731,15 +74248,15 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return "constructor"; - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: return "new()"; - case 153 /* CallSignature */: + case 154 /* CallSignature */: return "()"; - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: return "[]"; - case 286 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return ""; @@ -72751,7 +74268,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 206 /* VariableStatement */) { + if (parentNode && parentNode.kind === 207 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -72780,24 +74297,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 230 /* EnumDeclaration */: - case 228 /* InterfaceDeclaration */: - case 231 /* ModuleDeclaration */: - case 262 /* SourceFile */: - case 229 /* TypeAliasDeclaration */: - case 286 /* JSDocTypedefTag */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 231 /* EnumDeclaration */: + case 229 /* InterfaceDeclaration */: + case 232 /* ModuleDeclaration */: + case 264 /* SourceFile */: + case 230 /* TypeAliasDeclaration */: + case 289 /* JSDocTypedefTag */: return true; - case 150 /* Constructor */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 224 /* VariableDeclaration */: + case 151 /* Constructor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 225 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 185 /* ArrowFunction */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -72807,10 +74324,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 232 /* ModuleBlock */: - case 262 /* SourceFile */: - case 149 /* MethodDeclaration */: - case 150 /* Constructor */: + case 233 /* ModuleBlock */: + case 264 /* SourceFile */: + case 150 /* MethodDeclaration */: + case 151 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -72819,7 +74336,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 224 /* VariableDeclaration */ && childKind !== 174 /* BindingElement */; + return childKind !== 225 /* VariableDeclaration */ && childKind !== 175 /* BindingElement */; }); } } @@ -72830,7 +74347,7 @@ var ts; return { text: getItemName(n.node), kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: ts.map(n.children, convertToTree) }; @@ -72839,7 +74356,7 @@ var ts; return { text: getItemName(n.node), kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, indent: n.indent, @@ -72877,7 +74394,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 === 231 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 232 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -72888,28 +74405,34 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 231 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 232 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 142 /* ComputedPropertyName */; + return !member.name || member.name.kind === 143 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 262 /* SourceFile */ + return node.kind === 264 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) - : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); + : ts.createTextSpanFromNode(node, curSourceFile); + } + function getModifiers(node) { + if (node.parent && node.parent.kind === 225 /* VariableDeclaration */) { + node = node.parent; + } + return ts.getNodeModifiers(node); } function getFunctionOrClassName(node) { if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 224 /* VariableDeclaration */) { + else if (node.parent.kind === 225 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 192 /* BinaryExpression */ && + else if (node.parent.kind === 193 /* BinaryExpression */ && node.parent.operatorToken.kind === 57 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 258 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 260 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512 /* Default */) { @@ -72920,7 +74443,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 184 /* FunctionExpression */ || node.kind === 185 /* ArrowFunction */ || node.kind === 197 /* ClassExpression */; + return node.kind === 185 /* FunctionExpression */ || node.kind === 186 /* ArrowFunction */ || node.kind === 198 /* ClassExpression */; } /** * Matches all whitespace characters in a string. Eg: @@ -72950,7 +74473,7 @@ var ts; if (hintSpanNode && startElement && endElement) { var span_12 = { textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), - hintSpan: ts.createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), + hintSpan: ts.createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse }; @@ -73010,7 +74533,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 185 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 186 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -73022,30 +74545,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 205 /* Block */: + case 206 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_20 = n.parent; + var parent = n.parent; var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent_20.kind === 210 /* DoStatement */ || - parent_20.kind === 213 /* ForInStatement */ || - parent_20.kind === 214 /* ForOfStatement */ || - parent_20.kind === 212 /* ForStatement */ || - parent_20.kind === 209 /* IfStatement */ || - parent_20.kind === 211 /* WhileStatement */ || - parent_20.kind === 218 /* WithStatement */ || - parent_20.kind === 257 /* CatchClause */) { - addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); + if (parent.kind === 211 /* DoStatement */ || + parent.kind === 214 /* ForInStatement */ || + parent.kind === 215 /* ForOfStatement */ || + parent.kind === 213 /* ForStatement */ || + parent.kind === 210 /* IfStatement */ || + parent.kind === 212 /* WhileStatement */ || + parent.kind === 219 /* WithStatement */ || + parent.kind === 259 /* CatchClause */) { + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_20.kind === 222 /* TryStatement */) { + if (parent.kind === 223 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_20; + var tryStatement = parent; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -73055,10 +74578,11 @@ var ts; break; } } + // fall through. } // Block was a standalone block. In this case we want to only collapse // the span of the block, independent of any parent span. - var span_14 = ts.createTextSpanFromBounds(n.getStart(), n.end); + var span_14 = ts.createTextSpanFromNode(n); elements.push({ textSpan: span_14, hintSpan: span_14, @@ -73068,23 +74592,23 @@ var ts; break; } // Fallthrough. - case 232 /* ModuleBlock */: { + case 233 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 230 /* EnumDeclaration */: - case 176 /* ObjectLiteralExpression */: - case 233 /* CaseBlock */: { + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 177 /* ObjectLiteralExpression */: + case 234 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 20 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -73180,10 +74704,11 @@ var ts; return totalMatch; } function getWordSpans(word) { - if (!(word in stringToWordSpans)) { - stringToWordSpans[word] = breakIntoWordSpans(word); + var spans = stringToWordSpans.get(word); + if (!spans) { + stringToWordSpans.set(word, spans = breakIntoWordSpans(word)); } - return stringToWordSpans[word]; + return spans; } function matchTextChunk(candidate, chunk, punctuationStripped) { var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); @@ -73758,7 +75283,7 @@ var ts; else { if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -73789,7 +75314,7 @@ var ts; } if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -73805,7 +75330,7 @@ var ts; token = nextToken(); if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -73835,7 +75360,7 @@ var ts; } if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -73847,7 +75372,7 @@ var ts; } else if (token === 38 /* AsteriskToken */) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -73999,93 +75524,85 @@ var ts; var Rename; (function (Rename) { function getRenameInfo(typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile, position) { - var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); + var getCanonicalDefaultLibName = ts.memoize(function () { return getCanonicalFileName(ts.normalizePath(defaultLibFileName)); }); var node = ts.getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); - if (node) { - if (node.kind === 70 /* Identifier */ || - node.kind === 9 /* StringLiteral */ || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - ts.isThis(node)) { - var symbol = typeChecker.getSymbolAtLocation(node); - // Only allow a symbol to be renamed if it actually has at least one declaration. - if (symbol) { - var declarations = symbol.getDeclarations(); - if (declarations && declarations.length > 0) { - // Disallow rename for elements that are defined in the standard TypeScript library. - if (ts.forEach(declarations, isDefinedInLibraryFile)) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); - var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - if (kind) { - return { - canRename: true, - kind: kind, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: typeChecker.getFullyQualifiedName(symbol), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - else if (node.kind === 9 /* StringLiteral */) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (type) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - else { - var displayName = ts.stripQuotes(type.text); - return { - canRename: true, - kind: ts.ScriptElementKind.variableElement, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: displayName, - kindModifiers: ts.ScriptElementKindModifier.none, - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - } - } - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element)); - function getRenameInfoError(localizedErrorMessage) { - return { - canRename: false, - localizedErrorMessage: localizedErrorMessage, - displayName: undefined, - fullDisplayName: undefined, - kind: undefined, - kindModifiers: undefined, - triggerSpan: undefined - }; - } + var renameInfo = node && nodeIsEligibleForRename(node) + ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) + : undefined; + return renameInfo || getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); function isDefinedInLibraryFile(declaration) { - if (defaultLibFileName) { - var sourceFile_1 = declaration.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_1.fileName)); - if (canonicalName === canonicalDefaultLibName) { - return true; - } + if (!defaultLibFileName) { + return false; } - return false; - } - function createTriggerSpanForNode(node, sourceFile) { - var start = node.getStart(sourceFile); - var width = node.getWidth(sourceFile); - if (node.kind === 9 /* StringLiteral */) { - // Exclude the quotes - start += 1; - width -= 2; - } - return ts.createTextSpan(start, width); + var sourceFile = declaration.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); + return canonicalName === getCanonicalDefaultLibName(); } } Rename.getRenameInfo = getRenameInfo; + function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { + var symbol = typeChecker.getSymbolAtLocation(node); + // Only allow a symbol to be renamed if it actually has at least one declaration. + if (symbol) { + var declarations = symbol.getDeclarations(); + if (declarations && declarations.length > 0) { + // Disallow rename for elements that are defined in the standard TypeScript library. + if (ts.some(declarations, isDefinedInLibraryFile)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); + } + var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); + var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); + return kind ? getRenameInfoSuccess(displayName, typeChecker.getFullyQualifiedName(symbol), kind, ts.SymbolDisplay.getSymbolModifiers(symbol), node, sourceFile) : undefined; + } + } + else if (node.kind === 9 /* StringLiteral */) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (type) { + if (isDefinedInLibraryFile(node)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); + } + var displayName = ts.stripQuotes(type.text); + return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); + } + } + } + function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { + return { + canRename: true, + kind: kind, + displayName: displayName, + localizedErrorMessage: undefined, + fullDisplayName: fullDisplayName, + kindModifiers: kindModifiers, + triggerSpan: createTriggerSpanForNode(node, sourceFile) + }; + } + function getRenameInfoError(diagnostic) { + return { + canRename: false, + localizedErrorMessage: ts.getLocaleSpecificMessage(diagnostic), + displayName: undefined, + fullDisplayName: undefined, + kind: undefined, + kindModifiers: undefined, + triggerSpan: undefined + }; + } + function createTriggerSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var width = node.getWidth(sourceFile); + if (node.kind === 9 /* StringLiteral */) { + // Exclude the quotes + start += 1; + width -= 2; + } + return ts.createTextSpan(start, width); + } + function nodeIsEligibleForRename(node) { + return node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || + ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + ts.isThis(node); + } })(Rename = ts.Rename || (ts.Rename = {})); })(ts || (ts = {})); /// @@ -74232,6 +75749,7 @@ var ts; ArgumentListKind[ArgumentListKind["TypeArguments"] = 0] = "TypeArguments"; ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; + ArgumentListKind[ArgumentListKind["JSXAttributesArguments"] = 3] = "JSXAttributesArguments"; })(ArgumentListKind = SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); @@ -74263,7 +75781,7 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 179 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 180 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -74271,7 +75789,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 70 /* Identifier */ ? expression - : expression.kind === 177 /* PropertyAccessExpression */ + : expression.kind === 178 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -74281,10 +75799,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameToDeclarations = sourceFile.getNamedDeclarations(); - var declarations = nameToDeclarations[name.text]; + var declarations = nameToDeclarations.get(name.text); if (declarations) { - for (var _b = 0, declarations_10 = declarations; _b < declarations_10.length; _b++) { - var declaration = declarations_10[_b]; + for (var _b = 0, declarations_13 = declarations; _b < declarations_13.length; _b++) { + var declaration = declarations_13[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -74304,21 +75822,21 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 179 /* CallExpression */ || node.parent.kind === 180 /* NewExpression */) { + if (node.parent.kind === 180 /* CallExpression */ || node.parent.kind === 181 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: - // 1. The token introduces a list, and should begin a sig help session + // 1. The token introduces a list, and should begin a signature help session // 2. The token is either not associated with a list, or ends a list, so the session should end - // 3. The token is buried inside a list, and should give sig help + // 3. The token is buried inside a list, and should give signature help // // The following are examples of each: // // Case 1: - // foo<#T, U>(#a, b) -> The token introduces a list, and should begin a sig help session + // foo<#T, U>(#a, b) -> The token introduces a list, and should begin a signature help session // Case 2: // fo#o#(a, b)# -> The token is either not associated with a list, or ends a list, so the session should end // Case 3: - // foo(a#, #b#) -> The token is buried inside a list, and should give sig help + // foo(a#, #b#) -> The token is buried inside a list, and should give signature help // Find out if 'node' is an argument, a type argument, or neither if (node.kind === 26 /* LessThanToken */ || node.kind === 18 /* OpenParenToken */) { @@ -74337,7 +75855,7 @@ var ts; } // findListItemInfo can return undefined if we are not in parent's argument list // or type argument list. This includes cases where the cursor is: - // - To the right of the closing paren, non-substitution template, or template tail. + // - To the right of the closing parenthesis, non-substitution template, or template tail. // - Between the type arguments and the arguments (greater than token) // - On the target of the call (parent.func) // - On the 'new' keyword in a 'new' expression @@ -74358,25 +75876,25 @@ var ts; } return undefined; } - else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 181 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 182 /* 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, /*argumentIndex*/ 0, sourceFile); } } - else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 181 /* TaggedTemplateExpression */) { + else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 182 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 194 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 195 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 203 /* TemplateSpan */ && node.parent.parent.parent.kind === 181 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 204 /* TemplateSpan */ && node.parent.parent.parent.kind === 182 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 194 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 195 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 15 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -74385,8 +75903,25 @@ var ts; var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position); return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } + else if (node.parent && ts.isJsxOpeningLikeElement(node.parent)) { + // Provide a signature help for JSX opening element or JSX self-closing element. + // This is not guarantee that JSX tag-name is resolved into stateless function component. (that is done in "getSignatureHelpItems") + // i.e + // export function MainButton(props: ButtonProps, context: any): JSX.Element { ... } + // ' '' - // That will give us 2 non-commas. We then add one for the last comma, givin us an + // That will give us 2 non-commas. We then add one for the last comma, giving us an // arg count of 3. var listChildren = argumentsList.getChildren(); var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 25 /* CommaToken */; }); @@ -74494,7 +76029,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 === 194 /* TemplateExpression */) { + if (template.kind === 195 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -74503,7 +76038,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 262 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 264 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -74516,6 +76051,7 @@ var ts; if (argumentInfo) { return argumentInfo; } + // TODO: Handle generic call with incomplete syntax } return undefined; } @@ -74648,7 +76184,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 197 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 198 /* ClassExpression */) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ts.ScriptElementKind.enumElement; @@ -74705,7 +76241,7 @@ var ts; if (flags & 16384 /* Constructor */) return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4 /* Property */) { - if (flags & 268435456 /* SyntheticProperty */) { + if (flags & 134217728 /* Transient */ && symbol.checkFlags & 2 /* 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(); @@ -74725,6 +76261,9 @@ var ts; } return unionPropertyKind; } + if (location.parent && ts.isJsxAttribute(location.parent)) { + return ts.ScriptElementKind.jsxAttribute; + } return ts.ScriptElementKind.memberVariableElement; } return ts.ScriptElementKind.unknown; @@ -74754,7 +76293,7 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 177 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 178 /* 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)) { @@ -74762,21 +76301,24 @@ var ts; } } // try get the call/construct signature from the type if it matches - var callExpression = void 0; - if (location.kind === 179 /* CallExpression */ || location.kind === 180 /* NewExpression */) { - callExpression = location; + var callExpressionLike = void 0; + if (location.kind === 180 /* CallExpression */ || location.kind === 181 /* NewExpression */) { + callExpressionLike = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { - callExpression = location.parent; + callExpressionLike = location.parent; } - if (callExpression) { + else if (location.parent && ts.isJsxOpeningLikeElement(location.parent) && ts.isFunctionLike(symbol.valueDeclaration)) { + callExpressionLike = location.parent; + } + if (callExpressionLike) { var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); if (!signature && candidateSignatures.length) { // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 180 /* NewExpression */ || callExpression.expression.kind === 96 /* SuperKeyword */; + var useConstructSignatures = callExpressionLike.kind === 181 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 96 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -74803,6 +76345,7 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { + case ts.ScriptElementKind.jsxAttribute: case ts.ScriptElementKind.memberVariableElement: case ts.ScriptElementKind.variableElement: case ts.ScriptElementKind.constElement: @@ -74829,24 +76372,24 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 150 /* Constructor */)) { + (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 151 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 150 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 151 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 150 /* Constructor */) { + if (functionDeclaration.kind === 151 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 153 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 154 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -74855,7 +76398,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 197 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 198 /* 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 @@ -74878,7 +76421,7 @@ var ts; } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(136 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(137 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -74899,7 +76442,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 231 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 232 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 70 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 128 /* NamespaceKeyword */ : 127 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -74920,28 +76463,28 @@ var ts; } else { // Method/function type parameter - var declaration = ts.getDeclarationOfKind(symbol, 143 /* TypeParameter */); + var declaration = ts.getDeclarationOfKind(symbol, 144 /* TypeParameter */); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 154 /* ConstructSignature */) { + if (declaration.kind === 155 /* ConstructSignature */) { displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 153 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 154 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 229 /* TypeAliasDeclaration */) { + else if (declaration.kind === 230 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(136 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(137 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -74952,7 +76495,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 261 /* EnumMember */) { + if (declaration.kind === 263 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -74964,7 +76507,7 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 234 /* NamespaceExportDeclaration */) { + if (symbol.declarations[0].kind === 235 /* NamespaceExportDeclaration */) { displayParts.push(ts.keywordPart(83 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(128 /* NamespaceKeyword */)); @@ -74975,7 +76518,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 235 /* ImportEqualsDeclaration */) { + if (declaration.kind === 236 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -75011,6 +76554,7 @@ var ts; } // For properties, variables and local vars: show the type if (symbolKind === ts.ScriptElementKind.memberVariableElement || + symbolKind === ts.ScriptElementKind.jsxAttribute || symbolFlags & 3 /* Variable */ || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { @@ -75048,10 +76592,10 @@ var ts; // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 262 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 264 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 192 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 193 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -75132,16 +76676,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 184 /* FunctionExpression */) { + if (declaration.kind === 185 /* FunctionExpression */) { return true; } - if (declaration.kind !== 224 /* VariableDeclaration */ && declaration.kind !== 226 /* FunctionDeclaration */) { + if (declaration.kind !== 225 /* VariableDeclaration */ && declaration.kind !== 227 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { + for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent_21.kind === 262 /* SourceFile */ || parent_21.kind === 232 /* ModuleBlock */) { + if (parent.kind === 264 /* SourceFile */ || parent.kind === 233 /* ModuleBlock */) { return false; } } @@ -75194,7 +76738,7 @@ var ts; sourceFile.moduleName = transpileOptions.moduleName; } if (transpileOptions.renamedDependencies) { - sourceFile.renamedDependencies = ts.createMap(transpileOptions.renamedDependencies); + sourceFile.renamedDependencies = ts.createMapFromTemplate(transpileOptions.renamedDependencies); } var newLine = ts.getNewLineCharacter(options); // Output @@ -75249,10 +76793,10 @@ var ts; function fixupCompilerOptions(options, diagnostics) { // Lazily create this value to fix module loading errors. commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { - return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); + return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_3 = function (opt) { + var _loop_5 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -75263,7 +76807,7 @@ var ts; options[opt.name] = ts.parseCustomTypeOption(opt, value, diagnostics); } else { - if (!ts.forEachProperty(opt.type, function (v) { return v === value; })) { + if (!ts.forEachEntry(opt.type, function (v) { return v === value; })) { // Supplied value isn't a valid enum value. diagnostics.push(ts.createCompilerDiagnosticForInvalidCustomType(opt)); } @@ -75271,7 +76815,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_3(opt); + _loop_5(opt); } return options; } @@ -75379,10 +76923,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 251 /* JsxAttribute */: - case 249 /* JsxOpeningElement */: - case 250 /* JsxClosingElement */: - case 248 /* JsxSelfClosingElement */: + case 252 /* JsxAttribute */: + case 250 /* JsxOpeningElement */: + case 251 /* JsxClosingElement */: + case 249 /* JsxSelfClosingElement */: return node.kind === 70 /* Identifier */; } } @@ -75794,7 +77338,7 @@ var ts; this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Space after }. - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromRange(0 /* FirstToken */, 140 /* LastToken */, [19 /* CloseParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromRange(0 /* FirstToken */, 141 /* LastToken */, [19 /* CloseParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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(17 /* CloseBraceToken */, 81 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 105 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); @@ -75859,7 +77403,7 @@ var ts; this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101 /* TryKeyword */, 86 /* FinallyKeyword */]), 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124 /* GetKeyword */, 133 /* SetKeyword */]), 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124 /* GetKeyword */, 134 /* SetKeyword */]), 70 /* 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); @@ -75870,8 +77414,8 @@ var ts; // 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([127 /* ModuleKeyword */, 131 /* RequireKeyword */]), 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 130 /* ReadonlyKeyword */, 133 /* SetKeyword */, 114 /* StaticKeyword */, 136 /* TypeKeyword */, 138 /* FromKeyword */, 126 /* KeyOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 138 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 130 /* ReadonlyKeyword */, 134 /* SetKeyword */, 114 /* StaticKeyword */, 137 /* TypeKeyword */, 139 /* FromKeyword */, 126 /* KeyOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 139 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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(9 /* StringLiteral */, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions @@ -75891,7 +77435,7 @@ var ts; // decorators this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 133 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 134 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115 /* YieldKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); @@ -76021,9 +77565,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_50 in o) { - if (o[name_50] === rule) { - return name_50; + for (var name in o) { + if (o[name] === rule) { + return name; } } throw new Error("Unknown rule"); @@ -76032,44 +77576,44 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 212 /* ForStatement */; + return context.contextNode.kind === 213 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 192 /* BinaryExpression */: - case 193 /* ConditionalExpression */: - case 200 /* AsExpression */: - case 244 /* ExportSpecifier */: - case 240 /* ImportSpecifier */: - case 156 /* TypePredicate */: - case 164 /* UnionType */: - case 165 /* IntersectionType */: + case 193 /* BinaryExpression */: + case 194 /* ConditionalExpression */: + case 201 /* AsExpression */: + case 245 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: + case 157 /* TypePredicate */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 174 /* BindingElement */: + case 175 /* BindingElement */: // equals in type X = ... - case 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: // equal in p = 0; - case 144 /* Parameter */: - case 261 /* EnumMember */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 145 /* Parameter */: + case 263 /* EnumMember */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return context.currentTokenSpan.kind === 57 /* EqualsToken */ || context.nextTokenSpan.kind === 57 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return context.currentTokenSpan.kind === 91 /* InKeyword */ || context.nextTokenSpan.kind === 91 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 214 /* ForOfStatement */: - return context.currentTokenSpan.kind === 140 /* OfKeyword */ || context.nextTokenSpan.kind === 140 /* OfKeyword */; + case 215 /* ForOfStatement */: + return context.currentTokenSpan.kind === 141 /* OfKeyword */ || context.nextTokenSpan.kind === 141 /* OfKeyword */; } return false; }; @@ -76077,7 +77621,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 193 /* ConditionalExpression */; + return context.contextNode.kind === 194 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -76099,7 +77643,7 @@ var ts; return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; Rules.IsBraceWrappedContext = function (context) { - return context.contextNode.kind === 172 /* ObjectBindingPattern */ || Rules.IsSingleLineBlockContext(context); + return context.contextNode.kind === 173 /* ObjectBindingPattern */ || Rules.IsSingleLineBlockContext(context); }; // This check is done before an open brace in a control construct, a function, or a typescript block declaration Rules.IsBeforeMultilineBlockContext = function (context) { @@ -76124,70 +77668,70 @@ var ts; return true; } switch (node.kind) { - case 205 /* Block */: - case 233 /* CaseBlock */: - case 176 /* ObjectLiteralExpression */: - case 232 /* ModuleBlock */: + case 206 /* Block */: + case 234 /* CaseBlock */: + case 177 /* ObjectLiteralExpression */: + case 233 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 226 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 153 /* CallSignature */: - case 184 /* FunctionExpression */: - case 150 /* Constructor */: - case 185 /* ArrowFunction */: + case 154 /* CallSignature */: + case 185 /* FunctionExpression */: + case 151 /* Constructor */: + case 186 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 226 /* FunctionDeclaration */ || context.contextNode.kind === 184 /* FunctionExpression */; + return context.contextNode.kind === 227 /* FunctionDeclaration */ || context.contextNode.kind === 185 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 228 /* InterfaceDeclaration */: - case 230 /* EnumDeclaration */: - case 161 /* TypeLiteral */: - case 231 /* ModuleDeclaration */: - case 242 /* ExportDeclaration */: - case 243 /* NamedExports */: - case 236 /* ImportDeclaration */: - case 239 /* NamedImports */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 162 /* TypeLiteral */: + case 232 /* ModuleDeclaration */: + case 243 /* ExportDeclaration */: + case 244 /* NamedExports */: + case 237 /* ImportDeclaration */: + case 240 /* NamedImports */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 227 /* ClassDeclaration */: - case 231 /* ModuleDeclaration */: - case 230 /* EnumDeclaration */: - case 257 /* CatchClause */: - case 232 /* ModuleBlock */: - case 219 /* SwitchStatement */: + case 228 /* ClassDeclaration */: + case 232 /* ModuleDeclaration */: + case 231 /* EnumDeclaration */: + case 259 /* CatchClause */: + case 233 /* ModuleBlock */: + case 220 /* SwitchStatement */: return true; - case 205 /* Block */: { + case 206 /* Block */: { var blockParent = context.currentTokenParent.parent; - if (blockParent.kind !== 185 /* ArrowFunction */ && - blockParent.kind !== 184 /* FunctionExpression */) { + if (blockParent.kind !== 186 /* ArrowFunction */ && + blockParent.kind !== 185 /* FunctionExpression */) { return true; } } @@ -76196,31 +77740,31 @@ var ts; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 209 /* IfStatement */: - case 219 /* SwitchStatement */: - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 211 /* WhileStatement */: - case 222 /* TryStatement */: - case 210 /* DoStatement */: - case 218 /* WithStatement */: + case 210 /* IfStatement */: + case 220 /* SwitchStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 212 /* WhileStatement */: + case 223 /* TryStatement */: + case 211 /* DoStatement */: + case 219 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 257 /* CatchClause */: + case 259 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 176 /* ObjectLiteralExpression */; + return context.contextNode.kind === 177 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 179 /* CallExpression */; + return context.contextNode.kind === 180 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 180 /* NewExpression */; + return context.contextNode.kind === 181 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -76232,25 +77776,25 @@ var ts; return context.nextTokenSpan.kind !== 21 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 185 /* ArrowFunction */; + return context.contextNode.kind === 186 /* ArrowFunction */; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 247 /* JsxElement */; + return context.contextNode.kind !== 248 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 253 /* JsxExpression */; + return context.contextNode.kind === 255 /* JsxExpression */; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 251 /* JsxAttribute */; + return context.nextTokenParent.kind === 252 /* JsxAttribute */; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 251 /* JsxAttribute */; + return context.contextNode.kind === 252 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 248 /* JsxSelfClosingElement */; + return context.contextNode.kind === 249 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -76265,42 +77809,42 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 145 /* Decorator */; + return node.kind === 146 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 225 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 226 /* 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 === 231 /* ModuleDeclaration */; + return context.contextNode.kind === 232 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 161 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 162 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 26 /* LessThanToken */ && token.kind !== 28 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 157 /* TypeReference */: - case 182 /* TypeAssertionExpression */: - case 229 /* TypeAliasDeclaration */: - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 228 /* InterfaceDeclaration */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 199 /* ExpressionWithTypeArguments */: + case 158 /* TypeReference */: + case 183 /* TypeAssertionExpression */: + case 230 /* TypeAliasDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 200 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -76311,16 +77855,16 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 182 /* TypeAssertionExpression */; + return context.contextNode.kind === 183 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 188 /* VoidExpression */; + return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 189 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 195 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 196 /* YieldExpression */ && context.contextNode.expression !== undefined; }; Rules.IsNonNullAssertionContext = function (context) { - return context.contextNode.kind === 201 /* NonNullExpression */; + return context.contextNode.kind === 202 /* NonNullExpression */; }; return Rules; }()); @@ -76344,7 +77888,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 140 /* LastToken */ + 1; + this.mapRowLength = 141 /* 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); @@ -76358,7 +77902,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - ts.Debug.assert(row <= 140 /* LastKeyword */ && column <= 140 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 141 /* LastKeyword */ && column <= 141 /* LastKeyword */, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -76539,7 +78083,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 140 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 141 /* LastToken */; token++) { result.push(token); } return result; @@ -76583,9 +78127,9 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 140 /* LastKeyword */); + TokenRange.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 141 /* LastKeyword */); TokenRange.BinaryOperators = TokenRange.FromRange(26 /* FirstBinaryOperator */, 69 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 140 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 141 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42 /* PlusPlusToken */, 43 /* MinusMinusToken */, 51 /* TildeToken */, 50 /* ExclamationToken */]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 70 /* Identifier */, 18 /* OpenParenToken */, 20 /* OpenBracketToken */, 16 /* OpenBraceToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); @@ -76593,7 +78137,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 132 /* NumberKeyword */, 134 /* StringKeyword */, 121 /* BooleanKeyword */, 135 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 132 /* NumberKeyword */, 135 /* StringKeyword */, 121 /* BooleanKeyword */, 136 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -76864,17 +78408,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 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 232 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 262 /* SourceFile */: - case 205 /* Block */: - case 232 /* ModuleBlock */: + return body && body.kind === 233 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 264 /* SourceFile */: + case 206 /* Block */: + case 233 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -77079,20 +78623,20 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 227 /* ClassDeclaration */: return 74 /* ClassKeyword */; - case 228 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; - case 226 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; - case 230 /* EnumDeclaration */: return 230 /* EnumDeclaration */; - case 151 /* GetAccessor */: return 124 /* GetKeyword */; - case 152 /* SetAccessor */: return 133 /* SetKeyword */; - case 149 /* MethodDeclaration */: + case 228 /* ClassDeclaration */: return 74 /* ClassKeyword */; + case 229 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; + case 227 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; + case 231 /* EnumDeclaration */: return 231 /* EnumDeclaration */; + case 152 /* GetAccessor */: return 124 /* GetKeyword */; + case 153 /* SetAccessor */: return 134 /* SetKeyword */; + case 150 /* MethodDeclaration */: if (node.asteriskToken) { return 38 /* AsteriskToken */; } /* fall-through */ - case 147 /* PropertyDeclaration */: - case 144 /* Parameter */: + case 148 /* PropertyDeclaration */: + case 145 /* Parameter */: return node.name.kind; } } @@ -77130,16 +78674,16 @@ var ts; return indentation; case 40 /* SlashToken */: case 28 /* GreaterThanToken */: { - if (container.kind === 249 /* JsxOpeningElement */ || - container.kind === 250 /* JsxClosingElement */ || - container.kind === 248 /* JsxSelfClosingElement */) { + if (container.kind === 250 /* JsxOpeningElement */ || + container.kind === 251 /* JsxClosingElement */ || + container.kind === 249 /* JsxSelfClosingElement */) { return indentation; } break; } case 20 /* OpenBracketToken */: case 21 /* CloseBracketToken */: { - if (container.kind !== 170 /* MappedType */) { + if (container.kind !== 171 /* MappedType */) { return indentation; } break; @@ -77249,11 +78793,11 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 145 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 146 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 175 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 176 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -77610,12 +79154,12 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 150 /* Constructor */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 185 /* ArrowFunction */: + case 151 /* Constructor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 186 /* ArrowFunction */: if (node.typeParameters === list) { return 26 /* LessThanToken */; } @@ -77623,8 +79167,8 @@ var ts; return 18 /* OpenParenToken */; } break; - case 179 /* CallExpression */: - case 180 /* NewExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: if (node.typeArguments === list) { return 26 /* LessThanToken */; } @@ -77632,7 +79176,7 @@ var ts; return 18 /* OpenParenToken */; } break; - case 157 /* TypeReference */: + case 158 /* TypeReference */: if (node.typeArguments === list) { return 26 /* LessThanToken */; } @@ -77748,7 +79292,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 192 /* BinaryExpression */) { + if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 193 /* 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 */) { @@ -77871,7 +79415,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.isStatementButNotDeclaration(current)) && - (parent.kind === 262 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 264 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -77904,7 +79448,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 209 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 210 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -77916,23 +79460,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 157 /* TypeReference */: + case 158 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return node.parent.properties; - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return node.parent.elements; - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: { + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -77943,8 +79487,8 @@ var ts; } break; } - case 180 /* NewExpression */: - case 179 /* CallExpression */: { + case 181 /* NewExpression */: + case 180 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -77974,8 +79518,8 @@ var ts; if (node.kind === 19 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 179 /* CallExpression */ || - node.parent.kind === 180 /* NewExpression */) && + if (node.parent && (node.parent.kind === 180 /* CallExpression */ || + node.parent.kind === 181 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -77993,10 +79537,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 177 /* PropertyAccessExpression */: - case 178 /* ElementAccessExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 178 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: node = node.expression; break; default: @@ -78060,49 +79604,49 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 208 /* ExpressionStatement */: - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 228 /* InterfaceDeclaration */: - case 230 /* EnumDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 175 /* ArrayLiteralExpression */: - case 205 /* Block */: - case 232 /* ModuleBlock */: - case 176 /* ObjectLiteralExpression */: - case 161 /* TypeLiteral */: - case 170 /* MappedType */: - case 163 /* TupleType */: - case 233 /* CaseBlock */: - case 255 /* DefaultClause */: - case 254 /* CaseClause */: - case 183 /* ParenthesizedExpression */: - case 177 /* PropertyAccessExpression */: - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 206 /* VariableStatement */: - case 224 /* VariableDeclaration */: - case 241 /* ExportAssignment */: - case 217 /* ReturnStatement */: - case 193 /* ConditionalExpression */: - case 173 /* ArrayBindingPattern */: - case 172 /* ObjectBindingPattern */: - case 249 /* JsxOpeningElement */: - case 248 /* JsxSelfClosingElement */: - case 253 /* JsxExpression */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 144 /* Parameter */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 166 /* ParenthesizedType */: - case 181 /* TaggedTemplateExpression */: - case 189 /* AwaitExpression */: - case 243 /* NamedExports */: - case 239 /* NamedImports */: - case 244 /* ExportSpecifier */: - case 240 /* ImportSpecifier */: + case 209 /* ExpressionStatement */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 176 /* ArrayLiteralExpression */: + case 206 /* Block */: + case 233 /* ModuleBlock */: + case 177 /* ObjectLiteralExpression */: + case 162 /* TypeLiteral */: + case 171 /* MappedType */: + case 164 /* TupleType */: + case 234 /* CaseBlock */: + case 257 /* DefaultClause */: + case 256 /* CaseClause */: + case 184 /* ParenthesizedExpression */: + case 178 /* PropertyAccessExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 207 /* VariableStatement */: + case 225 /* VariableDeclaration */: + case 242 /* ExportAssignment */: + case 218 /* ReturnStatement */: + case 194 /* ConditionalExpression */: + case 174 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 250 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + case 255 /* JsxExpression */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 145 /* Parameter */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 167 /* ParenthesizedType */: + case 182 /* TaggedTemplateExpression */: + case 190 /* AwaitExpression */: + case 244 /* NamedExports */: + case 240 /* NamedImports */: + case 245 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: return true; } return false; @@ -78111,27 +79655,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 210 /* DoStatement */: - case 211 /* WhileStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 212 /* ForStatement */: - case 209 /* IfStatement */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 185 /* ArrowFunction */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - return childKind !== 205 /* Block */; - case 242 /* ExportDeclaration */: - return childKind !== 243 /* NamedExports */; - case 236 /* ImportDeclaration */: - return childKind !== 237 /* ImportClause */ || - (child.namedBindings && child.namedBindings.kind !== 239 /* NamedImports */); - case 247 /* JsxElement */: - return childKind !== 250 /* JsxClosingElement */; + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 213 /* ForStatement */: + case 210 /* IfStatement */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 186 /* ArrowFunction */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + return childKind !== 206 /* Block */; + case 243 /* ExportDeclaration */: + return childKind !== 244 /* NamedExports */; + case 237 /* ImportDeclaration */: + return childKind !== 238 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 240 /* NamedImports */); + case 248 /* JsxElement */: + return childKind !== 251 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -78152,7 +79696,7 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var codeFixes = ts.createMap(); + var codeFixes = []; function registerCodeFix(action) { ts.forEach(action.errorCodes, function (error) { var fixes = codeFixes[error]; @@ -78228,9 +79772,9 @@ var ts; if (IndexInfoOfKind) { var writer = ts.getSingleLineStringWriter(); checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); - var result_7 = writer.string(); + var result_6 = writer.string(); ts.releaseStringWriter(writer); - return result_7; + return result_6; } } return ""; @@ -78324,7 +79868,7 @@ var ts; } // figure out if the this access is actuall inside the supercall // i.e. super(this.a), since in that case we won't suggest a fix - if (superCall.expression && superCall.expression.kind == 179 /* CallExpression */) { + if (superCall.expression && superCall.expression.kind == 180 /* CallExpression */) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -78348,7 +79892,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -78431,6 +79975,25 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + var start = token.getStart(sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_this_to_unresolved_variable), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start: start, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -78450,43 +80013,43 @@ var ts; switch (token.kind) { case 70 /* Identifier */: switch (token.parent.kind) { - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: switch (token.parent.parent.parent.kind) { - case 212 /* ForStatement */: + case 213 /* ForStatement */: var forStatement = token.parent.parent.parent; var forInitializer = forStatement.initializer; if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); + return createCodeFixToRemoveNode(forInitializer); } else { return removeSingleItem(forInitializer.declarations, token); } - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 225 /* VariableDeclarationList */) { + if (forOfStatement.initializer.kind === 226 /* VariableDeclarationList */) { var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); + return createCodeFix("{}", forOfInitializer.declarations[0].getStart(), forOfInitializer.declarations[0].getWidth()); } break; - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: // There is no valid fix in the case of: // for .. in return undefined; - case 257 /* CatchClause */: + case 259 /* CatchClause */: var catchClause = token.parent.parent; var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); + return createCodeFixToRemoveNode(parameter); default: var variableStatement = token.parent.parent.parent; if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); + return createCodeFixToRemoveNode(variableStatement); } else { var declarations = variableStatement.declarationList.declarations; return removeSingleItem(declarations, token); } } - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: var typeParameters = token.parent.parent.typeParameters; if (typeParameters.length === 1) { return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); @@ -78494,75 +80057,101 @@ var ts; else { return removeSingleItem(typeParameters, token); } - case 144 /* Parameter */: + case 145 /* Parameter */: var functionDeclaration = token.parent.parent; if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + return createCodeFixToRemoveNode(token.parent); } else { return removeSingleItem(functionDeclaration.parameters, token); } // handle case where 'import a = A;' - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: var importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case 240 /* ImportSpecifier */: + return createCodeFixToRemoveNode(importEquals); + case 241 /* ImportSpecifier */: var namedImports = token.parent.parent; if (namedImports.elements.length === 1) { // Only 1 import and it is unused. So the entire declaration should be removed. var importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); + return createCodeFixToRemoveNode(importSpec); } else { return removeSingleItem(namedImports.elements, token); } - // handle case where "import d, * as ns from './file'" + // handle case where "import d, * as ns from './file'" // or "'import {a, b as ns} from './file'" - case 237 /* ImportClause */: + case 238 /* ImportClause */: var importClause = token.parent; if (!importClause.namedBindings) { var importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + return createCodeFixToRemoveNode(importDecl); } else { - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); + // import |d,| * as ns from './file' + var start_4 = importClause.name.getStart(); + var end = findFirstNonSpaceCharPosStarting(importClause.name.end); + if (sourceFile.text.charCodeAt(end) === 44 /* comma */) { + end = findFirstNonSpaceCharPosStarting(end + 1); + } + return createCodeFix("", start_4, end - start_4); } - case 238 /* NamespaceImport */: + case 239 /* NamespaceImport */: var namespaceImport = token.parent; if (namespaceImport.name == token && !namespaceImport.parent.name) { var importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + return createCodeFixToRemoveNode(importDecl); } else { - var start_4 = namespaceImport.parent.name.end; - return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); + var start_5 = namespaceImport.parent.name.end; + return createCodeFix("", start_5, namespaceImport.parent.namedBindings.end - start_5); } } break; - case 147 /* PropertyDeclaration */: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case 238 /* NamespaceImport */: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + case 148 /* PropertyDeclaration */: + case 239 /* NamespaceImport */: + return createCodeFixToRemoveNode(token.parent); } if (ts.isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + return createCodeFixToRemoveNode(token.parent); } else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); + return createCodeFixToRemoveNode(token.parent.parent); } else { return undefined; } function findImportDeclaration(token) { var importDecl = token; - while (importDecl.kind != 236 /* ImportDeclaration */ && importDecl.parent) { + while (importDecl.kind != 237 /* ImportDeclaration */ && importDecl.parent) { importDecl = importDecl.parent; } return importDecl; } + function createCodeFixToRemoveNode(node) { + var end = node.getEnd(); + var endCharCode = sourceFile.text.charCodeAt(end); + var afterEndCharCode = sourceFile.text.charCodeAt(end + 1); + if (ts.isLineBreak(endCharCode)) { + end += 1; + } + // in the case of CR LF, you could have two consecutive new line characters for one new line. + // this needs to be differenciated from two LF LF chars that actually mean two new lines. + if (ts.isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) { + end += 1; + } + var start = node.getStart(); + return createCodeFix("", start, end - start); + } + function findFirstNonSpaceCharPosStarting(start) { + while (ts.isWhiteSpace(sourceFile.text.charCodeAt(start))) { + start += 1; + } + return start; + } function createCodeFix(newText, start, length) { return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: newText, span: { start: start, length: length } }] @@ -78594,18 +80183,19 @@ var ts; })(ModuleSpecifierComparison || (ModuleSpecifierComparison = {})); var ImportCodeActionMap = (function () { function ImportCodeActionMap() { - this.symbolIdToActionMap = ts.createMap(); + this.symbolIdToActionMap = []; } ImportCodeActionMap.prototype.addAction = function (symbolId, newAction) { if (!newAction) { return; } - if (!this.symbolIdToActionMap[symbolId]) { + var actions = this.symbolIdToActionMap[symbolId]; + if (!actions) { this.symbolIdToActionMap[symbolId] = [newAction]; return; } if (newAction.kind === "CodeChange") { - this.symbolIdToActionMap[symbolId].push(newAction); + actions.push(newAction); return; } var updatedNewImports = []; @@ -78649,8 +80239,8 @@ var ts; }; ImportCodeActionMap.prototype.getAllActions = function () { var result = []; - for (var symbolId in this.symbolIdToActionMap) { - result = ts.concatenate(result, this.symbolIdToActionMap[symbolId]); + for (var key in this.symbolIdToActionMap) { + result = ts.concatenate(result, this.symbolIdToActionMap[key]); } return result; }; @@ -78684,6 +80274,7 @@ var ts; codefix.registerCodeFix({ errorCodes: [ ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics.Cannot_find_namespace_0.code, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code ], getCodeActions: function (context) { @@ -78695,7 +80286,7 @@ var ts; var name = token.getText(); var symbolIdActionMap = new ImportCodeActionMap(); // this is a module id -> module import declaration map - var cachedImportDeclarations = ts.createMap(); + var cachedImportDeclarations = []; var cachedNewImportInsertPosition; var currentTokenMeaning = ts.getMeaningFromLocation(token); if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { @@ -78732,8 +80323,9 @@ var ts; return symbolIdActionMap.getAllActions(); function getImportDeclarations(moduleSymbol) { var moduleSymbolId = getUniqueSymbolId(moduleSymbol); - if (cachedImportDeclarations[moduleSymbolId]) { - return cachedImportDeclarations[moduleSymbolId]; + var cached = cachedImportDeclarations[moduleSymbolId]; + if (cached) { + return cached; } var existingDeclarations = []; for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { @@ -78748,10 +80340,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 236 /* ImportDeclaration */) { + if (node.kind === 237 /* ImportDeclaration */) { return node; } - if (node.kind === 235 /* ImportEqualsDeclaration */) { + if (node.kind === 236 /* ImportEqualsDeclaration */) { return node; } node = node.parent; @@ -78795,11 +80387,11 @@ var ts; var namespaceImportDeclaration; var namedImportDeclaration; var existingModuleSpecifier; - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; - if (declaration.kind === 236 /* ImportDeclaration */) { + for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { + var declaration = declarations_14[_i]; + if (declaration.kind === 237 /* ImportDeclaration */) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 238 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 239 /* NamespaceImport */) { // case: // import * as ns from "foo" namespaceImportDeclaration = declaration; @@ -78839,7 +80431,7 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 246 /* ExternalModuleReference */) { + if (declaration.moduleReference && declaration.moduleReference.kind === 247 /* ExternalModuleReference */) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); @@ -78887,7 +80479,7 @@ var ts; } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 236 /* ImportDeclaration */) { + if (declaration.kind === 237 /* ImportDeclaration */) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -78935,18 +80527,18 @@ var ts; : "" + context.newLineCharacter + importStatementText + ";"; return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], newText, { start: cachedNewImportInsertPosition, length: 0 }, sourceFile.fileName, "NewImport", moduleSpecifierWithoutQuotes); function getModuleSpecifierForNewImport() { - var fileName = sourceFile.path; - var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().path; + var fileName = sourceFile.fileName; + var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; var sourceDirectory = ts.getDirectoryPath(fileName); var options = context.program.getCompilerOptions(); return tryGetModuleNameFromAmbientModule() || - tryGetModuleNameFromBaseUrl() || - tryGetModuleNameFromRootDirs() || tryGetModuleNameFromTypeRoots() || tryGetModuleNameAsNodeModule() || + tryGetModuleNameFromBaseUrl() || + tryGetModuleNameFromRootDirs() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 262 /* SourceFile */) { + if (moduleSymbol.valueDeclaration.kind !== 264 /* SourceFile */) { return moduleSymbol.name; } } @@ -78954,8 +80546,7 @@ var ts; if (!options.baseUrl) { return undefined; } - var normalizedBaseUrl = ts.toPath(options.baseUrl, ts.getDirectoryPath(options.baseUrl), getCanonicalFileName); - var relativeName = tryRemoveParentDirectoryName(moduleFileName, normalizedBaseUrl); + var relativeName = getRelativePathIfInDirectory(moduleFileName, options.baseUrl); if (!relativeName) { return undefined; } @@ -78989,9 +80580,8 @@ var ts; } function tryGetModuleNameFromRootDirs() { if (options.rootDirs) { - var normalizedRootDirs = ts.map(options.rootDirs, function (rootDir) { return ts.toPath(rootDir, /*basePath*/ undefined, getCanonicalFileName); }); - var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, normalizedRootDirs); - var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, normalizedRootDirs); + var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, options.rootDirs); + var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, options.rootDirs); if (normalizedTargetPath !== undefined) { var relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath; return ts.removeFileExtension(relativePath); @@ -79055,7 +80645,7 @@ var ts; function getPathRelativeToRootDirs(path, rootDirs) { for (var _i = 0, rootDirs_2 = rootDirs; _i < rootDirs_2.length; _i++) { var rootDir = rootDirs_2[_i]; - var relativeName = tryRemoveParentDirectoryName(path, rootDir); + var relativeName = getRelativePathIfInDirectory(path, rootDir); if (relativeName !== undefined) { return relativeName; } @@ -79069,19 +80659,14 @@ var ts; } return fileName; } + function getRelativePathIfInDirectory(path, directoryPath) { + var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); + return ts.isRootedDiskPath(relativePath) || ts.startsWith(relativePath, "..") ? undefined : relativePath; + } function getRelativePath(path, directoryPath) { var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); return ts.moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath; } - function tryRemoveParentDirectoryName(path, parentDirectory) { - var index = path.indexOf(parentDirectory); - if (index === 0) { - return ts.endsWith(parentDirectory, ts.directorySeparator) - ? path.substring(parentDirectory.length) - : path.substring(parentDirectory.length + 1); - } - return undefined; - } } } function createCodeAction(description, diagnosticArgs, newText, span, fileName, kind, moduleSpecifier) { @@ -79109,7 +80694,7 @@ var ts; */ function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { var classMembers = classDeclaration.symbol.members; - var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !(symbol.getName() in classMembers); }); + var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !classMembers.has(symbol.getName()); }); var insertion = ""; for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { var symbol = missingMembers_1[_i]; @@ -79132,14 +80717,14 @@ var ts; var name = declaration.name ? declaration.name.getText() : undefined; var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); switch (declaration.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 146 /* PropertySignature */: - case 147 /* PropertyDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 147 /* PropertySignature */: + case 148 /* PropertyDeclaration */: var typeString = checker.typeToString(type, enclosingDeclaration, 0 /* None */); return "" + visibility + name + ": " + typeString + ";" + newlineChar; - case 148 /* MethodSignature */: - case 149 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 150 /* MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -79179,7 +80764,7 @@ var ts; } } function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { - var newSignatureDeclaration = ts.createNode(153 /* CallSignature */); + var newSignatureDeclaration = ts.createNode(154 /* CallSignature */); newSignatureDeclaration.parent = enclosingDeclaration; newSignatureDeclaration.name = signatures[0].getDeclaration().name; var maxNonRestArgs = -1; @@ -79210,7 +80795,7 @@ var ts; } return checker.getSignatureFromDeclaration(newSignatureDeclaration); function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { - var newParameter = ts.createNode(144 /* Parameter */); + var newParameter = ts.createNode(145 /* Parameter */); newParameter.symbol = new SymbolConstructor(1 /* FunctionScopedVariable */, maxArgsParameterSymbolNames[index] || "rest"); newParameter.symbol.valueDeclaration = newParameter; newParameter.symbol.declarations = [newParameter]; @@ -79241,6 +80826,7 @@ var ts; /// /// /// +/// /// /// /// @@ -79276,7 +80862,7 @@ var ts; /** The version of the language service API */ ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 141 /* FirstNode */ ? new NodeObject(kind, pos, end) : + var node = kind >= 142 /* FirstNode */ ? new NodeObject(kind, pos, end) : kind === 70 /* Identifier */ ? new IdentifierObject(70 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; @@ -79334,7 +80920,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(293 /* SyntaxList */, nodes.pos, nodes.end, this); + var list = createNode(296 /* SyntaxList */, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -79353,11 +80939,11 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 141 /* FirstNode */) { + if (this.kind >= 142 /* FirstNode */) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 279 /* FirstJSDocTagNode */ && this.kind <= 292 /* LastJSDocTagNode */; + var useJSDocScanner_1 = this.kind >= 282 /* FirstJSDocTagNode */ && this.kind <= 295 /* LastJSDocTagNode */; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -79414,8 +81000,10 @@ var ts; if (!children.length) { return undefined; } - var child = children[0]; - return child.kind < 141 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + var child = ts.find(children, function (kid) { return kid.kind < 266 /* FirstJSDocNode */ || kid.kind > 295 /* LastJSDocNode */; }); + return child.kind < 142 /* FirstNode */ ? + child : + child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -79423,7 +81011,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 141 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 142 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -79622,27 +81210,31 @@ var ts; return this.namedDeclarations; }; SourceFileObject.prototype.computeNamedDeclarations = function () { - var result = ts.createMap(); + var result = ts.createMultiMap(); ts.forEachChild(this, visit); return result; function addDeclaration(declaration) { var name = getDeclarationName(declaration); if (name) { - ts.multiMapAdd(result, name, declaration); + result.add(name, declaration); } } function getDeclarations(name) { - return result[name] || (result[name] = []); + var declarations = result.get(name); + if (!declarations) { + result.set(name, declarations = []); + } + return declarations; } function getDeclarationName(declaration) { if (declaration.name) { - var result_8 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_8 !== undefined) { - return result_8; + var result_7 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_7 !== undefined) { + return result_7; } - if (declaration.name.kind === 142 /* ComputedPropertyName */) { + if (declaration.name.kind === 143 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 177 /* PropertyAccessExpression */) { + if (expr.kind === 178 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -79662,10 +81254,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -79685,32 +81277,32 @@ var ts; } ts.forEachChild(node, visit); break; - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 228 /* InterfaceDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 230 /* EnumDeclaration */: - case 231 /* ModuleDeclaration */: - case 235 /* ImportEqualsDeclaration */: - case 244 /* ExportSpecifier */: - case 240 /* ImportSpecifier */: - case 235 /* ImportEqualsDeclaration */: - case 237 /* ImportClause */: - case 238 /* NamespaceImport */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 161 /* TypeLiteral */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 231 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 245 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 238 /* ImportClause */: + case 239 /* NamespaceImport */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 162 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 144 /* Parameter */: + case 145 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // fall through - case 224 /* VariableDeclaration */: - case 174 /* BindingElement */: { + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -79719,19 +81311,19 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 261 /* EnumMember */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 263 /* EnumMember */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: addDeclaration(node); break; - case 242 /* ExportDeclaration */: + case 243 /* 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 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -79743,7 +81335,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 238 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 239 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -80173,6 +81765,7 @@ var ts; ts.Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + path); return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } + // We didn't already have the file. Fall through and acquire it from the registry. } // Could not find this file in the old program, create a new SourceFile for it. return documentRegistry.acquireDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); @@ -80273,10 +81866,10 @@ var ts; // Try getting just type at this position and show switch (node.kind) { case 70 /* Identifier */: - case 177 /* PropertyAccessExpression */: - case 141 /* QualifiedName */: + case 178 /* PropertyAccessExpression */: + case 142 /* QualifiedName */: case 98 /* ThisKeyword */: - case 167 /* ThisType */: + case 168 /* ThisType */: case 96 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); @@ -80318,10 +81911,10 @@ var ts; function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); if (results) { - var sourceFile_2 = getCanonicalFileName(ts.normalizeSlashes(fileName)); + var sourceFile_1 = getCanonicalFileName(ts.normalizeSlashes(fileName)); // Get occurrences only supports reporting occurrences for the file queried. So // filter down to that list. - results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_2; }); + results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_1; }); } return results; } @@ -80356,21 +81949,21 @@ var ts; } } function findRenameLocations(fileName, position, findInStrings, findInComments) { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments, /*isForRename*/ true); return ts.FindAllReferences.convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ false); return ts.FindAllReferences.convertReferences(referencedSymbols); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ false); // Only include referenced symbols that have a valid definition. return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); } - function findReferencedSymbols(fileName, position, findInStrings, findInComments) { + function findReferencedSymbols(fileName, position, findInStrings, findInComments, isForRename) { synchronizeHostData(); - return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments); + return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments, isForRename); } /// NavigateTo function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { @@ -80419,15 +82012,15 @@ var ts; return; } switch (node.kind) { - case 177 /* PropertyAccessExpression */: - case 141 /* QualifiedName */: + case 178 /* PropertyAccessExpression */: + case 142 /* QualifiedName */: case 9 /* StringLiteral */: case 85 /* FalseKeyword */: case 100 /* TrueKeyword */: case 94 /* NullKeyword */: case 96 /* SuperKeyword */: case 98 /* ThisKeyword */: - case 167 /* ThisType */: + case 168 /* ThisType */: case 70 /* Identifier */: break; // Cant create the text span @@ -80444,7 +82037,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 === 231 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 232 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -80587,7 +82180,7 @@ var ts; var span = { start: start, length: end - start }; var newLineChar = ts.getNewLineOrDefaultFromHost(host); var allFixes = []; - ts.forEach(errorCodes, function (error) { + ts.forEach(ts.deduplicate(errorCodes), function (error) { cancellationToken.throwIfCancellationRequested(); var context = { errorCode: error, @@ -80821,7 +82414,7 @@ var ts; function walk(node) { switch (node.kind) { case 70 /* Identifier */: - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + setNameTable(node.text, node); break; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: @@ -80830,10 +82423,10 @@ 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 === 246 /* ExternalModuleReference */ || + node.parent.kind === 247 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + setNameTable(node.text, node); } break; default: @@ -80846,11 +82439,72 @@ var ts; } } } + function setNameTable(text, node) { + nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); + } } + function isObjectLiteralElement(node) { + switch (node.kind) { + case 252 /* JsxAttribute */: + case 254 /* JsxSpreadAttribute */: + case 260 /* PropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + return true; + } + return false; + } + /** + * Returns the containing object literal property declaration given a possible name node, e.g. "a" in x = { "a": 1 } + */ + /* @internal */ + function getContainingObjectLiteralElement(node) { + switch (node.kind) { + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + if (node.parent.kind === 143 /* ComputedPropertyName */) { + return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; + } + // intentionally fall through + case 70 /* Identifier */: + return isObjectLiteralElement(node.parent) && + (node.parent.parent.kind === 177 /* ObjectLiteralExpression */ || node.parent.parent.kind === 253 /* JsxAttributes */) && + node.parent.name === node ? node.parent : undefined; + } + return undefined; + } + ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; + /* @internal */ + function getPropertySymbolsFromContextualType(typeChecker, node) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = ts.getTextOfPropertyName(node.name); + if (name && contextualType) { + var result_8 = []; + var symbol = contextualType.getProperty(name); + if (contextualType.flags & 65536 /* Union */) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_8.push(symbol); + } + }); + return result_8; + } + if (symbol) { + result_8.push(symbol); + return result_8; + } + } + return undefined; + } + ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 178 /* ElementAccessExpression */ && + node.parent.kind === 179 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -80866,10 +82520,7 @@ var ts; throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); } ts.getDefaultLibFilePath = getDefaultLibFilePath; - function initializeServices() { - ts.objectAllocator = getServicesObjectAllocator(); - } - initializeServices(); + ts.objectAllocator = getServicesObjectAllocator(); })(ts || (ts = {})); // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. @@ -80934,113 +82585,113 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 224 /* VariableDeclaration */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 225 /* VariableDeclaration */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return spanInVariableDeclaration(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return spanInParameterDeclaration(node); - case 226 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 150 /* Constructor */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 151 /* Constructor */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 205 /* Block */: + case 206 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 232 /* ModuleBlock */: + case 233 /* ModuleBlock */: return spanInBlock(node); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return spanInBlock(node.block); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 210 /* DoStatement */: + case 211 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 223 /* DebuggerStatement */: + case 224 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 209 /* IfStatement */: + case 210 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 216 /* BreakStatement */: - case 215 /* ContinueStatement */: + case 217 /* BreakStatement */: + case 216 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return spanInForStatement(node); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 254 /* CaseClause */: - case 255 /* DefaultClause */: + case 256 /* CaseClause */: + case 257 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 222 /* TryStatement */: + case 223 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 221 /* ThrowStatement */: + case 222 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 227 /* ClassDeclaration */: - case 230 /* EnumDeclaration */: - case 261 /* EnumMember */: - case 174 /* BindingElement */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 263 /* EnumMember */: + case 175 /* BindingElement */: // span on complete node return textSpan(node); - case 218 /* WithStatement */: + case 219 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 145 /* Decorator */: + case 146 /* Decorator */: return spanInNodeArray(node.parent.decorators); - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 228 /* InterfaceDeclaration */: - case 229 /* TypeAliasDeclaration */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: return undefined; // Tokens: case 24 /* SemicolonToken */: @@ -81070,7 +82721,7 @@ var ts; case 73 /* CatchKeyword */: case 86 /* FinallyKeyword */: return spanInNextNode(node); - case 140 /* OfKeyword */: + case 141 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -81083,13 +82734,13 @@ var ts; // a or ...c or d: x from // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern if ((node.kind === 70 /* Identifier */ || - node.kind == 196 /* SpreadElement */ || - node.kind === 258 /* PropertyAssignment */ || - node.kind === 259 /* ShorthandPropertyAssignment */) && + node.kind == 197 /* SpreadElement */ || + node.kind === 260 /* PropertyAssignment */ || + node.kind === 261 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 192 /* BinaryExpression */) { + if (node.kind === 193 /* BinaryExpression */) { var binaryExpression = node; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -81112,22 +82763,22 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 210 /* DoStatement */: + case 211 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 145 /* Decorator */: + case 146 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 212 /* ForStatement */: - case 214 /* ForOfStatement */: + case 213 /* ForStatement */: + case 215 /* ForOfStatement */: return textSpan(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: if (node.parent.operatorToken.kind === 25 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -81136,13 +82787,13 @@ var ts; } } // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 258 /* PropertyAssignment */ && + if (node.parent.kind === 260 /* PropertyAssignment */ && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 182 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 183 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNextNode(node.parent.type); } // return type of function go to previous token @@ -81150,8 +82801,8 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 224 /* VariableDeclaration */ || - node.parent.kind === 144 /* Parameter */)) { + if ((node.parent.kind === 225 /* VariableDeclaration */ || + node.parent.kind === 145 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -81159,7 +82810,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 192 /* BinaryExpression */) { + if (node.parent.kind === 193 /* BinaryExpression */) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -81185,7 +82836,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 213 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 214 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -81196,7 +82847,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 214 /* ForOfStatement */) { + variableDeclaration.parent.parent.kind === 215 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -81236,7 +82887,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 227 /* ClassDeclaration */ && functionDeclaration.kind !== 150 /* Constructor */); + (functionDeclaration.parent.kind === 228 /* ClassDeclaration */ && functionDeclaration.kind !== 151 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -81259,25 +82910,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 211 /* WhileStatement */: - case 209 /* IfStatement */: - case 213 /* ForInStatement */: + case 212 /* WhileStatement */: + case 210 /* IfStatement */: + case 214 /* ForInStatement */: 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 212 /* ForStatement */: - case 214 /* ForOfStatement */: + case 213 /* ForStatement */: + case 215 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 225 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 226 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -81302,23 +82953,23 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 198 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 199 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 174 /* BindingElement */) { + if (bindingPattern.parent.kind === 175 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 173 /* ArrayBindingPattern */ && node.kind !== 172 /* ObjectBindingPattern */); - var elements = node.kind === 175 /* ArrayLiteralExpression */ ? + ts.Debug.assert(node.kind !== 174 /* ArrayBindingPattern */ && node.kind !== 173 /* ObjectBindingPattern */); + var elements = node.kind === 176 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 198 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 199 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -81326,18 +82977,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 192 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 193 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 233 /* CaseBlock */: + case 234 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -81345,24 +82996,24 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 232 /* ModuleBlock */: + case 233 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 230 /* EnumDeclaration */: - case 227 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 228 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 205 /* Block */: + case 206 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through - case 257 /* CatchClause */: + case 259 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 233 /* CaseBlock */: + case 234 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -81370,7 +83021,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 172 /* ObjectBindingPattern */: + case 173 /* ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -81386,7 +83037,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 173 /* ArrayBindingPattern */: + case 174 /* ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -81401,12 +83052,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 210 /* DoStatement */ || - node.parent.kind === 179 /* CallExpression */ || - node.parent.kind === 180 /* NewExpression */) { + if (node.parent.kind === 211 /* DoStatement */ || + node.parent.kind === 180 /* CallExpression */ || + node.parent.kind === 181 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 183 /* ParenthesizedExpression */) { + if (node.parent.kind === 184 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -81415,21 +83066,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 184 /* FunctionExpression */: - case 226 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 150 /* Constructor */: - case 211 /* WhileStatement */: - case 210 /* DoStatement */: - case 212 /* ForStatement */: - case 214 /* ForOfStatement */: - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 183 /* ParenthesizedExpression */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 151 /* Constructor */: + case 212 /* WhileStatement */: + case 211 /* DoStatement */: + case 213 /* ForStatement */: + case 215 /* ForOfStatement */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 184 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -81439,20 +83090,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 258 /* PropertyAssignment */ || - node.parent.kind === 144 /* Parameter */) { + node.parent.kind === 260 /* PropertyAssignment */ || + node.parent.kind === 145 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 182 /* TypeAssertionExpression */) { + if (node.parent.kind === 183 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 210 /* DoStatement */) { + if (node.parent.kind === 211 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -81460,7 +83111,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 214 /* ForOfStatement */) { + if (node.parent.kind === 215 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -81591,7 +83242,10 @@ var ts; if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } - return JSON.parse(settingsJson); + var compilerOptions = JSON.parse(settingsJson); + // permit language service to handle all files (filtering should be performed on the host side) + compilerOptions.allowNonTsExtensions = true; + return compilerOptions; }; LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { var encoded = this.shimHost.getScriptFileNames(); @@ -82099,12 +83753,6 @@ var ts; var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (resolvedFileName && !compilerOptions.allowJs && ts.fileExtensionIs(resolvedFileName, ".js")) { - return { - resolvedFileName: undefined, - failedLookupLocations: [] - }; - } return { resolvedFileName: resolvedFileName, failedLookupLocations: result.failedLookupLocations @@ -82278,4 +83926,4 @@ var TypeScript; // 'toolsVersion' gets consumed by the managed side, so it's not unused. // TODO: it should be moved into a namespace though. /* @internal */ -var toolsVersion = "2.2"; +var toolsVersion = "2.3"; diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 24ec0a740ca..1be69fb2455 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -14,11 +14,36 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { + /** + * Type of objects whose values are all of the same type. + * The `in` and `for-in` operators can *not* be safely used, + * since `Object.prototype` may be modified by outside code. + */ interface MapLike { [index: string]: T; } - interface Map extends MapLike { - __mapBrand: any; + /** ES6 Map interface. */ + interface Map { + get(key: string): T; + has(key: string): boolean; + set(key: string, value: T): this; + delete(key: string): boolean; + clear(): void; + forEach(action: (value: T, key: string) => void): void; + readonly size: number; + keys(): Iterator; + values(): Iterator; + entries(): Iterator<[string, T]>; + } + /** ES6 Iterator type. */ + interface Iterator { + next(): { + value: T; + done: false; + } | { + value: never; + done: true; + }; } type Path = string & { __pathBrand: any; @@ -170,172 +195,175 @@ declare namespace ts { ReadonlyKeyword = 130, RequireKeyword = 131, NumberKeyword = 132, - SetKeyword = 133, - StringKeyword = 134, - SymbolKeyword = 135, - TypeKeyword = 136, - UndefinedKeyword = 137, - FromKeyword = 138, - GlobalKeyword = 139, - OfKeyword = 140, - QualifiedName = 141, - ComputedPropertyName = 142, - TypeParameter = 143, - Parameter = 144, - Decorator = 145, - PropertySignature = 146, - PropertyDeclaration = 147, - MethodSignature = 148, - MethodDeclaration = 149, - Constructor = 150, - GetAccessor = 151, - SetAccessor = 152, - CallSignature = 153, - ConstructSignature = 154, - IndexSignature = 155, - TypePredicate = 156, - TypeReference = 157, - FunctionType = 158, - ConstructorType = 159, - TypeQuery = 160, - TypeLiteral = 161, - ArrayType = 162, - TupleType = 163, - UnionType = 164, - IntersectionType = 165, - ParenthesizedType = 166, - ThisType = 167, - TypeOperator = 168, - IndexedAccessType = 169, - MappedType = 170, - LiteralType = 171, - ObjectBindingPattern = 172, - ArrayBindingPattern = 173, - BindingElement = 174, - ArrayLiteralExpression = 175, - ObjectLiteralExpression = 176, - PropertyAccessExpression = 177, - ElementAccessExpression = 178, - CallExpression = 179, - NewExpression = 180, - TaggedTemplateExpression = 181, - TypeAssertionExpression = 182, - ParenthesizedExpression = 183, - FunctionExpression = 184, - ArrowFunction = 185, - DeleteExpression = 186, - TypeOfExpression = 187, - VoidExpression = 188, - AwaitExpression = 189, - PrefixUnaryExpression = 190, - PostfixUnaryExpression = 191, - BinaryExpression = 192, - ConditionalExpression = 193, - TemplateExpression = 194, - YieldExpression = 195, - SpreadElement = 196, - ClassExpression = 197, - OmittedExpression = 198, - ExpressionWithTypeArguments = 199, - AsExpression = 200, - NonNullExpression = 201, - MetaProperty = 202, - TemplateSpan = 203, - SemicolonClassElement = 204, - Block = 205, - VariableStatement = 206, - EmptyStatement = 207, - ExpressionStatement = 208, - IfStatement = 209, - DoStatement = 210, - WhileStatement = 211, - ForStatement = 212, - ForInStatement = 213, - ForOfStatement = 214, - ContinueStatement = 215, - BreakStatement = 216, - ReturnStatement = 217, - WithStatement = 218, - SwitchStatement = 219, - LabeledStatement = 220, - ThrowStatement = 221, - TryStatement = 222, - DebuggerStatement = 223, - VariableDeclaration = 224, - VariableDeclarationList = 225, - FunctionDeclaration = 226, - ClassDeclaration = 227, - InterfaceDeclaration = 228, - TypeAliasDeclaration = 229, - EnumDeclaration = 230, - ModuleDeclaration = 231, - ModuleBlock = 232, - CaseBlock = 233, - NamespaceExportDeclaration = 234, - ImportEqualsDeclaration = 235, - ImportDeclaration = 236, - ImportClause = 237, - NamespaceImport = 238, - NamedImports = 239, - ImportSpecifier = 240, - ExportAssignment = 241, - ExportDeclaration = 242, - NamedExports = 243, - ExportSpecifier = 244, - MissingDeclaration = 245, - ExternalModuleReference = 246, - JsxElement = 247, - JsxSelfClosingElement = 248, - JsxOpeningElement = 249, - JsxClosingElement = 250, - JsxAttribute = 251, - JsxSpreadAttribute = 252, - JsxExpression = 253, - CaseClause = 254, - DefaultClause = 255, - HeritageClause = 256, - CatchClause = 257, - PropertyAssignment = 258, - ShorthandPropertyAssignment = 259, - SpreadAssignment = 260, - EnumMember = 261, - SourceFile = 262, - JSDocTypeExpression = 263, - JSDocAllType = 264, - JSDocUnknownType = 265, - JSDocArrayType = 266, - JSDocUnionType = 267, - JSDocTupleType = 268, - JSDocNullableType = 269, - JSDocNonNullableType = 270, - JSDocRecordType = 271, - JSDocRecordMember = 272, - JSDocTypeReference = 273, - JSDocOptionalType = 274, - JSDocFunctionType = 275, - JSDocVariadicType = 276, - JSDocConstructorType = 277, - JSDocThisType = 278, - JSDocComment = 279, - JSDocTag = 280, - JSDocAugmentsTag = 281, - JSDocParameterTag = 282, - JSDocReturnTag = 283, - JSDocTypeTag = 284, - JSDocTemplateTag = 285, - JSDocTypedefTag = 286, - JSDocPropertyTag = 287, - JSDocTypeLiteral = 288, - JSDocLiteralType = 289, - JSDocNullKeyword = 290, - JSDocUndefinedKeyword = 291, - JSDocNeverKeyword = 292, - SyntaxList = 293, - NotEmittedStatement = 294, - PartiallyEmittedExpression = 295, - MergeDeclarationMarker = 296, - EndOfDeclarationMarker = 297, - Count = 298, + ObjectKeyword = 133, + SetKeyword = 134, + StringKeyword = 135, + SymbolKeyword = 136, + TypeKeyword = 137, + UndefinedKeyword = 138, + FromKeyword = 139, + GlobalKeyword = 140, + OfKeyword = 141, + QualifiedName = 142, + ComputedPropertyName = 143, + TypeParameter = 144, + Parameter = 145, + Decorator = 146, + PropertySignature = 147, + PropertyDeclaration = 148, + MethodSignature = 149, + MethodDeclaration = 150, + Constructor = 151, + GetAccessor = 152, + SetAccessor = 153, + CallSignature = 154, + ConstructSignature = 155, + IndexSignature = 156, + TypePredicate = 157, + TypeReference = 158, + FunctionType = 159, + ConstructorType = 160, + TypeQuery = 161, + TypeLiteral = 162, + ArrayType = 163, + TupleType = 164, + UnionType = 165, + IntersectionType = 166, + ParenthesizedType = 167, + ThisType = 168, + TypeOperator = 169, + IndexedAccessType = 170, + MappedType = 171, + LiteralType = 172, + ObjectBindingPattern = 173, + ArrayBindingPattern = 174, + BindingElement = 175, + ArrayLiteralExpression = 176, + ObjectLiteralExpression = 177, + PropertyAccessExpression = 178, + ElementAccessExpression = 179, + CallExpression = 180, + NewExpression = 181, + TaggedTemplateExpression = 182, + TypeAssertionExpression = 183, + ParenthesizedExpression = 184, + FunctionExpression = 185, + ArrowFunction = 186, + DeleteExpression = 187, + TypeOfExpression = 188, + VoidExpression = 189, + AwaitExpression = 190, + PrefixUnaryExpression = 191, + PostfixUnaryExpression = 192, + BinaryExpression = 193, + ConditionalExpression = 194, + TemplateExpression = 195, + YieldExpression = 196, + SpreadElement = 197, + ClassExpression = 198, + OmittedExpression = 199, + ExpressionWithTypeArguments = 200, + AsExpression = 201, + NonNullExpression = 202, + MetaProperty = 203, + TemplateSpan = 204, + SemicolonClassElement = 205, + Block = 206, + VariableStatement = 207, + EmptyStatement = 208, + ExpressionStatement = 209, + IfStatement = 210, + DoStatement = 211, + WhileStatement = 212, + ForStatement = 213, + ForInStatement = 214, + ForOfStatement = 215, + ContinueStatement = 216, + BreakStatement = 217, + ReturnStatement = 218, + WithStatement = 219, + SwitchStatement = 220, + LabeledStatement = 221, + ThrowStatement = 222, + TryStatement = 223, + DebuggerStatement = 224, + VariableDeclaration = 225, + VariableDeclarationList = 226, + FunctionDeclaration = 227, + ClassDeclaration = 228, + InterfaceDeclaration = 229, + TypeAliasDeclaration = 230, + EnumDeclaration = 231, + ModuleDeclaration = 232, + ModuleBlock = 233, + CaseBlock = 234, + NamespaceExportDeclaration = 235, + ImportEqualsDeclaration = 236, + ImportDeclaration = 237, + ImportClause = 238, + NamespaceImport = 239, + NamedImports = 240, + ImportSpecifier = 241, + ExportAssignment = 242, + ExportDeclaration = 243, + NamedExports = 244, + ExportSpecifier = 245, + MissingDeclaration = 246, + ExternalModuleReference = 247, + JsxElement = 248, + JsxSelfClosingElement = 249, + JsxOpeningElement = 250, + JsxClosingElement = 251, + JsxAttribute = 252, + JsxAttributes = 253, + JsxSpreadAttribute = 254, + JsxExpression = 255, + CaseClause = 256, + DefaultClause = 257, + HeritageClause = 258, + CatchClause = 259, + PropertyAssignment = 260, + ShorthandPropertyAssignment = 261, + SpreadAssignment = 262, + EnumMember = 263, + SourceFile = 264, + Bundle = 265, + JSDocTypeExpression = 266, + JSDocAllType = 267, + JSDocUnknownType = 268, + JSDocArrayType = 269, + JSDocUnionType = 270, + JSDocTupleType = 271, + JSDocNullableType = 272, + JSDocNonNullableType = 273, + JSDocRecordType = 274, + JSDocRecordMember = 275, + JSDocTypeReference = 276, + JSDocOptionalType = 277, + JSDocFunctionType = 278, + JSDocVariadicType = 279, + JSDocConstructorType = 280, + JSDocThisType = 281, + JSDocComment = 282, + JSDocTag = 283, + JSDocAugmentsTag = 284, + JSDocParameterTag = 285, + JSDocReturnTag = 286, + JSDocTypeTag = 287, + JSDocTemplateTag = 288, + JSDocTypedefTag = 289, + JSDocPropertyTag = 290, + JSDocTypeLiteral = 291, + JSDocLiteralType = 292, + JSDocNullKeyword = 293, + JSDocUndefinedKeyword = 294, + JSDocNeverKeyword = 295, + SyntaxList = 296, + NotEmittedStatement = 297, + PartiallyEmittedExpression = 298, + MergeDeclarationMarker = 299, + EndOfDeclarationMarker = 300, + Count = 301, FirstAssignment = 57, LastAssignment = 69, FirstCompoundAssignment = 58, @@ -343,15 +371,15 @@ declare namespace ts { FirstReservedWord = 71, LastReservedWord = 106, FirstKeyword = 71, - LastKeyword = 140, + LastKeyword = 141, FirstFutureReservedWord = 107, LastFutureReservedWord = 115, - FirstTypeNode = 156, - LastTypeNode = 171, + FirstTypeNode = 157, + LastTypeNode = 172, FirstPunctuation = 16, LastPunctuation = 69, FirstToken = 0, - LastToken = 140, + LastToken = 141, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -360,11 +388,11 @@ declare namespace ts { LastTemplateToken = 15, FirstBinaryOperator = 26, LastBinaryOperator = 69, - FirstNode = 141, - FirstJSDocNode = 263, - LastJSDocNode = 289, - FirstJSDocTagNode = 279, - LastJSDocTagNode = 292, + FirstNode = 142, + FirstJSDocNode = 266, + LastJSDocNode = 295, + FirstJSDocTagNode = 282, + LastJSDocTagNode = 295, } enum NodeFlags { None = 0, @@ -481,6 +509,7 @@ declare namespace ts { kind: SyntaxKind.TypeParameter; name: Identifier; constraint?: TypeNode; + default?: TypeNode; expression?: Expression; } interface SignatureDeclaration extends Declaration { @@ -632,7 +661,7 @@ declare namespace ts { _typeNodeBrand: any; } interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; + kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; } interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; @@ -717,6 +746,10 @@ declare namespace ts { interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } + interface PartiallyEmittedExpression extends LeftHandSideExpression { + kind: SyntaxKind.PartiallyEmittedExpression; + expression: Expression; + } interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } @@ -953,7 +986,7 @@ declare namespace ts { tag: LeftHandSideExpression; template: TemplateLiteral; } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; + type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; interface AsExpression extends Expression { kind: SyntaxKind.AsExpression; expression: Expression; @@ -980,25 +1013,27 @@ declare namespace ts { children: NodeArray; closingElement: JsxClosingElement; } + type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + interface JsxAttributes extends ObjectLiteralExpressionBase { + } interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; tagName: JsxTagNameExpression; - attributes: NodeArray; + attributes: JsxAttributes; } interface JsxSelfClosingElement extends PrimaryExpression { kind: SyntaxKind.JsxSelfClosingElement; tagName: JsxTagNameExpression; - attributes: NodeArray; + attributes: JsxAttributes; } - type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; - type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - interface JsxAttribute extends Node { + interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; name: Identifier; initializer?: StringLiteral | JsxExpression; } - interface JsxSpreadAttribute extends Node { + interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; expression: Expression; } @@ -1018,6 +1053,9 @@ declare namespace ts { interface Statement extends Node { _statementBrand: any; } + interface NotEmittedStatement extends Statement { + kind: SyntaxKind.NotEmittedStatement; + } interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } @@ -1184,20 +1222,22 @@ declare namespace ts { name: Identifier; members: NodeArray; } - type ModuleBody = ModuleBlock | ModuleDeclaration; type ModuleName = Identifier | StringLiteral; + type ModuleBody = NamespaceBody | JSDocNamespaceBody; interface ModuleDeclaration extends DeclarationStatement { kind: SyntaxKind.ModuleDeclaration; name: Identifier | StringLiteral; - body?: ModuleBlock | NamespaceDeclaration | JSDocNamespaceDeclaration | Identifier; + body?: ModuleBody | JSDocNamespaceDeclaration | Identifier; } + type NamespaceBody = ModuleBlock | NamespaceDeclaration; interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: ModuleBlock | NamespaceDeclaration; + body: NamespaceBody; } + type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: JSDocNamespaceDeclaration | Identifier; + body: JSDocNamespaceBody; } interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; @@ -1412,9 +1452,21 @@ declare namespace ts { ArrayMutation = 256, Referenced = 512, Shared = 1024, + PreFinally = 2048, + AfterFinally = 4096, Label = 12, Condition = 96, } + interface FlowLock { + locked?: boolean; + } + interface AfterFinallyFlow extends FlowNode, FlowLock { + antecedent: FlowNode; + } + interface PreFinallyFlow extends FlowNode { + antecedent: FlowNode; + lock: FlowLock; + } interface FlowNode { flags: FlowFlags; id?: number; @@ -1476,6 +1528,10 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; } + interface Bundle extends Node { + kind: SyntaxKind.Bundle; + sourceFiles: SourceFile[]; + } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; getSourceFile(fileName: string): SourceFile; @@ -1578,7 +1634,7 @@ declare namespace ts { getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; - getBaseTypes(type: InterfaceType): ObjectType[]; + getBaseTypes(type: InterfaceType): BaseType[]; getReturnTypeOfSignature(signature: Signature): Type; getNonNullableType(type: Type): Type; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; @@ -1607,7 +1663,7 @@ declare namespace ts { isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; - getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; + getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; @@ -1642,6 +1698,7 @@ declare namespace ts { clear(): void; trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError(): void; + reportIllegalExtends(): void; } enum TypeFormatFlags { None = 0, @@ -1657,6 +1714,7 @@ declare namespace ts { InTypeAlias = 512, UseTypeAliasValue = 1024, SuppressAnyReturnType = 2048, + AddUndefined = 4096, } enum SymbolFormatFlags { None = 0, @@ -1706,13 +1764,10 @@ declare namespace ts { ExportType = 2097152, ExportNamespace = 4194304, Alias = 8388608, - Instantiated = 16777216, - Merged = 33554432, - Transient = 67108864, - Prototype = 134217728, - SyntheticProperty = 268435456, - Optional = 536870912, - ExportStar = 1073741824, + Prototype = 16777216, + ExportStar = 33554432, + Optional = 67108864, + Transient = 134217728, Enum = 384, Variable = 3, Value = 107455, @@ -1778,6 +1833,7 @@ declare namespace ts { Intersection = 131072, Index = 262144, IndexedAccess = 524288, + NonPrimitive = 16777216, Literal = 480, StringOrNumberLiteral = 96, PossiblyFalsy = 7406, @@ -1787,10 +1843,10 @@ declare namespace ts { EnumLike = 272, UnionOrIntersection = 196608, StructuredType = 229376, - StructuredOrTypeParameter = 507904, + StructuredOrTypeVariable = 1032192, TypeVariable = 540672, - Narrowable = 1033215, - NotUnionOrUnit = 33281, + Narrowable = 17810431, + NotUnionOrUnit = 16810497, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -1806,7 +1862,7 @@ declare namespace ts { regularType?: LiteralType; } interface EnumType extends Type { - memberTypes: Map; + memberTypes: EnumLiteralType[]; } interface EnumLiteralType extends LiteralType { baseType: EnumType & UnionType; @@ -1822,6 +1878,7 @@ declare namespace ts { ObjectLiteral = 128, EvolvingArray = 256, ObjectLiteralPatternWithComputedProperties = 512, + NonPrimitive = 1024, ClassOrInterface = 3, } interface ObjectType extends Type { @@ -1834,6 +1891,7 @@ declare namespace ts { localTypeParameters: TypeParameter[]; thisType: TypeParameter; } + type BaseType = ObjectType | IntersectionType; interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; @@ -1873,6 +1931,7 @@ declare namespace ts { } interface TypeParameter extends TypeVariable { constraint: Type; + default?: Type; } interface IndexedAccessType extends TypeVariable { objectType: Type; @@ -1900,9 +1959,8 @@ declare namespace ts { isReadonly: boolean; declaration?: SignatureDeclaration; } - interface FileExtensionInfo { + interface JsFileExtensionInfo { extension: string; - scriptKind: ScriptKind; isMixedContent: boolean; } interface DiagnosticMessage { @@ -1940,7 +1998,10 @@ declare namespace ts { Classic = 1, NodeJs = 2, } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; + interface PluginImport { + name: string; + } + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; interface CompilerOptions { allowJs?: boolean; allowSyntheticDefaultImports?: boolean; @@ -2034,6 +2095,7 @@ declare namespace ts { None = 0, Preserve = 1, React = 2, + ReactNative = 3, } enum NewLineKind { CarriageReturnLineFeed = 0, @@ -2049,6 +2111,7 @@ declare namespace ts { JSX = 2, TS = 3, TSX = 4, + External = 5, } enum ScriptTarget { ES3 = 0, @@ -2157,6 +2220,120 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getEnvironmentVariable?(name: string): string; } + enum EmitFlags { + SingleLine = 1, + AdviseOnEmitNode = 2, + NoSubstitution = 4, + CapturesThis = 8, + NoLeadingSourceMap = 16, + NoTrailingSourceMap = 32, + NoSourceMap = 48, + NoNestedSourceMaps = 64, + NoTokenLeadingSourceMaps = 128, + NoTokenTrailingSourceMaps = 256, + NoTokenSourceMaps = 384, + NoLeadingComments = 512, + NoTrailingComments = 1024, + NoComments = 1536, + NoNestedComments = 2048, + HelperName = 4096, + ExportName = 8192, + LocalName = 16384, + Indented = 32768, + NoIndentation = 65536, + AsyncFunctionBody = 131072, + ReuseTempVariableScope = 262144, + CustomPrologue = 524288, + NoHoisting = 1048576, + HasEndOfDeclarationMarker = 2097152, + } + interface EmitHelper { + readonly name: string; + readonly scoped: boolean; + readonly text: string; + readonly priority?: number; + } + enum EmitHint { + SourceFile = 0, + Expression = 1, + IdentifierName = 2, + Unspecified = 3, + } + interface Printer { + /** + * Print a node and its subtree as-is, without any emit transformations. + * @param hint A value indicating the purpose of a node. This is primarily used to + * distinguish between an `Identifier` used in an expression position, versus an + * `Identifier` used as an `IdentifierName` as part of a declaration. For most nodes you + * should just pass `Unspecified`. + * @param node The node to print. The node and its subtree are printed as-is, without any + * emit transformations. + * @param sourceFile A source file that provides context for the node. The source text of + * the file is used to emit the original source content for literals and identifiers, while + * the identifiers of the source file are used when generating unique names to avoid + * collisions. + */ + printNode(hint: EmitHint, node: Node, sourceFile: SourceFile): string; + /** + * Prints a source file as-is, without any emit transformations. + */ + printFile(sourceFile: SourceFile): string; + /** + * Prints a bundle of source files as-is, without any emit transformations. + */ + printBundle(bundle: Bundle): string; + } + interface PrintHandlers { + /** + * A hook used by the Printer when generating unique names to avoid collisions with + * globally defined names that exist outside of the current source file. + */ + hasGlobalName?(name: string): boolean; + /** + * A hook used by the Printer to provide notifications prior to emitting a node. A + * compatible implementation **must** invoke `emitCallback` with the provided `hint` and + * `node` values. + * @param hint A hint indicating the intended purpose of the node. + * @param node The node to emit. + * @param emitCallback A callback that, when invoked, will emit the node. + * @example + * ```ts + * var printer = createPrinter(printerOptions, { + * onEmitNode(hint, node, emitCallback) { + * // set up or track state prior to emitting the node... + * emitCallback(hint, node); + * // restore state after emitting the node... + * } + * }); + * ``` + */ + onEmitNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + /** + * A hook used by the Printer to perform just-in-time substitution of a node. This is + * primarily used by node transformations that need to substitute one node for another, + * such as replacing `myExportedVar` with `exports.myExportedVar`. A compatible + * implementation **must** invoke `emitCallback` eith the provided `hint` and either + * the provided `node`, or its substitute. + * @param hint A hint indicating the intended purpose of the node. + * @param node The node to emit. + * @param emitCallback A callback that, when invoked, will emit the node. + * @example + * ```ts + * var printer = createPrinter(printerOptions, { + * onSubstituteNode(hint, node, emitCallback) { + * // perform substitution if necessary... + * emitCallback(hint, node); + * } + * }); + * ``` + */ + onSubstituteNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + } + interface PrinterOptions { + target?: ScriptTarget; + removeComments?: boolean; + newLine?: NewLineKind; + } interface TextSpan { start: number; length: number; @@ -2171,8 +2348,10 @@ declare namespace ts { } declare namespace ts { /** The version of the TypeScript compiler release */ - const version = "2.2.0"; + const version = "2.3.0"; } +declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; +declare function clearTimeout(handle: any): void; declare namespace ts { type FileWatcherCallback = (fileName: string, removed?: boolean) => void; type DirectoryWatcherCallback = (fileName: string) => void; @@ -2267,8 +2446,8 @@ declare namespace ts { function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; - function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; - function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined; + function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; /** Optionally, get the shebang */ function getShebang(text: string): string; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; @@ -2317,6 +2496,356 @@ declare namespace ts { fileExists(fileName: string): boolean; readFile(fileName: string): string; }, errors?: Diagnostic[]): void; + function getOriginalNode(node: Node): Node; + function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; + /** + * Gets a value indicating whether a node originated in the parse tree. + * + * @param node The node to test. + */ + function isParseTreeNode(node: Node): boolean; + /** + * Gets the original parse tree node for a node. + * + * @param node The original node. + * @returns The original parse tree node if found; otherwise, undefined. + */ + function getParseTreeNode(node: Node): Node; + /** + * Gets the original parse tree node for a node. + * + * @param node The original node. + * @param nodeTest A callback used to ensure the correct type of parse tree node is returned. + * @returns The original parse tree node if found; otherwise, undefined. + */ + function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; + /** + * Remove extra underscore from escaped identifier text content. + * + * @param identifier The escaped identifier text. + * @returns The unescaped identifier text. + */ + function unescapeIdentifier(identifier: string): string; +} +declare namespace ts { + /** + * Make `elements` into a `NodeArray`. If `elements` is `undefined`, returns an empty `NodeArray`. + */ + function createNodeArray(elements?: T[], hasTrailingComma?: boolean): NodeArray; + function createLiteral(value: string): StringLiteral; + function createLiteral(value: number): NumericLiteral; + function createLiteral(value: boolean): BooleanLiteral; + /** Create a string literal whose source text is read from a source node during emit. */ + function createLiteral(sourceNode: StringLiteral | NumericLiteral | Identifier): StringLiteral; + function createLiteral(value: string | number | boolean): PrimaryExpression; + function createNumericLiteral(value: string): NumericLiteral; + function createIdentifier(text: string): Identifier; + /** Create a unique temporary variable. */ + function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier; + /** Create a unique temporary variable for use in a loop. */ + function createLoopVariable(): Identifier; + /** Create a unique name based on the supplied text. */ + function createUniqueName(text: string): Identifier; + /** Create a unique name generated for a node. */ + function getGeneratedNameForNode(node: Node): Identifier; + function createToken(token: TKind): Token; + function createSuper(): PrimaryExpression; + function createThis(): PrimaryExpression; + function createNull(): PrimaryExpression; + function createTrue(): BooleanLiteral; + function createFalse(): BooleanLiteral; + function createQualifiedName(left: EntityName, right: string | Identifier): QualifiedName; + function updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName; + function createComputedPropertyName(expression: Expression): ComputedPropertyName; + function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; + function createParameter(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: BindingName, type: TypeNode, initializer: Expression): ParameterDeclaration; + function createDecorator(expression: Expression): Decorator; + function updateDecorator(node: Decorator, expression: Expression): Decorator; + function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, type: TypeNode, initializer: Expression): PropertyDeclaration; + function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; + function createConstructor(decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; + function createGetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; + function createSetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; + function createObjectBindingPattern(elements: BindingElement[]): ObjectBindingPattern; + function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern; + function createArrayBindingPattern(elements: ArrayBindingElement[]): ArrayBindingPattern; + function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ArrayBindingElement[]): ArrayBindingPattern; + function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression): BindingElement; + function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken, propertyName: PropertyName, name: BindingName, initializer: Expression): BindingElement; + function createArrayLiteral(elements?: Expression[], multiLine?: boolean): ArrayLiteralExpression; + function updateArrayLiteral(node: ArrayLiteralExpression, elements: Expression[]): ArrayLiteralExpression; + function createObjectLiteral(properties?: ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; + function updateObjectLiteral(node: ObjectLiteralExpression, properties: ObjectLiteralElementLike[]): ObjectLiteralExpression; + function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; + function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; + function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; + function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; + function createCall(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; + function createNew(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; + function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; + function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; + function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; + function createParen(expression: Expression): ParenthesizedExpression; + function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; + function createFunctionExpression(modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; + function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: ConciseBody): ArrowFunction; + function createDelete(expression: Expression): DeleteExpression; + function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; + function createTypeOf(expression: Expression): TypeOfExpression; + function updateTypeOf(node: TypeOfExpression, expression: Expression): TypeOfExpression; + function createVoid(expression: Expression): VoidExpression; + function updateVoid(node: VoidExpression, expression: Expression): VoidExpression; + function createAwait(expression: Expression): AwaitExpression; + function updateAwait(node: AwaitExpression, expression: Expression): AwaitExpression; + function createPrefix(operator: PrefixUnaryOperator, operand: Expression): PrefixUnaryExpression; + function updatePrefix(node: PrefixUnaryExpression, operand: Expression): PrefixUnaryExpression; + function createPostfix(operand: Expression, operator: PostfixUnaryOperator): PostfixUnaryExpression; + function updatePostfix(node: PostfixUnaryExpression, operand: Expression): PostfixUnaryExpression; + function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression): BinaryExpression; + function updateBinary(node: BinaryExpression, left: Expression, right: Expression): BinaryExpression; + function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; + function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + function createTemplateExpression(head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; + function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; + function createYield(expression?: Expression): YieldExpression; + function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; + function updateYield(node: YieldExpression, expression: Expression): YieldExpression; + function createSpread(expression: Expression): SpreadElement; + function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; + function createClassExpression(modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; + function createOmittedExpression(): OmittedExpression; + function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; + function createAsExpression(expression: Expression, type: TypeNode): AsExpression; + function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; + function createNonNullExpression(expression: Expression): NonNullExpression; + function updateNonNullExpression(node: NonNullExpression, expression: Expression): NonNullExpression; + function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; + function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; + function createBlock(statements: Statement[], multiLine?: boolean): Block; + function updateBlock(node: Block, statements: Statement[]): Block; + function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList | VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: Modifier[], declarationList: VariableDeclarationList): VariableStatement; + function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; + function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList; + function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; + function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode, initializer: Expression): VariableDeclaration; + function createEmptyStatement(): EmptyStatement; + function createStatement(expression: Expression): ExpressionStatement; + function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; + function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement): IfStatement; + function createDo(statement: Statement, expression: Expression): DoStatement; + function updateDo(node: DoStatement, statement: Statement, expression: Expression): DoStatement; + function createWhile(expression: Expression, statement: Statement): WhileStatement; + function updateWhile(node: WhileStatement, expression: Expression, statement: Statement): WhileStatement; + function createFor(initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; + function updateFor(node: ForStatement, initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; + function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; + function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; + function createForOf(initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function createContinue(label?: string | Identifier): ContinueStatement; + function updateContinue(node: ContinueStatement, label: Identifier): ContinueStatement; + function createBreak(label?: string | Identifier): BreakStatement; + function updateBreak(node: BreakStatement, label: Identifier): BreakStatement; + function createReturn(expression?: Expression): ReturnStatement; + function updateReturn(node: ReturnStatement, expression: Expression): ReturnStatement; + function createWith(expression: Expression, statement: Statement): WithStatement; + function updateWith(node: WithStatement, expression: Expression, statement: Statement): WithStatement; + function createSwitch(expression: Expression, caseBlock: CaseBlock): SwitchStatement; + function updateSwitch(node: SwitchStatement, expression: Expression, caseBlock: CaseBlock): SwitchStatement; + function createLabel(label: string | Identifier, statement: Statement): LabeledStatement; + function updateLabel(node: LabeledStatement, label: Identifier, statement: Statement): LabeledStatement; + function createThrow(expression: Expression): ThrowStatement; + function updateThrow(node: ThrowStatement, expression: Expression): ThrowStatement; + function createTry(tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; + function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; + function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; + function createClassDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function createEnumDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, members: EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, members: EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody): ModuleDeclaration; + function createModuleBlock(statements: Statement[]): ModuleBlock; + function updateModuleBlock(node: ModuleBlock, statements: Statement[]): ModuleBlock; + function createCaseBlock(clauses: CaseOrDefaultClause[]): CaseBlock; + function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock; + function createImportEqualsDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier?: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier: Expression): ImportDeclaration; + function createImportClause(name: Identifier, namedBindings: NamedImportBindings): ImportClause; + function updateImportClause(node: ImportClause, name: Identifier, namedBindings: NamedImportBindings): ImportClause; + function createNamespaceImport(name: Identifier): NamespaceImport; + function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; + function createNamedImports(elements: ImportSpecifier[]): NamedImports; + function updateNamedImports(node: NamedImports, elements: ImportSpecifier[]): NamedImports; + function createImportSpecifier(propertyName: Identifier, name: Identifier): ImportSpecifier; + function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier, name: Identifier): ImportSpecifier; + function createExportAssignment(decorators: Decorator[], modifiers: Modifier[], isExportEquals: boolean, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: Decorator[], modifiers: Modifier[], expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier: Expression): ExportDeclaration; + function createNamedExports(elements: ExportSpecifier[]): NamedExports; + function updateNamedExports(node: NamedExports, elements: ExportSpecifier[]): NamedExports; + function createExportSpecifier(name: string | Identifier, propertyName?: string | Identifier): ExportSpecifier; + function updateExportSpecifier(node: ExportSpecifier, name: Identifier, propertyName: Identifier): ExportSpecifier; + function createExternalModuleReference(expression: Expression): ExternalModuleReference; + function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; + function createJsxElement(openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; + function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; + function createJsxSelfClosingElement(tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxSelfClosingElement; + function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxSelfClosingElement; + function createJsxOpeningElement(tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxOpeningElement; + function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxOpeningElement; + function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement; + function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; + function createJsxAttributes(properties: JsxAttributeLike[]): JsxAttributes; + function updateJsxAttributes(jsxAttributes: JsxAttributes, properties: JsxAttributeLike[]): JsxAttributes; + function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; + function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; + function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; + function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; + function createJsxExpression(expression: Expression, dotDotDotToken: DotDotDotToken): JsxExpression; + function updateJsxExpression(node: JsxExpression, expression: Expression): JsxExpression; + function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[]): HeritageClause; + function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause; + function createCaseClause(expression: Expression, statements: Statement[]): CaseClause; + function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]): CaseClause; + function createDefaultClause(statements: Statement[]): DefaultClause; + function updateDefaultClause(node: DefaultClause, statements: Statement[]): DefaultClause; + function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block): CatchClause; + function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause; + function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; + function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; + function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; + function createSpreadAssignment(expression: Expression): SpreadAssignment; + function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; + function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; + function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; + function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; + function updateSourceFileNode(node: SourceFile, statements: Statement[]): SourceFile; + /** + * Creates a shallow, memberwise clone of a node for mutation. + */ + function getMutableClone(node: T): T; + /** + * Creates a synthetic statement to act as a placeholder for a not-emitted statement in + * order to preserve comments. + * + * @param original The original statement. + */ + function createNotEmittedStatement(original: Node): NotEmittedStatement; + /** + * Creates a synthetic expression to act as a placeholder for a not-emitted expression in + * order to preserve comments or sourcemap positions. + * + * @param expression The inner expression to emit. + * @param original The original outer expression. + * @param location The location for the expression. Defaults to the positions from "original" if provided. + */ + function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression; + function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; + function createBundle(sourceFiles: SourceFile[]): Bundle; + function updateBundle(node: Bundle, sourceFiles: SourceFile[]): Bundle; + function createComma(left: Expression, right: Expression): Expression; + function createLessThan(left: Expression, right: Expression): Expression; + function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; + function createAssignment(left: Expression, right: Expression): BinaryExpression; + function createStrictEquality(left: Expression, right: Expression): BinaryExpression; + function createStrictInequality(left: Expression, right: Expression): BinaryExpression; + function createAdd(left: Expression, right: Expression): BinaryExpression; + function createSubtract(left: Expression, right: Expression): BinaryExpression; + function createPostfixIncrement(operand: Expression): PostfixUnaryExpression; + function createLogicalAnd(left: Expression, right: Expression): BinaryExpression; + function createLogicalOr(left: Expression, right: Expression): BinaryExpression; + function createLogicalNot(operand: Expression): PrefixUnaryExpression; + function createVoidZero(): VoidExpression; + function createExportDefault(expression: Expression): ExportAssignment; + function createExternalModuleExport(exportName: Identifier): ExportDeclaration; + /** + * Clears any EmitNode entries from parse-tree nodes. + * @param sourceFile A source file. + */ + function disposeEmitNodes(sourceFile: SourceFile): void; + function setTextRange(range: T, location: TextRange | undefined): T; + /** + * Gets flags that control emit behavior of a node. + */ + function getEmitFlags(node: Node): EmitFlags; + /** + * Sets flags that control emit behavior of a node. + */ + function setEmitFlags(node: T, emitFlags: EmitFlags): T; + /** + * Gets a custom text range to use when emitting source maps. + */ + function getSourceMapRange(node: Node): TextRange; + /** + * Sets a custom text range to use when emitting source maps. + */ + function setSourceMapRange(node: T, range: TextRange): T; + /** + * Gets the TextRange to use for source maps for a token of a node. + */ + function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange; + /** + * Sets the TextRange to use for source maps for a token of a node. + */ + function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange): T; + /** + * Gets a custom text range to use when emitting comments. + */ + function getCommentRange(node: Node): TextRange; + /** + * Sets a custom text range to use when emitting comments. + */ + function setCommentRange(node: T, range: TextRange): T; + /** + * Gets the constant value to emit for an expression. + */ + function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; + /** + * Sets the constant value to emit for an expression. + */ + function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number): PropertyAccessExpression | ElementAccessExpression; + /** + * Adds an EmitHelper to a node. + */ + function addEmitHelper(node: T, helper: EmitHelper): T; + /** + * Add EmitHelpers to a node. + */ + function addEmitHelpers(node: T, helpers: EmitHelper[] | undefined): T; + /** + * Removes an EmitHelper from a node. + */ + function removeEmitHelper(node: Node, helper: EmitHelper): boolean; + /** + * Gets the EmitHelpers of a node. + */ + function getEmitHelpers(node: Node): EmitHelper[] | undefined; + /** + * Moves matching emit helpers from a source node to a target node. + */ + function moveEmitHelpers(source: Node, target: Node, predicate: (helper: EmitHelper) => boolean): void; + function setOriginalNode(node: T, original: Node): T; } declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; @@ -2327,6 +2856,10 @@ declare namespace ts { function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } declare namespace ts { + /** Array that is only intended to be pushed to, never read. */ + interface Push { + push(value: T): void; + } function moduleHasNonRelativeName(moduleName: string): boolean; function getEffectiveTypeRoots(options: CompilerOptions, host: { directoryExists?: (directoryName: string) => boolean; @@ -2370,6 +2903,9 @@ declare namespace ts { function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; } +declare namespace ts { + function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; +} declare namespace ts { function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; function resolveTripleslashReference(moduleName: string, containingFile: string): string; @@ -2410,7 +2946,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: FileExtensionInfo[]): ParsedCommandLine; + function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: JsFileExtensionInfo[]): ParsedCommandLine; function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; @@ -2454,7 +2990,7 @@ declare namespace ts { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; - getBaseTypes(): ObjectType[]; + getBaseTypes(): BaseType[]; getNonNullableType(): Type; } interface Signature { @@ -3004,6 +3540,10 @@ declare namespace ts { const letElement = "let"; const directory = "directory"; const externalModuleName = "external module name"; + /** + * + **/ + const jsxAttribute = "JSX attribute"; } namespace ScriptElementKindModifier { const none = ""; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index bae2811e4de..a8db5a7997f 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -173,193 +173,196 @@ var ts; SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 130] = "ReadonlyKeyword"; SyntaxKind[SyntaxKind["RequireKeyword"] = 131] = "RequireKeyword"; SyntaxKind[SyntaxKind["NumberKeyword"] = 132] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 133] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 134] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 135] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 136] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 137] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 138] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 139] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 140] = "OfKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 133] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 134] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 135] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 136] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 137] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 138] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 139] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 140] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 141] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 141] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 142] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 142] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 143] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 143] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 144] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 145] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 144] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 145] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 146] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 146] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 147] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 148] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 149] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 150] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 151] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 152] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 153] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 154] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 155] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 147] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 148] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 149] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 150] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 151] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 152] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 153] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 154] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 155] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 156] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 156] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 157] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 158] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 159] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 160] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 161] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 162] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 163] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 164] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 165] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 166] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 167] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 168] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 169] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 170] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 171] = "LiteralType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 157] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 158] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 159] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 160] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 161] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 162] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 163] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 164] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 165] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 166] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 167] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 168] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 169] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 170] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 171] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 172] = "LiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 172] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 173] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 174] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 173] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 174] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 175] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 175] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 176] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 177] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 178] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 179] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 180] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 181] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 182] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 183] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 184] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 185] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 186] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 187] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 188] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 189] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 190] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 191] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 192] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 193] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 194] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 195] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 196] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 197] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 198] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 199] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 200] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 201] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 202] = "MetaProperty"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 176] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 177] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 178] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 179] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 180] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 181] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 182] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 183] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 184] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 185] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 186] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 187] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 188] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 189] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 190] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 191] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 192] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 193] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 194] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 195] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 196] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 197] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 198] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 199] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 200] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 201] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 202] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 203] = "MetaProperty"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 203] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 204] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 204] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 205] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 205] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 206] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 207] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 208] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 209] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 210] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 211] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 212] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 213] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 214] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 215] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 216] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 217] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 218] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 219] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 220] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 221] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 222] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 223] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 225] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 226] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 227] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 228] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 229] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 230] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 231] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 232] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 233] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 234] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 235] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 236] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 237] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 238] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 239] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 240] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 241] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 242] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 243] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 244] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 245] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 206] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 207] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 208] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 209] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 210] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 211] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 212] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 213] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 214] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 215] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 216] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 217] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 218] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 219] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 220] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 221] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 222] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 223] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 224] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 225] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 226] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 227] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 228] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 229] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 230] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 231] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 232] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 233] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 234] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 235] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 236] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 237] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 238] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 239] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 240] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 241] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 242] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 243] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 244] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 245] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 246] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 246] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 247] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 247] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 248] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 249] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 250] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 251] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 252] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 253] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 248] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 249] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 250] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 251] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 252] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 253] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 254] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 255] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 254] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 255] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 256] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 257] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 256] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 257] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 258] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 259] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 258] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 259] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 260] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 260] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 261] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 262] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 261] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 263] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 262] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 264] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 265] = "Bundle"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 263] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 266] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 264] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 267] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 265] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 266] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 267] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 268] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 269] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 270] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 271] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 272] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 273] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 274] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 275] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 276] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 277] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 278] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 279] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 280] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 281] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 282] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 283] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 284] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 285] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 286] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 287] = "JSDocPropertyTag"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 288] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocLiteralType"] = 289] = "JSDocLiteralType"; - SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 290] = "JSDocNullKeyword"; - SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 291] = "JSDocUndefinedKeyword"; - SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 292] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 268] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 269] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 270] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 271] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 272] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 273] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 274] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 275] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 276] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 277] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 278] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 279] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 280] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 281] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 282] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 283] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 284] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 285] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 286] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 287] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 288] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 289] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 290] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 291] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 292] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 293] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 294] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 295] = "JSDocNeverKeyword"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 293] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 296] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 294] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 295] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 296] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 297] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 297] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 298] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 299] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 300] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 298] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 301] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; @@ -368,15 +371,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 140] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 141] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 156] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 171] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 157] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 172] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 140] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 141] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -385,11 +388,11 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 141] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 263] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 289] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 279] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 292] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 142] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 266] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 295] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 282] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 295] = "LastJSDocTagNode"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -481,6 +484,8 @@ var ts; FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); @@ -517,6 +522,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 2048] = "SuppressAnyReturnType"; + TypeFormatFlags[TypeFormatFlags["AddUndefined"] = 4096] = "AddUndefined"; })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -598,13 +604,10 @@ var ts; SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; - SymbolFlags[SymbolFlags["Instantiated"] = 16777216] = "Instantiated"; - SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; - SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; - SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; - SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; - SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; - SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; + SymbolFlags[SymbolFlags["Prototype"] = 16777216] = "Prototype"; + SymbolFlags[SymbolFlags["ExportStar"] = 33554432] = "ExportStar"; + SymbolFlags[SymbolFlags["Optional"] = 67108864] = "Optional"; + SymbolFlags[SymbolFlags["Transient"] = 134217728] = "Transient"; SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; @@ -648,6 +651,19 @@ var ts; SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); /* @internal */ + var CheckFlags; + (function (CheckFlags) { + CheckFlags[CheckFlags["Instantiated"] = 1] = "Instantiated"; + CheckFlags[CheckFlags["SyntheticProperty"] = 2] = "SyntheticProperty"; + CheckFlags[CheckFlags["Readonly"] = 4] = "Readonly"; + CheckFlags[CheckFlags["Partial"] = 8] = "Partial"; + CheckFlags[CheckFlags["HasNonUniformType"] = 16] = "HasNonUniformType"; + CheckFlags[CheckFlags["ContainsPublic"] = 32] = "ContainsPublic"; + CheckFlags[CheckFlags["ContainsProtected"] = 64] = "ContainsProtected"; + CheckFlags[CheckFlags["ContainsPrivate"] = 128] = "ContainsPrivate"; + CheckFlags[CheckFlags["ContainsStatic"] = 256] = "ContainsStatic"; + })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); + /* @internal */ var NodeCheckFlags; (function (NodeCheckFlags) { NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; @@ -702,6 +718,9 @@ var ts; TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; /* @internal */ TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; + /* @internal */ + TypeFlags[TypeFlags["JsxAttributes"] = 33554432] = "JsxAttributes"; /* @internal */ TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; @@ -710,7 +729,7 @@ var ts; TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 16015] = "Intrinsic"; + TypeFlags[TypeFlags["Intrinsic"] = 16793231] = "Intrinsic"; /* @internal */ TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; TypeFlags[TypeFlags["StringLike"] = 262178] = "StringLike"; @@ -719,12 +738,12 @@ var ts; TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; TypeFlags[TypeFlags["UnionOrIntersection"] = 196608] = "UnionOrIntersection"; TypeFlags[TypeFlags["StructuredType"] = 229376] = "StructuredType"; - TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 507904] = "StructuredOrTypeParameter"; + TypeFlags[TypeFlags["StructuredOrTypeVariable"] = 1032192] = "StructuredOrTypeVariable"; TypeFlags[TypeFlags["TypeVariable"] = 540672] = "TypeVariable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 1033215] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 33281] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["Narrowable"] = 17810431] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 16810497] = "NotUnionOrUnit"; /* @internal */ TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; /* @internal */ @@ -742,6 +761,7 @@ var ts; ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; + ObjectFlags[ObjectFlags["NonPrimitive"] = 1024] = "NonPrimitive"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); var SignatureKind; @@ -792,6 +812,7 @@ var ts; JsxEmit[JsxEmit["None"] = 0] = "None"; JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; JsxEmit[JsxEmit["React"] = 2] = "React"; + JsxEmit[JsxEmit["ReactNative"] = 3] = "ReactNative"; })(JsxEmit = ts.JsxEmit || (ts.JsxEmit = {})); var NewLineKind; (function (NewLineKind) { @@ -805,6 +826,7 @@ var ts; ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; ScriptKind[ScriptKind["TS"] = 3] = "TS"; ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + ScriptKind[ScriptKind["External"] = 5] = "External"; })(ScriptKind = ts.ScriptKind || (ts.ScriptKind = {})); var ScriptTarget; (function (ScriptTarget) { @@ -1039,7 +1061,6 @@ var ts; TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 274432] = "TypeScriptClassSyntaxMask"; TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 163840] = "ES2015FunctionSyntaxMask"; })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); - /* @internal */ var EmitFlags; (function (EmitFlags) { EmitFlags[EmitFlags["SingleLine"] = 1] = "SingleLine"; @@ -1086,14 +1107,13 @@ var ts; ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 128] = "LastEmitHelper"; })(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {})); - /* @internal */ - var EmitContext; - (function (EmitContext) { - EmitContext[EmitContext["SourceFile"] = 0] = "SourceFile"; - EmitContext[EmitContext["Expression"] = 1] = "Expression"; - EmitContext[EmitContext["IdentifierName"] = 2] = "IdentifierName"; - EmitContext[EmitContext["Unspecified"] = 3] = "Unspecified"; - })(EmitContext = ts.EmitContext || (ts.EmitContext = {})); + var EmitHint; + (function (EmitHint) { + EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile"; + EmitHint[EmitHint["Expression"] = 1] = "Expression"; + EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; + EmitHint[EmitHint["Unspecified"] = 3] = "Unspecified"; + })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); })(ts || (ts = {})); /*@internal*/ var ts; @@ -1121,8 +1141,8 @@ var ts; */ function mark(markName) { if (enabled) { - marks[markName] = ts.timestamp(); - counts[markName] = (counts[markName] || 0) + 1; + marks.set(markName, ts.timestamp()); + counts.set(markName, (counts.get(markName) || 0) + 1); profilerEvent(markName); } } @@ -1138,9 +1158,9 @@ var ts; */ function measure(measureName, startMarkName, endMarkName) { if (enabled) { - var end = endMarkName && marks[endMarkName] || ts.timestamp(); - var start = startMarkName && marks[startMarkName] || profilerStart; - measures[measureName] = (measures[measureName] || 0) + (end - start); + var end = endMarkName && marks.get(endMarkName) || ts.timestamp(); + var start = startMarkName && marks.get(startMarkName) || profilerStart; + measures.set(measureName, (measures.get(measureName) || 0) + (end - start)); } } performance.measure = measure; @@ -1150,7 +1170,7 @@ var ts; * @param markName The name of the mark. */ function getCount(markName) { - return counts && counts[markName] || 0; + return counts && counts.get(markName) || 0; } performance.getCount = getCount; /** @@ -1159,7 +1179,7 @@ var ts; * @param measureName The name of the measure whose durations should be accumulated. */ function getDuration(measureName) { - return measures && measures[measureName] || 0; + return measures && measures.get(measureName) || 0; } performance.getDuration = getDuration; /** @@ -1168,9 +1188,9 @@ var ts; * @param cb The action to perform for each measure */ function forEachMeasure(cb) { - for (var key in measures) { - cb(key, measures[key]); - } + measures.forEach(function (measure, key) { + cb(key, measure); + }); } performance.forEachMeasure = forEachMeasure; /** Enables (and resets) performance measurements for the compiler. */ @@ -1194,7 +1214,7 @@ var ts; var ts; (function (ts) { /** The version of the TypeScript compiler release */ - ts.version = "2.2.0"; + ts.version = "2.3.0"; })(ts || (ts = {})); /* @internal */ (function (ts) { @@ -1213,25 +1233,106 @@ var ts; Ternary[Ternary["Maybe"] = 1] = "Maybe"; Ternary[Ternary["True"] = -1] = "True"; })(Ternary = ts.Ternary || (ts.Ternary = {})); - var createObject = Object.create; // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. - ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - function createMap(template) { - var map = createObject(null); // tslint:disable-line:no-null-keyword + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(/*locales*/ undefined, { usage: "sort", sensitivity: "accent" }) : undefined; + // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". + ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + /** Create a MapLike with good performance. */ + function createDictionaryObject() { + var map = Object.create(null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is // constantly changing shape. map["__"] = undefined; delete map["__"]; + return map; + } + /** Create a new map. If a template object is provided, the map will copy entries from it. */ + function createMap() { + return new MapCtr(); + } + ts.createMap = createMap; + function createMapFromTemplate(template) { + var map = new MapCtr(); // Copies keys/values from template. Note that for..in will not throw if // template is undefined, and instead will just exit the loop. for (var key in template) if (hasOwnProperty.call(template, key)) { - map[key] = template[key]; + map.set(key, template[key]); } return map; } - ts.createMap = createMap; + ts.createMapFromTemplate = createMapFromTemplate; + // Internet Explorer's Map doesn't support iteration, so don't use it. + // tslint:disable-next-line:no-in-operator + var MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); + // Keep the class inside a function so it doesn't get compiled if it's not used. + function shimMap() { + var MapIterator = (function () { + function MapIterator(data, selector) { + this.index = 0; + this.data = data; + this.selector = selector; + this.keys = Object.keys(data); + } + MapIterator.prototype.next = function () { + var index = this.index; + if (index < this.keys.length) { + this.index++; + return { value: this.selector(this.data, this.keys[index]), done: false }; + } + return { value: undefined, done: true }; + }; + return MapIterator; + }()); + return (function () { + function class_1() { + this.data = createDictionaryObject(); + this.size = 0; + } + class_1.prototype.get = function (key) { + return this.data[key]; + }; + class_1.prototype.set = function (key, value) { + if (!this.has(key)) { + this.size++; + } + this.data[key] = value; + return this; + }; + class_1.prototype.has = function (key) { + // tslint:disable-next-line:no-in-operator + return key in this.data; + }; + class_1.prototype.delete = function (key) { + if (this.has(key)) { + this.size--; + delete this.data[key]; + return true; + } + return false; + }; + class_1.prototype.clear = function () { + this.data = createDictionaryObject(); + this.size = 0; + }; + class_1.prototype.keys = function () { + return new MapIterator(this.data, function (_data, key) { return key; }); + }; + class_1.prototype.values = function () { + return new MapIterator(this.data, function (data, key) { return data[key]; }); + }; + class_1.prototype.entries = function () { + return new MapIterator(this.data, function (data, key) { return [key, data[key]]; }); + }; + class_1.prototype.forEach = function (action) { + for (var key in this.data) { + action(this.data[key], key); + } + }; + return class_1; + }()); + } function createFileMap(keyMapper) { var files = createMap(); return { @@ -1244,33 +1345,28 @@ var ts; clear: clear, }; function forEachValueInMap(f) { - for (var key in files) { - f(key, files[key]); - } + files.forEach(function (file, key) { + f(key, file); + }); } function getKeys() { - var keys = []; - for (var key in files) { - keys.push(key); - } - return keys; + return arrayFrom(files.keys()); } // path should already be well-formed so it does not need to be normalized function get(path) { - return files[toKey(path)]; + return files.get(toKey(path)); } function set(path, value) { - files[toKey(path)] = value; + files.set(toKey(path), value); } function contains(path) { - return toKey(path) in files; + return files.has(toKey(path)); } function remove(path) { - var key = toKey(path); - delete files[key]; + files.delete(toKey(path)); } function clear() { - files = createMap(); + files.clear(); } function toKey(path) { return keyMapper ? keyMapper(path) : path; @@ -1290,6 +1386,10 @@ var ts; Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; })(Comparison = ts.Comparison || (ts.Comparison = {})); + function length(array) { + return array ? array.length : 0; + } + ts.length = length; /** * 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. @@ -1341,6 +1441,16 @@ var ts; return undefined; } ts.find = find; + /** Works like Array.prototype.findIndex, returning `-1` if no element satisfying the predicate is found. */ + function findIndex(array, predicate) { + for (var i = 0; i < array.length; i++) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; + } + ts.findIndex = findIndex; /** * Returns the first truthy result of `callback`, or else fails. * This is like `forEach`, but never returns undefined. @@ -1589,21 +1699,18 @@ var ts; return result; } ts.spanMap = spanMap; - function mapObject(object, f) { - var result; - if (object) { - result = {}; - for (var _i = 0, _a = getOwnKeys(object); _i < _a.length; _i++) { - var v = _a[_i]; - var _b = f(v, object[v]) || [undefined, undefined], key = _b[0], value = _b[1]; - if (key !== undefined) { - result[key] = value; - } - } + function mapEntries(map, f) { + if (!map) { + return undefined; } + var result = createMap(); + map.forEach(function (value, key) { + var _a = f(key, value), newKey = _a[0], newValue = _a[1]; + result.set(newKey, newValue); + }); return result; } - ts.mapObject = mapObject; + ts.mapEntries = mapEntries; function some(array, predicate) { if (array) { if (predicate) { @@ -1921,9 +2028,6 @@ var ts; /** * Indicates whether a map-like contains an own property with the specified key. * - * NOTE: This is intended for use only with MapLike objects. For Map objects, use - * the 'in' operator. - * * @param map A map-like. * @param key A property key. */ @@ -1934,9 +2038,6 @@ var ts; /** * Gets the value of an owned property in a map-like. * - * NOTE: This is intended for use only with MapLike objects. For Map objects, use - * an indexer. - * * @param map A map-like. * @param key A property key. */ @@ -1961,56 +2062,62 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - /** - * Enumerates the properties of a Map, invoking a callback and returning the first truthy result. - * - * @param map A map for which properties should be enumerated. - * @param callback A callback to invoke for each property. - */ - function forEachProperty(map, callback) { - var result; - for (var key in map) { - if (result = callback(map[key], key)) - break; + /** Shims `Array.from`. */ + function arrayFrom(iterator) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(value); } return result; + var _b; } - ts.forEachProperty = forEachProperty; - /** - * Returns true if a Map has some matching property. - * - * @param map A map whose properties should be tested. - * @param predicate An optional callback used to test each property. - */ - function someProperties(map, predicate) { - for (var key in map) { - if (!predicate || predicate(map[key], key)) - return true; + ts.arrayFrom = arrayFrom; + function convertToArray(iterator, f) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(f(value)); } - return false; + return result; + var _b; } - ts.someProperties = someProperties; + ts.convertToArray = convertToArray; /** - * Performs a shallow copy of the properties from a source Map to a target MapLike - * - * @param source A map from which properties should be copied. - * @param target A map to which properties should be copied. + * Calls `callback` for each entry in the map, returning the first truthy result. + * Use `map.forEach` instead for normal iteration. */ - function copyProperties(source, target) { - for (var key in source) { - target[key] = source[key]; + function forEachEntry(map, callback) { + var iterator = map.entries(); + for (var _a = iterator.next(), pair = _a.value, done = _a.done; !done; _b = iterator.next(), pair = _b.value, done = _b.done, _b) { + var key = pair[0], value = pair[1]; + var result = callback(value, key); + if (result) { + return result; + } } + return undefined; + var _b; } - ts.copyProperties = copyProperties; - function appendProperty(map, key, value) { - if (key === undefined || value === undefined) - return map; - if (map === undefined) - map = createMap(); - map[key] = value; - return map; + ts.forEachEntry = forEachEntry; + /** `forEachEntry` for just keys. */ + function forEachKey(map, callback) { + var iterator = map.keys(); + for (var _a = iterator.next(), key = _a.value, done = _a.done; !done; _b = iterator.next(), key = _b.value, done = _b.done, _b) { + var result = callback(key); + if (result) { + return result; + } + } + return undefined; + var _b; } - ts.appendProperty = appendProperty; + ts.forEachKey = forEachKey; + /** Copy entries from `source` to `target`. */ + function copyEntries(source, target) { + source.forEach(function (value, key) { + target.set(key, value); + }); + } + ts.copyEntries = copyEntries; function assign(t) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -2026,24 +2133,6 @@ var ts; return t; } ts.assign = assign; - /** - * Reduce the properties of a map. - * - * NOTE: This is intended for use with Map objects. For MapLike objects, use - * reduceOwnProperties instead as it offers better runtime safety. - * - * @param map The map to reduce - * @param callback An aggregation function that is called for each entry in the map - * @param initial The initial value for the reduction. - */ - function reduceProperties(map, callback, initial) { - var result = initial; - for (var key in map) { - result = callback(result, map[key], String(key)); - } - return result; - } - ts.reduceProperties = reduceProperties; /** * Performs a shallow equality comparison of the contents of two map-likes. * @@ -2074,23 +2163,14 @@ var ts; var result = createMap(); for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { var value = array_8[_i]; - result[makeKey(value)] = makeValue ? makeValue(value) : value; + result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; } ts.arrayToMap = arrayToMap; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; function cloneMap(map) { var clone = createMap(); - copyProperties(map, clone); + copyEntries(map, clone); return clone; } ts.cloneMap = cloneMap; @@ -2117,36 +2197,32 @@ var ts; return result; } ts.extend = extend; - /** - * Adds the value to an array of values associated with the key, and returns the array. - * Creates the array if it does not already exist. - */ - function multiMapAdd(map, key, value) { - var values = map[key]; + function createMultiMap() { + var map = createMap(); + map.add = multiMapAdd; + map.remove = multiMapRemove; + return map; + } + ts.createMultiMap = createMultiMap; + function multiMapAdd(key, value) { + var values = this.get(key); if (values) { values.push(value); - return values; } else { - return map[key] = [value]; + this.set(key, values = [value]); } + return values; } - ts.multiMapAdd = multiMapAdd; - /** - * Removes a value from an array of values associated with the key. - * Does not preserve the order of those values. - * Does nothing if `key` is not in `map`, or `value` is not in `map[key]`. - */ - function multiMapRemove(map, key, value) { - var values = map[key]; + function multiMapRemove(key, value) { + var values = this.get(key); if (values) { unorderedRemoveItem(values, value); if (!values.length) { - delete map[key]; + this.delete(key); } } } - ts.multiMapRemove = multiMapRemove; /** * Tests whether a value is an array. */ @@ -2330,9 +2406,12 @@ var ts; if (b === undefined) return 1 /* GreaterThan */; if (ignoreCase) { - if (ts.collator && String.prototype.localeCompare) { - // accent means a ≠ b, a ≠ á, a = A - var result = a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); + // Checking if "collator exists indicates that Intl is available. + // We still have to check if "collator.compare" is correct. If it is not, use "String.localeComapre" + if (ts.collator) { + var result = ts.localeCompareIsCorrect ? + ts.collator.compare(a, b) : + a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); // accent means a ≠ b, a ≠ á, a = A return result < 0 ? -1 /* LessThan */ : result > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; } a = a.toUpperCase(); @@ -2777,6 +2856,17 @@ var ts; var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; var singleAsteriskRegexFragmentOther = "[^/]*"; function getRegularExpressionForWildcard(specs, basePath, usage) { + var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); + if (!patterns || !patterns.length) { + return undefined; + } + var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + // If excluding, match "foo/bar/baz...", but if including, only allow "foo". + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; + } + ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + function getRegularExpressionsForWildcards(specs, basePath, usage) { if (specs === undefined || specs.length === 0) { return undefined; } @@ -2787,31 +2877,10 @@ var ts; * files or directories, does not match subdirectories that start with a . character */ var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; - var pattern = ""; - var hasWrittenSubpattern = false; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!spec) { - continue; - } - var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); - if (subPattern === undefined) { - continue; - } - if (hasWrittenSubpattern) { - pattern += "|"; - } - pattern += "(" + subPattern + ")"; - hasWrittenSubpattern = true; - } - if (!pattern) { - return undefined; - } - // If excluding, match "foo/bar/baz...", but if including, only allow "foo". - var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return flatMap(specs, function (spec) { + return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + }); } - ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; /** * An "includes" path "foo" is implicitly a glob "foo/** /*" (without the space) if its last component has no extension, * and does not contain any glob characters itself. @@ -2890,6 +2959,7 @@ var ts; currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); return { + includeFilePatterns: map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -2902,34 +2972,50 @@ var ts; currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); - var result = []; + // Associate an array of results with each include regex. This keeps results in order of the "include" order. + // If there are no "includes", then just put everything in results[0]. + var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; + var comparer = useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive; for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; visitDirectory(basePath, combinePaths(currentDirectory, basePath)); } - return result; + return flatten(results); function visitDirectory(path, absolutePath) { var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; + files = files.slice().sort(comparer); + directories = directories.slice().sort(comparer); + var _loop_1 = function (current) { + var name = combinePaths(path, current); + var absoluteName = combinePaths(absolutePath, current); + if (extensions && !fileExtensionIsAny(name, extensions)) + return "continue"; + if (excludeRegex && excludeRegex.test(absoluteName)) + return "continue"; + if (!includeFileRegexes) { + results[0].push(name); + } + else { + var includeIndex = findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); }); + if (includeIndex !== -1) { + results[includeIndex].push(name); + } + } + }; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var current = files_1[_i]; - var name_1 = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); - if ((!extensions || fileExtensionIsAny(name_1, extensions)) && - (!includeFileRegex || includeFileRegex.test(absoluteName)) && - (!excludeRegex || !excludeRegex.test(absoluteName))) { - result.push(name_1); - } + _loop_1(current); } for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var current = directories_1[_b]; - var name_2 = combinePaths(path, current); + var name = combinePaths(path, current); var absoluteName = combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { - visitDirectory(name_2, absoluteName); + visitDirectory(name, absoluteName); } } } @@ -2954,7 +3040,7 @@ var ts; } // Sort the offsets array using either the literal or canonical path representations. includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); - var _loop_1 = function (includeBasePath) { + var _loop_2 = function (includeBasePath) { if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } @@ -2963,7 +3049,7 @@ var ts; // subpath of an existing base path for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { var includeBasePath = includeBasePaths_1[_a]; - _loop_1(includeBasePath); + _loop_2(includeBasePath); } } return basePaths; @@ -3014,13 +3100,13 @@ var ts; var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions); function getSupportedExtensions(options, extraFileExtensions) { var needAllExtensions = options && options.allowJs; - if (!extraFileExtensions || extraFileExtensions.length === 0) { + if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = (needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions).slice(0); + var extensions = allSupportedExtensions.slice(0); for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { var extInfo = extraFileExtensions_1[_i]; - if (needAllExtensions || extInfo.scriptKind === 3 /* TS */) { + if (extensions.indexOf(extInfo.extension) === -1) { extensions.push(extInfo.extension); } } @@ -3057,14 +3143,13 @@ var ts; (function (ExtensionPriority) { ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; - ExtensionPriority[ExtensionPriority["Limit"] = 5] = "Limit"; ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; })(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {})); function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { - return adjustExtensionPriority(i); + return adjustExtensionPriority(i, supportedExtensions); } } // If its not in the list of supported extensions, this is likely a @@ -3075,27 +3160,27 @@ var ts; /** * Adjusts an extension priority to be the highest priority within the same range. */ - function adjustExtensionPriority(extensionPriority) { + function adjustExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) { return 0 /* TypeScriptFiles */; } - else if (extensionPriority < 5 /* Limit */) { + else if (extensionPriority < supportedExtensions.length) { return 2 /* DeclarationAndJavaScriptFiles */; } else { - return 5 /* Limit */; + return supportedExtensions.length; } } ts.adjustExtensionPriority = adjustExtensionPriority; /** * Gets the next lowest extension priority for a given priority. */ - function getNextLowestExtensionPriority(extensionPriority) { + function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) { return 2 /* DeclarationAndJavaScriptFiles */; } else { - return 5 /* Limit */; + return supportedExtensions.length; } } ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority; @@ -3489,32 +3574,32 @@ var ts; function createWatchedFileSet() { var dirWatchers = ts.createMap(); // One file can have multiple watchers - var fileWatcherCallbacks = ts.createMap(); + var fileWatcherCallbacks = ts.createMultiMap(); return { addFile: addFile, removeFile: removeFile }; function reduceDirWatcherRefCountForFile(fileName) { var dirName = ts.getDirectoryPath(fileName); - var watcher = dirWatchers[dirName]; + var watcher = dirWatchers.get(dirName); if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); - delete dirWatchers[dirName]; + dirWatchers.delete(dirName); } } } function addDirWatcher(dirPath) { - var watcher = dirWatchers[dirPath]; + var watcher = dirWatchers.get(dirPath); if (watcher) { watcher.referenceCount += 1; return; } watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; - dirWatchers[dirPath] = watcher; + dirWatchers.set(dirPath, watcher); return; } function addFileWatcherCallback(filePath, callback) { - ts.multiMapAdd(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.add(filePath, callback); } function addFile(fileName, callback) { addFileWatcherCallback(fileName, callback); @@ -3526,7 +3611,7 @@ var ts; reduceDirWatcherRefCountForFile(watchedFile.fileName); } function removeFileWatcherCallback(filePath, callback) { - ts.multiMapRemove(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.remove(filePath, callback); } function fileEventHandler(eventName, relativeFileName, baseDirPath) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" @@ -3534,10 +3619,13 @@ var ts; ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); // Some applications save a working file via rename operations - if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { - for (var _i = 0, _a = fileWatcherCallbacks[fileName]; _i < _a.length; _i++) { - var fileCallback = _a[_i]; - fileCallback(fileName); + if ((eventName === "change" || eventName === "rename")) { + var callbacks = fileWatcherCallbacks.get(fileName); + if (callbacks) { + for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) { + var fileCallback = callbacks_1[_i]; + fileCallback(fileName); + } } } } @@ -3613,10 +3701,10 @@ var ts; if (entry === "." || entry === "..") { continue; } - var name_3 = ts.combinePaths(path, entry); + var name = ts.combinePaths(path, entry); var stat = void 0; try { - stat = _fs.statSync(name_3); + stat = _fs.statSync(name); } catch (e) { continue; @@ -3697,7 +3785,10 @@ var ts; // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) var options; - if (!directoryExists(directoryName)) { + if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { + // do nothing if either + // - target folder does not exist + // - this is UNC path on Windows (https://github.com/Microsoft/TypeScript/issues/13874) return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { @@ -3716,6 +3807,9 @@ var ts; } ; }); + function isUNCPath(s) { + return s.length > 2 && s.charCodeAt(0) === 47 /* slash */ && s.charCodeAt(1) === 47 /* slash */; + } }, resolvePath: function (path) { return _path.resolve(path); @@ -3778,6 +3872,7 @@ var ts; require("source-map-support").install(); } catch (e) { + // Could not enable source maps. } }, setTimeout: setTimeout, @@ -4034,6 +4129,7 @@ var ts; Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", message: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", message: "Invalid use of '{0}'. Modules are automatically in strict mode." }, + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", message: "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export_assignment_is_not_supported_when_module_flag_is_system_1218", message: "Export assignment is not supported when '--module' flag is 'system'." }, Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", message: "Generators are only available when targeting ECMAScript 2015 or higher." }, @@ -4312,6 +4408,8 @@ var ts; Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, + A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, + Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union 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_2601", message: "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_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -4322,6 +4420,7 @@ var ts; 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_2607", message: "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_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, + Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -4370,11 +4469,15 @@ var ts; The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: { code: 2699, category: ts.DiagnosticCategory.Error, key: "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", message: "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'." }, Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, + Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, + Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "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_4002", message: "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_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -4385,8 +4488,8 @@ var ts; Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4014", message: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_function_has_or_is_using_private_name_1_4016", message: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019", message: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "'extends' clause of exported class '{0}' has or is using private name '{1}'." }, + extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "'extends' clause of exported interface '{0}' has or is using private name '{1}'." }, Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023", message: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024", message: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_private_name_1_4025", message: "Exported variable '{0}' has or is using private name '{1}'." }, @@ -4449,6 +4552,7 @@ var ts; Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced: { code: 4093, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced_4093", message: "'extends' clause of exported class '{0}' refers to a type whose name cannot be referenced." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -4494,7 +4598,7 @@ var ts; Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, - Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_in_the_given_directory_6020", message: "Compile the project in the given directory." }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, @@ -4509,6 +4613,7 @@ var ts; LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, STRATEGY: { code: 6039, category: ts.DiagnosticCategory.Message, key: "STRATEGY_6039", message: "STRATEGY" }, + FILE_OR_DIRECTORY: { code: 6040, category: ts.DiagnosticCategory.Message, key: "FILE_OR_DIRECTORY_6040", message: "FILE OR DIRECTORY" }, Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation_complete_Watching_for_file_changes_6042", message: "Compilation complete. Watching for file changes." }, Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_map_file_6043", message: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_expects_an_argument_6044", message: "Compiler option '{0}' expects an argument." }, @@ -4542,7 +4647,7 @@ var ts; Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, @@ -4562,7 +4667,7 @@ var ts; File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, + package_json_does_not_have_a_0_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_0_field_6100", message: "'package.json' does not have a '{0}' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -4599,7 +4704,6 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, @@ -4652,7 +4756,7 @@ var ts; parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: ts.DiagnosticCategory.Error, key: "parameter_modifiers_can_only_be_used_in_a_ts_file_8012", message: "'parameter modifiers' 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_8015", message: "'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_8016", message: "'type assertion expressions' 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_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause." }, class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "class_expressions_are_not_currently_supported_9003", message: "'class' expressions are not currently supported." }, Language_service_is_disabled: { code: 9004, category: ts.DiagnosticCategory.Error, key: "Language_service_is_disabled_9004", message: "Language service is disabled." }, 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_17000", message: "JSX attributes must only be assigned a non-empty 'expression'." }, @@ -4676,9 +4780,10 @@ var ts; Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, + Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, @@ -4697,7 +4802,7 @@ var ts; return token >= 70 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = ts.createMap({ + var textToToken = ts.createMapFromTemplate({ "abstract": 116 /* AbstractKeyword */, "any": 118 /* AnyKeyword */, "as": 117 /* AsKeyword */, @@ -4721,7 +4826,7 @@ var ts; "false": 85 /* FalseKeyword */, "finally": 86 /* FinallyKeyword */, "for": 87 /* ForKeyword */, - "from": 138 /* FromKeyword */, + "from": 139 /* FromKeyword */, "function": 88 /* FunctionKeyword */, "get": 124 /* GetKeyword */, "if": 89 /* IfKeyword */, @@ -4739,27 +4844,28 @@ var ts; "new": 93 /* NewKeyword */, "null": 94 /* NullKeyword */, "number": 132 /* NumberKeyword */, + "object": 133 /* ObjectKeyword */, "package": 110 /* PackageKeyword */, "private": 111 /* PrivateKeyword */, "protected": 112 /* ProtectedKeyword */, "public": 113 /* PublicKeyword */, "readonly": 130 /* ReadonlyKeyword */, "require": 131 /* RequireKeyword */, - "global": 139 /* GlobalKeyword */, + "global": 140 /* GlobalKeyword */, "return": 95 /* ReturnKeyword */, - "set": 133 /* SetKeyword */, + "set": 134 /* SetKeyword */, "static": 114 /* StaticKeyword */, - "string": 134 /* StringKeyword */, + "string": 135 /* StringKeyword */, "super": 96 /* SuperKeyword */, "switch": 97 /* SwitchKeyword */, - "symbol": 135 /* SymbolKeyword */, + "symbol": 136 /* SymbolKeyword */, "this": 98 /* ThisKeyword */, "throw": 99 /* ThrowKeyword */, "true": 100 /* TrueKeyword */, "try": 101 /* TryKeyword */, - "type": 136 /* TypeKeyword */, + "type": 137 /* TypeKeyword */, "typeof": 102 /* TypeOfKeyword */, - "undefined": 137 /* UndefinedKeyword */, + "undefined": 138 /* UndefinedKeyword */, "var": 103 /* VarKeyword */, "void": 104 /* VoidKeyword */, "while": 105 /* WhileKeyword */, @@ -4767,7 +4873,7 @@ var ts; "yield": 115 /* YieldKeyword */, "async": 119 /* AsyncKeyword */, "await": 120 /* AwaitKeyword */, - "of": 140 /* OfKeyword */, + "of": 141 /* OfKeyword */, "{": 16 /* OpenBraceToken */, "}": 17 /* CloseBraceToken */, "(": 18 /* OpenParenToken */, @@ -4907,9 +5013,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_4 in source) { - result[source[name_4]] = name_4; - } + source.forEach(function (value, name) { + result[value] = name; + }); return result; } var tokenStrings = makeReverseMap(textToToken); @@ -4919,7 +5025,7 @@ var ts; ts.tokenToString = tokenToString; /* @internal */ function stringToToken(s) { - return textToToken[s]; + return textToToken.get(s); } ts.stringToToken = stringToToken; /* @internal */ @@ -4993,7 +5099,6 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - var hasOwnProperty = Object.prototype.hasOwnProperty; function isWhiteSpace(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } @@ -5736,8 +5841,11 @@ var ts; var len = tokenValue.length; if (len >= 2 && len <= 11) { var ch = tokenValue.charCodeAt(0); - if (ch >= 97 /* a */ && ch <= 122 /* z */ && hasOwnProperty.call(textToToken, tokenValue)) { - return token = textToToken[tokenValue]; + if (ch >= 97 /* a */ && ch <= 122 /* z */) { + token = textToToken.get(tokenValue); + if (token !== undefined) { + return token; + } } } return token = 70 /* Identifier */; @@ -6430,6 +6538,19 @@ var ts; return undefined; } ts.getDeclarationOfKind = getDeclarationOfKind; + function findDeclaration(symbol, predicate) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; + if (predicate(declaration)) { + return declaration; + } + } + } + return undefined; + } + ts.findDeclaration = findDeclaration; // Pool writers to avoid needing to allocate them for every symbol we write. var stringWriters = []; function getSingleLineStringWriter() { @@ -6453,7 +6574,8 @@ var ts; decreaseIndent: ts.noop, clear: function () { return str_1 = ""; }, trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop }; } return stringWriters.pop(); @@ -6469,25 +6591,25 @@ var ts; } ts.getFullWidth = getFullWidth; function hasResolvedModule(sourceFile, moduleNameText) { - return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText)); } ts.hasResolvedModule = hasResolvedModule; function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules.get(moduleNameText) : undefined; } ts.getResolvedModule = getResolvedModule; function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { if (!sourceFile.resolvedModules) { sourceFile.resolvedModules = ts.createMap(); } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; + sourceFile.resolvedModules.set(moduleNameText, resolvedModule); } ts.setResolvedModule = setResolvedModule; function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { if (!sourceFile.resolvedTypeReferenceDirectiveNames) { sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; + sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective); } ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; /* @internal */ @@ -6509,7 +6631,7 @@ var ts; } for (var i = 0; i < names.length; i++) { var newResolution = newResolutions[i]; - var oldResolution = oldResolutions && oldResolutions[names[i]]; + var oldResolution = oldResolutions && oldResolutions.get(names[i]); var changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) : newResolution; @@ -6544,7 +6666,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 262 /* SourceFile */) { + while (node && node.kind !== 264 /* SourceFile */) { node = node.parent; } return node; @@ -6552,11 +6674,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 205 /* Block */: - case 233 /* CaseBlock */: - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: + case 206 /* Block */: + case 234 /* CaseBlock */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: return true; } return false; @@ -6647,18 +6769,18 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 293 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 296 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 263 /* FirstJSDocNode */ && node.kind <= 289 /* LastJSDocNode */; + return node.kind >= 266 /* FirstJSDocNode */ && node.kind <= 295 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 279 /* FirstJSDocTagNode */ && node.kind <= 292 /* LastJSDocTagNode */; + return node.kind >= 282 /* FirstJSDocTagNode */ && node.kind <= 295 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6724,18 +6846,52 @@ var ts; } ts.getLiteralText = getLiteralText; function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { + return node.kind === 8 /* NumericLiteral */ + && (getNumericLiteralFlags(text, /*hint*/ 6 /* BinaryOrOctal */) & 6 /* BinaryOrOctal */) !== 0; + } + ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + var NumericLiteralFlags; + (function (NumericLiteralFlags) { + NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; + NumericLiteralFlags[NumericLiteralFlags["Hexadecimal"] = 1] = "Hexadecimal"; + NumericLiteralFlags[NumericLiteralFlags["Binary"] = 2] = "Binary"; + NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; + NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 8] = "Scientific"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctal"] = 6] = "BinaryOrOctal"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalOrHexadecimal"] = 7] = "BinaryOrOctalOrHexadecimal"; + NumericLiteralFlags[NumericLiteralFlags["All"] = 15] = "All"; + })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); + /** + * Scans a numeric literal string to determine the form of the number. + * @param text Numeric literal text + * @param hint If `Scientific` or `All` is specified, performs a more expensive check to scan for scientific notation. + */ + function getNumericLiteralFlags(text, hint) { + if (text.length > 1) { switch (text.charCodeAt(1)) { case 98 /* b */: case 66 /* B */: + return 2 /* Binary */; case 111 /* o */: case 79 /* O */: - return true; + return 4 /* Octal */; + case 120 /* x */: + case 88 /* X */: + return 1 /* Hexadecimal */; + } + if (hint & 8 /* Scientific */) { + for (var i = text.length - 1; i >= 0; i--) { + switch (text.charCodeAt(i)) { + case 101 /* e */: + case 69 /* E */: + return 8 /* Scientific */; + } + } } } - return false; + return 0 /* None */; } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + ts.getNumericLiteralFlags = getNumericLiteralFlags; function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; } @@ -6744,11 +6900,6 @@ var ts; return identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier; } ts.escapeIdentifier = escapeIdentifier; - // Remove extra underscore from escaped identifier - function unescapeIdentifier(identifier) { - return identifier.length >= 3 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ && identifier.charCodeAt(2) === 95 /* _ */ ? identifier.substr(1) : identifier; - } - ts.unescapeIdentifier = unescapeIdentifier; // Make an identifier from an external module name by extracting the string after the last "/" and replacing // all non-alphanumeric characters with underscores function makeIdentifierFromModuleName(moduleName) { @@ -6762,11 +6913,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 224 /* VariableDeclaration */ && node.parent.kind === 257 /* CatchClause */; + return node.kind === 225 /* VariableDeclaration */ && node.parent.kind === 259 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 231 /* ModuleDeclaration */ && + return node && node.kind === 232 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6777,11 +6928,11 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node.kind === 231 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 232 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 262 /* SourceFile */ || - node.kind === 231 /* ModuleDeclaration */ || + return node.kind === 264 /* SourceFile */ || + node.kind === 232 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6797,9 +6948,9 @@ var ts; return false; } switch (node.parent.kind) { - case 262 /* SourceFile */: + case 264 /* SourceFile */: return ts.isExternalModule(node.parent); - case 232 /* ModuleBlock */: + case 233 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6811,22 +6962,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 262 /* SourceFile */: - case 233 /* CaseBlock */: - case 257 /* CatchClause */: - case 231 /* ModuleDeclaration */: - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 150 /* Constructor */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 264 /* SourceFile */: + case 234 /* CaseBlock */: + case 259 /* CatchClause */: + case 232 /* ModuleDeclaration */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 151 /* Constructor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return true; - case 205 /* Block */: + case 206 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -6860,7 +7011,7 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: if (isStringOrNumericLiteral(name.expression)) { return name.expression.text; } @@ -6871,10 +7022,10 @@ var ts; function entityNameToString(name) { switch (name.kind) { case 70 /* Identifier */: - return getFullWidth(name) === 0 ? unescapeIdentifier(name.text) : getTextOfNode(name); - case 141 /* QualifiedName */: + return getFullWidth(name) === 0 ? ts.unescapeIdentifier(name.text) : getTextOfNode(name); + case 142 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); } } @@ -6911,7 +7062,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 205 /* Block */) { + if (node.body && node.body.kind === 206 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6925,7 +7076,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 262 /* SourceFile */: + case 264 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -6934,23 +7085,23 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 224 /* VariableDeclaration */: - case 174 /* BindingElement */: - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 228 /* InterfaceDeclaration */: - case 231 /* ModuleDeclaration */: - case 230 /* EnumDeclaration */: - case 261 /* EnumMember */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 229 /* TypeAliasDeclaration */: + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 232 /* ModuleDeclaration */: + case 231 /* EnumDeclaration */: + case 263 /* EnumMember */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 230 /* TypeAliasDeclaration */: errorNode = node.name; break; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -6973,7 +7124,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 230 /* EnumDeclaration */ && isConst(node); + return node.kind === 231 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -6986,11 +7137,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 179 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; + return n.kind === 180 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 208 /* ExpressionStatement */ + return node.kind === 209 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -7003,10 +7154,10 @@ var ts; } ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 144 /* Parameter */ || - node.kind === 143 /* TypeParameter */ || - node.kind === 184 /* FunctionExpression */ || - node.kind === 185 /* ArrowFunction */) ? + var commentRanges = (node.kind === 145 /* Parameter */ || + node.kind === 144 /* TypeParameter */ || + node.kind === 185 /* FunctionExpression */ || + node.kind === 186 /* ArrowFunction */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); // True if the comment starts with '/**' but not if it is '/**/' @@ -7021,39 +7172,39 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (156 /* FirstTypeNode */ <= node.kind && node.kind <= 171 /* LastTypeNode */) { + if (157 /* FirstTypeNode */ <= node.kind && node.kind <= 172 /* LastTypeNode */) { return true; } switch (node.kind) { case 118 /* AnyKeyword */: case 132 /* NumberKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: - case 137 /* UndefinedKeyword */: + case 136 /* SymbolKeyword */: + case 138 /* UndefinedKeyword */: case 129 /* NeverKeyword */: return true; case 104 /* VoidKeyword */: - return node.parent.kind !== 188 /* VoidExpression */; - case 199 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 189 /* VoidExpression */; + case 200 /* 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 70 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 177 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */ || node.kind === 177 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 141 /* QualifiedName */: - case 177 /* PropertyAccessExpression */: + ts.Debug.assert(node.kind === 70 /* Identifier */ || node.kind === 142 /* QualifiedName */ || node.kind === 178 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 142 /* QualifiedName */: + case 178 /* PropertyAccessExpression */: case 98 /* ThisKeyword */: - var parent_1 = node.parent; - if (parent_1.kind === 160 /* TypeQuery */) { + var parent = node.parent; + if (parent.kind === 161 /* TypeQuery */) { return false; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -7062,38 +7213,38 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (156 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 171 /* LastTypeNode */) { + if (157 /* FirstTypeNode */ <= parent.kind && parent.kind <= 172 /* LastTypeNode */) { return true; } - switch (parent_1.kind) { - case 199 /* ExpressionWithTypeArguments */: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 143 /* TypeParameter */: - return node === parent_1.constraint; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 144 /* Parameter */: - case 224 /* VariableDeclaration */: - return node === parent_1.type; - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 150 /* Constructor */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - return node === parent_1.type; - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - return node === parent_1.type; - case 182 /* TypeAssertionExpression */: - return node === parent_1.type; - case 179 /* CallExpression */: - case 180 /* NewExpression */: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 181 /* TaggedTemplateExpression */: + switch (parent.kind) { + case 200 /* ExpressionWithTypeArguments */: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); + case 144 /* TypeParameter */: + return node === parent.constraint; + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 145 /* Parameter */: + case 225 /* VariableDeclaration */: + return node === parent.type; + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 151 /* Constructor */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + return node === parent.type; + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + return node === parent.type; + case 183 /* TypeAssertionExpression */: + return node === parent.type; + case 180 /* CallExpression */: + case 181 /* NewExpression */: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 182 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -7112,7 +7263,7 @@ var ts; } ts.isChildOfNodeWithKind = isChildOfNodeWithKind; function isPrefixUnaryExpression(node) { - return node.kind === 190 /* PrefixUnaryExpression */; + return node.kind === 191 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; // Warning: This has the same semantics as the forEach family of functions, @@ -7121,23 +7272,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: return visitor(node); - case 233 /* CaseBlock */: - case 205 /* Block */: - case 209 /* IfStatement */: - case 210 /* DoStatement */: - case 211 /* WhileStatement */: - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 218 /* WithStatement */: - case 219 /* SwitchStatement */: - case 254 /* CaseClause */: - case 255 /* DefaultClause */: - case 220 /* LabeledStatement */: - case 222 /* TryStatement */: - case 257 /* CatchClause */: + case 234 /* CaseBlock */: + case 206 /* Block */: + case 210 /* IfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 219 /* WithStatement */: + case 220 /* SwitchStatement */: + case 256 /* CaseClause */: + case 257 /* DefaultClause */: + case 221 /* LabeledStatement */: + case 223 /* TryStatement */: + case 259 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -7147,29 +7298,29 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 230 /* EnumDeclaration */: - case 228 /* InterfaceDeclaration */: - case 231 /* ModuleDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 231 /* EnumDeclaration */: + case 229 /* InterfaceDeclaration */: + case 232 /* ModuleDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* 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_5 = node.name; - if (name_5 && name_5.kind === 142 /* ComputedPropertyName */) { + var name = node.name; + if (name && name.kind === 143 /* 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_5.expression); + traverse(name.expression); return; } } @@ -7189,10 +7340,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 162 /* ArrayType */) { + if (node && node.kind === 163 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 157 /* TypeReference */) { + else if (node && node.kind === 158 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -7203,14 +7354,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 174 /* BindingElement */: - case 261 /* EnumMember */: - case 144 /* Parameter */: - case 258 /* PropertyAssignment */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 259 /* ShorthandPropertyAssignment */: - case 224 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 263 /* EnumMember */: + case 145 /* Parameter */: + case 260 /* PropertyAssignment */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 261 /* ShorthandPropertyAssignment */: + case 225 /* VariableDeclaration */: return true; } } @@ -7218,11 +7369,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 151 /* GetAccessor */ || node.kind === 152 /* SetAccessor */); + return node && (node.kind === 152 /* GetAccessor */ || node.kind === 153 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 227 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */); + return node && (node.kind === 228 /* ClassDeclaration */ || node.kind === 198 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7231,19 +7382,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 150 /* Constructor */: - case 184 /* FunctionExpression */: - case 226 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 151 /* Constructor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return true; } return false; @@ -7251,13 +7402,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: return true; } return false; @@ -7265,13 +7416,13 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 210 /* DoStatement */: - case 211 /* WhileStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: return true; - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -7282,7 +7433,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 220 /* LabeledStatement */) { + if (node.statement.kind !== 221 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -7290,17 +7441,17 @@ var ts; } ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 205 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 206 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 149 /* MethodDeclaration */ && node.parent.kind === 176 /* ObjectLiteralExpression */; + return node && node.kind === 150 /* MethodDeclaration */ && node.parent.kind === 177 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 149 /* MethodDeclaration */ && - (node.parent.kind === 176 /* ObjectLiteralExpression */ || - node.parent.kind === 197 /* ClassExpression */); + return node.kind === 150 /* MethodDeclaration */ && + (node.parent.kind === 177 /* ObjectLiteralExpression */ || + node.parent.kind === 198 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -7336,7 +7487,7 @@ var ts; return undefined; } switch (node.kind) { - case 142 /* ComputedPropertyName */: + case 143 /* 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 @@ -7351,9 +7502,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 145 /* Decorator */: + case 146 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 144 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 145 /* 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; @@ -7364,26 +7515,26 @@ var ts; node = node.parent; } break; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 231 /* ModuleDeclaration */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 230 /* EnumDeclaration */: - case 262 /* SourceFile */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 232 /* ModuleDeclaration */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 231 /* EnumDeclaration */: + case 264 /* SourceFile */: return node; } } @@ -7393,9 +7544,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 150 /* Constructor */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 151 /* Constructor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: return container; } } @@ -7417,26 +7568,26 @@ var ts; return node; } switch (node.kind) { - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: node = node.parent; break; - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: if (!stopOnFunctions) { continue; } - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return node; - case 145 /* Decorator */: + case 146 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 144 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 145 /* 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; @@ -7452,15 +7603,15 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 184 /* FunctionExpression */ || func.kind === 185 /* ArrowFunction */) { + if (func.kind === 185 /* FunctionExpression */ || func.kind === 186 /* ArrowFunction */) { var prev = func; - var parent_2 = func.parent; - while (parent_2.kind === 183 /* ParenthesizedExpression */) { - prev = parent_2; - parent_2 = parent_2.parent; + var parent = func.parent; + while (parent.kind === 184 /* ParenthesizedExpression */) { + prev = parent; + parent = parent.parent; } - if (parent_2.kind === 179 /* CallExpression */ && parent_2.expression === prev) { - return parent_2; + if (parent.kind === 180 /* CallExpression */ && parent.expression === prev) { + return parent; } } } @@ -7470,21 +7621,21 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 177 /* PropertyAccessExpression */ || kind === 178 /* ElementAccessExpression */) + return (kind === 178 /* PropertyAccessExpression */ || kind === 179 /* ElementAccessExpression */) && node.expression.kind === 96 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 157 /* TypeReference */: - case 273 /* JSDocTypeReference */: + case 158 /* TypeReference */: + case 276 /* JSDocTypeReference */: return node.typeName; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 70 /* Identifier */: - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: return node; } return undefined; @@ -7492,10 +7643,12 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 181 /* TaggedTemplateExpression */: - case 145 /* Decorator */: + case 250 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 182 /* TaggedTemplateExpression */: + case 146 /* Decorator */: return true; default: return false; @@ -7503,34 +7656,37 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 181 /* TaggedTemplateExpression */) { + if (node.kind === 182 /* TaggedTemplateExpression */) { return node.tag; } + else if (isJsxOpeningLikeElement(node)) { + return node.tagName; + } // Will either be a CallExpression, NewExpression, or Decorator. return node.expression; } ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: // classes are valid targets return true; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 227 /* ClassDeclaration */; - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 149 /* MethodDeclaration */: + return node.parent.kind === 228 /* ClassDeclaration */; + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 150 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && node.parent.kind === 227 /* ClassDeclaration */; - case 144 /* Parameter */: + && node.parent.kind === 228 /* ClassDeclaration */; + case 145 /* 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 !== undefined - && (node.parent.kind === 150 /* Constructor */ - || node.parent.kind === 149 /* MethodDeclaration */ - || node.parent.kind === 152 /* SetAccessor */) - && node.parent.parent.kind === 227 /* ClassDeclaration */; + && (node.parent.kind === 151 /* Constructor */ + || node.parent.kind === 150 /* MethodDeclaration */ + || node.parent.kind === 153 /* SetAccessor */) + && node.parent.parent.kind === 228 /* ClassDeclaration */; } return false; } @@ -7546,19 +7702,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 149 /* MethodDeclaration */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 153 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 249 /* JsxOpeningElement */ || - parent.kind === 248 /* JsxSelfClosingElement */ || - parent.kind === 250 /* JsxClosingElement */) { + if (parent.kind === 250 /* JsxOpeningElement */ || + parent.kind === 249 /* JsxSelfClosingElement */ || + parent.kind === 251 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -7572,97 +7728,97 @@ var ts; case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: case 11 /* RegularExpressionLiteral */: - case 175 /* ArrayLiteralExpression */: - case 176 /* ObjectLiteralExpression */: - case 177 /* PropertyAccessExpression */: - case 178 /* ElementAccessExpression */: - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 181 /* TaggedTemplateExpression */: - case 200 /* AsExpression */: - case 182 /* TypeAssertionExpression */: - case 201 /* NonNullExpression */: - case 183 /* ParenthesizedExpression */: - case 184 /* FunctionExpression */: - case 197 /* ClassExpression */: - case 185 /* ArrowFunction */: - case 188 /* VoidExpression */: - case 186 /* DeleteExpression */: - case 187 /* TypeOfExpression */: - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: - case 192 /* BinaryExpression */: - case 193 /* ConditionalExpression */: - case 196 /* SpreadElement */: - case 194 /* TemplateExpression */: + case 176 /* ArrayLiteralExpression */: + case 177 /* ObjectLiteralExpression */: + case 178 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 182 /* TaggedTemplateExpression */: + case 201 /* AsExpression */: + case 183 /* TypeAssertionExpression */: + case 202 /* NonNullExpression */: + case 184 /* ParenthesizedExpression */: + case 185 /* FunctionExpression */: + case 198 /* ClassExpression */: + case 186 /* ArrowFunction */: + case 189 /* VoidExpression */: + case 187 /* DeleteExpression */: + case 188 /* TypeOfExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: + case 193 /* BinaryExpression */: + case 194 /* ConditionalExpression */: + case 197 /* SpreadElement */: + case 195 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: - case 198 /* OmittedExpression */: - case 247 /* JsxElement */: - case 248 /* JsxSelfClosingElement */: - case 195 /* YieldExpression */: - case 189 /* AwaitExpression */: - case 202 /* MetaProperty */: + case 199 /* OmittedExpression */: + case 248 /* JsxElement */: + case 249 /* JsxSelfClosingElement */: + case 196 /* YieldExpression */: + case 190 /* AwaitExpression */: + case 203 /* MetaProperty */: return true; - case 141 /* QualifiedName */: - while (node.parent.kind === 141 /* QualifiedName */) { + case 142 /* QualifiedName */: + while (node.parent.kind === 142 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 160 /* TypeQuery */ || isJSXTagName(node); + return node.parent.kind === 161 /* TypeQuery */ || isJSXTagName(node); case 70 /* Identifier */: - if (node.parent.kind === 160 /* TypeQuery */ || isJSXTagName(node)) { + if (node.parent.kind === 161 /* TypeQuery */ || isJSXTagName(node)) { return true; } // fall through case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 98 /* ThisKeyword */: - var parent_3 = node.parent; - switch (parent_3.kind) { - case 224 /* VariableDeclaration */: - case 144 /* Parameter */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 261 /* EnumMember */: - case 258 /* PropertyAssignment */: - case 174 /* BindingElement */: - return parent_3.initializer === node; - case 208 /* ExpressionStatement */: - case 209 /* IfStatement */: - case 210 /* DoStatement */: - case 211 /* WhileStatement */: - case 217 /* ReturnStatement */: - case 218 /* WithStatement */: - case 219 /* SwitchStatement */: - case 254 /* CaseClause */: - case 221 /* ThrowStatement */: - case 219 /* SwitchStatement */: - return parent_3.expression === node; - case 212 /* ForStatement */: - var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 225 /* VariableDeclarationList */) || + var parent = node.parent; + switch (parent.kind) { + case 225 /* VariableDeclaration */: + case 145 /* Parameter */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 263 /* EnumMember */: + case 260 /* PropertyAssignment */: + case 175 /* BindingElement */: + return parent.initializer === node; + case 209 /* ExpressionStatement */: + case 210 /* IfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 218 /* ReturnStatement */: + case 219 /* WithStatement */: + case 220 /* SwitchStatement */: + case 256 /* CaseClause */: + case 222 /* ThrowStatement */: + case 220 /* SwitchStatement */: + return parent.expression === node; + case 213 /* ForStatement */: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 226 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 225 /* VariableDeclarationList */) || + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + var forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 226 /* VariableDeclarationList */) || forInStatement.expression === node; - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: - return node === parent_3.expression; - case 203 /* TemplateSpan */: - return node === parent_3.expression; - case 142 /* ComputedPropertyName */: - return node === parent_3.expression; - case 145 /* Decorator */: - case 253 /* JsxExpression */: - case 252 /* JsxSpreadAttribute */: - case 260 /* SpreadAssignment */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: + return node === parent.expression; + case 204 /* TemplateSpan */: + return node === parent.expression; + case 143 /* ComputedPropertyName */: + return node === parent.expression; + case 146 /* Decorator */: + case 255 /* JsxExpression */: + case 254 /* JsxSpreadAttribute */: + case 262 /* SpreadAssignment */: return true; - case 199 /* ExpressionWithTypeArguments */: - return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); + case 200 /* ExpressionWithTypeArguments */: + return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: - if (isPartOfExpression(parent_3)) { + if (isPartOfExpression(parent)) { return true; } } @@ -7677,7 +7833,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 246 /* ExternalModuleReference */; + return node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 247 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7686,7 +7842,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 246 /* ExternalModuleReference */; + return node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 247 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7704,7 +7860,7 @@ var ts; */ function isRequireCall(expression, checkArgumentIsStringLiteral) { // of the form 'require("name")' - var isRequire = expression.kind === 179 /* CallExpression */ && + var isRequire = expression.kind === 180 /* CallExpression */ && expression.expression.kind === 70 /* Identifier */ && expression.expression.text === "require" && expression.arguments.length === 1; @@ -7720,9 +7876,9 @@ var ts; * This function does not test if the node is in a JavaScript file or not. */ function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 224 /* VariableDeclaration */) { + if (s.valueDeclaration && s.valueDeclaration.kind === 225 /* VariableDeclaration */) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 184 /* FunctionExpression */; + return declaration.initializer && declaration.initializer.kind === 185 /* FunctionExpression */; } return false; } @@ -7733,11 +7889,11 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0 /* None */; } - if (expression.kind !== 192 /* BinaryExpression */) { + if (expression.kind !== 193 /* BinaryExpression */) { return 0 /* None */; } var expr = expression; - if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 177 /* PropertyAccessExpression */) { + if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 178 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; @@ -7755,7 +7911,7 @@ var ts; else if (lhs.expression.kind === 98 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (lhs.expression.kind === 177 /* PropertyAccessExpression */) { + else if (lhs.expression.kind === 178 /* PropertyAccessExpression */) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 70 /* Identifier */) { @@ -7773,35 +7929,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 236 /* ImportDeclaration */) { + if (node.kind === 237 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 235 /* ImportEqualsDeclaration */) { + if (node.kind === 236 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 246 /* ExternalModuleReference */) { + if (reference.kind === 247 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 242 /* ExportDeclaration */) { + if (node.kind === 243 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 231 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 232 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 235 /* ImportEqualsDeclaration */) { + if (node.kind === 236 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 238 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 239 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 236 /* ImportDeclaration */ + return node.kind === 237 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7809,13 +7965,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 144 /* Parameter */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 259 /* ShorthandPropertyAssignment */: - case 258 /* PropertyAssignment */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 145 /* Parameter */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 261 /* ShorthandPropertyAssignment */: + case 260 /* PropertyAssignment */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -7823,22 +7979,27 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 275 /* JSDocFunctionType */ && + return node.kind === 278 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 277 /* JSDocConstructorType */; + node.parameters[0].type.kind === 280 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { return ts.map(getJSDocs(node), function (doc) { return doc.comment; }); } ts.getCommentsFromJSDoc = getCommentsFromJSDoc; + function hasJSDocParameterTags(node) { + var parameterTags = getJSDocTags(node, 285 /* JSDocParameterTag */); + return parameterTags && parameterTags.length > 0; + } + ts.hasJSDocParameterTags = hasJSDocParameterTags; function getJSDocTags(node, kind) { var docs = getJSDocs(node); if (docs) { var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 282 /* JSDocParameterTag */) { + if (doc.kind === 285 /* JSDocParameterTag */) { if (doc.kind === kind) { result.push(doc); } @@ -7870,9 +8031,9 @@ var ts; // var x = function(name) { return name.length; } var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 206 /* VariableStatement */; + parent.parent.parent.kind === 207 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 206 /* VariableStatement */; + parent.parent.kind === 207 /* VariableStatement */; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -7881,20 +8042,20 @@ var ts; } // Also recognize when the node is the RHS of an assignment expression var isSourceOfAssignmentExpressionStatement = parent && parent.parent && - parent.kind === 192 /* BinaryExpression */ && + parent.kind === 193 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && - parent.parent.kind === 208 /* ExpressionStatement */; + parent.parent.kind === 209 /* ExpressionStatement */; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 231 /* ModuleDeclaration */ && - parent && parent.kind === 231 /* ModuleDeclaration */; - var isPropertyAssignmentExpression = parent && parent.kind === 258 /* PropertyAssignment */; + var isModuleDeclaration = node.kind === 232 /* ModuleDeclaration */ && + parent && parent.kind === 232 /* ModuleDeclaration */; + var isPropertyAssignmentExpression = parent && parent.kind === 260 /* PropertyAssignment */; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } // Pull parameter comments from declaring function as well - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { cache = ts.concatenate(cache, getJSDocParameterTags(node)); } if (isVariableLike(node) && node.initializer) { @@ -7908,18 +8069,18 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 282 /* JSDocParameterTag */); + var tags = getJSDocTags(func, 285 /* JSDocParameterTag */); if (!param.name) { // this is an anonymous jsdoc param from a `function(type1, type2): type3` specification var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 282 /* JSDocParameterTag */; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 285 /* JSDocParameterTag */; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70 /* Identifier */) { - var name_6 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 282 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); + var name_1 = param.name.text; + return ts.filter(tags, function (tag) { return tag.kind === 285 /* JSDocParameterTag */ && tag.parameterName.text === name_1; }); } else { // TODO: it's a destructured parameter, so it should look up an "object type" series of multiple lines @@ -7929,8 +8090,8 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 284 /* JSDocTypeTag */); - if (!tag && node.kind === 144 /* Parameter */) { + var tag = getFirstJSDocTag(node, 287 /* JSDocTypeTag */); + if (!tag && node.kind === 145 /* Parameter */) { var paramTags = getJSDocParameterTags(node); if (paramTags) { tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); @@ -7940,15 +8101,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 281 /* JSDocAugmentsTag */); + return getFirstJSDocTag(node, 284 /* JSDocAugmentsTag */); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 283 /* JSDocReturnTag */); + return getFirstJSDocTag(node, 286 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 285 /* JSDocTemplateTag */); + return getFirstJSDocTag(node, 288 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -7961,8 +8122,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536 /* JavaScriptFile */)) { - if (node.type && node.type.kind === 276 /* JSDocVariadicType */ || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 276 /* JSDocVariadicType */; })) { + if (node.type && node.type.kind === 279 /* JSDocVariadicType */ || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 279 /* JSDocVariadicType */; })) { return true; } } @@ -7983,29 +8144,33 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 57 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 42 /* PlusPlusToken */ || unaryOperator === 43 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 183 /* ParenthesizedExpression */: - case 175 /* ArrayLiteralExpression */: - case 196 /* SpreadElement */: + case 184 /* ParenthesizedExpression */: + case 176 /* ArrayLiteralExpression */: + case 197 /* SpreadElement */: node = parent; break; - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } - // Fall through - case 258 /* PropertyAssignment */: + node = parent.parent; + break; + case 260 /* PropertyAssignment */: + if (parent.name === node) { + return 0 /* None */; + } node = parent.parent; break; default: @@ -8017,21 +8182,22 @@ var ts; ts.getAssignmentTargetKind = getAssignmentTargetKind; // A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property // assignment in an object literal that is an assignment target, or if it is parented by an array literal that is - // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. + // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'. + // (Note that `p` is not a target in the above examples, only `a`.) function isAssignmentTarget(node) { return getAssignmentTargetKind(node) !== 0 /* None */; } ts.isAssignmentTarget = isAssignmentTarget; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 177 /* PropertyAccessExpression */ && node.kind !== 178 /* ElementAccessExpression */) { + if (node.kind !== 178 /* PropertyAccessExpression */ && node.kind !== 179 /* ElementAccessExpression */) { return false; } node = node.parent; - while (node && node.kind === 183 /* ParenthesizedExpression */) { + while (node && node.kind === 184 /* ParenthesizedExpression */) { node = node.parent; } - return node && node.kind === 186 /* DeleteExpression */; + return node && node.kind === 187 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -8045,7 +8211,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2 /* Ambient */) || (node.kind === 262 /* SourceFile */ && node.isDeclarationFile)) { + if (hasModifier(node, 2 /* Ambient */) || (node.kind === 264 /* SourceFile */ && node.isDeclarationFile)) { return true; } node = node.parent; @@ -8059,7 +8225,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 240 /* ImportSpecifier */ || parent.kind === 244 /* ExportSpecifier */) { + if (parent.kind === 241 /* ImportSpecifier */ || parent.kind === 245 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -8072,7 +8238,7 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 142 /* ComputedPropertyName */ && + node.parent.kind === 143 /* ComputedPropertyName */ && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -8080,31 +8246,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 261 /* EnumMember */: - case 258 /* PropertyAssignment */: - case 177 /* PropertyAccessExpression */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 263 /* EnumMember */: + case 260 /* PropertyAssignment */: + case 178 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 141 /* QualifiedName */) { + while (parent.kind === 142 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 160 /* TypeQuery */; + return parent.kind === 161 /* TypeQuery */; } return false; - case 174 /* BindingElement */: - case 240 /* ImportSpecifier */: + case 175 /* BindingElement */: + case 241 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 244 /* ExportSpecifier */: + case 245 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -8120,13 +8286,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 235 /* ImportEqualsDeclaration */ || - node.kind === 234 /* NamespaceExportDeclaration */ || - node.kind === 237 /* ImportClause */ && !!node.name || - node.kind === 238 /* NamespaceImport */ || - node.kind === 240 /* ImportSpecifier */ || - node.kind === 244 /* ExportSpecifier */ || - node.kind === 241 /* ExportAssignment */ && exportAssignmentIsAlias(node); + return node.kind === 236 /* ImportEqualsDeclaration */ || + node.kind === 235 /* NamespaceExportDeclaration */ || + node.kind === 238 /* ImportClause */ && !!node.name || + node.kind === 239 /* NamespaceImport */ || + node.kind === 241 /* ImportSpecifier */ || + node.kind === 245 /* ExportSpecifier */ || + node.kind === 242 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8212,7 +8378,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 /* FirstKeyword */ <= token && token <= 140 /* LastKeyword */; + return 71 /* FirstKeyword */ <= token && token <= 141 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -8241,7 +8407,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 142 /* ComputedPropertyName */ && + return name.kind === 143 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -8256,10 +8422,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 144 /* Parameter */) { + if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 145 /* Parameter */) { return name.text; } - if (name.kind === 142 /* ComputedPropertyName */) { + if (name.kind === 143 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -8307,11 +8473,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 144 /* Parameter */; + return root.kind === 145 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 174 /* BindingElement */) { + while (node.kind === 175 /* BindingElement */) { node = node.parent.parent; } return node; @@ -8319,15 +8485,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 150 /* Constructor */ - || kind === 184 /* FunctionExpression */ - || kind === 226 /* FunctionDeclaration */ - || kind === 185 /* ArrowFunction */ - || kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */ - || kind === 231 /* ModuleDeclaration */ - || kind === 262 /* SourceFile */; + return kind === 151 /* Constructor */ + || kind === 185 /* FunctionExpression */ + || kind === 227 /* FunctionDeclaration */ + || kind === 186 /* ArrowFunction */ + || kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */ + || kind === 232 /* ModuleDeclaration */ + || kind === 264 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8335,49 +8501,22 @@ var ts; || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node, nodeTest) { - if (node) { - while (node.original !== undefined) { - node = node.original; - } + function getOriginalSourceFileOrBundle(sourceFileOrBundle) { + if (sourceFileOrBundle.kind === 265 /* Bundle */) { + return ts.updateBundle(sourceFileOrBundle, ts.sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile)); } - return !nodeTest || nodeTest(node) ? node : undefined; + return getOriginalSourceFile(sourceFileOrBundle); } - ts.getOriginalNode = getOriginalNode; - /** - * Gets a value indicating whether a node originated in the parse tree. - * - * @param node The node to test. - */ - function isParseTreeNode(node) { - return (node.flags & 8 /* Synthesized */) === 0; + ts.getOriginalSourceFileOrBundle = getOriginalSourceFileOrBundle; + function getOriginalSourceFile(sourceFile) { + return ts.getParseTreeNode(sourceFile, isSourceFile) || sourceFile; } - ts.isParseTreeNode = isParseTreeNode; - function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { - return node; - } - node = getOriginalNode(node); - if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { - return node; - } - return undefined; - } - ts.getParseTreeNode = getParseTreeNode; function getOriginalSourceFiles(sourceFiles) { - var originalSourceFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); - if (originalSourceFile) { - originalSourceFiles.push(originalSourceFile); - } - } - return originalSourceFiles; + return ts.sameMap(sourceFiles, getOriginalSourceFile); } ts.getOriginalSourceFiles = getOriginalSourceFiles; function getOriginalNodeId(node) { - node = getOriginalNode(node); + node = ts.getOriginalNode(node); return node ? ts.getNodeId(node) : 0; } ts.getOriginalNodeId = getOriginalNodeId; @@ -8388,23 +8527,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 180 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 181 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 180 /* NewExpression */: + case 181 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 190 /* PrefixUnaryExpression */: - case 187 /* TypeOfExpression */: - case 188 /* VoidExpression */: - case 186 /* DeleteExpression */: - case 189 /* AwaitExpression */: - case 193 /* ConditionalExpression */: - case 195 /* YieldExpression */: + case 191 /* PrefixUnaryExpression */: + case 188 /* TypeOfExpression */: + case 189 /* VoidExpression */: + case 187 /* DeleteExpression */: + case 190 /* AwaitExpression */: + case 194 /* ConditionalExpression */: + case 196 /* YieldExpression */: return 1 /* Right */; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (operator) { case 39 /* AsteriskAsteriskToken */: case 57 /* EqualsToken */: @@ -8428,15 +8567,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 180 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 181 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 192 /* BinaryExpression */) { + if (expression.kind === 193 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 190 /* PrefixUnaryExpression */ || expression.kind === 191 /* PostfixUnaryExpression */) { + else if (expression.kind === 191 /* PrefixUnaryExpression */ || expression.kind === 192 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -8454,36 +8593,36 @@ var ts; case 85 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 175 /* ArrayLiteralExpression */: - case 176 /* ObjectLiteralExpression */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 197 /* ClassExpression */: - case 247 /* JsxElement */: - case 248 /* JsxSelfClosingElement */: + case 176 /* ArrayLiteralExpression */: + case 177 /* ObjectLiteralExpression */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 198 /* ClassExpression */: + case 248 /* JsxElement */: + case 249 /* JsxSelfClosingElement */: case 11 /* RegularExpressionLiteral */: case 12 /* NoSubstitutionTemplateLiteral */: - case 194 /* TemplateExpression */: - case 183 /* ParenthesizedExpression */: - case 198 /* OmittedExpression */: + case 195 /* TemplateExpression */: + case 184 /* ParenthesizedExpression */: + case 199 /* OmittedExpression */: return 19; - case 181 /* TaggedTemplateExpression */: - case 177 /* PropertyAccessExpression */: - case 178 /* ElementAccessExpression */: + case 182 /* TaggedTemplateExpression */: + case 178 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: return 18; - case 180 /* NewExpression */: + case 181 /* NewExpression */: return hasArguments ? 18 : 17; - case 179 /* CallExpression */: + case 180 /* CallExpression */: return 17; - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return 16; - case 190 /* PrefixUnaryExpression */: - case 187 /* TypeOfExpression */: - case 188 /* VoidExpression */: - case 186 /* DeleteExpression */: - case 189 /* AwaitExpression */: + case 191 /* PrefixUnaryExpression */: + case 188 /* TypeOfExpression */: + case 189 /* VoidExpression */: + case 187 /* DeleteExpression */: + case 190 /* AwaitExpression */: return 15; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (operatorKind) { case 50 /* ExclamationToken */: case 51 /* TildeToken */: @@ -8541,11 +8680,11 @@ var ts; default: return -1; } - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return 4; - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return 2; - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return 1; default: return -1; @@ -8568,21 +8707,15 @@ var ts; return modificationCount; } function reattachFileDiagnostics(newFile) { - if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { - var diagnostic = _a[_i]; - diagnostic.file = newFile; - } + ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } function add(diagnostic) { var diagnostics; if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); if (!diagnostics) { diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; + fileDiagnostics.set(diagnostic.file.fileName, diagnostics); } } else { @@ -8599,16 +8732,16 @@ var ts; function getDiagnostics(fileName) { sortAndDeduplicate(); if (fileName) { - return fileDiagnostics[fileName] || []; + return fileDiagnostics.get(fileName) || []; } var allDiagnostics = []; function pushDiagnostic(d) { allDiagnostics.push(d); } ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } + fileDiagnostics.forEach(function (diagnostics) { + ts.forEach(diagnostics, pushDiagnostic); + }); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function sortAndDeduplicate() { @@ -8617,9 +8750,9 @@ var ts; } diagnosticsModified = false; nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } + fileDiagnostics.forEach(function (diagnostics, key) { + fileDiagnostics.set(key, ts.sortAndDeduplicateDiagnostics(diagnostics)); + }); } } ts.createDiagnosticCollection = createDiagnosticCollection; @@ -8629,7 +8762,7 @@ var ts; // the map below must be updated. Note that this regexp *does not* include the 'delete' character. // There is no reason for this other than that JSON.stringify does not handle it either. var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = ts.createMap({ + var escapedCharsMap = ts.createMapFromTemplate({ "\0": "\\0", "\t": "\\t", "\v": "\\v", @@ -8653,7 +8786,7 @@ var ts; } ts.escapeString = escapeString; function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); @@ -8811,168 +8944,77 @@ var ts; */ function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); + var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); }; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); - var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = getAllEmittableSourceFiles(); + var moduleEmitEnabled_1 = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified - return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); + return ts.filter(host.getSourceFiles(), function (sourceFile) { + return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); + }); } else { - var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; - return filterSourceFilesInDirectory(sourceFiles, function (file) { return host.isSourceFileFromExternalLibrary(file); }); - } - function getAllEmittableSourceFiles() { - return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); + var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); }); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; - /** Don't call this for `--outFile`, just for `--outDir` or plain emit. */ - function filterSourceFilesInDirectory(sourceFiles, isSourceFileFromExternalLibrary) { - return ts.filter(sourceFiles, function (file) { return shouldEmitInDirectory(file, isSourceFileFromExternalLibrary); }); - } - ts.filterSourceFilesInDirectory = filterSourceFilesInDirectory; - function isNonDeclarationFile(sourceFile) { - return !isDeclarationFile(sourceFile); + /** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */ + function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) { + return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !isDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); } + ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; /** - * Whether a file should be emitted in a non-`--outFile` case. - * Don't emit if source file is a declaration file, or was located under node_modules - */ - function shouldEmitInDirectory(sourceFile, isSourceFileFromExternalLibrary) { - return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); - } - function isBundleEmitNonExternalModule(sourceFile) { - return isNonDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); - } - /** - * Iterates over each source file to emit. The source files are expected to have been - * transformed for use by the pretty printer. - * - * Originally part of `forEachExpectedEmitFile`, this functionality was extracted to support - * transformations. + * Iterates over the source files that are expected to have an emit output. * * @param host An EmitHost. - * @param sourceFiles The transformed source files to emit. * @param action The action to execute. + * @param sourceFilesOrTargetSourceFile + * If an array, the full list of source files to emit. + * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); - // Emit on each source file if (options.outFile || options.out) { - onBundledEmit(sourceFiles); - } - else { - for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { - var sourceFile = sourceFiles_2[_i]; - // Don't emit if source file is a declaration file, or was located under node_modules - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } - } - function onSingleFileEmit(host, sourceFile) { - // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. - // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. - // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve - var extension = ".js"; - if (options.jsx === 1 /* Preserve */) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1 /* JSX */) { - // TypeScript source file preserving JSX syntax - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], /*isBundledEmit*/ false); - } - function onBundledEmit(sourceFiles) { if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, /*isBundledEmit*/ true); + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); + } + } + else { + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, sourceFile, emitOnlyDtsFiles); } } } - ts.forEachTransformedEmitFile = forEachTransformedEmitFile; + ts.forEachEmittedFile = forEachEmittedFile; function getSourceMapFilePath(jsFilePath, options) { return options.sourceMap ? jsFilePath + ".map" : undefined; } - /** - * Iterates over the source files that are expected to have an emit output. This function - * is used by the legacy emitter and the declaration emitter and should not be used by - * the tree transforming emitter. - * - * @param host An EmitHost. - * @param action The action to execute. - * @param targetSourceFile An optional target source file to emit. - */ - function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - // Emit on each source file - if (options.outFile || options.out) { - onBundledEmit(host); - } - else { - var sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; - if (shouldEmitInDirectory(sourceFile, function (file) { return host.isSourceFileFromExternalLibrary(file); })) { - onSingleFileEmit(host, sourceFile); + // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. + // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. + // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve + function getOutputExtension(sourceFile, options) { + if (options.jsx === 1 /* Preserve */) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + return ".jsx"; } } - } - function onSingleFileEmit(host, sourceFile) { - // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. - // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. - // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve - var extension = ".js"; - if (options.jsx === 1 /* Preserve */) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1 /* JSX */) { - // TypeScript source file preserving JSX syntax - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: declarationFilePath - }; - action(emitFileNames, [sourceFile], /*isBundledEmit*/ false, emitOnlyDtsFiles); - } - function onBundledEmit(host) { - // Can emit only sources that are not declaration file and are either non module code or module with - // --module or --target es6 specified. Files included by searching under node_modules are also not emitted. - var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (!ts.isExternalModule(sourceFile) || - !!ts.getEmitModuleKind(options)); }); - if (bundledSources.length) { - var jsFilePath = options.outFile || options.out; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined - }; - action(emitFileNames, bundledSources, /*isBundledEmit*/ true, emitOnlyDtsFiles); + else if (sourceFile.languageVariant === 1 /* JSX */) { + // TypeScript source file preserving JSX syntax + return ".jsx"; } } + return ".js"; } - ts.forEachExpectedEmitFile = forEachExpectedEmitFile; function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); var commonSourceDirectory = host.getCommonSourceDirectory(); @@ -8997,7 +9039,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 150 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 151 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -9039,10 +9081,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 151 /* GetAccessor */) { + if (accessor.kind === 152 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 152 /* SetAccessor */) { + else if (accessor.kind === 153 /* SetAccessor */) { setAccessor = accessor; } else { @@ -9051,7 +9093,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 151 /* GetAccessor */ || member.kind === 152 /* SetAccessor */) + if ((member.kind === 152 /* GetAccessor */ || member.kind === 153 /* SetAccessor */) && hasModifier(member, 32 /* Static */) === hasModifier(accessor, 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -9062,10 +9104,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 151 /* GetAccessor */ && !getAccessor) { + if (member.kind === 152 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 152 /* SetAccessor */ && !setAccessor) { + if (member.kind === 153 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -9328,7 +9370,7 @@ var ts; ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 199 /* ExpressionWithTypeArguments */ && + if (node.kind === 200 /* ExpressionWithTypeArguments */ && node.parent.token === 84 /* ExtendsKeyword */ && isClassLike(node.parent.parent)) { return node.parent.parent; @@ -9346,8 +9388,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 176 /* ObjectLiteralExpression */ - || kind === 175 /* ArrayLiteralExpression */; + return kind === 177 /* ObjectLiteralExpression */ + || kind === 176 /* ArrayLiteralExpression */; } return false; } @@ -9375,29 +9417,33 @@ var ts; ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { return node.kind === 70 /* Identifier */ || - node.kind === 177 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); + node.kind === 178 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 177 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 176 /* ObjectLiteralExpression */) { + if (kind === 177 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 175 /* ArrayLiteralExpression */) { + if (kind === 176 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; } ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; + return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function isExportDefaultSymbol(symbol) { + return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512 /* Default */); + } + ts.isExportDefaultSymbol = isExportDefaultSymbol; /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -9509,39 +9555,39 @@ var ts; || kind === 94 /* NullKeyword */) { return true; } - else if (kind === 177 /* PropertyAccessExpression */) { + else if (kind === 178 /* PropertyAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 178 /* ElementAccessExpression */) { + else if (kind === 179 /* ElementAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 190 /* PrefixUnaryExpression */ - || kind === 191 /* PostfixUnaryExpression */) { + else if (kind === 191 /* PrefixUnaryExpression */ + || kind === 192 /* PostfixUnaryExpression */) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 192 /* BinaryExpression */) { + else if (kind === 193 /* BinaryExpression */) { return node.operatorToken.kind !== 39 /* AsteriskAsteriskToken */ && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 193 /* ConditionalExpression */) { + else if (kind === 194 /* ConditionalExpression */) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 188 /* VoidExpression */ - || kind === 187 /* TypeOfExpression */ - || kind === 186 /* DeleteExpression */) { + else if (kind === 189 /* VoidExpression */ + || kind === 188 /* TypeOfExpression */ + || kind === 187 /* DeleteExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 175 /* ArrayLiteralExpression */) { + else if (kind === 176 /* ArrayLiteralExpression */) { return node.elements.length === 0; } - else if (kind === 176 /* ObjectLiteralExpression */) { + else if (kind === 177 /* ObjectLiteralExpression */) { return node.properties.length === 0; } - else if (kind === 179 /* CallExpression */) { + else if (kind === 180 /* CallExpression */) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9556,16 +9602,19 @@ var ts; } return false; } - var syntaxKindCache = ts.createMap(); + var syntaxKindCache = []; function formatSyntaxKind(kind) { var syntaxKindEnum = ts.SyntaxKind; if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; + var cached = syntaxKindCache[kind]; + if (cached !== undefined) { + return cached; } - for (var name_7 in syntaxKindEnum) { - if (syntaxKindEnum[name_7] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_7 + ")"; + for (var name in syntaxKindEnum) { + if (syntaxKindEnum[name] === kind) { + var result = kind + " (" + name + ")"; + syntaxKindCache[kind] = result; + return result; } } } @@ -9574,6 +9623,14 @@ var ts; } } ts.formatSyntaxKind = formatSyntaxKind; + function getRangePos(range) { + return range ? range.pos : -1; + } + ts.getRangePos = getRangePos; + function getRangeEnd(range) { + return range ? range.end : -1; + } + ts.getRangeEnd = getRangeEnd; /** * Increases (or decreases) a position by the provided amount. * @@ -9705,11 +9762,11 @@ var ts; * declaration. */ function isDeclarationNameOfEnumOrNamespace(node) { - var parseNode = getParseTreeNode(node); + var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 230 /* EnumDeclaration */: - case 231 /* ModuleDeclaration */: + case 231 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -9730,7 +9787,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 /* ClassDeclaration */ && declaration !== node) { + if (declaration.kind === 228 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9796,7 +9853,7 @@ var ts; } ts.isIdentifier = isIdentifier; function isVoidExpression(node) { - return node.kind === 188 /* VoidExpression */; + return node.kind === 189 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { @@ -9811,16 +9868,16 @@ var ts; ts.isModifier = isModifier; // Names function isQualifiedName(node) { - return node.kind === 141 /* QualifiedName */; + return node.kind === 142 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 142 /* ComputedPropertyName */; + return node.kind === 143 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 141 /* QualifiedName */ + return kind === 142 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isEntityName = isEntityName; @@ -9829,7 +9886,7 @@ var ts; return kind === 70 /* Identifier */ || kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 142 /* ComputedPropertyName */; + || kind === 143 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isModuleName(node) { @@ -9841,61 +9898,61 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 70 /* Identifier */ - || kind === 172 /* ObjectBindingPattern */ - || kind === 173 /* ArrayBindingPattern */; + || kind === 173 /* ObjectBindingPattern */ + || kind === 174 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Signature elements function isTypeParameter(node) { - return node.kind === 143 /* TypeParameter */; + return node.kind === 144 /* TypeParameter */; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 144 /* Parameter */; + return node.kind === 145 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 145 /* Decorator */; + return node.kind === 146 /* Decorator */; } ts.isDecorator = isDecorator; // Type members function isMethodDeclaration(node) { - return node.kind === 149 /* MethodDeclaration */; + return node.kind === 150 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 150 /* Constructor */ - || kind === 147 /* PropertyDeclaration */ - || kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */ - || kind === 155 /* IndexSignature */ - || kind === 204 /* SemicolonClassElement */; + return kind === 151 /* Constructor */ + || kind === 148 /* PropertyDeclaration */ + || kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */ + || kind === 156 /* IndexSignature */ + || kind === 205 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 258 /* PropertyAssignment */ - || kind === 259 /* ShorthandPropertyAssignment */ - || kind === 260 /* SpreadAssignment */ - || kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */ - || kind === 245 /* MissingDeclaration */; + return kind === 260 /* PropertyAssignment */ + || kind === 261 /* ShorthandPropertyAssignment */ + || kind === 262 /* SpreadAssignment */ + || kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */ + || kind === 246 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 156 /* FirstTypeNode */ && kind <= 171 /* LastTypeNode */) + return (kind >= 157 /* FirstTypeNode */ && kind <= 172 /* LastTypeNode */) || kind === 118 /* AnyKeyword */ || kind === 132 /* NumberKeyword */ || kind === 121 /* BooleanKeyword */ - || kind === 134 /* StringKeyword */ - || kind === 135 /* SymbolKeyword */ + || kind === 135 /* StringKeyword */ + || kind === 136 /* SymbolKeyword */ || kind === 104 /* VoidKeyword */ || kind === 129 /* NeverKeyword */ - || kind === 199 /* ExpressionWithTypeArguments */; + || kind === 200 /* ExpressionWithTypeArguments */; } /** * Node test that determines whether a node is a valid type node. @@ -9908,36 +9965,36 @@ var ts; ts.isTypeNode = isTypeNode; // Binding patterns function isArrayBindingPattern(node) { - return node.kind === 173 /* ArrayBindingPattern */; + return node.kind === 174 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isObjectBindingPattern(node) { - return node.kind === 172 /* ObjectBindingPattern */; + return node.kind === 173 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 173 /* ArrayBindingPattern */ - || kind === 172 /* ObjectBindingPattern */; + return kind === 174 /* ArrayBindingPattern */ + || kind === 173 /* ObjectBindingPattern */; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 175 /* ArrayLiteralExpression */ - || kind === 176 /* ObjectLiteralExpression */; + return kind === 176 /* ArrayLiteralExpression */ + || kind === 177 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; function isBindingElement(node) { - return node.kind === 174 /* BindingElement */; + return node.kind === 175 /* BindingElement */; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 174 /* BindingElement */ - || kind === 198 /* OmittedExpression */; + return kind === 175 /* BindingElement */ + || kind === 199 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -9945,9 +10002,9 @@ var ts; */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 224 /* VariableDeclaration */: - case 144 /* Parameter */: - case 174 /* BindingElement */: + case 225 /* VariableDeclaration */: + case 145 /* Parameter */: + case 175 /* BindingElement */: return true; } return false; @@ -9966,8 +10023,8 @@ var ts; */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 172 /* ObjectBindingPattern */: - case 176 /* ObjectLiteralExpression */: + case 173 /* ObjectBindingPattern */: + case 177 /* ObjectLiteralExpression */: return true; } return false; @@ -9978,8 +10035,8 @@ var ts; */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 173 /* ArrayBindingPattern */: - case 175 /* ArrayLiteralExpression */: + case 174 /* ArrayBindingPattern */: + case 176 /* ArrayLiteralExpression */: return true; } return false; @@ -9987,86 +10044,86 @@ var ts; ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; // Expression function isArrayLiteralExpression(node) { - return node.kind === 175 /* ArrayLiteralExpression */; + return node.kind === 176 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 176 /* ObjectLiteralExpression */; + return node.kind === 177 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 177 /* PropertyAccessExpression */; + return node.kind === 178 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 178 /* ElementAccessExpression */; + return node.kind === 179 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 192 /* BinaryExpression */; + return node.kind === 193 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 193 /* ConditionalExpression */; + return node.kind === 194 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 179 /* CallExpression */; + return node.kind === 180 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 194 /* TemplateExpression */ + return kind === 195 /* TemplateExpression */ || kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadExpression(node) { - return node.kind === 196 /* SpreadElement */; + return node.kind === 197 /* SpreadElement */; } ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 199 /* ExpressionWithTypeArguments */; + return node.kind === 200 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 177 /* PropertyAccessExpression */ - || kind === 178 /* ElementAccessExpression */ - || kind === 180 /* NewExpression */ - || kind === 179 /* CallExpression */ - || kind === 247 /* JsxElement */ - || kind === 248 /* JsxSelfClosingElement */ - || kind === 181 /* TaggedTemplateExpression */ - || kind === 175 /* ArrayLiteralExpression */ - || kind === 183 /* ParenthesizedExpression */ - || kind === 176 /* ObjectLiteralExpression */ - || kind === 197 /* ClassExpression */ - || kind === 184 /* FunctionExpression */ + return kind === 178 /* PropertyAccessExpression */ + || kind === 179 /* ElementAccessExpression */ + || kind === 181 /* NewExpression */ + || kind === 180 /* CallExpression */ + || kind === 248 /* JsxElement */ + || kind === 249 /* JsxSelfClosingElement */ + || kind === 182 /* TaggedTemplateExpression */ + || kind === 176 /* ArrayLiteralExpression */ + || kind === 184 /* ParenthesizedExpression */ + || kind === 177 /* ObjectLiteralExpression */ + || kind === 198 /* ClassExpression */ + || kind === 185 /* FunctionExpression */ || kind === 70 /* Identifier */ || kind === 11 /* RegularExpressionLiteral */ || kind === 8 /* NumericLiteral */ || kind === 9 /* StringLiteral */ || kind === 12 /* NoSubstitutionTemplateLiteral */ - || kind === 194 /* TemplateExpression */ + || kind === 195 /* TemplateExpression */ || kind === 85 /* FalseKeyword */ || kind === 94 /* NullKeyword */ || kind === 98 /* ThisKeyword */ || kind === 100 /* TrueKeyword */ || kind === 96 /* SuperKeyword */ - || kind === 201 /* NonNullExpression */ - || kind === 202 /* MetaProperty */; + || kind === 202 /* NonNullExpression */ + || kind === 203 /* MetaProperty */; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 190 /* PrefixUnaryExpression */ - || kind === 191 /* PostfixUnaryExpression */ - || kind === 186 /* DeleteExpression */ - || kind === 187 /* TypeOfExpression */ - || kind === 188 /* VoidExpression */ - || kind === 189 /* AwaitExpression */ - || kind === 182 /* TypeAssertionExpression */ + return kind === 191 /* PrefixUnaryExpression */ + || kind === 192 /* PostfixUnaryExpression */ + || kind === 187 /* DeleteExpression */ + || kind === 188 /* TypeOfExpression */ + || kind === 189 /* VoidExpression */ + || kind === 190 /* AwaitExpression */ + || kind === 183 /* TypeAssertionExpression */ || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -10074,13 +10131,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 193 /* ConditionalExpression */ - || kind === 195 /* YieldExpression */ - || kind === 185 /* ArrowFunction */ - || kind === 192 /* BinaryExpression */ - || kind === 196 /* SpreadElement */ - || kind === 200 /* AsExpression */ - || kind === 198 /* OmittedExpression */ + return kind === 194 /* ConditionalExpression */ + || kind === 196 /* YieldExpression */ + || kind === 186 /* ArrowFunction */ + || kind === 193 /* BinaryExpression */ + || kind === 197 /* SpreadElement */ + || kind === 201 /* AsExpression */ + || kind === 199 /* OmittedExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10089,16 +10146,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 182 /* TypeAssertionExpression */ - || kind === 200 /* AsExpression */; + return kind === 183 /* TypeAssertionExpression */ + || kind === 201 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 295 /* PartiallyEmittedExpression */; + return node.kind === 298 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 294 /* NotEmittedStatement */; + return node.kind === 297 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10107,17 +10164,17 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 198 /* OmittedExpression */; + return node.kind === 199 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 203 /* TemplateSpan */; + return node.kind === 204 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 205 /* Block */; + return node.kind === 206 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -10135,121 +10192,135 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 224 /* VariableDeclaration */; + return node.kind === 225 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 225 /* VariableDeclarationList */; + return node.kind === 226 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 233 /* CaseBlock */; + return node.kind === 234 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 232 /* ModuleBlock */ - || kind === 231 /* ModuleDeclaration */; + return kind === 233 /* ModuleBlock */ + || kind === 232 /* ModuleDeclaration */ + || kind === 70 /* Identifier */; } ts.isModuleBody = isModuleBody; + function isNamespaceBody(node) { + var kind = node.kind; + return kind === 233 /* ModuleBlock */ + || kind === 232 /* ModuleDeclaration */; + } + ts.isNamespaceBody = isNamespaceBody; + function isJSDocNamespaceBody(node) { + var kind = node.kind; + return kind === 70 /* Identifier */ + || kind === 232 /* ModuleDeclaration */; + } + ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isImportEqualsDeclaration(node) { - return node.kind === 235 /* ImportEqualsDeclaration */; + return node.kind === 236 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 237 /* ImportClause */; + return node.kind === 238 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 239 /* NamedImports */ - || kind === 238 /* NamespaceImport */; + return kind === 240 /* NamedImports */ + || kind === 239 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 240 /* ImportSpecifier */; + return node.kind === 241 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 243 /* NamedExports */; + return node.kind === 244 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 244 /* ExportSpecifier */; + return node.kind === 245 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 231 /* ModuleDeclaration */ || node.kind === 230 /* EnumDeclaration */; + return node.kind === 232 /* ModuleDeclaration */ || node.kind === 231 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 185 /* ArrowFunction */ - || kind === 174 /* BindingElement */ - || kind === 227 /* ClassDeclaration */ - || kind === 197 /* ClassExpression */ - || kind === 150 /* Constructor */ - || kind === 230 /* EnumDeclaration */ - || kind === 261 /* EnumMember */ - || kind === 244 /* ExportSpecifier */ - || kind === 226 /* FunctionDeclaration */ - || kind === 184 /* FunctionExpression */ - || kind === 151 /* GetAccessor */ - || kind === 237 /* ImportClause */ - || kind === 235 /* ImportEqualsDeclaration */ - || kind === 240 /* ImportSpecifier */ - || kind === 228 /* InterfaceDeclaration */ - || kind === 149 /* MethodDeclaration */ - || kind === 148 /* MethodSignature */ - || kind === 231 /* ModuleDeclaration */ - || kind === 234 /* NamespaceExportDeclaration */ - || kind === 238 /* NamespaceImport */ - || kind === 144 /* Parameter */ - || kind === 258 /* PropertyAssignment */ - || kind === 147 /* PropertyDeclaration */ - || kind === 146 /* PropertySignature */ - || kind === 152 /* SetAccessor */ - || kind === 259 /* ShorthandPropertyAssignment */ - || kind === 229 /* TypeAliasDeclaration */ - || kind === 143 /* TypeParameter */ - || kind === 224 /* VariableDeclaration */ - || kind === 286 /* JSDocTypedefTag */; + return kind === 186 /* ArrowFunction */ + || kind === 175 /* BindingElement */ + || kind === 228 /* ClassDeclaration */ + || kind === 198 /* ClassExpression */ + || kind === 151 /* Constructor */ + || kind === 231 /* EnumDeclaration */ + || kind === 263 /* EnumMember */ + || kind === 245 /* ExportSpecifier */ + || kind === 227 /* FunctionDeclaration */ + || kind === 185 /* FunctionExpression */ + || kind === 152 /* GetAccessor */ + || kind === 238 /* ImportClause */ + || kind === 236 /* ImportEqualsDeclaration */ + || kind === 241 /* ImportSpecifier */ + || kind === 229 /* InterfaceDeclaration */ + || kind === 252 /* JsxAttribute */ + || kind === 150 /* MethodDeclaration */ + || kind === 149 /* MethodSignature */ + || kind === 232 /* ModuleDeclaration */ + || kind === 235 /* NamespaceExportDeclaration */ + || kind === 239 /* NamespaceImport */ + || kind === 145 /* Parameter */ + || kind === 260 /* PropertyAssignment */ + || kind === 148 /* PropertyDeclaration */ + || kind === 147 /* PropertySignature */ + || kind === 153 /* SetAccessor */ + || kind === 261 /* ShorthandPropertyAssignment */ + || kind === 230 /* TypeAliasDeclaration */ + || kind === 144 /* TypeParameter */ + || kind === 225 /* VariableDeclaration */ + || kind === 289 /* JSDocTypedefTag */; } function isDeclarationStatementKind(kind) { - return kind === 226 /* FunctionDeclaration */ - || kind === 245 /* MissingDeclaration */ - || kind === 227 /* ClassDeclaration */ - || kind === 228 /* InterfaceDeclaration */ - || kind === 229 /* TypeAliasDeclaration */ - || kind === 230 /* EnumDeclaration */ - || kind === 231 /* ModuleDeclaration */ - || kind === 236 /* ImportDeclaration */ - || kind === 235 /* ImportEqualsDeclaration */ - || kind === 242 /* ExportDeclaration */ - || kind === 241 /* ExportAssignment */ - || kind === 234 /* NamespaceExportDeclaration */; + return kind === 227 /* FunctionDeclaration */ + || kind === 246 /* MissingDeclaration */ + || kind === 228 /* ClassDeclaration */ + || kind === 229 /* InterfaceDeclaration */ + || kind === 230 /* TypeAliasDeclaration */ + || kind === 231 /* EnumDeclaration */ + || kind === 232 /* ModuleDeclaration */ + || kind === 237 /* ImportDeclaration */ + || kind === 236 /* ImportEqualsDeclaration */ + || kind === 243 /* ExportDeclaration */ + || kind === 242 /* ExportAssignment */ + || kind === 235 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 216 /* BreakStatement */ - || kind === 215 /* ContinueStatement */ - || kind === 223 /* DebuggerStatement */ - || kind === 210 /* DoStatement */ - || kind === 208 /* ExpressionStatement */ - || kind === 207 /* EmptyStatement */ - || kind === 213 /* ForInStatement */ - || kind === 214 /* ForOfStatement */ - || kind === 212 /* ForStatement */ - || kind === 209 /* IfStatement */ - || kind === 220 /* LabeledStatement */ - || kind === 217 /* ReturnStatement */ - || kind === 219 /* SwitchStatement */ - || kind === 221 /* ThrowStatement */ - || kind === 222 /* TryStatement */ - || kind === 206 /* VariableStatement */ - || kind === 211 /* WhileStatement */ - || kind === 218 /* WithStatement */ - || kind === 294 /* NotEmittedStatement */ - || kind === 297 /* EndOfDeclarationMarker */ - || kind === 296 /* MergeDeclarationMarker */; + return kind === 217 /* BreakStatement */ + || kind === 216 /* ContinueStatement */ + || kind === 224 /* DebuggerStatement */ + || kind === 211 /* DoStatement */ + || kind === 209 /* ExpressionStatement */ + || kind === 208 /* EmptyStatement */ + || kind === 214 /* ForInStatement */ + || kind === 215 /* ForOfStatement */ + || kind === 213 /* ForStatement */ + || kind === 210 /* IfStatement */ + || kind === 221 /* LabeledStatement */ + || kind === 218 /* ReturnStatement */ + || kind === 220 /* SwitchStatement */ + || kind === 222 /* ThrowStatement */ + || kind === 223 /* TryStatement */ + || kind === 207 /* VariableStatement */ + || kind === 212 /* WhileStatement */ + || kind === 219 /* WithStatement */ + || kind === 297 /* NotEmittedStatement */ + || kind === 300 /* EndOfDeclarationMarker */ + || kind === 299 /* MergeDeclarationMarker */; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10270,93 +10341,102 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 205 /* Block */; + || kind === 206 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 246 /* ExternalModuleReference */ - || kind === 141 /* QualifiedName */ + return kind === 247 /* ExternalModuleReference */ + || kind === 142 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 249 /* JsxOpeningElement */; + return node.kind === 250 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 250 /* JsxClosingElement */; + return node.kind === 251 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; return kind === 98 /* ThisKeyword */ || kind === 70 /* Identifier */ - || kind === 177 /* PropertyAccessExpression */; + || kind === 178 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 247 /* JsxElement */ - || kind === 253 /* JsxExpression */ - || kind === 248 /* JsxSelfClosingElement */ + return kind === 248 /* JsxElement */ + || kind === 255 /* JsxExpression */ + || kind === 249 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; + function isJsxAttributes(node) { + var kind = node.kind; + return kind === 253 /* JsxAttributes */; + } + ts.isJsxAttributes = isJsxAttributes; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 251 /* JsxAttribute */ - || kind === 252 /* JsxSpreadAttribute */; + return kind === 252 /* JsxAttribute */ + || kind === 254 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 252 /* JsxSpreadAttribute */; + return node.kind === 254 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 251 /* JsxAttribute */; + return node.kind === 252 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; + function isJsxOpeningLikeElement(node) { + return node.kind === 250 /* JsxOpeningElement */ || node.kind === 249 /* JsxSelfClosingElement */; + } + ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 253 /* JsxExpression */; + || kind === 255 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 254 /* CaseClause */ - || kind === 255 /* DefaultClause */; + return kind === 256 /* CaseClause */ + || kind === 257 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 256 /* HeritageClause */; + return node.kind === 258 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 257 /* CatchClause */; + return node.kind === 259 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 258 /* PropertyAssignment */; + return node.kind === 260 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 259 /* ShorthandPropertyAssignment */; + return node.kind === 261 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; // Enum function isEnumMember(node) { - return node.kind === 261 /* EnumMember */; + return node.kind === 263 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 262 /* SourceFile */; + return node.kind === 264 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10586,9 +10666,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 143 /* TypeParameter */) { + if (d && d.kind === 144 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 228 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 229 /* InterfaceDeclaration */) { return current; } } @@ -10596,11 +10676,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 150 /* Constructor */ && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 151 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 174 /* BindingElement */ || ts.isBindingPattern(node))) { + while (node && (node.kind === 175 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10608,14 +10688,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 224 /* VariableDeclaration */) { + if (node.kind === 225 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 225 /* VariableDeclarationList */) { + if (node && node.kind === 226 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 206 /* VariableStatement */) { + if (node && node.kind === 207 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10631,14 +10711,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 224 /* VariableDeclaration */) { + if (node.kind === 225 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 225 /* VariableDeclarationList */) { + if (node && node.kind === 226 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 206 /* VariableStatement */) { + if (node && node.kind === 207 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -10698,27 +10778,60 @@ var ts; } } ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage; + function getOriginalNode(node, nodeTest) { + if (node) { + while (node.original !== undefined) { + node = node.original; + } + } + return !nodeTest || nodeTest(node) ? node : undefined; + } + ts.getOriginalNode = getOriginalNode; + /** + * Gets a value indicating whether a node originated in the parse tree. + * + * @param node The node to test. + */ + function isParseTreeNode(node) { + return (node.flags & 8 /* Synthesized */) === 0; + } + ts.isParseTreeNode = isParseTreeNode; + function getParseTreeNode(node, nodeTest) { + if (isParseTreeNode(node)) { + return node; + } + node = getOriginalNode(node); + if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { + return node; + } + return undefined; + } + ts.getParseTreeNode = getParseTreeNode; + /** + * Remove extra underscore from escaped identifier text content. + * + * @param identifier The escaped identifier text. + * @returns The unescaped identifier text. + */ + function unescapeIdentifier(identifier) { + return identifier.length >= 3 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ && identifier.charCodeAt(2) === 95 /* _ */ ? identifier.substr(1) : identifier; + } + ts.unescapeIdentifier = unescapeIdentifier; })(ts || (ts = {})); /// /// -/* @internal */ var ts; (function (ts) { - var NodeConstructor; - var SourceFileConstructor; - function createNode(kind, location, flags) { - var ConstructorForKind = kind === 262 /* SourceFile */ - ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) - : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); - var node = location - ? new ConstructorForKind(kind, location.pos, location.end) - : new ConstructorForKind(kind, /*pos*/ -1, /*end*/ -1); - node.flags = flags | 8 /* Synthesized */; + function createSynthesizedNode(kind) { + var node = ts.createNode(kind, -1, -1); + node.flags |= 8 /* Synthesized */; return node; } + /* @internal */ function updateNode(updated, original) { if (updated !== original) { setOriginalNode(updated, original); + setTextRange(updated, original); if (original.startsOnNewLine) { updated.startsOnNewLine = true; } @@ -10727,7 +10840,10 @@ var ts; return updated; } ts.updateNode = updateNode; - function createNodeArray(elements, location, hasTrailingComma) { + /** + * Make `elements` into a `NodeArray`. If `elements` is `undefined`, returns an empty `NodeArray`. + */ + function createNodeArray(elements, hasTrailingComma) { if (elements) { if (ts.isNodeArray(elements)) { return elements; @@ -10737,38 +10853,22 @@ var ts; elements = []; } var array = elements; - if (location) { - array.pos = location.pos; - array.end = location.end; - } - else { - array.pos = -1; - array.end = -1; - } - if (hasTrailingComma) { - array.hasTrailingComma = true; - } + array.pos = -1; + array.end = -1; + array.hasTrailingComma = hasTrailingComma; return array; } ts.createNodeArray = createNodeArray; - function createSynthesizedNode(kind, startsOnNewLine) { - var node = createNode(kind, /*location*/ undefined); - node.startsOnNewLine = startsOnNewLine; - return node; - } - ts.createSynthesizedNode = createSynthesizedNode; - function createSynthesizedNodeArray(elements) { - return createNodeArray(elements, /*location*/ undefined); - } - ts.createSynthesizedNodeArray = createSynthesizedNodeArray; /** * Creates a shallow, memberwise clone of a node with no source map location. */ + /* @internal */ function getSynthesizedClone(node) { // We don't use "clone" from core.ts here, as we need to preserve the prototype chain of // the original node. We also need to exclude specific properties and only include own- // properties (to skip members already defined on the shared prototype). - var clone = createNode(node.kind, /*location*/ undefined, node.flags); + var clone = createSynthesizedNode(node.kind); + clone.flags |= node.flags; setOriginalNode(clone, node); for (var key in node) { if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { @@ -10779,54 +10879,49 @@ var ts; return clone; } ts.getSynthesizedClone = getSynthesizedClone; - /** - * Creates a shallow, memberwise clone of a node for mutation. - */ - function getMutableClone(node) { - var clone = getSynthesizedClone(node); - clone.pos = node.pos; - clone.end = node.end; - clone.parent = node.parent; - return clone; - } - ts.getMutableClone = getMutableClone; - function createLiteral(value, location) { + function createLiteral(value) { if (typeof value === "number") { - var node = createNode(8 /* NumericLiteral */, location, /*flags*/ undefined); - node.text = value.toString(); - return node; + return createNumericLiteral(value + ""); } - else if (typeof value === "boolean") { - return createNode(value ? 100 /* TrueKeyword */ : 85 /* FalseKeyword */, location, /*flags*/ undefined); + if (typeof value === "boolean") { + return value ? createTrue() : createFalse(); } - else if (typeof value === "string") { - var node = createNode(9 /* StringLiteral */, location, /*flags*/ undefined); - node.text = value; - return node; - } - else if (value) { - var node = createNode(9 /* StringLiteral */, location, /*flags*/ undefined); - node.textSourceNode = value; - node.text = value.text; - return node; + if (typeof value === "string") { + return createStringLiteral(value); } + return createLiteralFromNode(value); } ts.createLiteral = createLiteral; + function createNumericLiteral(value) { + var node = createSynthesizedNode(8 /* NumericLiteral */); + node.text = value; + return node; + } + ts.createNumericLiteral = createNumericLiteral; + function createStringLiteral(text) { + var node = createSynthesizedNode(9 /* StringLiteral */); + node.text = text; + return node; + } + function createLiteralFromNode(sourceNode) { + var node = createStringLiteral(sourceNode.text); + node.textSourceNode = sourceNode; + return node; + } // Identifiers - var nextAutoGenerateId = 0; - function createIdentifier(text, location) { - var node = createNode(70 /* Identifier */, location); + function createIdentifier(text) { + var node = createSynthesizedNode(70 /* Identifier */); node.text = ts.escapeIdentifier(text); - node.originalKeywordKind = ts.stringToToken(text); + node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateKind = 0 /* None */; node.autoGenerateId = 0; return node; } ts.createIdentifier = createIdentifier; - function createTempVariable(recordTempVariable, location) { - var name = createNode(70 /* Identifier */, location); - name.text = ""; - name.originalKeywordKind = 0 /* Unknown */; + var nextAutoGenerateId = 0; + /** Create a unique temporary variable. */ + function createTempVariable(recordTempVariable) { + var name = createIdentifier(""); name.autoGenerateKind = 1 /* Auto */; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; @@ -10836,98 +10931,129 @@ var ts; return name; } ts.createTempVariable = createTempVariable; - function createLoopVariable(location) { - var name = createNode(70 /* Identifier */, location); - name.text = ""; - name.originalKeywordKind = 0 /* Unknown */; + /** Create a unique temporary variable for use in a loop. */ + function createLoopVariable() { + var name = createIdentifier(""); name.autoGenerateKind = 2 /* Loop */; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createLoopVariable = createLoopVariable; - function createUniqueName(text, location) { - var name = createNode(70 /* Identifier */, location); - name.text = text; - name.originalKeywordKind = 0 /* Unknown */; + /** Create a unique name based on the supplied text. */ + function createUniqueName(text) { + var name = createIdentifier(text); name.autoGenerateKind = 3 /* Unique */; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createUniqueName = createUniqueName; - function getGeneratedNameForNode(node, location) { - var name = createNode(70 /* Identifier */, location); - name.original = node; - name.text = ""; - name.originalKeywordKind = 0 /* Unknown */; + /** Create a unique name generated for a node. */ + function getGeneratedNameForNode(node) { + var name = createIdentifier(""); name.autoGenerateKind = 4 /* Node */; name.autoGenerateId = nextAutoGenerateId; + name.original = node; nextAutoGenerateId++; return name; } ts.getGeneratedNameForNode = getGeneratedNameForNode; // Punctuation function createToken(token) { - return createNode(token); + return createSynthesizedNode(token); } ts.createToken = createToken; // Reserved words function createSuper() { - var node = createNode(96 /* SuperKeyword */); - return node; + return createSynthesizedNode(96 /* SuperKeyword */); } ts.createSuper = createSuper; - function createThis(location) { - var node = createNode(98 /* ThisKeyword */, location); - return node; + function createThis() { + return createSynthesizedNode(98 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - var node = createNode(94 /* NullKeyword */); - return node; + return createSynthesizedNode(94 /* NullKeyword */); } ts.createNull = createNull; + function createTrue() { + return createSynthesizedNode(100 /* TrueKeyword */); + } + ts.createTrue = createTrue; + function createFalse() { + return createSynthesizedNode(85 /* FalseKeyword */); + } + ts.createFalse = createFalse; // Names - function createComputedPropertyName(expression, location) { - var node = createNode(142 /* ComputedPropertyName */, location); + function createQualifiedName(left, right) { + var node = createSynthesizedNode(142 /* QualifiedName */); + node.left = left; + node.right = asName(right); + return node; + } + ts.createQualifiedName = createQualifiedName; + function updateQualifiedName(node, left, right) { + return node.left !== left + || node.right !== right + ? updateNode(createQualifiedName(left, right), node) + : node; + } + ts.updateQualifiedName = updateQualifiedName; + function createComputedPropertyName(expression) { + var node = createSynthesizedNode(143 /* ComputedPropertyName */); node.expression = expression; return node; } ts.createComputedPropertyName = createComputedPropertyName; function updateComputedPropertyName(node, expression) { - if (node.expression !== expression) { - return updateNode(createComputedPropertyName(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createComputedPropertyName(expression), node) + : node; } ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements - function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(144 /* Parameter */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { + var node = createSynthesizedNode(145 /* Parameter */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.questionToken = questionToken; node.type = type; - node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createParameter = createParameter; function updateParameter(node, decorators, modifiers, dotDotDotToken, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer, /*location*/ node, /*flags*/ node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + : node; } ts.updateParameter = updateParameter; + function createDecorator(expression) { + var node = createSynthesizedNode(146 /* Decorator */); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createDecorator = createDecorator; + function updateDecorator(node, expression) { + return node.expression !== expression + ? updateNode(createDecorator(expression), node) + : node; + } + ts.updateDecorator = updateDecorator; // Type members - function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(147 /* PropertyDeclaration */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createProperty(decorators, modifiers, name, questionToken, type, initializer) { + var node = createSynthesizedNode(148 /* PropertyDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.questionToken = questionToken; node.type = type; node.initializer = initializer; @@ -10935,19 +11061,22 @@ var ts; } ts.createProperty = createProperty; function updateProperty(node, decorators, modifiers, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer), node) + : node; } ts.updateProperty = updateProperty; - function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(149 /* MethodDeclaration */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(150 /* MethodDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -10955,16 +11084,21 @@ var ts; } ts.createMethod = createMethod; function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateMethod = updateMethod; - function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(150 /* Constructor */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createConstructor(decorators, modifiers, parameters, body) { + var node = createSynthesizedNode(151 /* Constructor */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = undefined; @@ -10973,17 +11107,19 @@ var ts; } ts.createConstructor = createConstructor; function updateConstructor(node, decorators, modifiers, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.parameters !== parameters || node.body !== body) { - return updateNode(createConstructor(decorators, modifiers, parameters, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.parameters !== parameters + || node.body !== body + ? updateNode(createConstructor(decorators, modifiers, parameters, body), node) + : node; } ts.updateConstructor = updateConstructor; - function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(151 /* GetAccessor */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createGetAccessor(decorators, modifiers, name, parameters, type, body) { + var node = createSynthesizedNode(152 /* GetAccessor */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = type; @@ -10992,17 +11128,21 @@ var ts; } ts.createGetAccessor = createGetAccessor; function updateGetAccessor(node, decorators, modifiers, name, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body), node) + : node; } ts.updateGetAccessor = updateGetAccessor; - function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(152 /* SetAccessor */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createSetAccessor(decorators, modifiers, name, parameters, body) { + var node = createSynthesizedNode(153 /* SetAccessor */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.body = body; @@ -11010,59 +11150,62 @@ var ts; } ts.createSetAccessor = createSetAccessor; function updateSetAccessor(node, decorators, modifiers, name, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.body !== body) { - return updateNode(createSetAccessor(decorators, modifiers, name, parameters, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.body !== body + ? updateNode(createSetAccessor(decorators, modifiers, name, parameters, body), node) + : node; } ts.updateSetAccessor = updateSetAccessor; // Binding Patterns - function createObjectBindingPattern(elements, location) { - var node = createNode(172 /* ObjectBindingPattern */, location); + function createObjectBindingPattern(elements) { + var node = createSynthesizedNode(173 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } ts.createObjectBindingPattern = createObjectBindingPattern; function updateObjectBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createObjectBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createObjectBindingPattern(elements), node) + : node; } ts.updateObjectBindingPattern = updateObjectBindingPattern; - function createArrayBindingPattern(elements, location) { - var node = createNode(173 /* ArrayBindingPattern */, location); + function createArrayBindingPattern(elements) { + var node = createSynthesizedNode(174 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } ts.createArrayBindingPattern = createArrayBindingPattern; function updateArrayBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayBindingPattern(elements), node) + : node; } ts.updateArrayBindingPattern = updateArrayBindingPattern; - function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(174 /* BindingElement */, location); - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createBindingElement(propertyName, dotDotDotToken, name, initializer) { + var node = createSynthesizedNode(175 /* BindingElement */); + node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.initializer = initializer; return node; } ts.createBindingElement = createBindingElement; function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) { - if (node.propertyName !== propertyName || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer) { - return updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer, node), node); - } - return node; + return node.propertyName !== propertyName + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.initializer !== initializer + ? updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer), node) + : node; } ts.updateBindingElement = updateBindingElement; // Expression - function createArrayLiteral(elements, location, multiLine) { - var node = createNode(175 /* ArrayLiteralExpression */, location); - node.elements = parenthesizeListElements(createNodeArray(elements)); + function createArrayLiteral(elements, multiLine) { + var node = createSynthesizedNode(176 /* ArrayLiteralExpression */); + node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; } @@ -11070,14 +11213,13 @@ var ts; } ts.createArrayLiteral = createArrayLiteral; function updateArrayLiteral(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayLiteral(elements, node, node.multiLine), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayLiteral(elements, node.multiLine), node) + : node; } ts.updateArrayLiteral = updateArrayLiteral; - function createObjectLiteral(properties, location, multiLine) { - var node = createNode(176 /* ObjectLiteralExpression */, location); + function createObjectLiteral(properties, multiLine) { + var node = createSynthesizedNode(177 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -11086,109 +11228,120 @@ var ts; } ts.createObjectLiteral = createObjectLiteral; function updateObjectLiteral(node, properties) { - if (node.properties !== properties) { - return updateNode(createObjectLiteral(properties, node, node.multiLine), node); - } - return node; + return node.properties !== properties + ? updateNode(createObjectLiteral(properties, node.multiLine), node) + : node; } ts.updateObjectLiteral = updateObjectLiteral; - function createPropertyAccess(expression, name, location, flags) { - var node = createNode(177 /* PropertyAccessExpression */, location, flags); - node.expression = parenthesizeForAccess(expression); - (node.emitNode || (node.emitNode = {})).flags |= 65536 /* NoIndentation */; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAccess(expression, name) { + var node = createSynthesizedNode(178 /* PropertyAccessExpression */); + node.expression = ts.parenthesizeForAccess(expression); + node.name = asName(name); + setEmitFlags(node, 65536 /* NoIndentation */); return node; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { - if (node.expression !== expression || node.name !== name) { - var propertyAccess = createPropertyAccess(expression, name, /*location*/ node, node.flags); - // Because we are updating existed propertyAccess we want to inherit its emitFlags instead of using default from createPropertyAccess - (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); - return updateNode(propertyAccess, node); - } - return node; + // Because we are updating existed propertyAccess we want to inherit its emitFlags + // instead of using the default from createPropertyAccess + return node.expression !== expression + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccess(expression, name), getEmitFlags(node)), node) + : node; } ts.updatePropertyAccess = updatePropertyAccess; - function createElementAccess(expression, index, location) { - var node = createNode(178 /* ElementAccessExpression */, location); - node.expression = parenthesizeForAccess(expression); - node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; + function createElementAccess(expression, index) { + var node = createSynthesizedNode(179 /* ElementAccessExpression */); + node.expression = ts.parenthesizeForAccess(expression); + node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { - if (node.expression !== expression || node.argumentExpression !== argumentExpression) { - return updateNode(createElementAccess(expression, argumentExpression, node), node); - } - return node; + return node.expression !== expression + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccess(expression, argumentExpression), node) + : node; } ts.updateElementAccess = updateElementAccess; - function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(179 /* CallExpression */, location, flags); - node.expression = parenthesizeForAccess(expression); - if (typeArguments) { - node.typeArguments = createNodeArray(typeArguments); - } - node.arguments = parenthesizeListElements(createNodeArray(argumentsArray)); + function createCall(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(180 /* CallExpression */); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); return node; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { - if (expression !== node.expression || typeArguments !== node.typeArguments || argumentsArray !== node.arguments) { - return updateNode(createCall(expression, typeArguments, argumentsArray, /*location*/ node, node.flags), node); - } - return node; + return expression !== node.expression + || typeArguments !== node.typeArguments + || argumentsArray !== node.arguments + ? updateNode(createCall(expression, typeArguments, argumentsArray), node) + : node; } ts.updateCall = updateCall; - function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(180 /* NewExpression */, location, flags); - node.expression = parenthesizeForNew(expression); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; + function createNew(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(181 /* NewExpression */); + node.expression = ts.parenthesizeForNew(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; return node; } ts.createNew = createNew; function updateNew(node, expression, typeArguments, argumentsArray) { - if (node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray) { - return updateNode(createNew(expression, typeArguments, argumentsArray, /*location*/ node, node.flags), node); - } - return node; + return node.expression !== expression + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createNew(expression, typeArguments, argumentsArray), node) + : node; } ts.updateNew = updateNew; - function createTaggedTemplate(tag, template, location) { - var node = createNode(181 /* TaggedTemplateExpression */, location); - node.tag = parenthesizeForAccess(tag); + function createTaggedTemplate(tag, template) { + var node = createSynthesizedNode(182 /* TaggedTemplateExpression */); + node.tag = ts.parenthesizeForAccess(tag); node.template = template; return node; } ts.createTaggedTemplate = createTaggedTemplate; function updateTaggedTemplate(node, tag, template) { - if (node.tag !== tag || node.template !== template) { - return updateNode(createTaggedTemplate(tag, template, node), node); - } - return node; + return node.tag !== tag + || node.template !== template + ? updateNode(createTaggedTemplate(tag, template), node) + : node; } ts.updateTaggedTemplate = updateTaggedTemplate; - function createParen(expression, location) { - var node = createNode(183 /* ParenthesizedExpression */, location); + function createTypeAssertion(type, expression) { + var node = createSynthesizedNode(183 /* TypeAssertionExpression */); + node.type = type; + node.expression = ts.parenthesizePrefixOperand(expression); + return node; + } + ts.createTypeAssertion = createTypeAssertion; + function updateTypeAssertion(node, type, expression) { + return node.type !== type + || node.expression !== expression + ? updateNode(createTypeAssertion(type, expression), node) + : node; + } + ts.updateTypeAssertion = updateTypeAssertion; + function createParen(expression) { + var node = createSynthesizedNode(184 /* ParenthesizedExpression */); node.expression = expression; return node; } ts.createParen = createParen; function updateParen(node, expression) { - if (node.expression !== expression) { - return updateNode(createParen(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createParen(expression), node) + : node; } ts.updateParen = updateParen; - function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(184 /* FunctionExpression */, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(185 /* FunctionExpression */); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -11196,326 +11349,342 @@ var ts; } ts.createFunctionExpression = createFunctionExpression; function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + return node.name !== name + || node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionExpression = updateFunctionExpression; - function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(185 /* ArrowFunction */, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { + var node = createSynthesizedNode(186 /* ArrowFunction */); + node.modifiers = asNodeArray(modifiers); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35 /* EqualsGreaterThanToken */); - node.body = parenthesizeConciseBody(body); + node.body = ts.parenthesizeConciseBody(body); return node; } ts.createArrowFunction = createArrowFunction; function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { - if (node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body, /*location*/ node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + : node; } ts.updateArrowFunction = updateArrowFunction; - function createDelete(expression, location) { - var node = createNode(186 /* DeleteExpression */, location); - node.expression = parenthesizePrefixOperand(expression); + function createDelete(expression) { + var node = createSynthesizedNode(187 /* DeleteExpression */); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createDelete = createDelete; function updateDelete(node, expression) { - if (node.expression !== expression) { - return updateNode(createDelete(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createDelete(expression), node) + : node; } ts.updateDelete = updateDelete; - function createTypeOf(expression, location) { - var node = createNode(187 /* TypeOfExpression */, location); - node.expression = parenthesizePrefixOperand(expression); + function createTypeOf(expression) { + var node = createSynthesizedNode(188 /* TypeOfExpression */); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createTypeOf = createTypeOf; function updateTypeOf(node, expression) { - if (node.expression !== expression) { - return updateNode(createTypeOf(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createTypeOf(expression), node) + : node; } ts.updateTypeOf = updateTypeOf; - function createVoid(expression, location) { - var node = createNode(188 /* VoidExpression */, location); - node.expression = parenthesizePrefixOperand(expression); + function createVoid(expression) { + var node = createSynthesizedNode(189 /* VoidExpression */); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createVoid = createVoid; function updateVoid(node, expression) { - if (node.expression !== expression) { - return updateNode(createVoid(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createVoid(expression), node) + : node; } ts.updateVoid = updateVoid; - function createAwait(expression, location) { - var node = createNode(189 /* AwaitExpression */, location); - node.expression = parenthesizePrefixOperand(expression); + function createAwait(expression) { + var node = createSynthesizedNode(190 /* AwaitExpression */); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createAwait = createAwait; function updateAwait(node, expression) { - if (node.expression !== expression) { - return updateNode(createAwait(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createAwait(expression), node) + : node; } ts.updateAwait = updateAwait; - function createPrefix(operator, operand, location) { - var node = createNode(190 /* PrefixUnaryExpression */, location); + function createPrefix(operator, operand) { + var node = createSynthesizedNode(191 /* PrefixUnaryExpression */); node.operator = operator; - node.operand = parenthesizePrefixOperand(operand); + node.operand = ts.parenthesizePrefixOperand(operand); return node; } ts.createPrefix = createPrefix; function updatePrefix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPrefix(node.operator, operand, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPrefix(node.operator, operand), node) + : node; } ts.updatePrefix = updatePrefix; - function createPostfix(operand, operator, location) { - var node = createNode(191 /* PostfixUnaryExpression */, location); - node.operand = parenthesizePostfixOperand(operand); + function createPostfix(operand, operator) { + var node = createSynthesizedNode(192 /* PostfixUnaryExpression */); + node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; } ts.createPostfix = createPostfix; function updatePostfix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPostfix(operand, node.operator, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPostfix(operand, node.operator), node) + : node; } ts.updatePostfix = updatePostfix; - function createBinary(left, operator, right, location) { - var operatorToken = typeof operator === "number" ? createToken(operator) : operator; + function createBinary(left, operator, right) { + var node = createSynthesizedNode(193 /* BinaryExpression */); + var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; - var node = createNode(192 /* BinaryExpression */, location); - node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); + node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); node.operatorToken = operatorToken; - node.right = parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); + node.right = ts.parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); return node; } ts.createBinary = createBinary; function updateBinary(node, left, right) { - if (node.left !== left || node.right !== right) { - return updateNode(createBinary(left, node.operatorToken, right, /*location*/ node), node); - } - return node; + return node.left !== left + || node.right !== right + ? updateNode(createBinary(left, node.operatorToken, right), node) + : node; } ts.updateBinary = updateBinary; - function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonTokenOrLocation, whenFalse, location) { - var node = createNode(193 /* ConditionalExpression */, whenFalse ? location : colonTokenOrLocation); - node.condition = parenthesizeForConditionalHead(condition); - if (whenFalse) { - // second overload - node.questionToken = questionTokenOrWhenTrue; - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - node.colonToken = colonTokenOrLocation; - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenFalse); - } - else { - // first overload - node.questionToken = createToken(54 /* QuestionToken */); - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(questionTokenOrWhenTrue); - node.colonToken = createToken(55 /* ColonToken */); - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - } + function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { + var node = createSynthesizedNode(194 /* ConditionalExpression */); + node.condition = ts.parenthesizeForConditionalHead(condition); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(54 /* QuestionToken */); + node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); + node.colonToken = whenFalse ? colonToken : createToken(55 /* ColonToken */); + node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } ts.createConditional = createConditional; function updateConditional(node, condition, whenTrue, whenFalse) { - if (node.condition !== condition || node.whenTrue !== whenTrue || node.whenFalse !== whenFalse) { - return updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse, node), node); - } - return node; + return node.condition !== condition + || node.whenTrue !== whenTrue + || node.whenFalse !== whenFalse + ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + : node; } ts.updateConditional = updateConditional; - function createTemplateExpression(head, templateSpans, location) { - var node = createNode(194 /* TemplateExpression */, location); + function createTemplateExpression(head, templateSpans) { + var node = createSynthesizedNode(195 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; } ts.createTemplateExpression = createTemplateExpression; function updateTemplateExpression(node, head, templateSpans) { - if (node.head !== head || node.templateSpans !== templateSpans) { - return updateNode(createTemplateExpression(head, templateSpans, node), node); - } - return node; + return node.head !== head + || node.templateSpans !== templateSpans + ? updateNode(createTemplateExpression(head, templateSpans), node) + : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createYield(asteriskToken, expression, location) { - var node = createNode(195 /* YieldExpression */, location); - node.asteriskToken = asteriskToken; - node.expression = expression; + function createYield(asteriskTokenOrExpression, expression) { + var node = createSynthesizedNode(196 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 38 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 38 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; function updateYield(node, expression) { - if (node.expression !== expression) { - return updateNode(createYield(node.asteriskToken, expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createYield(node.asteriskToken, expression), node) + : node; } ts.updateYield = updateYield; - function createSpread(expression, location) { - var node = createNode(196 /* SpreadElement */, location); - node.expression = parenthesizeExpressionForList(expression); + function createSpread(expression) { + var node = createSynthesizedNode(197 /* SpreadElement */); + node.expression = ts.parenthesizeExpressionForList(expression); return node; } ts.createSpread = createSpread; function updateSpread(node, expression) { - if (node.expression !== expression) { - return updateNode(createSpread(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createSpread(expression), node) + : node; } ts.updateSpread = updateSpread; - function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(197 /* ClassExpression */, location); + function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(198 /* ClassExpression */); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassExpression = createClassExpression; function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) { - if (node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassExpression = updateClassExpression; - function createOmittedExpression(location) { - var node = createNode(198 /* OmittedExpression */, location); - return node; + function createOmittedExpression() { + return createSynthesizedNode(199 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; - function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(199 /* ExpressionWithTypeArguments */, location); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.expression = parenthesizeForAccess(expression); + function createExpressionWithTypeArguments(typeArguments, expression) { + var node = createSynthesizedNode(200 /* ExpressionWithTypeArguments */); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); return node; } ts.createExpressionWithTypeArguments = createExpressionWithTypeArguments; function updateExpressionWithTypeArguments(node, typeArguments, expression) { - if (node.typeArguments !== typeArguments || node.expression !== expression) { - return updateNode(createExpressionWithTypeArguments(typeArguments, expression, node), node); - } - return node; + return node.typeArguments !== typeArguments + || node.expression !== expression + ? updateNode(createExpressionWithTypeArguments(typeArguments, expression), node) + : node; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; + function createAsExpression(expression, type) { + var node = createSynthesizedNode(201 /* AsExpression */); + node.expression = expression; + node.type = type; + return node; + } + ts.createAsExpression = createAsExpression; + function updateAsExpression(node, expression, type) { + return node.expression !== expression + || node.type !== type + ? updateNode(createAsExpression(expression, type), node) + : node; + } + ts.updateAsExpression = updateAsExpression; + function createNonNullExpression(expression) { + var node = createSynthesizedNode(202 /* NonNullExpression */); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createNonNullExpression = createNonNullExpression; + function updateNonNullExpression(node, expression) { + return node.expression !== expression + ? updateNode(createNonNullExpression(expression), node) + : node; + } + ts.updateNonNullExpression = updateNonNullExpression; // Misc - function createTemplateSpan(expression, literal, location) { - var node = createNode(203 /* TemplateSpan */, location); + function createTemplateSpan(expression, literal) { + var node = createSynthesizedNode(204 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; } ts.createTemplateSpan = createTemplateSpan; function updateTemplateSpan(node, expression, literal) { - if (node.expression !== expression || node.literal !== literal) { - return updateNode(createTemplateSpan(expression, literal, node), node); - } - return node; + return node.expression !== expression + || node.literal !== literal + ? updateNode(createTemplateSpan(expression, literal), node) + : node; } ts.updateTemplateSpan = updateTemplateSpan; // Element - function createBlock(statements, location, multiLine, flags) { - var block = createNode(205 /* Block */, location, flags); + function createBlock(statements, multiLine) { + var block = createSynthesizedNode(206 /* Block */); block.statements = createNodeArray(statements); - if (multiLine) { - block.multiLine = true; - } + if (multiLine) + block.multiLine = multiLine; return block; } ts.createBlock = createBlock; function updateBlock(node, statements) { - if (statements !== node.statements) { - return updateNode(createBlock(statements, /*location*/ node, node.multiLine, node.flags), node); - } - return node; + return statements !== node.statements + ? updateNode(createBlock(statements, node.multiLine), node) + : node; } ts.updateBlock = updateBlock; - function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(206 /* VariableStatement */, location, flags); + function createVariableStatement(modifiers, declarationList) { + var node = createSynthesizedNode(207 /* VariableStatement */); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; return node; } ts.createVariableStatement = createVariableStatement; function updateVariableStatement(node, modifiers, declarationList) { - if (node.modifiers !== modifiers || node.declarationList !== declarationList) { - return updateNode(createVariableStatement(modifiers, declarationList, /*location*/ node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.declarationList !== declarationList + ? updateNode(createVariableStatement(modifiers, declarationList), node) + : node; } ts.updateVariableStatement = updateVariableStatement; - function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(225 /* VariableDeclarationList */, location, flags); + function createVariableDeclarationList(declarations, flags) { + var node = createSynthesizedNode(226 /* VariableDeclarationList */); + node.flags |= flags; node.declarations = createNodeArray(declarations); return node; } ts.createVariableDeclarationList = createVariableDeclarationList; function updateVariableDeclarationList(node, declarations) { - if (node.declarations !== declarations) { - return updateNode(createVariableDeclarationList(declarations, /*location*/ node, node.flags), node); - } - return node; + return node.declarations !== declarations + ? updateNode(createVariableDeclarationList(declarations, node.flags), node) + : node; } ts.updateVariableDeclarationList = updateVariableDeclarationList; - function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(224 /* VariableDeclaration */, location, flags); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createVariableDeclaration(name, type, initializer) { + var node = createSynthesizedNode(225 /* VariableDeclaration */); + node.name = asName(name); node.type = type; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createVariableDeclaration = createVariableDeclaration; function updateVariableDeclaration(node, name, type, initializer) { - if (node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createVariableDeclaration(name, type, initializer, /*location*/ node, node.flags), node); - } - return node; + return node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createVariableDeclaration(name, type, initializer), node) + : node; } ts.updateVariableDeclaration = updateVariableDeclaration; - function createEmptyStatement(location) { - return createNode(207 /* EmptyStatement */, location); + function createEmptyStatement() { + return createSynthesizedNode(208 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression, location, flags) { - var node = createNode(208 /* ExpressionStatement */, location, flags); - node.expression = parenthesizeExpressionForExpressionStatement(expression); + function createStatement(expression) { + var node = createSynthesizedNode(209 /* ExpressionStatement */); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } ts.createStatement = createStatement; function updateStatement(node, expression) { - if (node.expression !== expression) { - return updateNode(createStatement(expression, /*location*/ node, node.flags), node); - } - return node; + return node.expression !== expression + ? updateNode(createStatement(expression), node) + : node; } ts.updateStatement = updateStatement; - function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(209 /* IfStatement */, location); + function createIf(expression, thenStatement, elseStatement) { + var node = createSynthesizedNode(210 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11523,42 +11692,43 @@ var ts; } ts.createIf = createIf; function updateIf(node, expression, thenStatement, elseStatement) { - if (node.expression !== expression || node.thenStatement !== thenStatement || node.elseStatement !== elseStatement) { - return updateNode(createIf(expression, thenStatement, elseStatement, /*location*/ node), node); - } - return node; + return node.expression !== expression + || node.thenStatement !== thenStatement + || node.elseStatement !== elseStatement + ? updateNode(createIf(expression, thenStatement, elseStatement), node) + : node; } ts.updateIf = updateIf; - function createDo(statement, expression, location) { - var node = createNode(210 /* DoStatement */, location); + function createDo(statement, expression) { + var node = createSynthesizedNode(211 /* DoStatement */); node.statement = statement; node.expression = expression; return node; } ts.createDo = createDo; function updateDo(node, statement, expression) { - if (node.statement !== statement || node.expression !== expression) { - return updateNode(createDo(statement, expression, node), node); - } - return node; + return node.statement !== statement + || node.expression !== expression + ? updateNode(createDo(statement, expression), node) + : node; } ts.updateDo = updateDo; - function createWhile(expression, statement, location) { - var node = createNode(211 /* WhileStatement */, location); + function createWhile(expression, statement) { + var node = createSynthesizedNode(212 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; } ts.createWhile = createWhile; function updateWhile(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWhile(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWhile(expression, statement), node) + : node; } ts.updateWhile = updateWhile; - function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(212 /* ForStatement */, location, /*flags*/ undefined); + function createFor(initializer, condition, incrementor, statement) { + var node = createSynthesizedNode(213 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11567,14 +11737,16 @@ var ts; } ts.createFor = createFor; function updateFor(node, initializer, condition, incrementor, statement) { - if (node.initializer !== initializer || node.condition !== condition || node.incrementor !== incrementor || node.statement !== statement) { - return updateNode(createFor(initializer, condition, incrementor, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.condition !== condition + || node.incrementor !== incrementor + || node.statement !== statement + ? updateNode(createFor(initializer, condition, incrementor, statement), node) + : node; } ts.updateFor = updateFor; - function createForIn(initializer, expression, statement, location) { - var node = createNode(213 /* ForInStatement */, location); + function createForIn(initializer, expression, statement) { + var node = createSynthesizedNode(214 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11582,14 +11754,15 @@ var ts; } ts.createForIn = createForIn; function updateForIn(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForIn(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForIn(initializer, expression, statement), node) + : node; } ts.updateForIn = updateForIn; - function createForOf(initializer, expression, statement, location) { - var node = createNode(214 /* ForOfStatement */, location); + function createForOf(initializer, expression, statement) { + var node = createSynthesizedNode(215 /* ForOfStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11597,112 +11770,105 @@ var ts; } ts.createForOf = createForOf; function updateForOf(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForOf(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForOf(initializer, expression, statement), node) + : node; } ts.updateForOf = updateForOf; - function createContinue(label, location) { - var node = createNode(215 /* ContinueStatement */, location); - if (label) { - node.label = label; - } + function createContinue(label) { + var node = createSynthesizedNode(216 /* ContinueStatement */); + node.label = asName(label); return node; } ts.createContinue = createContinue; function updateContinue(node, label) { - if (node.label !== label) { - return updateNode(createContinue(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createContinue(label), node) + : node; } ts.updateContinue = updateContinue; - function createBreak(label, location) { - var node = createNode(216 /* BreakStatement */, location); - if (label) { - node.label = label; - } + function createBreak(label) { + var node = createSynthesizedNode(217 /* BreakStatement */); + node.label = asName(label); return node; } ts.createBreak = createBreak; function updateBreak(node, label) { - if (node.label !== label) { - return updateNode(createBreak(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createBreak(label), node) + : node; } ts.updateBreak = updateBreak; - function createReturn(expression, location) { - var node = createNode(217 /* ReturnStatement */, location); + function createReturn(expression) { + var node = createSynthesizedNode(218 /* ReturnStatement */); node.expression = expression; return node; } ts.createReturn = createReturn; function updateReturn(node, expression) { - if (node.expression !== expression) { - return updateNode(createReturn(expression, /*location*/ node), node); - } - return node; + return node.expression !== expression + ? updateNode(createReturn(expression), node) + : node; } ts.updateReturn = updateReturn; - function createWith(expression, statement, location) { - var node = createNode(218 /* WithStatement */, location); + function createWith(expression, statement) { + var node = createSynthesizedNode(219 /* WithStatement */); node.expression = expression; node.statement = statement; return node; } ts.createWith = createWith; function updateWith(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWith(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWith(expression, statement), node) + : node; } ts.updateWith = updateWith; - function createSwitch(expression, caseBlock, location) { - var node = createNode(219 /* SwitchStatement */, location); - node.expression = parenthesizeExpressionForList(expression); + function createSwitch(expression, caseBlock) { + var node = createSynthesizedNode(220 /* SwitchStatement */); + node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; } ts.createSwitch = createSwitch; function updateSwitch(node, expression, caseBlock) { - if (node.expression !== expression || node.caseBlock !== caseBlock) { - return updateNode(createSwitch(expression, caseBlock, node), node); - } - return node; + return node.expression !== expression + || node.caseBlock !== caseBlock + ? updateNode(createSwitch(expression, caseBlock), node) + : node; } ts.updateSwitch = updateSwitch; - function createLabel(label, statement, location) { - var node = createNode(220 /* LabeledStatement */, location); - node.label = typeof label === "string" ? createIdentifier(label) : label; + function createLabel(label, statement) { + var node = createSynthesizedNode(221 /* LabeledStatement */); + node.label = asName(label); node.statement = statement; return node; } ts.createLabel = createLabel; function updateLabel(node, label, statement) { - if (node.label !== label || node.statement !== statement) { - return updateNode(createLabel(label, statement, node), node); - } - return node; + return node.label !== label + || node.statement !== statement + ? updateNode(createLabel(label, statement), node) + : node; } ts.updateLabel = updateLabel; - function createThrow(expression, location) { - var node = createNode(221 /* ThrowStatement */, location); + function createThrow(expression) { + var node = createSynthesizedNode(222 /* ThrowStatement */); node.expression = expression; return node; } ts.createThrow = createThrow; function updateThrow(node, expression) { - if (node.expression !== expression) { - return updateNode(createThrow(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createThrow(expression), node) + : node; } ts.updateThrow = updateThrow; - function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(222 /* TryStatement */, location); + function createTry(tryBlock, catchClause, finallyBlock) { + var node = createSynthesizedNode(223 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11710,32 +11876,20 @@ var ts; } ts.createTry = createTry; function updateTry(node, tryBlock, catchClause, finallyBlock) { - if (node.tryBlock !== tryBlock || node.catchClause !== catchClause || node.finallyBlock !== finallyBlock) { - return updateNode(createTry(tryBlock, catchClause, finallyBlock, node), node); - } - return node; + return node.tryBlock !== tryBlock + || node.catchClause !== catchClause + || node.finallyBlock !== finallyBlock + ? updateNode(createTry(tryBlock, catchClause, finallyBlock), node) + : node; } ts.updateTry = updateTry; - function createCaseBlock(clauses, location) { - var node = createNode(233 /* CaseBlock */, location); - node.clauses = createNodeArray(clauses); - return node; - } - ts.createCaseBlock = createCaseBlock; - function updateCaseBlock(node, clauses) { - if (node.clauses !== clauses) { - return updateNode(createCaseBlock(clauses, node), node); - } - return node; - } - ts.updateCaseBlock = updateCaseBlock; - function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(226 /* FunctionDeclaration */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(227 /* FunctionDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -11743,162 +11897,263 @@ var ts; } ts.createFunctionDeclaration = createFunctionDeclaration; function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionDeclaration = updateFunctionDeclaration; - function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(227 /* ClassDeclaration */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(228 /* ClassDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassDeclaration = createClassDeclaration; function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassDeclaration = updateClassDeclaration; - function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(236 /* ImportDeclaration */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createEnumDeclaration(decorators, modifiers, name, members) { + var node = createSynthesizedNode(231 /* EnumDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.members = createNodeArray(members); + return node; + } + ts.createEnumDeclaration = createEnumDeclaration; + function updateEnumDeclaration(node, decorators, modifiers, name, members) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.members !== members + ? updateNode(createEnumDeclaration(decorators, modifiers, name, members), node) + : node; + } + ts.updateEnumDeclaration = updateEnumDeclaration; + function createModuleDeclaration(decorators, modifiers, name, body, flags) { + var node = createSynthesizedNode(232 /* ModuleDeclaration */); + node.flags |= flags; + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = name; + node.body = body; + return node; + } + ts.createModuleDeclaration = createModuleDeclaration; + function updateModuleDeclaration(node, decorators, modifiers, name, body) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.body !== body + ? updateNode(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node) + : node; + } + ts.updateModuleDeclaration = updateModuleDeclaration; + function createModuleBlock(statements) { + var node = createSynthesizedNode(234 /* CaseBlock */); + node.statements = createNodeArray(statements); + return node; + } + ts.createModuleBlock = createModuleBlock; + function updateModuleBlock(node, statements) { + return node.statements !== statements + ? updateNode(createModuleBlock(statements), node) + : node; + } + ts.updateModuleBlock = updateModuleBlock; + function createCaseBlock(clauses) { + var node = createSynthesizedNode(234 /* CaseBlock */); + node.clauses = createNodeArray(clauses); + return node; + } + ts.createCaseBlock = createCaseBlock; + function updateCaseBlock(node, clauses) { + return node.clauses !== clauses + ? updateNode(createCaseBlock(clauses), node) + : node; + } + ts.updateCaseBlock = updateCaseBlock; + function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { + var node = createSynthesizedNode(236 /* ImportEqualsDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.moduleReference = moduleReference; + return node; + } + ts.createImportEqualsDeclaration = createImportEqualsDeclaration; + function updateImportEqualsDeclaration(node, decorators, modifiers, name, moduleReference) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.moduleReference !== moduleReference + ? updateNode(createImportEqualsDeclaration(decorators, modifiers, name, moduleReference), node) + : node; + } + ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; + function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { + var node = createSynthesizedNode(237 /* ImportDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createImportDeclaration = createImportDeclaration; function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node) + : node; } ts.updateImportDeclaration = updateImportDeclaration; - function createImportClause(name, namedBindings, location) { - var node = createNode(237 /* ImportClause */, location); + function createImportClause(name, namedBindings) { + var node = createSynthesizedNode(238 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; } ts.createImportClause = createImportClause; function updateImportClause(node, name, namedBindings) { - if (node.name !== name || node.namedBindings !== namedBindings) { - return updateNode(createImportClause(name, namedBindings, node), node); - } - return node; + return node.name !== name + || node.namedBindings !== namedBindings + ? updateNode(createImportClause(name, namedBindings), node) + : node; } ts.updateImportClause = updateImportClause; - function createNamespaceImport(name, location) { - var node = createNode(238 /* NamespaceImport */, location); + function createNamespaceImport(name) { + var node = createSynthesizedNode(239 /* NamespaceImport */); node.name = name; return node; } ts.createNamespaceImport = createNamespaceImport; function updateNamespaceImport(node, name) { - if (node.name !== name) { - return updateNode(createNamespaceImport(name, node), node); - } - return node; + return node.name !== name + ? updateNode(createNamespaceImport(name), node) + : node; } ts.updateNamespaceImport = updateNamespaceImport; - function createNamedImports(elements, location) { - var node = createNode(239 /* NamedImports */, location); + function createNamedImports(elements) { + var node = createSynthesizedNode(240 /* NamedImports */); node.elements = createNodeArray(elements); return node; } ts.createNamedImports = createNamedImports; function updateNamedImports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedImports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedImports(elements), node) + : node; } ts.updateNamedImports = updateNamedImports; - function createImportSpecifier(propertyName, name, location) { - var node = createNode(240 /* ImportSpecifier */, location); + function createImportSpecifier(propertyName, name) { + var node = createSynthesizedNode(241 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; } ts.createImportSpecifier = createImportSpecifier; function updateImportSpecifier(node, propertyName, name) { - if (node.propertyName !== propertyName || node.name !== name) { - return updateNode(createImportSpecifier(propertyName, name, node), node); - } - return node; + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createImportSpecifier(propertyName, name), node) + : node; } ts.updateImportSpecifier = updateImportSpecifier; - function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(241 /* ExportAssignment */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportAssignment(decorators, modifiers, isExportEquals, expression) { + var node = createSynthesizedNode(242 /* ExportAssignment */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = expression; return node; } ts.createExportAssignment = createExportAssignment; function updateExportAssignment(node, decorators, modifiers, expression) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.expression !== expression) { - return updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.expression !== expression + ? updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node) + : node; } ts.updateExportAssignment = updateExportAssignment; - function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(242 /* ExportDeclaration */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { + var node = createSynthesizedNode(243 /* ExportDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createExportDeclaration = createExportDeclaration; function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.exportClause !== exportClause + || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier), node) + : node; } ts.updateExportDeclaration = updateExportDeclaration; - function createNamedExports(elements, location) { - var node = createNode(243 /* NamedExports */, location); + function createNamedExports(elements) { + var node = createSynthesizedNode(244 /* NamedExports */); node.elements = createNodeArray(elements); return node; } ts.createNamedExports = createNamedExports; function updateNamedExports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedExports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedExports(elements), node) + : node; } ts.updateNamedExports = updateNamedExports; - function createExportSpecifier(name, propertyName, location) { - var node = createNode(244 /* ExportSpecifier */, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createExportSpecifier(name, propertyName) { + var node = createSynthesizedNode(245 /* ExportSpecifier */); + node.name = asName(name); + node.propertyName = asName(propertyName); return node; } ts.createExportSpecifier = createExportSpecifier; function updateExportSpecifier(node, name, propertyName) { - if (node.name !== name || node.propertyName !== propertyName) { - return updateNode(createExportSpecifier(name, propertyName, node), node); - } - return node; + return node.name !== name || node.propertyName !== propertyName + ? updateNode(createExportSpecifier(name, propertyName), node) + : node; } ts.updateExportSpecifier = updateExportSpecifier; + // Module references + function createExternalModuleReference(expression) { + var node = createSynthesizedNode(247 /* ExternalModuleReference */); + node.expression = expression; + return node; + } + ts.createExternalModuleReference = createExternalModuleReference; + function updateExternalModuleReference(node, expression) { + return node.expression !== expression + ? updateNode(createExternalModuleReference(expression), node) + : node; + } + ts.updateExternalModuleReference = updateExternalModuleReference; // JSX - function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(247 /* JsxElement */, location); + function createJsxElement(openingElement, children, closingElement) { + var node = createSynthesizedNode(248 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11906,97 +12161,108 @@ var ts; } ts.createJsxElement = createJsxElement; function updateJsxElement(node, openingElement, children, closingElement) { - if (node.openingElement !== openingElement || node.children !== children || node.closingElement !== closingElement) { - return updateNode(createJsxElement(openingElement, children, closingElement, node), node); - } - return node; + return node.openingElement !== openingElement + || node.children !== children + || node.closingElement !== closingElement + ? updateNode(createJsxElement(openingElement, children, closingElement), node) + : node; } ts.updateJsxElement = updateJsxElement; - function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(248 /* JsxSelfClosingElement */, location); + function createJsxSelfClosingElement(tagName, attributes) { + var node = createSynthesizedNode(249 /* JsxSelfClosingElement */); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxSelfClosingElement = createJsxSelfClosingElement; function updateJsxSelfClosingElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxSelfClosingElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxSelfClosingElement(tagName, attributes), node) + : node; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; - function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(249 /* JsxOpeningElement */, location); + function createJsxOpeningElement(tagName, attributes) { + var node = createSynthesizedNode(250 /* JsxOpeningElement */); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxOpeningElement = createJsxOpeningElement; function updateJsxOpeningElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxOpeningElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxOpeningElement(tagName, attributes), node) + : node; } ts.updateJsxOpeningElement = updateJsxOpeningElement; - function createJsxClosingElement(tagName, location) { - var node = createNode(250 /* JsxClosingElement */, location); + function createJsxClosingElement(tagName) { + var node = createSynthesizedNode(251 /* JsxClosingElement */); node.tagName = tagName; return node; } ts.createJsxClosingElement = createJsxClosingElement; function updateJsxClosingElement(node, tagName) { - if (node.tagName !== tagName) { - return updateNode(createJsxClosingElement(tagName, node), node); - } - return node; + return node.tagName !== tagName + ? updateNode(createJsxClosingElement(tagName), node) + : node; } ts.updateJsxClosingElement = updateJsxClosingElement; - function createJsxAttribute(name, initializer, location) { - var node = createNode(251 /* JsxAttribute */, location); + function createJsxAttributes(properties) { + var jsxAttributes = createSynthesizedNode(253 /* JsxAttributes */); + jsxAttributes.properties = createNodeArray(properties); + return jsxAttributes; + } + ts.createJsxAttributes = createJsxAttributes; + function updateJsxAttributes(jsxAttributes, properties) { + if (jsxAttributes.properties !== properties) { + return updateNode(createJsxAttributes(properties), jsxAttributes); + } + return jsxAttributes; + } + ts.updateJsxAttributes = updateJsxAttributes; + function createJsxAttribute(name, initializer) { + var node = createSynthesizedNode(252 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; } ts.createJsxAttribute = createJsxAttribute; function updateJsxAttribute(node, name, initializer) { - if (node.name !== name || node.initializer !== initializer) { - return updateNode(createJsxAttribute(name, initializer, node), node); - } - return node; + return node.name !== name + || node.initializer !== initializer + ? updateNode(createJsxAttribute(name, initializer), node) + : node; } ts.updateJsxAttribute = updateJsxAttribute; - function createJsxSpreadAttribute(expression, location) { - var node = createNode(252 /* JsxSpreadAttribute */, location); + function createJsxSpreadAttribute(expression) { + var node = createSynthesizedNode(254 /* JsxSpreadAttribute */); node.expression = expression; return node; } ts.createJsxSpreadAttribute = createJsxSpreadAttribute; function updateJsxSpreadAttribute(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxSpreadAttribute(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxSpreadAttribute(expression), node) + : node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, dotDotDotToken, location) { - var node = createNode(253 /* JsxExpression */, location); + function createJsxExpression(expression, dotDotDotToken) { + var node = createSynthesizedNode(255 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxExpression(expression, node.dotDotDotToken), node) + : node; } ts.updateJsxExpression = updateJsxExpression; // Clauses - function createHeritageClause(token, types, location) { - var node = createNode(256 /* HeritageClause */, location); + function createHeritageClause(token, types) { + var node = createSynthesizedNode(258 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -12004,40 +12270,40 @@ var ts; ts.createHeritageClause = createHeritageClause; function updateHeritageClause(node, types) { if (node.types !== types) { - return updateNode(createHeritageClause(node.token, types, node), node); + return updateNode(createHeritageClause(node.token, types), node); } return node; } ts.updateHeritageClause = updateHeritageClause; - function createCaseClause(expression, statements, location) { - var node = createNode(254 /* CaseClause */, location); - node.expression = parenthesizeExpressionForList(expression); + function createCaseClause(expression, statements) { + var node = createSynthesizedNode(256 /* CaseClause */); + node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; } ts.createCaseClause = createCaseClause; function updateCaseClause(node, expression, statements) { if (node.expression !== expression || node.statements !== statements) { - return updateNode(createCaseClause(expression, statements, node), node); + return updateNode(createCaseClause(expression, statements), node); } return node; } ts.updateCaseClause = updateCaseClause; - function createDefaultClause(statements, location) { - var node = createNode(255 /* DefaultClause */, location); + function createDefaultClause(statements) { + var node = createSynthesizedNode(257 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } ts.createDefaultClause = createDefaultClause; function updateDefaultClause(node, statements) { if (node.statements !== statements) { - return updateNode(createDefaultClause(statements, node), node); + return updateNode(createDefaultClause(statements), node); } return node; } ts.updateDefaultClause = updateDefaultClause; - function createCatchClause(variableDeclaration, block, location) { - var node = createNode(257 /* CatchClause */, location); + function createCatchClause(variableDeclaration, block) { + var node = createSynthesizedNode(259 /* CatchClause */); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -12045,58 +12311,74 @@ var ts; ts.createCatchClause = createCatchClause; function updateCatchClause(node, variableDeclaration, block) { if (node.variableDeclaration !== variableDeclaration || node.block !== block) { - return updateNode(createCatchClause(variableDeclaration, block, node), node); + return updateNode(createCatchClause(variableDeclaration, block), node); } return node; } ts.updateCatchClause = updateCatchClause; // Property assignments - function createPropertyAssignment(name, initializer, location) { - var node = createNode(258 /* PropertyAssignment */, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAssignment(name, initializer) { + var node = createSynthesizedNode(260 /* PropertyAssignment */); + node.name = asName(name); node.questionToken = undefined; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createPropertyAssignment = createPropertyAssignment; function updatePropertyAssignment(node, name, initializer) { if (node.name !== name || node.initializer !== initializer) { - return updateNode(createPropertyAssignment(name, initializer, node), node); + return updateNode(createPropertyAssignment(name, initializer), node); } return node; } ts.updatePropertyAssignment = updatePropertyAssignment; - function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(259 /* ShorthandPropertyAssignment */, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; + function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { + var node = createSynthesizedNode(261 /* ShorthandPropertyAssignment */); + node.name = asName(name); + node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; - function createSpreadAssignment(expression, location) { - var node = createNode(260 /* SpreadAssignment */, location); - node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; + function createSpreadAssignment(expression) { + var node = createSynthesizedNode(262 /* SpreadAssignment */); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; return node; } ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { - return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); + return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); } return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function updateSpreadAssignment(node, expression) { if (node.expression !== expression) { - return updateNode(createSpreadAssignment(expression, node), node); + return updateNode(createSpreadAssignment(expression), node); } return node; } ts.updateSpreadAssignment = updateSpreadAssignment; + // Enum + function createEnumMember(name, initializer) { + var node = createSynthesizedNode(263 /* EnumMember */); + node.name = asName(name); + node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); + return node; + } + ts.createEnumMember = createEnumMember; + function updateEnumMember(node, name, initializer) { + return node.name !== name + || node.initializer !== initializer + ? updateNode(createEnumMember(name, initializer), node) + : node; + } + ts.updateEnumMember = updateEnumMember; // Top-level nodes function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(262 /* SourceFile */, /*location*/ node, node.flags); + var updated = createSynthesizedNode(264 /* SourceFile */); + updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -12155,6 +12437,17 @@ var ts; return node; } ts.updateSourceFileNode = updateSourceFileNode; + /** + * Creates a shallow, memberwise clone of a node for mutation. + */ + function getMutableClone(node) { + var clone = getSynthesizedClone(node); + clone.pos = node.pos; + clone.end = node.end; + clone.parent = node.parent; + return clone; + } + ts.getMutableClone = getMutableClone; // Transformation nodes /** * Creates a synthetic statement to act as a placeholder for a not-emitted statement in @@ -12163,8 +12456,9 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createNode(294 /* NotEmittedStatement */, /*location*/ original); + var node = createSynthesizedNode(297 /* NotEmittedStatement */); node.original = original; + setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; @@ -12172,8 +12466,9 @@ var ts; * Creates a synthetic element to act as a placeholder for the end of an emitted declaration in * order to properly emit exports. */ + /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createNode(297 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(300 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12183,8 +12478,9 @@ var ts; * Creates a synthetic element to act as a placeholder for the beginning of a merged declaration in * order to properly emit exports. */ + /* @internal */ function createMergeDeclarationMarker(original) { - var node = createNode(296 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(299 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12198,31 +12494,45 @@ var ts; * @param original The original outer expression. * @param location The location for the expression. Defaults to the positions from "original" if provided. */ - function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(295 /* PartiallyEmittedExpression */, /*location*/ location || original); + function createPartiallyEmittedExpression(expression, original) { + var node = createSynthesizedNode(298 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; + setTextRange(node, original); return node; } ts.createPartiallyEmittedExpression = createPartiallyEmittedExpression; function updatePartiallyEmittedExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createPartiallyEmittedExpression(expression, node.original, node), node); + return updateNode(createPartiallyEmittedExpression(expression, node.original), node); } return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; + function createBundle(sourceFiles) { + var node = ts.createNode(265 /* Bundle */); + node.sourceFiles = sourceFiles; + return node; + } + ts.createBundle = createBundle; + function updateBundle(node, sourceFiles) { + if (node.sourceFiles !== sourceFiles) { + return createBundle(sourceFiles); + } + return node; + } + ts.updateBundle = updateBundle; // Compound nodes function createComma(left, right) { return createBinary(left, 25 /* CommaToken */, right); } ts.createComma = createComma; - function createLessThan(left, right, location) { - return createBinary(left, 26 /* LessThanToken */, right, location); + function createLessThan(left, right) { + return createBinary(left, 26 /* LessThanToken */, right); } ts.createLessThan = createLessThan; - function createAssignment(left, right, location) { - return createBinary(left, 57 /* EqualsToken */, right, location); + function createAssignment(left, right) { + return createBinary(left, 57 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { @@ -12241,8 +12551,8 @@ var ts; return createBinary(left, 37 /* MinusToken */, right); } ts.createSubtract = createSubtract; - function createPostfixIncrement(operand, location) { - return createPostfix(operand, 42 /* PlusPlusToken */, location); + function createPostfixIncrement(operand) { + return createPostfix(operand, 42 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { @@ -12261,61 +12571,346 @@ var ts; return createVoid(createLiteral(0)); } ts.createVoidZero = createVoidZero; + function createExportDefault(expression) { + return createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportEquals*/ false, expression); + } + ts.createExportDefault = createExportDefault; + function createExternalModuleExport(exportName) { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(exportName)])); + } + ts.createExternalModuleExport = createExternalModuleExport; + function asName(name) { + return typeof name === "string" ? createIdentifier(name) : name; + } + function asExpression(value) { + return typeof value === "string" || typeof value === "number" ? createLiteral(value) : value; + } + function asNodeArray(array) { + return array ? createNodeArray(array) : undefined; + } + function asToken(value) { + return typeof value === "number" ? createToken(value) : value; + } + /** + * Clears any EmitNode entries from parse-tree nodes. + * @param sourceFile A source file. + */ + function disposeEmitNodes(sourceFile) { + // During transformation we may need to annotate a parse tree node with transient + // transformation properties. As parse tree nodes live longer than transformation + // nodes, we need to make sure we reclaim any memory allocated for custom ranges + // from these nodes to ensure we do not hold onto entire subtrees just for position + // information. We also need to reset these nodes to a pre-transformation state + // for incremental parsing scenarios so that we do not impact later emit. + sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); + var emitNode = sourceFile && sourceFile.emitNode; + var annotatedNodes = emitNode && emitNode.annotatedNodes; + if (annotatedNodes) { + for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) { + var node = annotatedNodes_1[_i]; + node.emitNode = undefined; + } + } + } + ts.disposeEmitNodes = disposeEmitNodes; + /** + * Associates a node with the current transformation, initializing + * various transient transformation properties. + */ + /* @internal */ + function getOrCreateEmitNode(node) { + if (!node.emitNode) { + if (ts.isParseTreeNode(node)) { + // To avoid holding onto transformation artifacts, we keep track of any + // parse tree node we are annotating. This allows us to clean them up after + // all transformations have completed. + if (node.kind === 264 /* SourceFile */) { + return node.emitNode = { annotatedNodes: [node] }; + } + var sourceFile = ts.getSourceFileOfNode(node); + getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); + } + node.emitNode = {}; + } + return node.emitNode; + } + ts.getOrCreateEmitNode = getOrCreateEmitNode; + function setTextRange(range, location) { + if (location) { + range.pos = location.pos; + range.end = location.end; + } + return range; + } + ts.setTextRange = setTextRange; + /** + * Gets flags that control emit behavior of a node. + */ + function getEmitFlags(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.flags; + } + ts.getEmitFlags = getEmitFlags; + /** + * Sets flags that control emit behavior of a node. + */ + function setEmitFlags(node, emitFlags) { + getOrCreateEmitNode(node).flags = emitFlags; + return node; + } + ts.setEmitFlags = setEmitFlags; + /** + * Gets a custom text range to use when emitting source maps. + */ + function getSourceMapRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.sourceMapRange) || node; + } + ts.getSourceMapRange = getSourceMapRange; + /** + * Sets a custom text range to use when emitting source maps. + */ + function setSourceMapRange(node, range) { + getOrCreateEmitNode(node).sourceMapRange = range; + return node; + } + ts.setSourceMapRange = setSourceMapRange; + /** + * Gets the TextRange to use for source maps for a token of a node. + */ + function getTokenSourceMapRange(node, token) { + var emitNode = node.emitNode; + var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; + return tokenSourceMapRanges && tokenSourceMapRanges[token]; + } + ts.getTokenSourceMapRange = getTokenSourceMapRange; + /** + * Sets the TextRange to use for source maps for a token of a node. + */ + function setTokenSourceMapRange(node, token, range) { + var emitNode = getOrCreateEmitNode(node); + var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []); + tokenSourceMapRanges[token] = range; + return node; + } + ts.setTokenSourceMapRange = setTokenSourceMapRange; + /** + * Gets a custom text range to use when emitting comments. + */ + function getCommentRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.commentRange) || node; + } + ts.getCommentRange = getCommentRange; + /** + * Sets a custom text range to use when emitting comments. + */ + function setCommentRange(node, range) { + getOrCreateEmitNode(node).commentRange = range; + return node; + } + ts.setCommentRange = setCommentRange; + /** + * Gets the constant value to emit for an expression. + */ + function getConstantValue(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.constantValue; + } + ts.getConstantValue = getConstantValue; + /** + * Sets the constant value to emit for an expression. + */ + function setConstantValue(node, value) { + var emitNode = getOrCreateEmitNode(node); + emitNode.constantValue = value; + return node; + } + ts.setConstantValue = setConstantValue; + /** + * Adds an EmitHelper to a node. + */ + function addEmitHelper(node, helper) { + var emitNode = getOrCreateEmitNode(node); + emitNode.helpers = ts.append(emitNode.helpers, helper); + return node; + } + ts.addEmitHelper = addEmitHelper; + /** + * Add EmitHelpers to a node. + */ + function addEmitHelpers(node, helpers) { + if (ts.some(helpers)) { + var emitNode = getOrCreateEmitNode(node); + for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { + var helper = helpers_1[_i]; + if (!ts.contains(emitNode.helpers, helper)) { + emitNode.helpers = ts.append(emitNode.helpers, helper); + } + } + } + return node; + } + ts.addEmitHelpers = addEmitHelpers; + /** + * Removes an EmitHelper from a node. + */ + function removeEmitHelper(node, helper) { + var emitNode = node.emitNode; + if (emitNode) { + var helpers = emitNode.helpers; + if (helpers) { + return ts.orderedRemoveItem(helpers, helper); + } + } + return false; + } + ts.removeEmitHelper = removeEmitHelper; + /** + * Gets the EmitHelpers of a node. + */ + function getEmitHelpers(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.helpers; + } + ts.getEmitHelpers = getEmitHelpers; + /** + * Moves matching emit helpers from a source node to a target node. + */ + function moveEmitHelpers(source, target, predicate) { + var sourceEmitNode = source.emitNode; + var sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers; + if (!ts.some(sourceEmitHelpers)) + return; + var targetEmitNode = getOrCreateEmitNode(target); + var helpersRemoved = 0; + for (var i = 0; i < sourceEmitHelpers.length; i++) { + var helper = sourceEmitHelpers[i]; + if (predicate(helper)) { + helpersRemoved++; + if (!ts.contains(targetEmitNode.helpers, helper)) { + targetEmitNode.helpers = ts.append(targetEmitNode.helpers, helper); + } + } + else if (helpersRemoved > 0) { + sourceEmitHelpers[i - helpersRemoved] = helper; + } + } + if (helpersRemoved > 0) { + sourceEmitHelpers.length -= helpersRemoved; + } + } + ts.moveEmitHelpers = moveEmitHelpers; + /* @internal */ + function compareEmitHelpers(x, y) { + if (x === y) + return 0 /* EqualTo */; + if (x.priority === y.priority) + return 0 /* EqualTo */; + if (x.priority === undefined) + return 1 /* GreaterThan */; + if (y.priority === undefined) + return -1 /* LessThan */; + return ts.compareValues(x.priority, y.priority); + } + ts.compareEmitHelpers = compareEmitHelpers; + function setOriginalNode(node, original) { + node.original = original; + if (original) { + var emitNode = original.emitNode; + if (emitNode) + node.emitNode = mergeEmitNode(emitNode, node.emitNode); + } + return node; + } + ts.setOriginalNode = setOriginalNode; + function mergeEmitNode(sourceEmitNode, destEmitNode) { + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; + if (!destEmitNode) + destEmitNode = {}; + if (flags) + destEmitNode.flags = flags; + if (commentRange) + destEmitNode.commentRange = commentRange; + if (sourceMapRange) + destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + if (constantValue !== undefined) + destEmitNode.constantValue = constantValue; + if (helpers) + destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); + return destEmitNode; + } + function mergeTokenSourceMapRanges(sourceRanges, destRanges) { + if (!destRanges) + destRanges = []; + for (var key in sourceRanges) { + destRanges[key] = sourceRanges[key]; + } + return destRanges; + } +})(ts || (ts = {})); +/* @internal */ +(function (ts) { + // Compound nodes function createTypeCheck(value, tag) { return tag === "undefined" - ? createStrictEquality(value, createVoidZero()) - : createStrictEquality(createTypeOf(value), createLiteral(tag)); + ? ts.createStrictEquality(value, ts.createVoidZero()) + : ts.createStrictEquality(ts.createTypeOf(value), ts.createLiteral(tag)); } ts.createTypeCheck = createTypeCheck; function createMemberAccessForPropertyName(target, memberName, location) { if (ts.isComputedPropertyName(memberName)) { - return createElementAccess(target, memberName.expression, location); + return ts.setTextRange(ts.createElementAccess(target, memberName.expression), location); } else { - var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - (expression.emitNode || (expression.emitNode = {})).flags |= 64 /* NoNestedSourceMaps */; + var expression = ts.setTextRange(ts.isIdentifier(memberName) + ? ts.createPropertyAccess(target, memberName) + : ts.createElementAccess(target, memberName), memberName); + ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; return expression; } } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createFunctionCall(func, thisArg, argumentsList, location) { - return createCall(createPropertyAccess(func, "call"), + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), /*typeArguments*/ undefined, [ thisArg - ].concat(argumentsList), location); + ].concat(argumentsList)), location); } ts.createFunctionCall = createFunctionCall; function createFunctionApply(func, thisArg, argumentsExpression, location) { - return createCall(createPropertyAccess(func, "apply"), + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "apply"), /*typeArguments*/ undefined, [ thisArg, argumentsExpression - ], location); + ]), location); } ts.createFunctionApply = createFunctionApply; function createArraySlice(array, start) { var argumentsList = []; if (start !== undefined) { - argumentsList.push(typeof start === "number" ? createLiteral(start) : start); + argumentsList.push(typeof start === "number" ? ts.createLiteral(start) : start); } - return createCall(createPropertyAccess(array, "slice"), /*typeArguments*/ undefined, argumentsList); + return ts.createCall(ts.createPropertyAccess(array, "slice"), /*typeArguments*/ undefined, argumentsList); } ts.createArraySlice = createArraySlice; function createArrayConcat(array, values) { - return createCall(createPropertyAccess(array, "concat"), + return ts.createCall(ts.createPropertyAccess(array, "concat"), /*typeArguments*/ undefined, values); } ts.createArrayConcat = createArrayConcat; function createMathPow(left, right, location) { - return createCall(createPropertyAccess(createIdentifier("Math"), "pow"), - /*typeArguments*/ undefined, [left, right], location); + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Math"), "pow"), + /*typeArguments*/ undefined, [left, right]), location); } ts.createMathPow = createMathPow; function createReactNamespace(reactNamespace, parent) { // To ensure the emit resolver can properly resolve the namespace, we need to // treat this identifier as if it were a source tree node by clearing the `Synthesized` // flag and setting a parent node. - var react = createIdentifier(reactNamespace || "React"); + var react = ts.createIdentifier(reactNamespace || "React"); react.flags &= ~8 /* Synthesized */; // Set the parent that is in parse tree // this makes sure that parent chain is intact for checker to traverse complete scope tree @@ -12325,9 +12920,9 @@ var ts; function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { if (ts.isQualifiedName(jsxFactory)) { var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); - var right = createSynthesizedNode(70 /* Identifier */); + var right = ts.createIdentifier(jsxFactory.right.text); right.text = jsxFactory.right.text; - return createPropertyAccess(left, right); + return ts.createPropertyAccess(left, right); } else { return createReactNamespace(jsxFactory.text, parent); @@ -12336,7 +12931,7 @@ var ts; function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { return jsxFactoryEntity ? createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : - createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); + ts.createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); } function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { var argumentsList = [tagName]; @@ -12345,7 +12940,7 @@ var ts; } if (children && children.length > 0) { if (!props) { - argumentsList.push(createNull()); + argumentsList.push(ts.createNull()); } if (children.length > 1) { for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { @@ -12358,33 +12953,13 @@ var ts; argumentsList.push(children[0]); } } - return createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), - /*typeArguments*/ undefined, argumentsList, location); + return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), + /*typeArguments*/ undefined, argumentsList), location); } ts.createExpressionForJsxElement = createExpressionForJsxElement; - function createExportDefault(expression) { - return createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportEquals*/ false, expression); - } - ts.createExportDefault = createExportDefault; - function createExternalModuleExport(exportName) { - return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(exportName)])); - } - ts.createExternalModuleExport = createExternalModuleExport; - function createLetStatement(name, initializer, location) { - return createVariableStatement(/*modifiers*/ undefined, createLetDeclarationList([createVariableDeclaration(name, /*type*/ undefined, initializer)]), location); - } - ts.createLetStatement = createLetStatement; - function createLetDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 1 /* Let */); - } - ts.createLetDeclarationList = createLetDeclarationList; - function createConstDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 2 /* Const */); - } - ts.createConstDeclarationList = createConstDeclarationList; // Helpers function getHelperName(name) { - return setEmitFlags(createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); + return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } ts.getHelperName = getHelperName; // Utilities @@ -12392,7 +12967,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 220 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 221 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -12410,13 +12985,13 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -12427,22 +13002,23 @@ var ts; var thisArg; var target; if (ts.isSuperProperty(callee)) { - thisArg = createThis(); + thisArg = ts.createThis(); target = callee; } else if (callee.kind === 96 /* SuperKeyword */) { - thisArg = createThis(); - target = languageVersion < 2 /* ES2015 */ ? createIdentifier("_super", /*location*/ callee) : callee; + thisArg = ts.createThis(); + target = languageVersion < 2 /* ES2015 */ + ? ts.setTextRange(ts.createIdentifier("_super"), callee) + : callee; } else { switch (callee.kind) { - case 177 /* PropertyAccessExpression */: { + case 178 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` - thisArg = createTempVariable(recordTempVariable); - target = createPropertyAccess(createAssignment(thisArg, callee.expression, - /*location*/ callee.expression), callee.name, - /*location*/ callee); + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); + ts.setTextRange(target, callee); } else { thisArg = callee.expression; @@ -12450,13 +13026,12 @@ var ts; } break; } - case 178 /* ElementAccessExpression */: { + case 179 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` - thisArg = createTempVariable(recordTempVariable); - target = createElementAccess(createAssignment(thisArg, callee.expression, - /*location*/ callee.expression), callee.argumentExpression, - /*location*/ callee); + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); + ts.setTextRange(target, callee); } else { thisArg = callee.expression; @@ -12466,7 +13041,7 @@ var ts; } default: { // for `a()` target is `a` and thisArg is `void 0` - thisArg = createVoidZero(); + thisArg = ts.createVoidZero(); target = parenthesizeForAccess(expression); break; } @@ -12476,42 +13051,42 @@ var ts; } ts.createCallBinding = createCallBinding; function inlineExpressions(expressions) { - return ts.reduceLeft(expressions, createComma); + return ts.reduceLeft(expressions, ts.createComma); } ts.inlineExpressions = inlineExpressions; function createExpressionFromEntityName(node) { if (ts.isQualifiedName(node)) { var left = createExpressionFromEntityName(node.left); - var right = getMutableClone(node.right); - return createPropertyAccess(left, right, /*location*/ node); + var right = ts.getMutableClone(node.right); + return ts.setTextRange(ts.createPropertyAccess(left, right), node); } else { - return getMutableClone(node); + return ts.getMutableClone(node); } } ts.createExpressionFromEntityName = createExpressionFromEntityName; function createExpressionForPropertyName(memberName) { if (ts.isIdentifier(memberName)) { - return createLiteral(memberName, /*location*/ undefined); + return ts.createLiteral(memberName); } else if (ts.isComputedPropertyName(memberName)) { - return getMutableClone(memberName.expression); + return ts.getMutableClone(memberName.expression); } else { - return getMutableClone(memberName); + return ts.getMutableClone(memberName); } } ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -12521,57 +13096,55 @@ var ts; if (property === firstAccessor) { var properties_1 = []; if (getAccessor) { - var getterFunction = createFunctionExpression(getAccessor.modifiers, + var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, getAccessor.parameters, - /*type*/ undefined, getAccessor.body, - /*location*/ getAccessor); - setOriginalNode(getterFunction, getAccessor); - var getter = createPropertyAssignment("get", getterFunction); + /*type*/ undefined, getAccessor.body); + ts.setTextRange(getterFunction, getAccessor); + ts.setOriginalNode(getterFunction, getAccessor); + var getter = ts.createPropertyAssignment("get", getterFunction); properties_1.push(getter); } if (setAccessor) { - var setterFunction = createFunctionExpression(setAccessor.modifiers, + var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, setAccessor.parameters, - /*type*/ undefined, setAccessor.body, - /*location*/ setAccessor); - setOriginalNode(setterFunction, setAccessor); - var setter = createPropertyAssignment("set", setterFunction); + /*type*/ undefined, setAccessor.body); + ts.setTextRange(setterFunction, setAccessor); + ts.setOriginalNode(setterFunction, setAccessor); + var setter = ts.createPropertyAssignment("set", setterFunction); properties_1.push(setter); } - properties_1.push(createPropertyAssignment("enumerable", createLiteral(true))); - properties_1.push(createPropertyAssignment("configurable", createLiteral(true))); - var expression = createCall(createPropertyAccess(createIdentifier("Object"), "defineProperty"), + properties_1.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_1.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ receiver, createExpressionForPropertyName(property.name), - createObjectLiteral(properties_1, /*location*/ undefined, multiLine) - ], + ts.createObjectLiteral(properties_1, multiLine) + ]), /*location*/ firstAccessor); return ts.aggregateTransformFlags(expression); } return undefined; } function createExpressionForPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), property.initializer, - /*location*/ property), - /*original*/ property)); + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), property.initializer), property), property)); } function createExpressionForShorthandPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), getSynthesizedClone(property.name), + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), ts.getSynthesizedClone(property.name)), /*location*/ property), /*original*/ property)); } function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, /*name*/ undefined, /*typeParameters*/ undefined, method.parameters, - /*type*/ undefined, method.body, + /*type*/ undefined, method.body), /*location*/ method), - /*original*/ method), + /*original*/ method)), /*location*/ method), /*original*/ method)); } @@ -12593,7 +13166,7 @@ var ts; * Gets whether an identifier should only be referred to by its local name. */ function isLocalName(node) { - return (getEmitFlags(node) & 16384 /* LocalName */) !== 0; + return (ts.getEmitFlags(node) & 16384 /* LocalName */) !== 0; } ts.isLocalName = isLocalName; /** @@ -12615,7 +13188,7 @@ var ts; * name points to an exported symbol. */ function isExportName(node) { - return (getEmitFlags(node) & 8192 /* ExportName */) !== 0; + return (ts.getEmitFlags(node) & 8192 /* ExportName */) !== 0; } ts.isExportName = isExportName; /** @@ -12631,17 +13204,17 @@ var ts; ts.getDeclarationName = getDeclarationName; function getName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { - var name_8 = getMutableClone(node.name); - emitFlags |= getEmitFlags(node.name); + var name = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) emitFlags |= 48 /* NoSourceMap */; if (!allowComments) emitFlags |= 1536 /* NoComments */; if (emitFlags) - setEmitFlags(name_8, emitFlags); - return name_8; + ts.setEmitFlags(name, emitFlags); + return name; } - return getGeneratedNameForNode(node); + return ts.getGeneratedNameForNode(node); } /** * Gets the exported name of a declaration for use in expressions. @@ -12670,19 +13243,20 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { - var qualifiedName = createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : getSynthesizedClone(name), /*location*/ name); + var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name)); + ts.setTextRange(qualifiedName, name); var emitFlags; if (!allowSourceMaps) emitFlags |= 48 /* NoSourceMap */; if (!allowComments) emitFlags |= 1536 /* NoComments */; if (emitFlags) - setEmitFlags(qualifiedName, emitFlags); + ts.setEmitFlags(qualifiedName, emitFlags); return qualifiedName; } ts.getNamespaceMemberName = getNamespaceMemberName; function convertToFunctionBody(node, multiLine) { - return ts.isBlock(node) ? node : createBlock([createReturn(node, /*location*/ node)], /*location*/ node, multiLine); + return ts.isBlock(node) ? node : ts.setTextRange(ts.createBlock([ts.setTextRange(ts.createReturn(node), node)], multiLine), node); } ts.convertToFunctionBody = convertToFunctionBody; function isUseStrictPrologue(node) { @@ -12718,11 +13292,11 @@ var ts; statementOffset++; } if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); + target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))); } while (statementOffset < numStatements) { var statement = source[statementOffset]; - if (getEmitFlags(statement) & 524288 /* CustomPrologue */) { + if (ts.getEmitFlags(statement) & 524288 /* CustomPrologue */) { target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -12760,9 +13334,9 @@ var ts; } } if (!foundUseStrict) { - return createNodeArray([ - startOnNewLine(createStatement(createLiteral("use strict"))) - ].concat(statements), statements); + return ts.setTextRange(ts.createNodeArray([ + startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) + ].concat(statements)), statements); } return statements; } @@ -12779,11 +13353,11 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 183 /* ParenthesizedExpression */) { + if (skipped.kind === 184 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) - ? createParen(operand) + ? ts.createParen(operand) : operand; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; @@ -12813,8 +13387,8 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(192 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(192 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(193 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(193 /* BinaryExpression */, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -12823,7 +13397,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 195 /* YieldExpression */) { + && operand.kind === 196 /* YieldExpression */) { return false; } return true; @@ -12911,7 +13485,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 192 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { + if (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12926,11 +13500,11 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(193 /* ConditionalExpression */, 54 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(194 /* ConditionalExpression */, 54 /* QuestionToken */); var emittedCondition = skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { - return createParen(condition); + return ts.createParen(condition); } return condition; } @@ -12939,10 +13513,11 @@ var ts; // per ES grammar both 'whenTrue' and 'whenFalse' parts of conditional expression are assignment expressions // so in case when comma expression is introduced as a part of previous transformations // if should be wrapped in parens since comma operator has the lowest precedence - return e.kind === 192 /* BinaryExpression */ && e.operatorToken.kind === 25 /* CommaToken */ - ? createParen(e) + return e.kind === 193 /* BinaryExpression */ && e.operatorToken.kind === 25 /* CommaToken */ + ? ts.createParen(e) : e; } + ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression; /** * Wraps an expression in parentheses if it is needed in order to use the expression * as the expression of a NewExpression node. @@ -12952,12 +13527,12 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 179 /* CallExpression */: - return createParen(expression); - case 180 /* NewExpression */: + case 180 /* CallExpression */: + return ts.createParen(expression); + case 181 /* NewExpression */: return emittedExpression.arguments ? expression - : createParen(expression); + : ts.createParen(expression); } return parenthesizeForAccess(expression); } @@ -12979,23 +13554,23 @@ var ts; // var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 180 /* NewExpression */ || emittedExpression.arguments) + && (emittedExpression.kind !== 181 /* NewExpression */ || emittedExpression.arguments) && emittedExpression.kind !== 8 /* NumericLiteral */) { return expression; } - return createParen(expression, /*location*/ expression); + return ts.setTextRange(ts.createParen(expression), expression); } ts.parenthesizeForAccess = parenthesizeForAccess; function parenthesizePostfixOperand(operand) { return ts.isLeftHandSideExpression(operand) ? operand - : createParen(operand, /*location*/ operand); + : ts.setTextRange(ts.createParen(operand), operand); } ts.parenthesizePostfixOperand = parenthesizePostfixOperand; function parenthesizePrefixOperand(operand) { return ts.isUnaryExpression(operand) ? operand - : createParen(operand, /*location*/ operand); + : ts.setTextRange(ts.createParen(operand), operand); } ts.parenthesizePrefixOperand = parenthesizePrefixOperand; function parenthesizeListElements(elements) { @@ -13010,17 +13585,18 @@ var ts; } } if (result !== undefined) { - return createNodeArray(result, elements, elements.hasTrailingComma); + return ts.setTextRange(ts.createNodeArray(result, elements.hasTrailingComma), elements); } return elements; } + ts.parenthesizeListElements = parenthesizeListElements; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(192 /* BinaryExpression */, 25 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(193 /* BinaryExpression */, 25 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression - : createParen(expression, /*location*/ expression); + : ts.setTextRange(ts.createParen(expression), expression); } ts.parenthesizeExpressionForList = parenthesizeExpressionForList; function parenthesizeExpressionForExpressionStatement(expression) { @@ -13028,16 +13604,16 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 184 /* FunctionExpression */ || kind === 185 /* ArrowFunction */) { - var mutableCall = getMutableClone(emittedExpression); - mutableCall.expression = createParen(callee, /*location*/ callee); + if (kind === 185 /* FunctionExpression */ || kind === 186 /* ArrowFunction */) { + var mutableCall = ts.getMutableClone(emittedExpression); + mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); } } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 176 /* ObjectLiteralExpression */ || leftmostExpressionKind === 184 /* FunctionExpression */) { - return createParen(expression, /*location*/ expression); + if (leftmostExpressionKind === 177 /* ObjectLiteralExpression */ || leftmostExpressionKind === 185 /* FunctionExpression */) { + return ts.setTextRange(ts.createParen(expression), expression); } } return expression; @@ -13051,7 +13627,7 @@ var ts; */ function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { - var clone_1 = getMutableClone(originalOuterExpression); + var clone_1 = ts.getMutableClone(originalOuterExpression); clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); return clone_1; } @@ -13060,21 +13636,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: node = node.operand; continue; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: node = node.left; continue; - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: node = node.condition; continue; - case 179 /* CallExpression */: - case 178 /* ElementAccessExpression */: - case 177 /* PropertyAccessExpression */: + case 180 /* CallExpression */: + case 179 /* ElementAccessExpression */: + case 178 /* PropertyAccessExpression */: node = node.expression; continue; - case 295 /* PartiallyEmittedExpression */: + case 298 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -13083,8 +13659,8 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 176 /* ObjectLiteralExpression */) { - return createParen(body, /*location*/ body); + if (emittedBody.kind === 177 /* ObjectLiteralExpression */) { + return ts.setTextRange(ts.createParen(body), body); } return body; } @@ -13115,7 +13691,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 183 /* ParenthesizedExpression */) { + while (node.kind === 184 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -13129,7 +13705,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 295 /* PartiallyEmittedExpression */) { + while (node.kind === 298 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -13140,188 +13716,6 @@ var ts; return node; } ts.startOnNewLine = startOnNewLine; - function setOriginalNode(node, original) { - node.original = original; - if (original) { - var emitNode = original.emitNode; - if (emitNode) - node.emitNode = mergeEmitNode(emitNode, node.emitNode); - } - return node; - } - ts.setOriginalNode = setOriginalNode; - function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; - if (!destEmitNode) - destEmitNode = {}; - if (flags) - destEmitNode.flags = flags; - if (commentRange) - destEmitNode.commentRange = commentRange; - if (sourceMapRange) - destEmitNode.sourceMapRange = sourceMapRange; - if (tokenSourceMapRanges) - destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); - if (constantValue !== undefined) - destEmitNode.constantValue = constantValue; - if (helpers) - destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); - return destEmitNode; - } - function mergeTokenSourceMapRanges(sourceRanges, destRanges) { - if (!destRanges) - destRanges = ts.createMap(); - ts.copyProperties(sourceRanges, destRanges); - return destRanges; - } - /** - * Clears any EmitNode entries from parse-tree nodes. - * @param sourceFile A source file. - */ - function disposeEmitNodes(sourceFile) { - // During transformation we may need to annotate a parse tree node with transient - // transformation properties. As parse tree nodes live longer than transformation - // nodes, we need to make sure we reclaim any memory allocated for custom ranges - // from these nodes to ensure we do not hold onto entire subtrees just for position - // information. We also need to reset these nodes to a pre-transformation state - // for incremental parsing scenarios so that we do not impact later emit. - sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); - var emitNode = sourceFile && sourceFile.emitNode; - var annotatedNodes = emitNode && emitNode.annotatedNodes; - if (annotatedNodes) { - for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) { - var node = annotatedNodes_1[_i]; - node.emitNode = undefined; - } - } - } - ts.disposeEmitNodes = disposeEmitNodes; - /** - * Associates a node with the current transformation, initializing - * various transient transformation properties. - * - * @param node The node. - */ - function getOrCreateEmitNode(node) { - if (!node.emitNode) { - if (ts.isParseTreeNode(node)) { - // To avoid holding onto transformation artifacts, we keep track of any - // parse tree node we are annotating. This allows us to clean them up after - // all transformations have completed. - if (node.kind === 262 /* SourceFile */) { - return node.emitNode = { annotatedNodes: [node] }; - } - var sourceFile = ts.getSourceFileOfNode(node); - getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); - } - node.emitNode = {}; - } - return node.emitNode; - } - ts.getOrCreateEmitNode = getOrCreateEmitNode; - /** - * Gets flags that control emit behavior of a node. - * - * @param node The node. - */ - function getEmitFlags(node) { - var emitNode = node.emitNode; - return emitNode && emitNode.flags; - } - ts.getEmitFlags = getEmitFlags; - /** - * Sets flags that control emit behavior of a node. - * - * @param node The node. - * @param emitFlags The NodeEmitFlags for the node. - */ - function setEmitFlags(node, emitFlags) { - getOrCreateEmitNode(node).flags = emitFlags; - return node; - } - ts.setEmitFlags = setEmitFlags; - /** - * Gets a custom text range to use when emitting source maps. - * - * @param node The node. - */ - function getSourceMapRange(node) { - var emitNode = node.emitNode; - return (emitNode && emitNode.sourceMapRange) || node; - } - ts.getSourceMapRange = getSourceMapRange; - /** - * Sets a custom text range to use when emitting source maps. - * - * @param node The node. - * @param range The text range. - */ - function setSourceMapRange(node, range) { - getOrCreateEmitNode(node).sourceMapRange = range; - return node; - } - ts.setSourceMapRange = setSourceMapRange; - /** - * Gets the TextRange to use for source maps for a token of a node. - * - * @param node The node. - * @param token The token. - */ - function getTokenSourceMapRange(node, token) { - var emitNode = node.emitNode; - var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; - return tokenSourceMapRanges && tokenSourceMapRanges[token]; - } - ts.getTokenSourceMapRange = getTokenSourceMapRange; - /** - * Sets the TextRange to use for source maps for a token of a node. - * - * @param node The node. - * @param token The token. - * @param range The text range. - */ - function setTokenSourceMapRange(node, token, range) { - var emitNode = getOrCreateEmitNode(node); - var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); - tokenSourceMapRanges[token] = range; - return node; - } - ts.setTokenSourceMapRange = setTokenSourceMapRange; - /** - * Gets a custom text range to use when emitting comments. - * - * @param node The node. - */ - function getCommentRange(node) { - var emitNode = node.emitNode; - return (emitNode && emitNode.commentRange) || node; - } - ts.getCommentRange = getCommentRange; - /** - * Sets a custom text range to use when emitting comments. - */ - function setCommentRange(node, range) { - getOrCreateEmitNode(node).commentRange = range; - return node; - } - ts.setCommentRange = setCommentRange; - /** - * Gets the constant value to emit for an expression. - */ - function getConstantValue(node) { - var emitNode = node.emitNode; - return emitNode && emitNode.constantValue; - } - ts.getConstantValue = getConstantValue; - /** - * Sets the constant value to emit for an expression. - */ - function setConstantValue(node, value) { - var emitNode = getOrCreateEmitNode(node); - emitNode.constantValue = value; - return node; - } - ts.setConstantValue = setConstantValue; function getExternalHelpersModuleName(node) { var parseNode = ts.getOriginalNode(node, ts.isSourceFile); var emitNode = parseNode && parseNode.emitNode; @@ -13334,143 +13728,34 @@ var ts; if (externalHelpersModuleName) { return externalHelpersModuleName; } - var helpers = getEmitHelpers(node); + var helpers = ts.getEmitHelpers(node); if (helpers) { - for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { - var helper = helpers_1[_i]; + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; if (!helper.scoped) { var parseNode = ts.getOriginalNode(node, ts.isSourceFile); - var emitNode = getOrCreateEmitNode(parseNode); - return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = createUniqueName(ts.externalHelpersModuleNameText)); + var emitNode = ts.getOrCreateEmitNode(parseNode); + return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = ts.createUniqueName(ts.externalHelpersModuleNameText)); } } } } } ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; - /** - * Adds an EmitHelper to a node. - */ - function addEmitHelper(node, helper) { - var emitNode = getOrCreateEmitNode(node); - emitNode.helpers = ts.append(emitNode.helpers, helper); - return node; - } - ts.addEmitHelper = addEmitHelper; - /** - * Adds an EmitHelper to a node. - */ - function addEmitHelpers(node, helpers) { - if (ts.some(helpers)) { - var emitNode = getOrCreateEmitNode(node); - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; - if (!ts.contains(emitNode.helpers, helper)) { - emitNode.helpers = ts.append(emitNode.helpers, helper); - } - } - } - return node; - } - ts.addEmitHelpers = addEmitHelpers; - /** - * Removes an EmitHelper from a node. - */ - function removeEmitHelper(node, helper) { - var emitNode = node.emitNode; - if (emitNode) { - var helpers = emitNode.helpers; - if (helpers) { - return ts.orderedRemoveItem(helpers, helper); - } - } - return false; - } - ts.removeEmitHelper = removeEmitHelper; - /** - * Gets the EmitHelpers of a node. - */ - function getEmitHelpers(node) { - var emitNode = node.emitNode; - return emitNode && emitNode.helpers; - } - ts.getEmitHelpers = getEmitHelpers; - /** - * Moves matching emit helpers from a source node to a target node. - */ - function moveEmitHelpers(source, target, predicate) { - var sourceEmitNode = source.emitNode; - var sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers; - if (!ts.some(sourceEmitHelpers)) - return; - var targetEmitNode = getOrCreateEmitNode(target); - var helpersRemoved = 0; - for (var i = 0; i < sourceEmitHelpers.length; i++) { - var helper = sourceEmitHelpers[i]; - if (predicate(helper)) { - helpersRemoved++; - if (!ts.contains(targetEmitNode.helpers, helper)) { - targetEmitNode.helpers = ts.append(targetEmitNode.helpers, helper); - } - } - else if (helpersRemoved > 0) { - sourceEmitHelpers[i - helpersRemoved] = helper; - } - } - if (helpersRemoved > 0) { - sourceEmitHelpers.length -= helpersRemoved; - } - } - ts.moveEmitHelpers = moveEmitHelpers; - function compareEmitHelpers(x, y) { - if (x === y) - return 0 /* EqualTo */; - if (x.priority === y.priority) - return 0 /* EqualTo */; - if (x.priority === undefined) - return 1 /* GreaterThan */; - if (y.priority === undefined) - return -1 /* LessThan */; - return ts.compareValues(x.priority, y.priority); - } - ts.compareEmitHelpers = compareEmitHelpers; - function setTextRange(node, location) { - if (location) { - node.pos = location.pos; - node.end = location.end; - } - return node; - } - ts.setTextRange = setTextRange; - function setNodeFlags(node, flags) { - node.flags = flags; - return node; - } - ts.setNodeFlags = setNodeFlags; - function setMultiLine(node, multiLine) { - node.multiLine = multiLine; - return node; - } - ts.setMultiLine = setMultiLine; - function setHasTrailingComma(nodes, hasTrailingComma) { - nodes.hasTrailingComma = hasTrailingComma; - return nodes; - } - ts.setHasTrailingComma = setHasTrailingComma; /** * Get the name of that target module from an import or export declaration */ function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_9 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 236 /* ImportDeclaration */ && node.importClause) { - return getGeneratedNameForNode(node); + if (node.kind === 237 /* ImportDeclaration */ && node.importClause) { + return ts.getGeneratedNameForNode(node); } - if (node.kind === 242 /* ExportDeclaration */ && node.moduleSpecifier) { - return getGeneratedNameForNode(node); + if (node.kind === 243 /* ExportDeclaration */ && node.moduleSpecifier) { + return ts.getGeneratedNameForNode(node); } return undefined; } @@ -13488,7 +13773,7 @@ var ts; if (moduleName.kind === 9 /* StringLiteral */) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) - || getSynthesizedClone(moduleName); + || ts.getSynthesizedClone(moduleName); } return undefined; } @@ -13498,10 +13783,8 @@ var ts; * Here we check if alternative name was provided for a given moduleName and return it if possible. */ function tryRenameExternalModule(moduleName, sourceFile) { - if (sourceFile.renamedDependencies && ts.hasProperty(sourceFile.renamedDependencies, moduleName.text)) { - return createLiteral(sourceFile.renamedDependencies[moduleName.text]); - } - return undefined; + var rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text); + return rename && ts.createLiteral(rename); } /** * Get the name of a module as should be written in the emitted output. @@ -13515,10 +13798,10 @@ var ts; return undefined; } if (file.moduleName) { - return createLiteral(file.moduleName); + return ts.createLiteral(file.moduleName); } if (!ts.isDeclarationFile(file) && (options.out || options.outFile)) { - return createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); + return ts.createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); } return undefined; } @@ -13589,7 +13872,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -13601,11 +13884,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 260 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -13637,12 +13920,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 144 /* Parameter */: - case 174 /* BindingElement */: + case 145 /* Parameter */: + case 175 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 196 /* SpreadElement */: - case 260 /* SpreadAssignment */: + case 197 /* SpreadElement */: + case 262 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -13654,7 +13937,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 174 /* BindingElement */: + case 175 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -13666,7 +13949,7 @@ var ts; : propertyName; } break; - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -13678,7 +13961,7 @@ var ts; : propertyName; } break; - case 260 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -13696,13 +13979,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: - case 175 /* ArrayLiteralExpression */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: + case 176 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -13712,10 +13995,12 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpread(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpread(element.name), element), element); } var expression = convertToAssignmentElementTarget(element.name); - return element.initializer ? setOriginalNode(createAssignment(expression, element.initializer, element), element) : expression; + return element.initializer + ? ts.setOriginalNode(ts.setTextRange(ts.createAssignment(expression, element.initializer), element), element) + : expression; } ts.Debug.assertNode(element, ts.isExpression); return element; @@ -13725,14 +14010,14 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpreadAssignment(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpreadAssignment(element.name), element), element); } if (element.propertyName) { var expression = convertToAssignmentElementTarget(element.name); - return setOriginalNode(createPropertyAssignment(element.propertyName, element.initializer ? createAssignment(expression, element.initializer) : expression, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createPropertyAssignment(element.propertyName, element.initializer ? ts.createAssignment(expression, element.initializer) : expression), element), element); } ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createShorthandPropertyAssignment(element.name, element.initializer, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createShorthandPropertyAssignment(element.name, element.initializer), element), element); } ts.Debug.assertNode(element, ts.isObjectLiteralElementLike); return element; @@ -13740,18 +14025,18 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 173 /* ArrayBindingPattern */: - case 175 /* ArrayLiteralExpression */: + case 174 /* ArrayBindingPattern */: + case 176 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 172 /* ObjectBindingPattern */: - case 176 /* ObjectLiteralExpression */: + case 173 /* ObjectBindingPattern */: + case 177 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } ts.convertToAssignmentPattern = convertToAssignmentPattern; function convertToObjectAssignmentPattern(node) { if (ts.isObjectBindingPattern(node)) { - return setOriginalNode(createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isObjectLiteralExpression); return node; @@ -13759,7 +14044,7 @@ var ts; ts.convertToObjectAssignmentPattern = convertToObjectAssignmentPattern; function convertToArrayAssignmentPattern(node) { if (ts.isArrayBindingPattern(node)) { - return setOriginalNode(createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isArrayLiteralExpression); return node; @@ -13775,37 +14060,37 @@ var ts; ts.convertToAssignmentElementTarget = convertToAssignmentElementTarget; function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) { var externalImports = []; - var exportSpecifiers = ts.createMap(); - var exportedBindings = ts.createMap(); + var exportSpecifiers = ts.createMultiMap(); + var exportedBindings = []; var uniqueExports = ts.createMap(); var exportedNames; var hasExportDefault = false; var exportEquals = undefined; var hasExportStarsToExportValues = false; var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions); - var externalHelpersImportDeclaration = externalHelpersModuleName && createImportDeclaration( + var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, createImportClause(/*name*/ undefined, createNamespaceImport(externalHelpersModuleName)), createLiteral(ts.externalHelpersModuleNameText)); + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); if (externalHelpersImportDeclaration) { externalImports.push(externalHelpersImportDeclaration); } for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); break; - case 235 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 246 /* ExternalModuleReference */) { + case 236 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 247 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -13821,27 +14106,27 @@ var ts; // export { x, y } for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - if (!uniqueExports[specifier.name.text]) { - var name_10 = specifier.propertyName || specifier.name; - ts.multiMapAdd(exportSpecifiers, name_10.text, specifier); - var decl = resolver.getReferencedImportDeclaration(name_10) - || resolver.getReferencedValueDeclaration(name_10); + if (!uniqueExports.get(specifier.name.text)) { + var name = specifier.propertyName || specifier.name; + exportSpecifiers.add(name.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); if (decl) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); } - uniqueExports[specifier.name.text] = true; + uniqueExports.set(specifier.name.text, true); exportedNames = ts.append(exportedNames, specifier.name); } } } break; - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13849,42 +14134,42 @@ var ts; } } break; - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { // export function x() { } - var name_11 = node.name; - if (!uniqueExports[name_11.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_11); - uniqueExports[name_11.text] = true; - exportedNames = ts.append(exportedNames, name_11); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } break; - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { // export class x { } - var name_12 = node.name; - if (!uniqueExports[name_12.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_12); - uniqueExports[name_12.text] = true; - exportedNames = ts.append(exportedNames, name_12); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } @@ -13904,13 +14189,24 @@ var ts; } } else if (!ts.isGeneratedIdentifier(decl.name)) { - if (!uniqueExports[decl.name.text]) { - uniqueExports[decl.name.text] = true; + if (!uniqueExports.get(decl.name.text)) { + uniqueExports.set(decl.name.text, true); exportedNames = ts.append(exportedNames, decl.name); } } return exportedNames; } + /** Use a sparse array as a multi-map. */ + function multiMapSparseArrayAdd(map, key, value) { + var values = map[key]; + if (values) { + values.push(value); + } + else { + map[key] = values = [value]; + } + return values; + } })(ts || (ts = {})); /// /// @@ -13922,13 +14218,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 262 /* SourceFile */) { + if (kind === 264 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 141 /* FirstNode */) { + else if (kind < 142 /* FirstNode */) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -13971,28 +14267,29 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || + visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 260 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 144 /* Parameter */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 258 /* PropertyAssignment */: - case 224 /* VariableDeclaration */: - case 174 /* BindingElement */: + case 145 /* Parameter */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 260 /* PropertyAssignment */: + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -14001,24 +14298,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 226 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -14029,323 +14326,325 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 161 /* TypeLiteral */: + case 162 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 162 /* ArrayType */: + case 163 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 163 /* TupleType */: + case 164 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 164 /* UnionType */: - case 165 /* IntersectionType */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 166 /* ParenthesizedType */: - case 168 /* TypeOperator */: + case 167 /* ParenthesizedType */: + case 169 /* TypeOperator */: return visitNode(cbNode, node.type); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 170 /* MappedType */: + case 171 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 171 /* LiteralType */: + case 172 /* LiteralType */: return visitNode(cbNode, node.literal); - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 179 /* CallExpression */: - case 180 /* NewExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 182 /* TypeAssertionExpression */: + case 183 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 187 /* TypeOfExpression */: + case 188 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 200 /* AsExpression */: + case 201 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 201 /* NonNullExpression */: + case 202 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 202 /* MetaProperty */: + case 203 /* MetaProperty */: return visitNode(cbNode, node.name); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 205 /* Block */: - case 232 /* ModuleBlock */: + case 206 /* Block */: + case 233 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 262 /* SourceFile */: + case 264 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 225 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 209 /* IfStatement */: + case 210 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 210 /* DoStatement */: + case 211 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 215 /* ContinueStatement */: - case 216 /* BreakStatement */: + case 216 /* ContinueStatement */: + case 217 /* BreakStatement */: return visitNode(cbNode, node.label); - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 218 /* WithStatement */: + case 219 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 233 /* CaseBlock */: + case 234 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 254 /* CaseClause */: + case 256 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 255 /* DefaultClause */: + case 257 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 221 /* ThrowStatement */: + case 222 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 222 /* TryStatement */: + case 223 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 145 /* Decorator */: + case 146 /* Decorator */: return visitNode(cbNode, node.expression); - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* 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 228 /* InterfaceDeclaration */: + case 229 /* 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 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 261 /* EnumMember */: + case 263 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 237 /* ImportClause */: + case 238 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 234 /* NamespaceExportDeclaration */: + case 235 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 238 /* NamespaceImport */: + case 239 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 239 /* NamedImports */: - case 243 /* NamedExports */: + case 240 /* NamedImports */: + case 244 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 240 /* ImportSpecifier */: - case 244 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: + case 245 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 203 /* TemplateSpan */: + case 204 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 256 /* HeritageClause */: + case 258 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 246 /* ExternalModuleReference */: + case 247 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 245 /* MissingDeclaration */: + case 246 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 247 /* JsxElement */: + case 248 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 248 /* JsxSelfClosingElement */: - case 249 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + case 250 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || - visitNodes(cbNodes, node.attributes); - case 251 /* JsxAttribute */: + visitNode(cbNode, node.attributes); + case 253 /* JsxAttributes */: + return visitNodes(cbNodes, node.properties); + case 252 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 252 /* JsxSpreadAttribute */: + case 254 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 253 /* JsxExpression */: + case 255 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 250 /* JsxClosingElement */: + case 251 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 263 /* JSDocTypeExpression */: + case 266 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 267 /* JSDocUnionType */: + case 270 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 268 /* JSDocTupleType */: + case 271 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 266 /* JSDocArrayType */: + case 269 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 270 /* JSDocNonNullableType */: + case 273 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 269 /* JSDocNullableType */: + case 272 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 271 /* JSDocRecordType */: + case 274 /* JSDocRecordType */: return visitNode(cbNode, node.literal); - case 273 /* JSDocTypeReference */: + case 276 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 274 /* JSDocOptionalType */: + case 277 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 275 /* JSDocFunctionType */: + case 278 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 276 /* JSDocVariadicType */: + case 279 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 277 /* JSDocConstructorType */: + case 280 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 278 /* JSDocThisType */: + case 281 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 272 /* JSDocRecordMember */: + case 275 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 279 /* JSDocComment */: + case 282 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 282 /* JSDocParameterTag */: + case 285 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 283 /* JSDocReturnTag */: + case 286 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 284 /* JSDocTypeTag */: + case 287 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 281 /* JSDocAugmentsTag */: + case 284 /* JSDocAugmentsTag */: return visitNode(cbNode, node.typeExpression); - case 285 /* JSDocTemplateTag */: + case 288 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); - case 286 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 288 /* JSDocTypeLiteral */: + case 291 /* JSDocTypeLiteral */: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 287 /* JSDocPropertyTag */: + case 290 /* JSDocPropertyTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 295 /* PartiallyEmittedExpression */: + case 298 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); - case 289 /* JSDocLiteralType */: + case 292 /* JSDocLiteralType */: return visitNode(cbNode, node.literal); } } @@ -14617,7 +14916,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(262 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(264 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -14901,7 +15200,7 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 141 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : + return kind >= 142 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : kind === 70 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } @@ -14941,7 +15240,11 @@ var ts; } function internIdentifier(text) { text = ts.escapeIdentifier(text); - return identifiers[text] || (identifiers[text] = text); + var identifier = identifiers.get(text); + if (identifier === undefined) { + identifiers.set(text, identifier = text); + } + return identifier; } // An identifier that starts with two underscores has an extra underscore character prepended to it to avoid issues // with magic property names like '__proto__'. The 'identifiers' object is used to share a single string instance for @@ -14993,7 +15296,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(142 /* ComputedPropertyName */); + var node = createNode(143 /* ComputedPropertyName */); parseExpected(20 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -15400,14 +15703,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 150 /* Constructor */: - case 155 /* IndexSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 147 /* PropertyDeclaration */: - case 204 /* SemicolonClassElement */: + case 151 /* Constructor */: + case 156 /* IndexSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 148 /* PropertyDeclaration */: + case 205 /* SemicolonClassElement */: return true; - case 149 /* MethodDeclaration */: + case 150 /* 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. @@ -15422,8 +15725,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 254 /* CaseClause */: - case 255 /* DefaultClause */: + case 256 /* CaseClause */: + case 257 /* DefaultClause */: return true; } } @@ -15432,58 +15735,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 226 /* FunctionDeclaration */: - case 206 /* VariableStatement */: - case 205 /* Block */: - case 209 /* IfStatement */: - case 208 /* ExpressionStatement */: - case 221 /* ThrowStatement */: - case 217 /* ReturnStatement */: - case 219 /* SwitchStatement */: - case 216 /* BreakStatement */: - case 215 /* ContinueStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 212 /* ForStatement */: - case 211 /* WhileStatement */: - case 218 /* WithStatement */: - case 207 /* EmptyStatement */: - case 222 /* TryStatement */: - case 220 /* LabeledStatement */: - case 210 /* DoStatement */: - case 223 /* DebuggerStatement */: - case 236 /* ImportDeclaration */: - case 235 /* ImportEqualsDeclaration */: - case 242 /* ExportDeclaration */: - case 241 /* ExportAssignment */: - case 231 /* ModuleDeclaration */: - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 230 /* EnumDeclaration */: - case 229 /* TypeAliasDeclaration */: + case 227 /* FunctionDeclaration */: + case 207 /* VariableStatement */: + case 206 /* Block */: + case 210 /* IfStatement */: + case 209 /* ExpressionStatement */: + case 222 /* ThrowStatement */: + case 218 /* ReturnStatement */: + case 220 /* SwitchStatement */: + case 217 /* BreakStatement */: + case 216 /* ContinueStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 213 /* ForStatement */: + case 212 /* WhileStatement */: + case 219 /* WithStatement */: + case 208 /* EmptyStatement */: + case 223 /* TryStatement */: + case 221 /* LabeledStatement */: + case 211 /* DoStatement */: + case 224 /* DebuggerStatement */: + case 237 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 243 /* ExportDeclaration */: + case 242 /* ExportAssignment */: + case 232 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 230 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 261 /* EnumMember */; + return node.kind === 263 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 154 /* ConstructSignature */: - case 148 /* MethodSignature */: - case 155 /* IndexSignature */: - case 146 /* PropertySignature */: - case 153 /* CallSignature */: + case 155 /* ConstructSignature */: + case 149 /* MethodSignature */: + case 156 /* IndexSignature */: + case 147 /* PropertySignature */: + case 154 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 224 /* VariableDeclaration */) { + if (node.kind !== 225 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -15504,7 +15807,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 144 /* Parameter */) { + if (node.kind !== 145 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -15617,7 +15920,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(22 /* DotToken */)) { - var node = createNode(141 /* QualifiedName */, entity.pos); // !!! + var node = createNode(142 /* QualifiedName */, entity.pos); // !!! node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -15656,7 +15959,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(194 /* TemplateExpression */); + var template = createNode(195 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -15668,7 +15971,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(203 /* TemplateSpan */); + var span = createNode(204 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17 /* CloseBraceToken */) { @@ -15723,7 +16026,7 @@ var ts; // TYPES function parseTypeReference() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - var node = createNode(157 /* TypeReference */, typeName.pos); + var node = createNode(158 /* TypeReference */, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token() === 26 /* LessThanToken */) { node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); @@ -15732,24 +16035,24 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(156 /* TypePredicate */, lhs.pos); + var node = createNode(157 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(167 /* ThisType */); + var node = createNode(168 /* ThisType */); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(160 /* TypeQuery */); + var node = createNode(161 /* TypeQuery */); parseExpected(102 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(143 /* TypeParameter */); + var node = createNode(144 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(84 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -15770,6 +16073,9 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } + if (parseOptional(57 /* EqualsToken */)) { + node.default = parseType(); + } return finishNode(node); } function parseTypeParameters() { @@ -15787,7 +16093,7 @@ var ts; return token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 /* AtToken */ || token() === 98 /* ThisKeyword */; } function parseParameter() { - var node = createNode(144 /* Parameter */); + var node = createNode(145 /* Parameter */); if (token() === 98 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true, undefined); node.type = parseParameterType(); @@ -15886,7 +16192,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 154 /* ConstructSignature */) { + if (kind === 155 /* ConstructSignature */) { parseExpected(93 /* NewKeyword */); } fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -15950,7 +16256,7 @@ var ts; return token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || token() === 21 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(155 /* IndexSignature */, fullStart); + var node = createNode(156 /* IndexSignature */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); @@ -15962,7 +16268,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(54 /* QuestionToken */); if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { - var method = createNode(148 /* MethodSignature */, fullStart); + var method = createNode(149 /* MethodSignature */, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; @@ -15973,7 +16279,7 @@ var ts; return addJSDocComment(finishNode(method)); } else { - var property = createNode(146 /* PropertySignature */, fullStart); + var property = createNode(147 /* PropertySignature */, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; @@ -16022,10 +16328,10 @@ var ts; } function parseTypeMember() { if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { - return parseSignatureMember(153 /* CallSignature */); + return parseSignatureMember(154 /* CallSignature */); } if (token() === 93 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(154 /* ConstructSignature */); + return parseSignatureMember(155 /* ConstructSignature */); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -16039,7 +16345,7 @@ var ts; return token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(161 /* TypeLiteral */); + var node = createNode(162 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -16062,14 +16368,14 @@ var ts; return token() === 20 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 91 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(143 /* TypeParameter */); + var node = createNode(144 /* TypeParameter */); node.name = parseIdentifier(); parseExpected(91 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(170 /* MappedType */); + var node = createNode(171 /* MappedType */); parseExpected(16 /* OpenBraceToken */); node.readonlyToken = parseOptionalToken(130 /* ReadonlyKeyword */); parseExpected(20 /* OpenBracketToken */); @@ -16082,12 +16388,12 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(163 /* TupleType */); + var node = createNode(164 /* TupleType */); node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(166 /* ParenthesizedType */); + var node = createNode(167 /* ParenthesizedType */); parseExpected(18 /* OpenParenToken */); node.type = parseType(); parseExpected(19 /* CloseParenToken */); @@ -16095,7 +16401,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 159 /* ConstructorType */) { + if (kind === 160 /* ConstructorType */) { parseExpected(93 /* NewKeyword */); } fillSignature(35 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -16106,7 +16412,7 @@ var ts; return token() === 22 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(171 /* LiteralType */); + var node = createNode(172 /* LiteralType */); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -16117,12 +16423,13 @@ var ts; function parseNonArrayType() { switch (token()) { case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: - case 137 /* UndefinedKeyword */: + case 136 /* SymbolKeyword */: + case 138 /* UndefinedKeyword */: case 129 /* NeverKeyword */: + case 133 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); @@ -16160,12 +16467,12 @@ var ts; function isStartOfType() { switch (token()) { case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 94 /* NullKeyword */: case 98 /* ThisKeyword */: case 102 /* TypeOfKeyword */: @@ -16180,6 +16487,7 @@ var ts; case 8 /* NumericLiteral */: case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: + case 133 /* ObjectKeyword */: return true; case 37 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral); @@ -16199,14 +16507,14 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(20 /* OpenBracketToken */)) { if (isStartOfType()) { - var node = createNode(169 /* IndexedAccessType */, type.pos); + var node = createNode(170 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(21 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(162 /* ArrayType */, type.pos); + var node = createNode(163 /* ArrayType */, type.pos); node.elementType = type; parseExpected(21 /* CloseBracketToken */); type = finishNode(node); @@ -16215,7 +16523,7 @@ var ts; return type; } function parseTypeOperator(operator) { - var node = createNode(168 /* TypeOperator */); + var node = createNode(169 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); @@ -16244,10 +16552,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(165 /* IntersectionType */, parseTypeOperatorOrHigher, 47 /* AmpersandToken */); + return parseUnionOrIntersectionType(166 /* IntersectionType */, parseTypeOperatorOrHigher, 47 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(164 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); + return parseUnionOrIntersectionType(165 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); } function isStartOfFunctionType() { if (token() === 26 /* LessThanToken */) { @@ -16304,7 +16612,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(156 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(157 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -16327,10 +16635,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(158 /* FunctionType */); + return parseFunctionOrConstructorType(159 /* FunctionType */); } if (token() === 93 /* NewKeyword */) { - return parseFunctionOrConstructorType(159 /* ConstructorType */); + return parseFunctionOrConstructorType(160 /* ConstructorType */); } return parseUnionTypeOrHigher(); } @@ -16531,7 +16839,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(195 /* YieldExpression */); + var node = createNode(196 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -16553,13 +16861,13 @@ var ts; ts.Debug.assert(token() === 35 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(185 /* ArrowFunction */, asyncModifier.pos); + node = createNode(186 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(185 /* ArrowFunction */, identifier.pos); + node = createNode(186 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(144 /* Parameter */, identifier.pos); + var parameter = createNode(145 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); @@ -16741,7 +17049,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(185 /* ArrowFunction */); + var node = createNode(186 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); // Arrow functions are never generators. @@ -16807,7 +17115,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(193 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(194 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -16820,7 +17128,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 /* InKeyword */ || t === 140 /* OfKeyword */; + return t === 91 /* InKeyword */ || t === 141 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -16928,39 +17236,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(192 /* BinaryExpression */, left.pos); + var node = createNode(193 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(200 /* AsExpression */, left.pos); + var node = createNode(201 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(190 /* PrefixUnaryExpression */); + var node = createNode(191 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(186 /* DeleteExpression */); + var node = createNode(187 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(187 /* TypeOfExpression */); + var node = createNode(188 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(188 /* VoidExpression */); + var node = createNode(189 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -16976,7 +17284,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(189 /* AwaitExpression */); + var node = createNode(190 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -17019,7 +17327,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39 /* AsteriskAsteriskToken */) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 182 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 183 /* TypeAssertionExpression */) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -17115,7 +17423,7 @@ var ts; */ function parseIncrementExpression() { if (token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) { - var node = createNode(190 /* PrefixUnaryExpression */); + var node = createNode(191 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -17128,7 +17436,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(191 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(192 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -17232,7 +17540,7 @@ 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(177 /* PropertyAccessExpression */, expression.pos); + var node = createNode(178 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(22 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -17257,8 +17565,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 249 /* JsxOpeningElement */) { - var node = createNode(247 /* JsxElement */, opening.pos); + if (opening.kind === 250 /* JsxOpeningElement */) { + var node = createNode(248 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -17268,7 +17576,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 248 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 249 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -17283,7 +17591,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(192 /* BinaryExpression */, result.pos); + var badNode = createNode(193 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -17332,17 +17640,22 @@ var ts; parsingContext = saveParsingContext; return result; } + function parseJsxAttributes() { + var jsxAttributes = createNode(253 /* JsxAttributes */); + jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); + return finishNode(jsxAttributes); + } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); parseExpected(26 /* LessThanToken */); var tagName = parseJsxElementName(); - var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); + var attributes = parseJsxAttributes(); var node; if (token() === 28 /* GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(249 /* JsxOpeningElement */, fullStart); + node = createNode(250 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -17354,7 +17667,7 @@ var ts; parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(248 /* JsxSelfClosingElement */, fullStart); + node = createNode(249 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -17370,7 +17683,7 @@ var ts; var expression = token() === 98 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22 /* DotToken */)) { - var propertyAccess = createNode(177 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(178 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -17378,7 +17691,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(253 /* JsxExpression */); + var node = createNode(255 /* JsxExpression */); parseExpected(16 /* OpenBraceToken */); if (token() !== 17 /* CloseBraceToken */) { node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); @@ -17398,7 +17711,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(251 /* JsxAttribute */); + var node = createNode(252 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 57 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -17413,7 +17726,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(252 /* JsxSpreadAttribute */); + var node = createNode(254 /* JsxSpreadAttribute */); parseExpected(16 /* OpenBraceToken */); parseExpected(23 /* DotDotDotToken */); node.expression = parseExpression(); @@ -17421,7 +17734,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(250 /* JsxClosingElement */); + var node = createNode(251 /* JsxClosingElement */); parseExpected(27 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -17434,7 +17747,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(182 /* TypeAssertionExpression */); + var node = createNode(183 /* TypeAssertionExpression */); parseExpected(26 /* LessThanToken */); node.type = parseType(); parseExpected(28 /* GreaterThanToken */); @@ -17445,7 +17758,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(177 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(178 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -17453,14 +17766,14 @@ var ts; } if (token() === 50 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(201 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(202 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(20 /* OpenBracketToken */)) { - var indexedAccess = createNode(178 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(179 /* 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. @@ -17476,7 +17789,7 @@ var ts; continue; } if (token() === 12 /* NoSubstitutionTemplateLiteral */ || token() === 13 /* TemplateHead */) { - var tagExpression = createNode(181 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(182 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -17499,7 +17812,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(179 /* CallExpression */, expression.pos); + var callExpr = createNode(180 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -17507,7 +17820,7 @@ var ts; continue; } else if (token() === 18 /* OpenParenToken */) { - var callExpr = createNode(179 /* CallExpression */, expression.pos); + var callExpr = createNode(180 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -17617,28 +17930,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(183 /* ParenthesizedExpression */); + var node = createNode(184 /* ParenthesizedExpression */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(196 /* SpreadElement */); + var node = createNode(197 /* SpreadElement */); parseExpected(23 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 25 /* CommaToken */ ? createNode(198 /* OmittedExpression */) : + token() === 25 /* CommaToken */ ? createNode(199 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(175 /* ArrayLiteralExpression */); + var node = createNode(176 /* ArrayLiteralExpression */); parseExpected(20 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17649,10 +17962,10 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(124 /* GetKeyword */)) { - return parseAccessorDeclaration(151 /* GetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(152 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(133 /* SetKeyword */)) { - return parseAccessorDeclaration(152 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(134 /* SetKeyword */)) { + return parseAccessorDeclaration(153 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -17660,7 +17973,7 @@ var ts; var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); if (dotDotDotToken) { - var spreadElement = createNode(260 /* SpreadAssignment */, fullStart); + var spreadElement = createNode(262 /* SpreadAssignment */, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -17685,7 +17998,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 /* CommaToken */ || token() === 17 /* CloseBraceToken */ || token() === 57 /* EqualsToken */); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(259 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(261 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57 /* EqualsToken */); @@ -17696,7 +18009,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(258 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(260 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -17706,7 +18019,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(176 /* ObjectLiteralExpression */); + var node = createNode(177 /* ObjectLiteralExpression */); parseExpected(16 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17725,7 +18038,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(184 /* FunctionExpression */); + var node = createNode(185 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(88 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); @@ -17750,12 +18063,12 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(93 /* NewKeyword */); if (parseOptional(22 /* DotToken */)) { - var node_1 = createNode(202 /* MetaProperty */, fullStart); + var node_1 = createNode(203 /* MetaProperty */, fullStart); node_1.keywordToken = 93 /* NewKeyword */; node_1.name = parseIdentifierName(); return finishNode(node_1); } - var node = createNode(180 /* NewExpression */, fullStart); + var node = createNode(181 /* NewExpression */, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18 /* OpenParenToken */) { @@ -17765,7 +18078,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(205 /* Block */); + var node = createNode(206 /* Block */); if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17798,12 +18111,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(207 /* EmptyStatement */); + var node = createNode(208 /* EmptyStatement */); parseExpected(24 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(209 /* IfStatement */); + var node = createNode(210 /* IfStatement */); parseExpected(89 /* IfKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17813,7 +18126,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(210 /* DoStatement */); + var node = createNode(211 /* DoStatement */); parseExpected(80 /* DoKeyword */); node.statement = parseStatement(); parseExpected(105 /* WhileKeyword */); @@ -17828,7 +18141,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(211 /* WhileStatement */); + var node = createNode(212 /* WhileStatement */); parseExpected(105 /* WhileKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17851,21 +18164,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91 /* InKeyword */)) { - var forInStatement = createNode(213 /* ForInStatement */, pos); + var forInStatement = createNode(214 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(140 /* OfKeyword */)) { - var forOfStatement = createNode(214 /* ForOfStatement */, pos); + else if (parseOptional(141 /* OfKeyword */)) { + var forOfStatement = createNode(215 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(212 /* ForStatement */, pos); + var forStatement = createNode(213 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(24 /* SemicolonToken */); if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { @@ -17883,7 +18196,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 216 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); + parseExpected(kind === 217 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -17891,7 +18204,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(217 /* ReturnStatement */); + var node = createNode(218 /* ReturnStatement */); parseExpected(95 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -17900,7 +18213,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(218 /* WithStatement */); + var node = createNode(219 /* WithStatement */); parseExpected(106 /* WithKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17909,7 +18222,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(254 /* CaseClause */); + var node = createNode(256 /* CaseClause */); parseExpected(72 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(55 /* ColonToken */); @@ -17917,7 +18230,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(255 /* DefaultClause */); + var node = createNode(257 /* DefaultClause */); parseExpected(78 /* DefaultKeyword */); parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -17927,12 +18240,12 @@ var ts; return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(219 /* SwitchStatement */); + var node = createNode(220 /* SwitchStatement */); parseExpected(97 /* SwitchKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); - var caseBlock = createNode(233 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(234 /* CaseBlock */, scanner.getStartPos()); parseExpected(16 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(17 /* CloseBraceToken */); @@ -17947,7 +18260,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(221 /* ThrowStatement */); + var node = createNode(222 /* ThrowStatement */); parseExpected(99 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -17955,7 +18268,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(222 /* TryStatement */); + var node = createNode(223 /* TryStatement */); parseExpected(101 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 73 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -17968,7 +18281,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(257 /* CatchClause */); + var result = createNode(259 /* CatchClause */); parseExpected(73 /* CatchKeyword */); if (parseExpected(18 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -17978,7 +18291,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(223 /* DebuggerStatement */); + var node = createNode(224 /* DebuggerStatement */); parseExpected(77 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -17990,13 +18303,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 /* Identifier */ && parseOptional(55 /* ColonToken */)) { - var labeledStatement = createNode(220 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(221 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(208 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(209 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -18046,7 +18359,7 @@ var ts; // // could be legal, it would add complexity for very little gain. case 108 /* InterfaceKeyword */: - case 136 /* TypeKeyword */: + case 137 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); case 127 /* ModuleKeyword */: case 128 /* NamespaceKeyword */: @@ -18064,7 +18377,7 @@ var ts; return false; } continue; - case 139 /* GlobalKeyword */: + case 140 /* GlobalKeyword */: nextToken(); return token() === 16 /* OpenBraceToken */ || token() === 70 /* Identifier */ || token() === 83 /* ExportKeyword */; case 90 /* ImportKeyword */: @@ -18126,8 +18439,8 @@ var ts; case 108 /* InterfaceKeyword */: case 127 /* ModuleKeyword */: case 128 /* NamespaceKeyword */: - case 136 /* TypeKeyword */: - case 139 /* GlobalKeyword */: + case 137 /* TypeKeyword */: + case 140 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; case 113 /* PublicKeyword */: @@ -18177,9 +18490,9 @@ var ts; case 87 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 76 /* ContinueKeyword */: - return parseBreakOrContinueStatement(215 /* ContinueStatement */); + return parseBreakOrContinueStatement(216 /* ContinueStatement */); case 71 /* BreakKeyword */: - return parseBreakOrContinueStatement(216 /* BreakStatement */); + return parseBreakOrContinueStatement(217 /* BreakStatement */); case 95 /* ReturnKeyword */: return parseReturnStatement(); case 106 /* WithKeyword */: @@ -18199,7 +18512,7 @@ var ts; return parseDeclaration(); case 119 /* AsyncKeyword */: case 108 /* InterfaceKeyword */: - case 136 /* TypeKeyword */: + case 137 /* TypeKeyword */: case 127 /* ModuleKeyword */: case 128 /* NamespaceKeyword */: case 123 /* DeclareKeyword */: @@ -18213,7 +18526,7 @@ var ts; case 116 /* AbstractKeyword */: case 114 /* StaticKeyword */: case 130 /* ReadonlyKeyword */: - case 139 /* GlobalKeyword */: + case 140 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -18236,11 +18549,11 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 108 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 136 /* TypeKeyword */: + case 137 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 82 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 139 /* GlobalKeyword */: + case 140 /* GlobalKeyword */: case 127 /* ModuleKeyword */: case 128 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -18261,7 +18574,7 @@ var ts; 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(245 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(246 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -18283,16 +18596,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 25 /* CommaToken */) { - return createNode(198 /* OmittedExpression */); + return createNode(199 /* OmittedExpression */); } - var node = createNode(174 /* BindingElement */); + var node = createNode(175 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(174 /* BindingElement */); + var node = createNode(175 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -18308,14 +18621,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(172 /* ObjectBindingPattern */); + var node = createNode(173 /* ObjectBindingPattern */); parseExpected(16 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(173 /* ArrayBindingPattern */); + var node = createNode(174 /* ArrayBindingPattern */); parseExpected(20 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(21 /* CloseBracketToken */); @@ -18334,7 +18647,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(224 /* VariableDeclaration */); + var node = createNode(225 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -18343,7 +18656,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(225 /* VariableDeclarationList */); + var node = createNode(226 /* VariableDeclarationList */); switch (token()) { case 103 /* VarKeyword */: break; @@ -18366,7 +18679,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() === 140 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 141 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -18381,7 +18694,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(206 /* VariableStatement */, fullStart); + var node = createNode(207 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -18389,7 +18702,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226 /* FunctionDeclaration */, fullStart); + var node = createNode(227 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88 /* FunctionKeyword */); @@ -18402,7 +18715,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(150 /* Constructor */, pos); + var node = createNode(151 /* Constructor */, pos); node.decorators = decorators; node.modifiers = modifiers; parseExpected(122 /* ConstructorKeyword */); @@ -18411,7 +18724,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(149 /* MethodDeclaration */, fullStart); + var method = createNode(150 /* MethodDeclaration */, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -18424,7 +18737,7 @@ var ts; return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(147 /* PropertyDeclaration */, fullStart); + var property = createNode(148 /* PropertyDeclaration */, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -18517,7 +18830,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 === 133 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 134 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -18547,7 +18860,7 @@ var ts; if (!parseOptional(56 /* AtToken */)) { break; } - var decorator = createNode(145 /* Decorator */, decoratorStart); + var decorator = createNode(146 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -18613,7 +18926,7 @@ var ts; } function parseClassElement() { if (token() === 24 /* SemicolonToken */) { - var result = createNode(204 /* SemicolonClassElement */); + var result = createNode(205 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -18641,8 +18954,8 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_13 = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_13, /*questionToken*/ undefined); + var name = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. ts.Debug.fail("Should not have attempted to parse class member declaration."); @@ -18651,10 +18964,10 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 197 /* ClassExpression */); + /*modifiers*/ undefined, 198 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 227 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 228 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -18698,7 +19011,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */) { - var node = createNode(256 /* HeritageClause */); + var node = createNode(258 /* HeritageClause */); node.token = token(); nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -18707,7 +19020,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(199 /* ExpressionWithTypeArguments */); + var node = createNode(200 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26 /* LessThanToken */) { node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); @@ -18721,7 +19034,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228 /* InterfaceDeclaration */, fullStart); + var node = createNode(229 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108 /* InterfaceKeyword */); @@ -18732,10 +19045,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229 /* TypeAliasDeclaration */, fullStart); + var node = createNode(230 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(136 /* TypeKeyword */); + parseExpected(137 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57 /* EqualsToken */); @@ -18748,13 +19061,13 @@ 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(261 /* EnumMember */, scanner.getStartPos()); + var node = createNode(263 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230 /* EnumDeclaration */, fullStart); + var node = createNode(231 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82 /* EnumKeyword */); @@ -18769,7 +19082,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(232 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(233 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(16 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(17 /* CloseBraceToken */); @@ -18780,7 +19093,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(231 /* ModuleDeclaration */, fullStart); + var node = createNode(232 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -18794,10 +19107,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(231 /* ModuleDeclaration */, fullStart); + var node = createNode(232 /* ModuleDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 139 /* GlobalKeyword */) { + if (token() === 140 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -18815,7 +19128,7 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 139 /* GlobalKeyword */) { + if (token() === 140 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -18841,7 +19154,7 @@ var ts; return nextToken() === 40 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(234 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(235 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117 /* AsKeyword */); @@ -18856,11 +19169,11 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 /* CommaToken */ && token() !== 138 /* FromKeyword */) { + if (token() !== 25 /* CommaToken */ && token() !== 139 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(235 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(236 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -18871,7 +19184,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(236 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(237 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: @@ -18881,7 +19194,7 @@ var ts; token() === 38 /* AsteriskToken */ || token() === 16 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(138 /* FromKeyword */); + parseExpected(139 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -18894,7 +19207,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(237 /* ImportClause */, fullStart); + var importClause = createNode(238 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -18904,7 +19217,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(25 /* CommaToken */)) { - importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(239 /* NamedImports */); + importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(240 /* NamedImports */); } return finishNode(importClause); } @@ -18914,7 +19227,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(246 /* ExternalModuleReference */); + var node = createNode(247 /* ExternalModuleReference */); parseExpected(131 /* RequireKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -18937,7 +19250,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(238 /* NamespaceImport */); + var namespaceImport = createNode(239 /* NamespaceImport */); parseExpected(38 /* AsteriskToken */); parseExpected(117 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -18952,14 +19265,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 239 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 240 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(244 /* ExportSpecifier */); + return parseImportOrExportSpecifier(245 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(240 /* ImportSpecifier */); + return parseImportOrExportSpecifier(241 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -18984,27 +19297,27 @@ var ts; else { node.name = identifierName; } - if (kind === 240 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 241 /* 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(242 /* ExportDeclaration */, fullStart); + var node = createNode(243 /* ExportDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38 /* AsteriskToken */)) { - parseExpected(138 /* FromKeyword */); + parseExpected(139 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(243 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(244 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 138 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(138 /* FromKeyword */); + if (token() === 139 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(139 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -19012,7 +19325,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(241 /* ExportAssignment */, fullStart); + var node = createNode(242 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57 /* EqualsToken */)) { @@ -19094,10 +19407,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 246 /* ExternalModuleReference */ - || node.kind === 236 /* ImportDeclaration */ - || node.kind === 241 /* ExportAssignment */ - || node.kind === 242 /* ExportDeclaration */ + || node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 247 /* ExternalModuleReference */ + || node.kind === 237 /* ImportDeclaration */ + || node.kind === 242 /* ExportAssignment */ + || node.kind === 243 /* ExportDeclaration */ ? node : undefined; }); @@ -19172,7 +19485,7 @@ var ts; // Parses out a JSDoc type expression. /* @internal */ function parseJSDocTypeExpression() { - var result = createNode(263 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(266 /* JSDocTypeExpression */, scanner.getTokenPos()); parseExpected(16 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(17 /* CloseBraceToken */); @@ -19183,12 +19496,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48 /* BarToken */) { - var unionType = createNode(267 /* JSDocUnionType */, type.pos); + var unionType = createNode(270 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57 /* EqualsToken */) { - var optionalType = createNode(274 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(277 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -19199,20 +19512,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20 /* OpenBracketToken */) { - var arrayType = createNode(266 /* JSDocArrayType */, type.pos); + var arrayType = createNode(269 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token() === 54 /* QuestionToken */) { - var nullableType = createNode(269 /* JSDocNullableType */, type.pos); + var nullableType = createNode(272 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50 /* ExclamationToken */) { - var nonNullableType = createNode(270 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(273 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -19246,14 +19559,15 @@ var ts; case 98 /* ThisKeyword */: return parseJSDocThisType(); case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: case 94 /* NullKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 129 /* NeverKeyword */: + case 133 /* ObjectKeyword */: return parseTokenNode(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: @@ -19264,27 +19578,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(278 /* JSDocThisType */); + var result = createNode(281 /* JSDocThisType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(277 /* JSDocConstructorType */); + var result = createNode(280 /* JSDocConstructorType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(276 /* JSDocVariadicType */); + var result = createNode(279 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(275 /* JSDocFunctionType */); + var result = createNode(278 /* JSDocFunctionType */); nextToken(); parseExpected(18 /* OpenParenToken */); result.parameters = parseDelimitedList(23 /* JSDocFunctionParameters */, parseJSDocParameter); @@ -19297,7 +19611,7 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(144 /* Parameter */); + var parameter = createNode(145 /* Parameter */); parameter.type = parseJSDocType(); if (parseOptional(57 /* EqualsToken */)) { // TODO(rbuckton): Can this be changed to SyntaxKind.QuestionToken? @@ -19306,7 +19620,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(273 /* JSDocTypeReference */); + var result = createNode(276 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); @@ -19341,24 +19655,24 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(141 /* QualifiedName */, left.pos); + var result = createNode(142 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(271 /* JSDocRecordType */); + var result = createNode(274 /* JSDocRecordType */); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(270 /* JSDocNonNullableType */); + var result = createNode(273 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(268 /* JSDocTupleType */); + var result = createNode(271 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(26 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); @@ -19372,7 +19686,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(267 /* JSDocUnionType */); + var result = createNode(270 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19 /* CloseParenToken */); @@ -19388,12 +19702,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(264 /* JSDocAllType */); + var result = createNode(267 /* JSDocAllType */); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(289 /* JSDocLiteralType */); + var result = createNode(292 /* JSDocLiteralType */); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -19416,11 +19730,11 @@ var ts; token() === 28 /* GreaterThanToken */ || token() === 57 /* EqualsToken */ || token() === 48 /* BarToken */) { - var result = createNode(265 /* JSDocUnknownType */, pos); + var result = createNode(268 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(269 /* JSDocNullableType */, pos); + var result = createNode(272 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -19585,7 +19899,7 @@ var ts; content.charCodeAt(start + 3) !== 42 /* asterisk */; } function createJSDocComment() { - var result = createNode(279 /* JSDocComment */, start); + var result = createNode(282 /* JSDocComment */, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -19701,7 +20015,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(280 /* JSDocTag */, atToken.pos); + var result = createNode(283 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -19758,7 +20072,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(282 /* JSDocParameterTag */, atToken.pos); + var result = createNode(285 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -19769,20 +20083,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 286 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283 /* JSDocReturnTag */, atToken.pos); + var result = createNode(286 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 287 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(284 /* JSDocTypeTag */, atToken.pos); + var result = createNode(287 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -19797,7 +20111,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(287 /* JSDocPropertyTag */, atToken.pos); + var result = createNode(290 /* JSDocPropertyTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -19806,7 +20120,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(281 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(284 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -19815,25 +20129,30 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(286 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(289 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0); if (typedefTag.fullName) { var rightNode = typedefTag.fullName; - while (rightNode.kind !== 70 /* Identifier */) { + while (true) { + if (rightNode.kind === 70 /* Identifier */ || !rightNode.body) { + // if node is identifier - use it as name + // otherwise use name of the rightmost part that we were able to parse + typedefTag.name = rightNode.kind === 70 /* Identifier */ ? rightNode : rightNode.name; + break; + } rightNode = rightNode.body; } - typedefTag.name = rightNode; } typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 273 /* JSDocTypeReference */) { + if (typeExpression.type.kind === 276 /* JSDocTypeReference */) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70 /* Identifier */) { - var name_14 = jsDocTypeReference.name; - if (name_14.text === "Object") { + var name = jsDocTypeReference.name; + if (name.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -19847,7 +20166,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(288 /* JSDocTypeLiteral */, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(291 /* JSDocTypeLiteral */, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -19888,7 +20207,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22 /* DotToken */)) { - var jsDocNamespaceNode = createNode(231 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(232 /* ModuleDeclaration */, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */); @@ -19934,20 +20253,20 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 285 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 288 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } // Type parameter list looks like '@template T,U,V' var typeParameters = createNodeArray(); while (true) { - var name_15 = parseJSDocIdentifierName(); + var name = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_15) { + if (!name) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(143 /* TypeParameter */, name_15.pos); - typeParameter.name = name_15; + var typeParameter = createNode(144 /* TypeParameter */, name.pos); + typeParameter.name = name; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25 /* CommaToken */) { @@ -19958,7 +20277,7 @@ var ts; break; } } - var result = createNode(285 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(288 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -20478,16 +20797,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 228 /* InterfaceDeclaration */ || node.kind === 229 /* TypeAliasDeclaration */) { + if (node.kind === 229 /* InterfaceDeclaration */ || node.kind === 230 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 236 /* ImportDeclaration */ || node.kind === 235 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { + else if ((node.kind === 237 /* ImportDeclaration */ || node.kind === 236 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 232 /* ModuleBlock */) { + else if (node.kind === 233 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -20506,7 +20825,7 @@ var ts; }); return state_1; } - else if (node.kind === 231 /* ModuleDeclaration */) { + else if (node.kind === 232 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } @@ -20647,7 +20966,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 231 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 232 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -20660,7 +20979,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression)) { @@ -20672,21 +20991,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 150 /* Constructor */: + case 151 /* Constructor */: return "__constructor"; - case 158 /* FunctionType */: - case 153 /* CallSignature */: + case 159 /* FunctionType */: + case 154 /* CallSignature */: return "__call"; - case 159 /* ConstructorType */: - case 154 /* ConstructSignature */: + case 160 /* ConstructorType */: + case 155 /* ConstructSignature */: return "__new"; - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: return "__index"; - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return "__export"; - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... @@ -20701,22 +21020,22 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 226 /* FunctionDeclaration */: - case 227 /* ClassDeclaration */: + case 227 /* FunctionDeclaration */: + case 228 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; - case 275 /* JSDocFunctionType */: + case 278 /* JSDocFunctionType */: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 144 /* Parameter */: + case 145 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 275 /* JSDocFunctionType */); + ts.Debug.assert(node.parent.kind === 278 /* JSDocFunctionType */); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 286 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 206 /* VariableStatement */) { + if (parentNode && parentNode.kind === 207 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -20771,15 +21090,18 @@ var ts; // Otherwise, we'll be merging into a compatible existing symbol (for example when // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. - symbol = symbolTable[name] || (symbolTable[name] = createSymbol(0 /* None */, name)); + symbol = symbolTable.get(name); + if (!symbol) { + symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + } if (name && (includes & 788448 /* Classifiable */)) { - classifiableNames[name] = name; + classifiableNames.set(name, name); } if (symbol.flags & excludes) { if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbol = symbolTable[name] = createSymbol(0 /* None */, name); + symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); } else { if (node.name) { @@ -20803,7 +21125,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 241 /* ExportAssignment */ && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 242 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -20823,7 +21145,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 244 /* ExportSpecifier */ || (node.kind === 235 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 245 /* ExportSpecifier */ || (node.kind === 236 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -20846,7 +21168,7 @@ var ts; // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation // and this case is specially handled. Module augmentations should only be merged with original module definition // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. - var isJSDocTypedefInJSDocNamespace = node.kind === 286 /* JSDocTypedefTag */ && + var isJSDocTypedefInJSDocNamespace = node.kind === 289 /* JSDocTypedefTag */ && node.name && node.name.kind === 70 /* Identifier */ && node.name.isInJSDocNamespace; @@ -20933,7 +21255,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 262 /* SourceFile */) { + if (node.kind === 264 /* SourceFile */) { node.flags |= emitFlags; } if (isIIFE) { @@ -21012,64 +21334,64 @@ var ts; return; } switch (node.kind) { - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: bindWhileStatement(node); break; - case 210 /* DoStatement */: + case 211 /* DoStatement */: bindDoStatement(node); break; - case 212 /* ForStatement */: + case 213 /* ForStatement */: bindForStatement(node); break; - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 209 /* IfStatement */: + case 210 /* IfStatement */: bindIfStatement(node); break; - case 217 /* ReturnStatement */: - case 221 /* ThrowStatement */: + case 218 /* ReturnStatement */: + case 222 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 216 /* BreakStatement */: - case 215 /* ContinueStatement */: + case 217 /* BreakStatement */: + case 216 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 222 /* TryStatement */: + case 223 /* TryStatement */: bindTryStatement(node); break; - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: bindSwitchStatement(node); break; - case 233 /* CaseBlock */: + case 234 /* CaseBlock */: bindCaseBlock(node); break; - case 254 /* CaseClause */: + case 256 /* CaseClause */: bindCaseClause(node); break; - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: bindLabeledStatement(node); break; - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 179 /* CallExpression */: + case 180 /* CallExpression */: bindCallExpressionFlow(node); break; default: @@ -21081,15 +21403,15 @@ var ts; switch (expr.kind) { case 70 /* Identifier */: case 98 /* ThisKeyword */: - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return hasNarrowableArgument(expr); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return expr.operator === 50 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -21097,7 +21419,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 /* Identifier */ || expr.kind === 98 /* ThisKeyword */ || - expr.kind === 177 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 178 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -21108,14 +21430,14 @@ var ts; } } } - if (expr.expression.kind === 177 /* PropertyAccessExpression */ && + if (expr.expression.kind === 178 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 187 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; + return expr1.kind === 188 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -21136,9 +21458,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 57 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -21233,33 +21555,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 209 /* IfStatement */: - case 211 /* WhileStatement */: - case 210 /* DoStatement */: + case 210 /* IfStatement */: + case 212 /* WhileStatement */: + case 211 /* DoStatement */: return parent.expression === node; - case 212 /* ForStatement */: - case 193 /* ConditionalExpression */: + case 213 /* ForStatement */: + case 194 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 183 /* ParenthesizedExpression */) { + if (node.kind === 184 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 190 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { + else if (node.kind === 191 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 192 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || + return node.kind === 193 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 53 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 183 /* ParenthesizedExpression */ || - node.parent.kind === 190 /* PrefixUnaryExpression */ && + while (node.parent.kind === 184 /* ParenthesizedExpression */ || + node.parent.kind === 191 /* PrefixUnaryExpression */ && node.parent.operator === 50 /* ExclamationToken */) { node = node.parent; } @@ -21301,7 +21623,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 220 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 221 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -21338,7 +21660,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 225 /* VariableDeclarationList */) { + if (node.initializer.kind !== 226 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -21360,7 +21682,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 217 /* ReturnStatement */) { + if (node.kind === 218 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -21380,7 +21702,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 216 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 217 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -21416,7 +21738,32 @@ var ts; if (node.finallyBlock) { // in finally flow is combined from pre-try/flow from try/flow from catch // pre-flow is necessary to make sure that finally is reachable even if finally flows in both try and finally blocks are unreachable - addAntecedent(preFinallyLabel, preTryFlow); + // also for finally blocks we inject two extra edges into the flow graph. + // first -> edge that connects pre-try flow with the label at the beginning of the finally block, it has lock associated with it + // second -> edge that represents post-finally flow. + // these edges are used in following scenario: + // let a; (1) + // try { a = someOperation(); (2)} + // finally { (3) console.log(a) } (4) + // (5) a + // flow graph for this case looks roughly like this (arrows show ): + // (1-pre-try-flow) <--.. <-- (2-post-try-flow) + // ^ ^ + // |*****(3-pre-finally-label) -----| + // ^ + // |-- ... <-- (4-post-finally-label) <--- (5) + // In case when we walk the flow starting from inside the finally block we want to take edge '*****' into account + // since it ensures that finally is always reachable. However when we start outside the finally block and go through label (5) + // then edge '*****' should be discarded because label 4 is only reachable if post-finally label-4 is reachable + // Simply speaking code inside finally block is treated as reachable as pre-try-flow + // since we conservatively assume that any line in try block can throw or return in which case we'll enter finally. + // However code after finally is reachable only if control flow was not abrupted in try/catch or finally blocks - it should be composed from + // final flows of these blocks without taking pre-try flow into account. + // + // extra edges that we inject allows to control this behavior + // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. + var preFinallyFlow = { flags: 2048 /* PreFinally */, antecedent: preTryFlow, lock: {} }; + addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); // if flow after finally is unreachable - keep it @@ -21432,6 +21779,11 @@ var ts; : unreachableFlow; } } + if (!(currentFlow.flags & 1 /* Unreachable */)) { + var afterFinallyFlow = { flags: 4096 /* AfterFinally */, antecedent: currentFlow }; + preFinallyFlow.lock = afterFinallyFlow; + currentFlow = afterFinallyFlow; + } } else { currentFlow = finishFlowLabel(preFinallyLabel); @@ -21446,7 +21798,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 255 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 257 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -21513,14 +21865,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 210 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 211 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 192 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { + if (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -21531,10 +21883,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 175 /* ArrayLiteralExpression */) { + else if (node.kind === 176 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 196 /* SpreadElement */) { + if (e.kind === 197 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -21542,16 +21894,16 @@ var ts; } } } - else if (node.kind === 176 /* ObjectLiteralExpression */) { + else if (node.kind === 177 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 258 /* PropertyAssignment */) { + if (p.kind === 260 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 259 /* ShorthandPropertyAssignment */) { + else if (p.kind === 261 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 260 /* SpreadAssignment */) { + else if (p.kind === 262 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -21607,7 +21959,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 57 /* EqualsToken */ && node.left.kind === 178 /* ElementAccessExpression */) { + if (operator === 57 /* EqualsToken */ && node.left.kind === 179 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -21618,7 +21970,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 177 /* PropertyAccessExpression */) { + if (node.expression.kind === 178 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -21651,7 +22003,7 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 213 /* ForInStatement */ || node.parent.parent.kind === 214 /* ForOfStatement */) { + if (node.initializer || node.parent.parent.kind === 214 /* ForInStatement */ || node.parent.parent.kind === 215 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } @@ -21660,10 +22012,10 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 183 /* ParenthesizedExpression */) { + while (expr.kind === 184 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 184 /* FunctionExpression */ || expr.kind === 185 /* ArrowFunction */) { + if (expr.kind === 185 /* FunctionExpression */ || expr.kind === 186 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -21671,7 +22023,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 177 /* PropertyAccessExpression */) { + if (node.expression.kind === 178 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -21680,52 +22032,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 197 /* ClassExpression */: - case 227 /* ClassDeclaration */: - case 230 /* EnumDeclaration */: - case 176 /* ObjectLiteralExpression */: - case 161 /* TypeLiteral */: - case 288 /* JSDocTypeLiteral */: - case 271 /* JSDocRecordType */: + case 198 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 177 /* ObjectLiteralExpression */: + case 162 /* TypeLiteral */: + case 291 /* JSDocTypeLiteral */: + case 274 /* JSDocRecordType */: + case 253 /* JsxAttributes */: return 1 /* IsContainer */; - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 275 /* JSDocFunctionType */: - case 231 /* ModuleDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 170 /* MappedType */: + case 278 /* JSDocFunctionType */: + case 232 /* ModuleDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 171 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 262 /* SourceFile */: + case 264 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } - case 150 /* Constructor */: - case 226 /* FunctionDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 151 /* Constructor */: + case 227 /* FunctionDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 232 /* ModuleBlock */: + case 233 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 257 /* CatchClause */: - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 233 /* CaseBlock */: + case 259 /* CatchClause */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 234 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 205 /* Block */: + case 206 /* 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. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -21762,42 +22115,43 @@ 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 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 262 /* SourceFile */: + case 264 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 197 /* ClassExpression */: - case 227 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 228 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 161 /* TypeLiteral */: - case 176 /* ObjectLiteralExpression */: - case 228 /* InterfaceDeclaration */: - case 271 /* JSDocRecordType */: - case 288 /* JSDocTypeLiteral */: + case 162 /* TypeLiteral */: + case 177 /* ObjectLiteralExpression */: + case 229 /* InterfaceDeclaration */: + case 274 /* JSDocRecordType */: + case 291 /* JSDocTypeLiteral */: + case 253 /* JsxAttributes */: // 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 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 275 /* JSDocFunctionType */: - case 229 /* TypeAliasDeclaration */: - case 170 /* MappedType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 278 /* JSDocFunctionType */: + case 230 /* TypeAliasDeclaration */: + case 171 /* MappedType */: // 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 @@ -21818,11 +22172,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 262 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 262 /* SourceFile */ || body.kind === 232 /* ModuleBlock */)) { + var body = node.kind === 264 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 264 /* SourceFile */ || body.kind === 233 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 242 /* ExportDeclaration */ || stat.kind === 241 /* ExportAssignment */) { + if (stat.kind === 243 /* ExportDeclaration */ || stat.kind === 242 /* ExportAssignment */) { return true; } } @@ -21846,7 +22200,7 @@ var ts; errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isExternalModuleAugmentation(node)) { - declareSymbolAndAddToSymbolTable(node, 1024 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */); + declareModuleSymbol(node); } else { var pattern = void 0; @@ -21866,12 +22220,8 @@ var ts; } } else { - var state = getModuleInstanceState(node); - if (state === 0 /* NonInstantiated */) { - declareSymbolAndAddToSymbolTable(node, 1024 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */); - } - else { - declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); + var state = declareModuleSymbol(node); + if (state !== 0 /* NonInstantiated */) { if (node.symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */)) { // if module was already merged with some function, class or non-const enum // treat is a non-const-enum-only @@ -21891,6 +22241,12 @@ var ts; } } } + function declareModuleSymbol(node) { + var state = getModuleInstanceState(node); + var instantiated = state !== 0 /* NonInstantiated */; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* ValueModule */ : 1024 /* NamespaceModule */, instantiated ? 106639 /* ValueModuleExcludes */ : 0 /* NamespaceModuleExcludes */); + return state; + } function bindFunctionOrConstructorType(node) { // For a given function symbol "<...>(...) => T" we want to generate a symbol identical // to the one we would get for: { <...>(...): T } @@ -21903,7 +22259,7 @@ var ts; var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); typeLiteralSymbol.members = ts.createMap(); - typeLiteralSymbol.members[symbol.name] = symbol; + typeLiteralSymbol.members.set(symbol.name, symbol); } function bindObjectLiteralExpression(node) { var ElementKind; @@ -21915,7 +22271,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 260 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { + if (prop.kind === 262 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { continue; } var identifier = prop.name; @@ -21927,12 +22283,12 @@ 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 === 258 /* PropertyAssignment */ || prop.kind === 259 /* ShorthandPropertyAssignment */ || prop.kind === 149 /* MethodDeclaration */ + var currentKind = prop.kind === 260 /* PropertyAssignment */ || prop.kind === 261 /* ShorthandPropertyAssignment */ || prop.kind === 150 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; - var existingKind = seen[identifier.text]; + var existingKind = seen.get(identifier.text); if (!existingKind) { - seen[identifier.text] = currentKind; + seen.set(identifier.text, currentKind); continue; } if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { @@ -21943,16 +22299,22 @@ var ts; } return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); } + function bindJsxAttributes(node) { + return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__jsxAttributes"); + } + function bindJsxAttribute(node, symbolFlags, symbolExcludes) { + return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 262 /* SourceFile */: + case 264 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -22063,8 +22425,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 262 /* SourceFile */ && - blockScopeContainer.kind !== 231 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 264 /* SourceFile */ && + blockScopeContainer.kind !== 232 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -22130,7 +22492,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 140 /* LastToken */) { + if (node.kind > 141 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -22177,23 +22539,23 @@ var ts; // current "blockScopeContainer" needs to be set to its immediate namespace parent. if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 286 /* JSDocTypedefTag */) { + while (parentNode && parentNode.kind !== 289 /* JSDocTypedefTag */) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); break; } case 98 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 259 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 261 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -22217,48 +22579,48 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return checkStrictModeCatchClause(node); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 218 /* WithStatement */: + case 219 /* WithStatement */: return checkStrictModeWithStatement(node); - case 167 /* ThisType */: + case 168 /* ThisType */: seenThisKeyword = true; return; - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return checkTypePredicate(node); - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530920 /* TypeParameterExcludes */); - case 144 /* Parameter */: + case 145 /* Parameter */: return bindParameter(node); - case 224 /* VariableDeclaration */: - case 174 /* BindingElement */: + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 272 /* JSDocRecordMember */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); - case 287 /* JSDocPropertyTag */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 275 /* JSDocRecordMember */: + return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 67108864 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + case 290 /* JSDocPropertyTag */: return bindJSDocProperty(node); - case 258 /* PropertyAssignment */: - case 259 /* ShorthandPropertyAssignment */: + case 260 /* PropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 261 /* EnumMember */: + case 263 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 260 /* SpreadAssignment */: - case 252 /* JsxSpreadAttribute */: + case 262 /* SpreadAssignment */: + case 254 /* JsxSpreadAttribute */: var root = container; var hasRest = false; while (root.parent) { - if (root.kind === 176 /* ObjectLiteralExpression */ && - root.parent.kind === 192 /* BinaryExpression */ && + if (root.kind === 177 /* ObjectLiteralExpression */ && + root.parent.kind === 193 /* BinaryExpression */ && root.parent.operatorToken.kind === 57 /* EqualsToken */ && root.parent.left === root) { hasRest = true; @@ -22267,86 +22629,91 @@ var ts; root = root.parent; } return; - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* 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) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 226 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 67108864 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); + case 227 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 275 /* JSDocFunctionType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 278 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); - case 161 /* TypeLiteral */: - case 170 /* MappedType */: - case 288 /* JSDocTypeLiteral */: - case 271 /* JSDocRecordType */: + case 162 /* TypeLiteral */: + case 171 /* MappedType */: + case 291 /* JSDocTypeLiteral */: + case 274 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return bindFunctionExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 197 /* ClassExpression */: - case 227 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 228 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); - case 286 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: if (!node.fullName || node.fullName.kind === 70 /* Identifier */) { return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); } break; - case 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return bindModuleDeclaration(node); + // Jsx-attributes + case 253 /* JsxAttributes */: + return bindJsxAttributes(node); + case 252 /* JsxAttribute */: + return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 235 /* ImportEqualsDeclaration */: - case 238 /* NamespaceImport */: - case 240 /* ImportSpecifier */: - case 244 /* ExportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 239 /* NamespaceImport */: + case 241 /* ImportSpecifier */: + case 245 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 234 /* NamespaceExportDeclaration */: + case 235 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 237 /* ImportClause */: + case 238 /* ImportClause */: return bindImportClause(node); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return bindExportDeclaration(node); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return bindExportAssignment(node); - case 262 /* SourceFile */: + case 264 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 205 /* Block */: + case 206 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // Fall through - case 232 /* ModuleBlock */: + case 233 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } @@ -22355,7 +22722,7 @@ var ts; if (parameterName && parameterName.kind === 70 /* Identifier */) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 167 /* ThisType */) { + if (parameterName && parameterName.kind === 168 /* ThisType */) { seenThisKeyword = true; } bind(type); @@ -22378,7 +22745,7 @@ var ts; // An export default clause with an expression exports a value // We want to exclude both class and function here, this is necessary to issue an error when there are both // default export-assignment and default export function and class declaration. - var flags = node.kind === 241 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 242 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -22388,17 +22755,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 262 /* SourceFile */) { + if (node.parent.kind !== 264 /* SourceFile */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_4 = node.parent; - if (!ts.isExternalModule(parent_4)) { + var parent_1 = node.parent; + if (!ts.isExternalModule(parent_1)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_4.isDeclarationFile) { + if (!parent_1.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -22409,11 +22776,11 @@ var ts; function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { // Export * in some sort of block construct - bindAnonymousDeclaration(node, 1073741824 /* ExportStar */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 33554432 /* ExportStar */, getDeclarationName(node)); } else if (!node.exportClause) { // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, 1073741824 /* ExportStar */, 0 /* None */); + declareSymbol(container.symbol.exports, container.symbol, node, 33554432 /* ExportStar */, 0 /* None */); } } function bindImportClause(node) { @@ -22443,12 +22810,12 @@ var ts; function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === 226 /* FunctionDeclaration */ || container.kind === 184 /* FunctionExpression */) { + if (container.kind === 227 /* FunctionDeclaration */ || container.kind === 185 /* FunctionExpression */) { container.symbol.members = container.symbol.members || ts.createMap(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); } - else if (container.kind === 150 /* Constructor */) { + else if (container.kind === 151 /* Constructor */) { // this.foo assignment in a JavaScript class // Bind this property to the containing class var saveContainer = container; @@ -22472,7 +22839,7 @@ var ts; leftSideOfAssignment.parent = node; constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - var funcSymbol = container.locals[constructorFunction.text]; + var funcSymbol = container.locals.get(constructorFunction.text); if (!funcSymbol || !(funcSymbol.flags & 16 /* Function */ || ts.isDeclarationOfFunctionExpression(funcSymbol))) { return; } @@ -22491,7 +22858,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 227 /* ClassDeclaration */) { + if (node.kind === 228 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -22499,7 +22866,7 @@ var ts; bindAnonymousDeclaration(node, 32 /* Class */, bindingName); // Add name of class expression into the map for semantic classifier if (node.name) { - classifiableNames[node.name.text] = node.name.text; + classifiableNames.set(node.name.text, node.name.text); } } var symbol = node.symbol; @@ -22512,14 +22879,15 @@ var ts; // Note: we check for this here because this class may be merging into a module. The // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. - var prototypeSymbol = createSymbol(4 /* Property */ | 134217728 /* Prototype */, "prototype"); - if (symbol.exports[prototypeSymbol.name]) { + var prototypeSymbol = createSymbol(4 /* Property */ | 16777216 /* Prototype */, "prototype"); + var symbolExport = symbol.exports.get(prototypeSymbol.name); + if (symbolExport) { if (node.name) { node.name.parent = node; } - file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbolExport.declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; + symbol.exports.set(prototypeSymbol.name, prototypeSymbol); prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { @@ -22568,7 +22936,7 @@ var ts; // containing class. if (ts.isParameterPropertyDeclaration(node)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 67108864 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } } function bindFunctionDeclaration(node) { @@ -22627,13 +22995,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 207 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 208 /* EmptyStatement */) || // report error on class declarations - node.kind === 227 /* ClassDeclaration */ || + node.kind === 228 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 231 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 232 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 230 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 231 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -22647,7 +23015,7 @@ var ts; // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 206 /* VariableStatement */ || + (node.kind !== 207 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -22667,56 +23035,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 179 /* CallExpression */: + case 180 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 144 /* Parameter */: + case 145 /* Parameter */: return computeParameter(node, subtreeFlags); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 225 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 256 /* HeritageClause */: + case 258 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 150 /* Constructor */: + case 151 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -22743,8 +23111,8 @@ var ts; switch (kind) { case 96 /* SuperKeyword */: return true; - case 177 /* PropertyAccessExpression */: - case 178 /* ElementAccessExpression */: + case 178 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96 /* SuperKeyword */; @@ -22768,12 +23136,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 176 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 177 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ESNext if they contain rest transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 175 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 176 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } @@ -22823,8 +23191,8 @@ 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 (expressionKind === 200 /* AsExpression */ - || expressionKind === 182 /* TypeAssertionExpression */) { + if (expressionKind === 201 /* AsExpression */ + || expressionKind === 183 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -23189,7 +23557,7 @@ var ts; var excludeFlags = 536872257 /* NodeExcludes */; switch (kind) { case 119 /* AsyncKeyword */: - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: // async/await is ES2017 syntax transformFlags |= 16 /* AssertES2017 */; break; @@ -23199,27 +23567,28 @@ var ts; case 116 /* AbstractKeyword */: case 123 /* DeclareKeyword */: case 75 /* ConstKeyword */: - case 230 /* EnumDeclaration */: - case 261 /* EnumMember */: - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: - case 201 /* NonNullExpression */: + case 231 /* EnumDeclaration */: + case 263 /* EnumMember */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: + case 202 /* NonNullExpression */: case 130 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 247 /* JsxElement */: - case 248 /* JsxSelfClosingElement */: - case 249 /* JsxOpeningElement */: + case 248 /* JsxElement */: + case 249 /* JsxSelfClosingElement */: + case 250 /* JsxOpeningElement */: case 10 /* JsxText */: - case 250 /* JsxClosingElement */: - case 251 /* JsxAttribute */: - case 252 /* JsxSpreadAttribute */: - case 253 /* JsxExpression */: + case 251 /* JsxClosingElement */: + case 252 /* JsxAttribute */: + case 253 /* JsxAttributes */: + case 254 /* JsxSpreadAttribute */: + case 255 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: // for-of might be ESNext if it has a rest destructuring transformFlags |= 8 /* AssertESNext */; // FALLTHROUGH @@ -23227,54 +23596,55 @@ var ts; case 13 /* TemplateHead */: case 14 /* TemplateMiddle */: case 15 /* TemplateTail */: - case 194 /* TemplateExpression */: - case 181 /* TaggedTemplateExpression */: - case 259 /* ShorthandPropertyAssignment */: + case 195 /* TemplateExpression */: + case 182 /* TaggedTemplateExpression */: + case 261 /* ShorthandPropertyAssignment */: case 114 /* StaticKeyword */: - case 202 /* MetaProperty */: + case 203 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: // This node is ES6 syntax. transformFlags |= 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; break; case 118 /* AnyKeyword */: case 132 /* NumberKeyword */: case 129 /* NeverKeyword */: - case 134 /* StringKeyword */: + case 133 /* ObjectKeyword */: + case 135 /* StringKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 143 /* TypeParameter */: - case 146 /* PropertySignature */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 156 /* TypePredicate */: - case 157 /* TypeReference */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 160 /* TypeQuery */: - case 161 /* TypeLiteral */: - case 162 /* ArrayType */: - case 163 /* TupleType */: - case 164 /* UnionType */: - case 165 /* IntersectionType */: - case 166 /* ParenthesizedType */: - case 228 /* InterfaceDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 167 /* ThisType */: - case 168 /* TypeOperator */: - case 169 /* IndexedAccessType */: - case 170 /* MappedType */: - case 171 /* LiteralType */: + case 144 /* TypeParameter */: + case 147 /* PropertySignature */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 157 /* TypePredicate */: + case 158 /* TypeReference */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 161 /* TypeQuery */: + case 162 /* TypeLiteral */: + case 163 /* ArrayType */: + case 164 /* TupleType */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: + case 167 /* ParenthesizedType */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 168 /* ThisType */: + case 169 /* TypeOperator */: + case 170 /* IndexedAccessType */: + case 171 /* MappedType */: + case 172 /* LiteralType */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. @@ -23291,10 +23661,10 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 260 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 96 /* SuperKeyword */: @@ -23305,28 +23675,28 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 172 /* ObjectBindingPattern */: + case 173 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 537396545 /* BindingPatternExcludes */; break; - case 173 /* ArrayBindingPattern */: + case 174 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 537396545 /* BindingPatternExcludes */; break; - case 174 /* BindingElement */: + case 175 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; } break; - case 145 /* Decorator */: + case 146 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: excludeFlags = 540087617 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -23344,8 +23714,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 175 /* ArrayLiteralExpression */: - case 180 /* NewExpression */: + case 176 /* ArrayLiteralExpression */: + case 181 /* NewExpression */: excludeFlags = 537396545 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -23353,23 +23723,23 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 210 /* DoStatement */: - case 211 /* WhileStatement */: - case 212 /* ForStatement */: - case 213 /* ForInStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 262 /* SourceFile */: + case 264 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 217 /* ReturnStatement */: - case 215 /* ContinueStatement */: - case 216 /* BreakStatement */: + case 218 /* ReturnStatement */: + case 216 /* ContinueStatement */: + case 217 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -23385,56 +23755,57 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 156 /* FirstTypeNode */ && kind <= 171 /* LastTypeNode */) { + if (kind >= 157 /* FirstTypeNode */ && kind <= 172 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 175 /* ArrayLiteralExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 176 /* ArrayLiteralExpression */: return 537396545 /* ArrayLiteralOrCallOrNewExcludes */; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return 574674241 /* ModuleExcludes */; - case 144 /* Parameter */: + case 145 /* Parameter */: return 536872257 /* ParameterExcludes */; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return 601249089 /* ArrowFunctionExcludes */; - case 184 /* FunctionExpression */: - case 226 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: return 601281857 /* FunctionExcludes */; - case 225 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return 546309441 /* VariableDeclarationListExcludes */; - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: return 539358529 /* ClassExcludes */; - case 150 /* Constructor */: + case 151 /* Constructor */: return 601015617 /* ConstructorExcludes */; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return 601015617 /* MethodOrAccessorExcludes */; case 118 /* AnyKeyword */: case 132 /* NumberKeyword */: case 129 /* NeverKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: + case 133 /* ObjectKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 143 /* TypeParameter */: - case 146 /* PropertySignature */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 228 /* InterfaceDeclaration */: - case 229 /* TypeAliasDeclaration */: + case 144 /* TypeParameter */: + case 147 /* PropertySignature */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return 540087617 /* ObjectLiteralExcludes */; - case 257 /* CatchClause */: + case 259 /* CatchClause */: return 537920833 /* CatchClauseExcludes */; - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: return 537396545 /* BindingPatternExcludes */; default: return 536872257 /* NodeExcludes */; @@ -23486,37 +23857,28 @@ var ts; } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; /** Reads from "main" or "types"/"typings" depending on `extensions`. */ - function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { + function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); - switch (extensions) { - case Extensions.DtsOnly: - case Extensions.TypeScript: - return tryReadFromField("typings") || tryReadFromField("types"); - case Extensions.JavaScript: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; - } + return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); - } - return typesFilePath; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } + if (!ts.hasProperty(jsonContent, fieldName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName); } + return; } + var fileName = jsonContent[fieldName]; + if (typeof fileName !== "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof fileName); + } + return; + } + var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path); + } + return path; } } function readJson(path, host) { @@ -23552,6 +23914,7 @@ var ts; function getDefaultTypeRoots(currentDirectory, host) { if (!host.directoryExists) { return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; + // And if it doesn't exist, tough. } var typeRoots; forEachAncestorDirectory(currentDirectory, function (directory) { @@ -23712,9 +24075,10 @@ var ts; if (!moduleHasNonRelativeName(nonRelativeModuleName)) { return undefined; } - var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); if (!perModuleNameCache) { - moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + perModuleNameCache = createPerModuleNameCache(); + moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); } return perModuleNameCache; } @@ -23750,12 +24114,12 @@ var ts; var commonPrefix = getCommonPrefix(path, resolvedFileName); var current = path; while (true) { - var parent_5 = ts.getDirectoryPath(current); - if (parent_5 === current || directoryPathMap.contains(parent_5)) { + var parent = ts.getDirectoryPath(current); + if (parent === current || directoryPathMap.contains(parent)) { break; } - directoryPathMap.set(parent_5, result); - current = parent_5; + directoryPathMap.set(parent, result); + current = parent; if (current == commonPrefix) { break; } @@ -23788,7 +24152,7 @@ var ts; } var containingDirectory = ts.getDirectoryPath(containingFile); var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); - var result = perFolderCache && perFolderCache[moduleName]; + var result = perFolderCache && perFolderCache.get(moduleName); if (result) { if (traceEnabled) { trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); @@ -23816,7 +24180,7 @@ var ts; break; } if (perFolderCache) { - perFolderCache[moduleName] = result; + perFolderCache.set(moduleName, result); // put result in per-module name cache var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); if (perModuleNameCache) { @@ -24016,18 +24380,25 @@ var ts; } } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /* jsOnly*/ false); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + /* @internal */ + function nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, jsOnly) { + if (jsOnly === void 0) { jsOnly = false; } var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + var result = jsOnly ? tryResolve(Extensions.JavaScript) : (tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript)); if (result && result.value) { var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { - var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + var loader = function (extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/ true); }; + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); if (resolved) { return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } @@ -24041,12 +24412,12 @@ var ts; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true); return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } - ts.nodeModuleNameResolver = nodeModuleNameResolver; + ts.nodeModuleNameResolverWorker = nodeModuleNameResolverWorker; function realpath(path, host, traceEnabled) { if (!host.realpath) { return path; @@ -24057,7 +24428,7 @@ var ts; } return real; } - function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } @@ -24085,7 +24456,7 @@ var ts; onlyRecordFailures = true; } } - return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson); } /* @internal */ function directoryProbablyExists(directoryName, host) { @@ -24154,47 +24525,51 @@ var ts; failedLookupLocations.push(fileName); return undefined; } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { + if (considerPackageJson === void 0) { considerPackageJson = true; } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); - if (mainOrTypesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); - // A package.json "typings" may specify an exact filename, or may choose to omit an extension. - var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromExactFile) { - var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); - if (resolved_3) { - return resolved_3; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); - } - } - var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); - if (resolved) { - return resolved; + if (considerPackageJson) { + var packageJsonPath = pathToPackageJson(candidate); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; } } else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); + if (directoryExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocations.push(packageJsonPath); } } - else { - if (directoryExists && state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results - failedLookupLocations.push(packageJsonPath); - } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + if (!file) { + return undefined; + } + var onlyRecordFailures = !directoryProbablyExists(ts.getDirectoryPath(file), state.host); + var fromFile = tryFile(file, failedLookupLocations, onlyRecordFailures, state); + if (fromFile) { + var resolved = fromFile && resolvedIfExtensionMatches(extensions, fromFile); + if (resolved) { + return resolved; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile); + } + } + // Even if extensions is DtsOnly, we can still look up a .ts file as a result of package.json "types" + var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; + // Don't do package.json lookup recursively, because Node.js' package lookup doesn't. + return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/ false); + } /** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */ function resolvedIfExtensionMatches(extensions, path) { var extension = ts.tryGetExtensionFromPath(path); @@ -24286,7 +24661,7 @@ var ts; var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { // Climb up parent directories looking for a module. - var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); if (resolutionFromCache) { return resolutionFromCache; @@ -24294,8 +24669,8 @@ var ts; var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state)); }); - if (resolved_4) { - return resolved_4; + if (resolved_3) { + return resolved_3; } if (extensions === Extensions.TypeScript) { // If we didn't find the file normally, look it up in @types. @@ -24400,9 +24775,9 @@ var ts; var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; var strictNullChecks = compilerOptions.strictNullChecks; var emitResolver = createResolver(); - var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); + var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); undefinedSymbol.declarations = []; - var argumentsSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "arguments"); + var argumentsSymbol = createSymbol(4 /* Property */, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, @@ -24423,6 +24798,7 @@ var ts; getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, getTypeFromTypeNode: getTypeFromTypeNode, + getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -24447,8 +24823,9 @@ var ts; getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getAmbientModules: getAmbientModules, - getJsxElementAttributesType: getJsxElementAttributesType, + getAllAttributesTypeFromJsxOpeningLikeElement: getAllAttributesTypeFromJsxOpeningLikeElement, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, isOptionalParameter: isOptionalParameter, tryGetMemberInModuleExports: tryGetMemberInModuleExports, @@ -24466,8 +24843,8 @@ var ts; var numericLiteralTypes = ts.createMap(); var indexedAccessTypes = ts.createMap(); var evolvingArrayTypes = []; - var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); - var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); + var unknownSymbol = createSymbol(4 /* Property */, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__"); var anyType = createIntrinsicType(1 /* Any */, "any"); var autoType = createIntrinsicType(1 /* Any */, "any"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); @@ -24484,8 +24861,9 @@ var ts; var voidType = createIntrinsicType(1024 /* Void */, "void"); var neverType = createIntrinsicType(8192 /* Never */, "never"); var silentNeverType = createIntrinsicType(8192 /* Never */, "never"); + var nonPrimitiveType = createIntrinsicType(16777216 /* NonPrimitive */, "object"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */ | 67108864 /* Transient */, "__type"); + var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); emptyTypeLiteralSymbol.members = ts.createMap(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -24495,6 +24873,7 @@ var ts; // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); @@ -24627,7 +25006,7 @@ var ts; TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; })(TypeFacts || (TypeFacts = {})); - var typeofEQFacts = ts.createMap({ + var typeofEQFacts = ts.createMapFromTemplate({ "string": 1 /* TypeofEQString */, "number": 2 /* TypeofEQNumber */, "boolean": 4 /* TypeofEQBoolean */, @@ -24636,7 +25015,7 @@ var ts; "object": 16 /* TypeofEQObject */, "function": 32 /* TypeofEQFunction */ }); - var typeofNEFacts = ts.createMap({ + var typeofNEFacts = ts.createMapFromTemplate({ "string": 128 /* TypeofNEString */, "number": 256 /* TypeofNENumber */, "boolean": 512 /* TypeofNEBoolean */, @@ -24645,13 +25024,14 @@ var ts; "object": 2048 /* TypeofNEObject */, "function": 4096 /* TypeofNEFunction */ }); - var typeofTypesByName = ts.createMap({ + var typeofTypesByName = ts.createMapFromTemplate({ "string": stringType, "number": numberType, "boolean": booleanType, "symbol": esSymbolType, "undefined": undefinedType }); + var typeofType = createTypeofType(); var jsxElementType; var _jsxNamespace; var _jsxFactoryEntity; @@ -24681,7 +25061,7 @@ var ts; TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); - builtinGlobals[undefinedSymbol.name] = undefinedSymbol; + builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); return checker; function getJsxNamespace() { @@ -24713,7 +25093,9 @@ var ts; } function createSymbol(flags, name) { symbolCount++; - return new Symbol(flags, name); + var symbol = (new Symbol(flags | 134217728 /* Transient */, name)); + symbol.checkFlags = 0; + return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; @@ -24759,7 +25141,7 @@ var ts; mergedSymbols[source.mergeId] = target; } function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 33554432 /* Merged */, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) @@ -24782,7 +25164,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 231 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 231 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 232 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 232 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -24799,6 +25181,9 @@ var ts; } recordMergedSymbol(target, source); } + else if (target.flags & 1024 /* NamespaceModule */) { + error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + } else { var message_2 = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -24811,18 +25196,19 @@ var ts; } } function mergeSymbolTable(target, source) { - for (var id in source) { - var targetSymbol = target[id]; + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); if (!targetSymbol) { - target[id] = source[id]; + target.set(id, sourceSymbol); } else { - if (!(targetSymbol.flags & 33554432 /* Merged */)) { - target[id] = targetSymbol = cloneSymbol(targetSymbol); + if (!(targetSymbol.flags & 134217728 /* Transient */)) { + targetSymbol = cloneSymbol(targetSymbol); + target.set(id, targetSymbol); } - mergeSymbol(targetSymbol, source[id]); + mergeSymbol(targetSymbol, sourceSymbol); } - } + }); } function mergeModuleAugmentation(moduleName) { var moduleAugmentation = moduleName.parent; @@ -24851,7 +25237,7 @@ var ts; if (mainModule.flags & 1920 /* Namespace */) { // if module symbol has already been merged - it is safe to use it. // otherwise clone it - mainModule = mainModule.flags & 33554432 /* Merged */ ? mainModule : cloneSymbol(mainModule); + mainModule = mainModule.flags & 134217728 /* Transient */ ? mainModule : cloneSymbol(mainModule); mergeSymbol(mainModule, moduleAugmentation.symbol); } else { @@ -24860,21 +25246,22 @@ var ts; } } function addToSymbolTable(target, source, message) { - for (var id in source) { - if (target[id]) { + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); + if (targetSymbol) { // Error on redeclarations - ts.forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); + ts.forEach(targetSymbol.declarations, addDeclarationDiagnostic(id, message)); } else { - target[id] = source[id]; + target.set(id, sourceSymbol); } - } + }); function addDeclarationDiagnostic(id, message) { return function (declaration) { return diagnostics.add(ts.createDiagnosticForNode(declaration, message, id)); }; } } function getSymbolLinks(symbol) { - if (symbol.flags & 67108864 /* Transient */) + if (symbol.flags & 134217728 /* Transient */) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = {}); @@ -24886,14 +25273,17 @@ var ts; function getObjectFlags(type) { return type.flags & 32768 /* Object */ ? type.objectFlags : 0; } + function getCheckFlags(symbol) { + return symbol.flags & 134217728 /* Transient */ ? symbol.checkFlags : 0; + } function isGlobalSourceFile(node) { - return node.kind === 262 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 264 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { - var symbol = symbols[name]; + var symbol = symbols.get(name); if (symbol) { - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } @@ -24935,7 +25325,7 @@ var ts; } // declaration is after usage // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) - if (isUsedInFunctionOrNonStaticProperty(usage)) { + if (isUsedInFunctionOrInstanceProperty(usage)) { return true; } var sourceFiles = host.getSourceFiles(); @@ -24943,32 +25333,34 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 174 /* BindingElement */) { + if (declaration.kind === 175 /* BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 174 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 175 /* BindingElement */); if (errorBindingElement) { return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 224 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 225 /* VariableDeclaration */), usage); } - else if (declaration.kind === 224 /* VariableDeclaration */) { + else if (declaration.kind === 225 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return true; } - // declaration is after usage - // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) + // declaration is after usage, but it can still be legal if usage is deferred: + // 1. inside a function + // 2. inside an instance property initializer, a reference to a non-instance property var container = ts.getEnclosingBlockScopeContainer(declaration); - return isUsedInFunctionOrNonStaticProperty(usage, container); + var isInstanceProperty = declaration.kind === 148 /* PropertyDeclaration */ && !(ts.getModifierFlags(declaration) & 32 /* Static */); + return isUsedInFunctionOrInstanceProperty(usage, isInstanceProperty, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 206 /* VariableStatement */: - case 212 /* ForStatement */: - case 214 /* ForOfStatement */: + case 207 /* VariableStatement */: + case 213 /* ForStatement */: + case 215 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -24977,8 +25369,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -24986,7 +25378,7 @@ var ts; } return false; } - function isUsedInFunctionOrNonStaticProperty(usage, container) { + function isUsedInFunctionOrInstanceProperty(usage, isDeclarationInstanceProperty, container) { var current = usage; while (current) { if (current === container) { @@ -24995,12 +25387,12 @@ var ts; if (ts.isFunctionLike(current)) { return true; } - var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 147 /* PropertyDeclaration */ && + var initializerOfInstanceProperty = current.parent && + current.parent.kind === 148 /* PropertyDeclaration */ && (ts.getModifierFlags(current.parent) & 32 /* Static */) === 0 && current.parent.initializer === current; - if (initializerOfNonStaticProperty) { - return true; + if (initializerOfInstanceProperty) { + return !isDeclarationInstanceProperty; } current = current.parent; } @@ -25038,11 +25430,11 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 279 /* JSDocComment */) { + if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 282 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || - lastLocation.kind === 144 /* Parameter */ || - lastLocation.kind === 143 /* TypeParameter */ + lastLocation.kind === 145 /* Parameter */ || + lastLocation.kind === 144 /* TypeParameter */ : false; } if (meaning & 107455 /* Value */ && result.flags & 1 /* FunctionScopedVariable */) { @@ -25051,9 +25443,9 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 144 /* Parameter */ || + lastLocation.kind === 145 /* Parameter */ || (lastLocation === location.type && - result.valueDeclaration.kind === 144 /* Parameter */); + result.valueDeclaration.kind === 145 /* Parameter */); } } if (useResult) { @@ -25065,16 +25457,16 @@ var ts; } } switch (location.kind) { - case 262 /* SourceFile */: + case 264 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 262 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 264 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports["default"]) { + if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; @@ -25092,9 +25484,10 @@ var ts; // 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely* // an alias. If we used &, we'd be throwing out symbols that have non alias aspects, // which is not the desired behavior. - if (moduleExports[name] && - moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 244 /* ExportSpecifier */)) { + var moduleExport = moduleExports.get(name); + if (moduleExport && + moduleExport.flags === 8388608 /* Alias */ && + ts.getDeclarationOfKind(moduleExport, 245 /* ExportSpecifier */)) { break; } } @@ -25102,13 +25495,13 @@ var ts; break loop; } break; - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* 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 @@ -25125,10 +25518,15 @@ var ts; } } break; - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 228 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064 /* Type */)) { + if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { + // ignore type parameters not declared in this container + result = undefined; + break; + } if (lastLocation && ts.getModifierFlags(lastLocation) & 32 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 // The scope of a type parameter extends over the entire declaration with which the type @@ -25138,7 +25536,7 @@ var ts; } break loop; } - if (location.kind === 197 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 198 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -25154,9 +25552,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 228 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 229 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -25164,19 +25562,19 @@ var ts; } } break; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 226 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -25189,7 +25587,7 @@ var ts; } } break; - case 145 /* Decorator */: + case 146 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -25198,7 +25596,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 === 144 /* Parameter */) { + if (location.parent && location.parent.kind === 145 /* Parameter */) { location = location.parent; } // @@ -25249,10 +25647,10 @@ var ts; // interface bar {} // } // const foo/*1*/: foo/*2*/.bar; - // The foo at /*1*/ and /*2*/ will share same symbol with two meaning - // block - scope variable and namespace module. However, only when we + // The foo at /*1*/ and /*2*/ will share same symbol with two meanings: + // block-scoped variable and namespace module. However, only when we // try to resolve name in /*1*/ which is used in variable position, - // we want to check for block- scoped + // we want to check for block-scoped if (meaning & 2 /* BlockScopedVariable */) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */) { @@ -25262,18 +25660,27 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 107455 /* Value */) === 107455 /* Value */) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 234 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 235 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } } return result; } + function isTypeParameterSymbolDeclaredInContainer(symbol, container) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 144 /* TypeParameter */ && decl.parent === container) { + return true; + } + } + return false; + } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { if ((errorLocation.kind === 70 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } - var container = ts.getThisContainer(errorLocation, /* includeArrowFunctions */ true); + var container = ts.getThisContainer(errorLocation, /*includeArrowFunctions*/ true); var location = container; while (location) { if (ts.isClassLike(location.parent)) { @@ -25316,9 +25723,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70 /* Identifier */: - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -25371,10 +25778,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 235 /* ImportEqualsDeclaration */) { + if (node.kind === 236 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 236 /* ImportDeclaration */) { + while (node && node.kind !== 237 /* ImportDeclaration */) { node = node.parent; } return node; @@ -25384,7 +25791,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 246 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 247 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -25392,11 +25799,16 @@ var ts; function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { - var exportDefaultSymbol = ts.isShorthandAmbientModuleSymbol(moduleSymbol) ? - moduleSymbol : - moduleSymbol.exports["export="] ? - getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") : - resolveSymbol(moduleSymbol.exports["default"]); + var exportDefaultSymbol = void 0; + if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { + exportDefaultSymbol = moduleSymbol; + } + else { + var exportValue = moduleSymbol.exports.get("export="); + exportDefaultSymbol = exportValue + ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") + : resolveSymbol(moduleSymbol.exports.get("default")); + } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } @@ -25445,7 +25857,7 @@ var ts; } function getExportOfModule(symbol, name) { if (symbol.flags & 1536 /* Module */) { - var exportedSymbol = getExportsOfSymbol(symbol)[name]; + var exportedSymbol = getExportsOfSymbol(symbol).get(name); if (exportedSymbol) { return resolveSymbol(exportedSymbol); } @@ -25463,31 +25875,31 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_16 = specifier.propertyName || specifier.name; - if (name_16.text) { + var name = specifier.propertyName || specifier.name; + if (name.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_16.text); + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) { + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_16.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_16.text); + var symbolFromModule = getExportOfModule(targetSymbol, name.text); // If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default - if (!symbolFromModule && allowSyntheticDefaultImports && name_16.text === "default") { + if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_16, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_16)); + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name)); } return symbol; } @@ -25509,19 +25921,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 237 /* ImportClause */: + case 238 /* ImportClause */: return getTargetOfImportClause(node); - case 238 /* NamespaceImport */: + case 239 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 240 /* ImportSpecifier */: + case 241 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 244 /* ExportSpecifier */: + case 245 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return getTargetOfExportAssignment(node); - case 234 /* NamespaceExportDeclaration */: + case 235 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node); } } @@ -25568,11 +25980,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 241 /* ExportAssignment */) { + if (node.kind === 242 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 244 /* ExportSpecifier */) { + else if (node.kind === 245 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -25594,13 +26006,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 141 /* QualifiedName */) { + if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 142 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 235 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 236 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -25622,9 +26034,9 @@ var ts; return undefined; } } - else if (name.kind === 141 /* QualifiedName */ || name.kind === 177 /* PropertyAccessExpression */) { - var left = name.kind === 141 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 141 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 142 /* QualifiedName */ || name.kind === 178 /* PropertyAccessExpression */) { + var left = name.kind === 142 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 142 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1920 /* Namespace */, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -25643,7 +26055,7 @@ var ts; else { ts.Debug.fail("Unknown entity name kind."); } - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); } function resolveExternalModuleName(location, moduleReferenceExpression) { @@ -25723,7 +26135,7 @@ var ts; // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, // and an external module with no 'export =' declaration resolves to the module itself. function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="))) || moduleSymbol; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may @@ -25737,15 +26149,23 @@ var ts; return symbol; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="] !== undefined; + return moduleSymbol.exports.get("export=") !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); } + function getExportsAndPropertiesOfModule(moduleSymbol) { + var exports = getExportsOfModuleAsArray(moduleSymbol); + var exportEquals = resolveExternalModuleSymbol(moduleSymbol); + if (exportEquals !== moduleSymbol) { + ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + } + return exports; + } function tryGetMemberInModuleExports(memberName, moduleSymbol) { var symbolTable = getExportsOfModule(moduleSymbol); if (symbolTable) { - return symbolTable[memberName]; + return symbolTable.get(memberName); } } function getExportsOfSymbol(symbol) { @@ -25760,24 +26180,28 @@ var ts; * Not passing `lookupTable` and `exportNode` disables this collection, and just extends the tables */ function extendExportSymbols(target, source, lookupTable, exportNode) { - for (var id in source) { - if (id !== "default" && !target[id]) { - target[id] = source[id]; + source && source.forEach(function (sourceSymbol, id) { + if (id === "default") + return; + var targetSymbol = target.get(id); + if (!targetSymbol) { + target.set(id, sourceSymbol); if (lookupTable && exportNode) { - lookupTable[id] = { + lookupTable.set(id, { specifierText: ts.getTextOfNode(exportNode.moduleSpecifier) - }; + }); } } - else if (lookupTable && exportNode && id !== "default" && target[id] && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { - if (!lookupTable[id].exportsWithDuplicate) { - lookupTable[id].exportsWithDuplicate = [exportNode]; + else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) { + var collisionTracker = lookupTable.get(id); + if (!collisionTracker.exportsWithDuplicate) { + collisionTracker.exportsWithDuplicate = [exportNode]; } else { - lookupTable[id].exportsWithDuplicate.push(exportNode); + collisionTracker.exportsWithDuplicate.push(exportNode); } } - } + }); } function getExportsForModule(moduleSymbol) { var visitedSymbols = []; @@ -25793,27 +26217,27 @@ var ts; visitedSymbols.push(symbol); var symbols = ts.cloneMap(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - var exportStars = symbol.exports["__export"]; + var exportStars = symbol.exports.get("__export"); if (exportStars) { var nestedSymbols = ts.createMap(); - var lookupTable = ts.createMap(); + var lookupTable_1 = ts.createMap(); for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { var node = _a[_i]; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable, node); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); } - for (var id in lookupTable) { - var exportsWithDuplicate = lookupTable[id].exportsWithDuplicate; + lookupTable_1.forEach(function (_a, id) { + var exportsWithDuplicate = _a.exportsWithDuplicate; // It's not an error if the file with multiple `export *`s with duplicate names exports a member with that name itself - if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols[id]) { - continue; + if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) { + return; } - for (var _b = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _b < exportsWithDuplicate_1.length; _b++) { - var node = exportsWithDuplicate_1[_b]; - diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable[id].specifierText, id)); + for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) { + var node = exportsWithDuplicate_1[_i]; + diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable_1.get(id).specifierText, id)); } - } + }); extendExportSymbols(symbols, nestedSymbols); } return symbols; @@ -25835,26 +26259,13 @@ var ts; : symbol; } function symbolIsValue(symbol) { - // If it is an instantiated symbol, then it is a value if the symbol it is an - // instantiation of is a value. - if (symbol.flags & 16777216 /* Instantiated */) { - return symbolIsValue(getSymbolLinks(symbol).target); - } - // If the symbol has the value flag, it is trivially a value. - if (symbol.flags & 107455 /* Value */) { - return true; - } - // If it is an alias, then it is a value if the symbol it resolves to is a value. - if (symbol.flags & 8388608 /* Alias */) { - return (resolveAlias(symbol).flags & 107455 /* Value */) !== 0; - } - return false; + return !!(symbol.flags & 107455 /* Value */ || symbol.flags & 8388608 /* Alias */ && resolveAlias(symbol).flags & 107455 /* Value */); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 150 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 151 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -25882,6 +26293,9 @@ var ts; type.symbol = symbol; return type; } + function createTypeofType() { + return getUnionType(ts.convertToArray(typeofEQFacts.keys(), function (s) { return getLiteralTypeForText(32 /* StringLiteral */, s); })); + } // A reserved member name starts with two underscores, but the third character cannot be an underscore // or the @ symbol. A third underscore indicates an escaped form of an identifer that started // with at least two underscores. The @ character indicates that the name is denoted by a well known ES @@ -25894,16 +26308,15 @@ var ts; } function getNamedMembers(members) { var result; - for (var id in members) { + members.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { if (!result) result = []; - var symbol = members[id]; if (symbolIsValue(symbol)) { result.push(symbol); } } - } + }); return result || emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -25922,20 +26335,20 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { + for (var location = enclosingDeclaration; location; location = location.parent) { // Locals of a source file are not in scope (because they get merged into the global symbol table) - if (location_1.locals && !isGlobalSourceFile(location_1)) { - if (result = callback(location_1.locals)) { + if (location.locals && !isGlobalSourceFile(location)) { + if (result = callback(location.locals)) { return result; } } - switch (location_1.kind) { - case 262 /* SourceFile */: - if (!ts.isExternalOrCommonJsModule(location_1)) { + switch (location.kind) { + case 264 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 231 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location_1).exports)) { + case 232 /* ModuleDeclaration */: + if (result = callback(getSymbolOfNode(location).exports)) { return result; } break; @@ -25979,14 +26392,14 @@ var ts; } function trySymbolTable(symbols) { // If symbol is directly available by its name in the symbol table - if (isAccessible(symbols[symbol.name])) { + if (isAccessible(symbols.get(symbol.name))) { return [symbol]; } // Check if symbol is any of the alias - return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { + return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -26015,7 +26428,7 @@ var ts; var qualify = false; forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { // If symbol of this name is not available in the symbol table we are ok - var symbolFromSymbolTable = symbolTable[symbol.name]; + var symbolFromSymbolTable = symbolTable.get(symbol.name); if (!symbolFromSymbolTable) { // Continue to the next symbol table return false; @@ -26026,7 +26439,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -26041,10 +26454,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 147 /* PropertyDeclaration */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 148 /* PropertyDeclaration */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: continue; default: return false; @@ -26125,7 +26538,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 264 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -26166,12 +26579,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 160 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 161 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 141 /* QualifiedName */ || entityName.kind === 177 /* PropertyAccessExpression */ || - entityName.parent.kind === 235 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 142 /* QualifiedName */ || entityName.kind === 178 /* PropertyAccessExpression */ || + entityName.parent.kind === 236 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -26267,10 +26680,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 166 /* ParenthesizedType */) { + while (node.kind === 167 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 229 /* TypeAliasDeclaration */) { + if (node.kind === 230 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -26278,29 +26691,29 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 232 /* ModuleBlock */ && + node.parent.kind === 233 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { return type.flags & 32 /* StringLiteral */ ? "\"" + ts.escapeString(type.text) + "\"" : type.text; } - function getSymbolDisplayBuilder() { - function getNameOfSymbol(symbol) { - if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - if (declaration.name) { - return ts.declarationNameToString(declaration.name); - } - switch (declaration.kind) { - case 197 /* ClassExpression */: - return "(Anonymous class)"; - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - return "(Anonymous function)"; - } + function getNameOfSymbol(symbol) { + if (symbol.declarations && symbol.declarations.length) { + var declaration = symbol.declarations[0]; + if (declaration.name) { + return ts.declarationNameToString(declaration.name); + } + switch (declaration.kind) { + case 198 /* ClassExpression */: + return "(Anonymous class)"; + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + return "(Anonymous function)"; } - return symbol.name; } + return symbol.name; + } + function getSymbolDisplayBuilder() { /** * Writes only the name of the symbol out to the writer. Uses the original source text * for the name of the symbol if it is available to match how the user wrote the name. @@ -26342,7 +26755,7 @@ var ts; if (parentSymbol) { // Write type arguments of instantiated class/interface here if (flags & 1 /* WriteTypeParametersOrArguments */) { - if (symbol.flags & 16777216 /* Instantiated */) { + if (getCheckFlags(symbol) & 1 /* Instantiated */) { buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); } else { @@ -26370,9 +26783,9 @@ var ts; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - var parent_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_6) { - walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + walkSymbol(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); } } if (accessibleSymbolChain) { @@ -26410,7 +26823,7 @@ var ts; function writeType(type, flags) { var nextFlags = flags & ~512 /* InTypeAlias */; // Write undefined/null type as any - if (type.flags & 16015 /* Intrinsic */) { + if (type.flags & 16793231 /* 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" @@ -26437,7 +26850,7 @@ var ts; else if (!(flags & 512 /* InTypeAlias */) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === 0 /* Accessible */) { var typeArguments = type.aliasTypeArguments; - writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); + writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, ts.length(typeArguments), nextFlags); } else if (type.flags & 196608 /* UnionOrIntersection */) { writeUnionOrIntersectionType(type, nextFlags); @@ -26522,14 +26935,14 @@ var ts; while (i < length_1) { // Find group of type arguments for type parameters with the same declaring container. var start = i; - var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); + writeSymbolTypeReference(parent, typeArguments, start, i, flags); writePunctuation(writer, 22 /* DotToken */); } } @@ -26556,7 +26969,8 @@ var ts; var symbol = type.symbol; if (symbol) { // Always use 'typeof T' for type of class, enum, and module objects - if (symbol.flags & (32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (384 /* Enum */ | 512 /* ValueModule */)) { writeTypeOfSymbol(type, flags); } else if (shouldWriteTypeOfFunctionSymbol()) { @@ -26595,7 +27009,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 262 /* SourceFile */ || declaration.parent.kind === 232 /* ModuleBlock */; + return declaration.parent.kind === 264 /* SourceFile */ || declaration.parent.kind === 233 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -26615,7 +27029,7 @@ var ts; writeSpace(writer); } buildSymbolDisplay(prop, writer); - if (prop.flags & 536870912 /* Optional */) { + if (prop.flags & 67108864 /* Optional */) { writePunctuation(writer, 54 /* QuestionToken */); } } @@ -26759,6 +27173,13 @@ var ts; writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } + var defaultType = getDefaultFromTypeParameter(tp); + if (defaultType) { + writeSpace(writer); + writePunctuation(writer, 57 /* EqualsToken */); + writeSpace(writer); + buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack); + } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; @@ -26776,16 +27197,20 @@ var ts; } writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); - buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); + var type = getTypeOfSymbol(p); + if (isRequiredInitializedParameter(parameterNode)) { + type = includeFalsyTypes(type, 2048 /* Undefined */); + } + buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { // We have to explicitly emit square bracket and bracket because these tokens are not stored inside the node. - if (bindingPattern.kind === 172 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 173 /* ObjectBindingPattern */) { writePunctuation(writer, 16 /* OpenBraceToken */); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); writePunctuation(writer, 17 /* CloseBraceToken */); } - else if (bindingPattern.kind === 173 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 174 /* ArrayBindingPattern */) { writePunctuation(writer, 20 /* OpenBracketToken */); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -26799,7 +27224,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 174 /* BindingElement */); + ts.Debug.assert(bindingElement.kind === 175 /* BindingElement */); if (bindingElement.propertyName) { writer.writeProperty(ts.getTextOfNode(bindingElement.propertyName)); writePunctuation(writer, 55 /* ColonToken */); @@ -26923,7 +27348,7 @@ var ts; writeKeyword(writer, 132 /* NumberKeyword */); break; case 0 /* String */: - writeKeyword(writer, 134 /* StringKeyword */); + writeKeyword(writer, 135 /* StringKeyword */); break; } writePunctuation(writer, 21 /* CloseBracketToken */); @@ -26959,75 +27384,75 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 174 /* BindingElement */: + case 175 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 224 /* VariableDeclaration */: + case 225 /* 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 231 /* ModuleDeclaration */: - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 226 /* FunctionDeclaration */: - case 230 /* EnumDeclaration */: - case 235 /* ImportEqualsDeclaration */: + case 232 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 227 /* FunctionDeclaration */: + case 231 /* EnumDeclaration */: + case 236 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_8 = getDeclarationContainer(node); + var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 235 /* ImportEqualsDeclaration */ && parent_8.kind !== 262 /* SourceFile */ && ts.isInAmbientContext(parent_8))) { - return isGlobalSourceFile(parent_8); + !(node.kind !== 236 /* ImportEqualsDeclaration */ && parent.kind !== 264 /* SourceFile */ && ts.isInAmbientContext(parent))) { + return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent_8); - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + return isDeclarationVisible(parent); + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: if (ts.getModifierFlags(node) & (8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so const it fall into next case statement - case 150 /* Constructor */: - case 154 /* ConstructSignature */: - case 153 /* CallSignature */: - case 155 /* IndexSignature */: - case 144 /* Parameter */: - case 232 /* ModuleBlock */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 161 /* TypeLiteral */: - case 157 /* TypeReference */: - case 162 /* ArrayType */: - case 163 /* TupleType */: - case 164 /* UnionType */: - case 165 /* IntersectionType */: - case 166 /* ParenthesizedType */: + case 151 /* Constructor */: + case 155 /* ConstructSignature */: + case 154 /* CallSignature */: + case 156 /* IndexSignature */: + case 145 /* Parameter */: + case 233 /* ModuleBlock */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 162 /* TypeLiteral */: + case 158 /* TypeReference */: + case 163 /* ArrayType */: + case 164 /* TupleType */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: + case 167 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 237 /* ImportClause */: - case 238 /* NamespaceImport */: - case 240 /* ImportSpecifier */: + case 238 /* ImportClause */: + case 239 /* NamespaceImport */: + case 241 /* ImportSpecifier */: return false; // Type parameters are always visible - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: // Source file and namespace export are always visible - case 262 /* SourceFile */: - case 234 /* NamespaceExportDeclaration */: + case 264 /* SourceFile */: + case 235 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return false; default: return false; @@ -27036,10 +27461,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 241 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 242 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 244 /* ExportSpecifier */) { + else if (node.parent.kind === 245 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -27132,12 +27557,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 224 /* VariableDeclaration */: - case 225 /* VariableDeclarationList */: - case 240 /* ImportSpecifier */: - case 239 /* NamedImports */: - case 238 /* NamespaceImport */: - case 237 /* ImportClause */: + case 225 /* VariableDeclaration */: + case 226 /* VariableDeclarationList */: + case 241 /* ImportSpecifier */: + case 240 /* NamedImports */: + case 239 /* NamespaceImport */: + case 238 /* ImportClause */: node = node.parent; break; default: @@ -27168,7 +27593,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 142 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 143 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 6144 /* Nullable */); }); @@ -27181,17 +27606,16 @@ var ts; var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name_17 = properties_2[_i]; - names[ts.getTextOfPropertyName(name_17)] = true; + var name = properties_2[_i]; + names.set(ts.getTextOfPropertyName(name), true); } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - var inNamesToRemove = prop.name in names; + var inNamesToRemove = names.has(prop.name); var isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */); - var isMethod = prop.flags & 8192 /* Method */; var isSetOnlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { - members[prop.name] = prop; + if (!inNamesToRemove && !isPrivate && !isClassMethod(prop) && !isSetOnlyAccessor) { + members.set(prop.name, prop); } } var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); @@ -27216,7 +27640,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 172 /* ObjectBindingPattern */) { + if (pattern.kind === 173 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -27233,8 +27657,8 @@ var ts; } else { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) - var name_18 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_18)) { + var name = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name)) { // computed properties with non-literal names are treated as 'any' return anyType; } @@ -27243,12 +27667,12 @@ var ts; } // 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. - var text = ts.getTextOfPropertyName(name_18); + var text = ts.getTextOfPropertyName(name); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); if (!type) { - error(name_18, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_18)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); return unknownType; } } @@ -27288,7 +27712,7 @@ var ts; getUnionType([type, checkExpressionCached(declaration.initializer)], /*subtypeReduction*/ true) : type; } - function getTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); if (jsdocType) { return getTypeFromTypeNode(jsdocType); @@ -27301,29 +27725,38 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 175 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 176 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048 /* Undefined */) : type; } + /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ + function removeOptionalityFromAnnotation(annotatedType, declaration) { + var annotationIncludesUndefined = strictNullChecks && + declaration.kind === 145 /* Parameter */ && + declaration.initializer && + getFalsyFlags(annotatedType) & 2048 /* Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048 /* Undefined */); + return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; + } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { if (declaration.flags & 65536 /* JavaScriptFile */) { // If this is a variable in a JavaScript file, then use the JSDoc type (if it has // one as its type), otherwise fallback to the below standard TS codepaths to // try to figure it out. - var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); + var type = getTypeForDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } } // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (declaration.parent.parent.kind === 213 /* ForInStatement */) { + if (declaration.parent.parent.kind === 214 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 /* TypeParameter */ | 262144 /* Index */) ? indexType : stringType; } - if (declaration.parent.parent.kind === 214 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 215 /* 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, @@ -27335,10 +27768,11 @@ var ts; } // Use type from type annotation if one is present if (declaration.type) { - return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); + var declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + return addOptionality(declaredType, /*optional*/ declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536 /* JavaScriptFile */) && - declaration.kind === 224 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 225 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -27352,11 +27786,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 144 /* Parameter */) { + if (declaration.kind === 145 /* 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 === 152 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 151 /* GetAccessor */); + if (func.kind === 153 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 152 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -27385,8 +27819,13 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); } + if (ts.isJsxAttribute(declaration)) { + // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. + // I.e is sugar for + return trueType; + } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 259 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 261 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -27396,6 +27835,23 @@ var ts; // No type specified and nothing can be inferred return undefined; } + // Return the inferred type for a variable, parameter, or property declaration + function getTypeForJSSpecialPropertyDeclaration(declaration) { + var expression = declaration.kind === 193 /* BinaryExpression */ ? declaration : + declaration.kind === 178 /* PropertyAccessExpression */ ? ts.getAncestor(declaration, 193 /* BinaryExpression */) : + undefined; + if (!expression) { + return unknownType; + } + if (expression.flags & 65536 /* JavaScriptFile */) { + // If there is a JSDoc type, use it + var type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + return getWidenedType(type); + } + } + return getWidenedLiteralType(checkExpressionCached(expression.right)); + } // Return the type implied by a binding pattern element. This is the type of the initializer of the element if // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding // pattern. Otherwise, it is the type any. @@ -27428,11 +27884,11 @@ var ts; return; } var text = ts.getTextOfPropertyName(name); - var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0); + var flags = 4 /* Property */ | (e.initializer ? 67108864 /* Optional */ : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; - members[symbol.name] = symbol; + members.set(symbol.name, symbol); }); var result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { @@ -27467,7 +27923,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, includePatternInType, reportErrors) { - return pattern.kind === 172 /* ObjectBindingPattern */ + return pattern.kind === 173 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -27489,7 +27945,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. - if (declaration.kind === 258 /* PropertyAssignment */) { + if (declaration.kind === 260 /* PropertyAssignment */) { return type; } return getWidenedType(type); @@ -27506,14 +27962,14 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 144 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 145 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { // Handle prototype property - if (symbol.flags & 134217728 /* Prototype */) { + if (symbol.flags & 16777216 /* Prototype */) { return links.type = getTypeOfPrototypeProperty(symbol); } // Handle catch clause variables @@ -27522,10 +27978,10 @@ var ts; return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 241 /* ExportAssignment */) { + if (declaration.kind === 242 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 287 /* JSDocPropertyTag */ && declaration.typeExpression) { + if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 290 /* JSDocPropertyTag */ && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } // Handle variable, parameter or property @@ -27538,19 +27994,9 @@ var ts; // * exports.p = expr // * this.p = expr // * className.prototype.method = expr - if (declaration.kind === 192 /* BinaryExpression */ || - declaration.kind === 177 /* PropertyAccessExpression */ && declaration.parent.kind === 192 /* BinaryExpression */) { - // Use JS Doc type if present on parent expression statement - if (declaration.flags & 65536 /* JavaScriptFile */) { - var jsdocType = ts.getJSDocType(declaration.parent); - if (jsdocType) { - return links.type = getTypeFromTypeNode(jsdocType); - } - } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 192 /* BinaryExpression */ ? - checkExpressionCached(decl.right) : - checkExpressionCached(decl.parent.right); }); - type = getUnionType(declaredTypes, /*subtypeReduction*/ true); + if (declaration.kind === 193 /* BinaryExpression */ || + declaration.kind === 178 /* PropertyAccessExpression */ && declaration.parent.kind === 193 /* BinaryExpression */) { + type = getWidenedType(getUnionType(ts.map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), /*subtypeReduction*/ true)); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); @@ -27564,7 +28010,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 151 /* GetAccessor */) { + if (accessor.kind === 152 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -27584,10 +28030,10 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 151 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 152 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 152 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 153 /* SetAccessor */); if (getter && getter.flags & 65536 /* JavaScriptFile */) { - var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); + var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; } @@ -27629,7 +28075,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 151 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 152 /* 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)); } } @@ -27637,6 +28083,10 @@ var ts; } return links.type; } + function getBaseTypeVariableOfClass(symbol) { + var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); + return baseConstructorType.flags & 540672 /* TypeVariable */ ? baseConstructorType : undefined; + } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { @@ -27645,8 +28095,13 @@ var ts; } else { var type = createObjectType(16 /* Anonymous */, symbol); - links.type = strictNullChecks && symbol.flags & 536870912 /* Optional */ ? - includeFalsyTypes(type, 2048 /* Undefined */) : type; + if (symbol.flags & 32 /* Class */) { + var baseTypeVariable = getBaseTypeVariableOfClass(symbol); + links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; + } + else { + links.type = strictNullChecks && symbol.flags & 67108864 /* Optional */ ? includeFalsyTypes(type, 2048 /* Undefined */) : type; + } } } return links.type; @@ -27700,7 +28155,7 @@ var ts; return anyType; } function getTypeOfSymbol(symbol) { - if (symbol.flags & 16777216 /* Instantiated */) { + if (getCheckFlags(symbol) & 1 /* Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { @@ -27726,16 +28181,21 @@ var ts; function hasBaseType(type, checkBase) { return check(type); function check(type) { - var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); + if (getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + var target = getTargetType(type); + return target === checkBase || ts.forEach(getBaseTypes(target), check); + } + else if (type.flags & 131072 /* Intersection */) { + return ts.forEach(type.types, check); + } } } // Appends the type parameters given by a list of declarations to a set of type parameters and returns the resulting set. // The function allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set // in-place and returns the same array. function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { - var declaration = declarations_2[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -27755,9 +28215,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 227 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */ || - node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || - node.kind === 149 /* MethodDeclaration */ || node.kind === 185 /* ArrowFunction */) { + if (node.kind === 228 /* ClassDeclaration */ || node.kind === 198 /* ClassExpression */ || + node.kind === 227 /* FunctionDeclaration */ || node.kind === 185 /* FunctionExpression */ || + node.kind === 150 /* MethodDeclaration */ || node.kind === 186 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -27767,7 +28227,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, 228 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 229 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -27776,8 +28236,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 228 /* InterfaceDeclaration */ || node.kind === 227 /* ClassDeclaration */ || - node.kind === 197 /* ClassExpression */ || node.kind === 229 /* TypeAliasDeclaration */) { + if (node.kind === 229 /* InterfaceDeclaration */ || node.kind === 228 /* ClassDeclaration */ || + node.kind === 198 /* ClassExpression */ || node.kind === 230 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -27791,15 +28251,32 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } + // A type is a mixin constructor if it has a single construct signature taking no type parameters and a single + // rest parameter of type any[]. + function isMixinConstructorType(type) { + var signatures = getSignaturesOfType(type, 1 /* Construct */); + if (signatures.length === 1) { + var s = signatures[0]; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + } + return false; + } function isConstructorType(type) { - return type.flags & 32768 /* Object */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; + if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { + return true; + } + if (type.flags & 540672 /* TypeVariable */) { + var constraint = getBaseConstraintOfType(type); + return isValidBaseType(constraint) && isMixinConstructorType(constraint); + } + return false; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); } function getConstructorsForTypeArguments(type, typeArgumentNodes) { - var typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; - return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount; }); + var typeArgCount = ts.length(typeArgumentNodes); + return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); @@ -27826,7 +28303,7 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 32768 /* Object */) { + if (baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */)) { // 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. resolveStructuredTypeMembers(baseConstructorType); @@ -27864,8 +28341,8 @@ var ts; } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - var baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & 32768 /* Object */)) { + var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); + if (!(baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */))) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -27900,7 +28377,7 @@ var ts; if (baseType === unknownType) { return; } - if (!(getObjectFlags(getTargetType(baseType)) & 3 /* ClassOrInterface */)) { + if (!isValidBaseType(baseType)) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -27926,16 +28403,22 @@ var ts; } return true; } + // A valid base type is any non-generic object type or intersection of non-generic + // object types. + function isValidBaseType(type) { + return type.flags & (32768 /* Object */ | 16777216 /* NonPrimitive */) && !isGenericMappedType(type) || + type.flags & 131072 /* Intersection */ && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); + } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 228 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 229 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { - if (getObjectFlags(getTargetType(baseType)) & 3 /* ClassOrInterface */) { + if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -27962,7 +28445,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 228 /* InterfaceDeclaration */) { + if (declaration.kind === 229 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -28000,7 +28483,7 @@ var ts; type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384 /* TypeParameter */); @@ -28019,7 +28502,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 286 /* JSDocTypedefTag */); + var declaration = ts.getDeclarationOfKind(symbol, 289 /* JSDocTypedefTag */); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -28030,7 +28513,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 229 /* TypeAliasDeclaration */); + declaration = ts.getDeclarationOfKind(symbol, 230 /* TypeAliasDeclaration */); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -28040,7 +28523,7 @@ var ts; // an instantiation of the type alias with the type parameters supplied as type arguments. links.typeParameters = typeParameters; links.instantiations = ts.createMap(); - links.instantiations[getTypeListId(typeParameters)] = type; + links.instantiations.set(getTypeListId(typeParameters), type); } } else { @@ -28057,14 +28540,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 /* NumericLiteral */ || - expr.kind === 190 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 191 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */ || - expr.kind === 70 /* Identifier */ && !!symbol.exports[expr.text]; + expr.kind === 70 /* Identifier */ && !!symbol.exports.get(expr.text); } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 230 /* EnumDeclaration */) { + if (declaration.kind === 231 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -28089,10 +28572,10 @@ var ts; enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { var memberTypeList = []; - var memberTypes = ts.createMap(); + var memberTypes = []; for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 230 /* EnumDeclaration */) { + if (declaration.kind === 231 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -28109,7 +28592,7 @@ var ts; if (memberTypeList.length > 1) { enumType.flags |= 65536 /* Union */; enumType.types = memberTypeList; - unionTypes[getTypeListId(memberTypeList)] = enumType; + unionTypes.set(getTypeListId(memberTypeList), enumType); } } } @@ -28130,9 +28613,6 @@ var ts; if (!links.declaredType) { var type = createType(16384 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 143 /* TypeParameter */).constraint) { - type.constraint = noConstraintType; - } links.declaredType = type; } return links.declaredType; @@ -28145,7 +28625,6 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0); if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { return getDeclaredTypeOfClassOrInterface(symbol); } @@ -28184,19 +28663,20 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: + case 133 /* ObjectKeyword */: case 104 /* VoidKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 94 /* NullKeyword */: case 129 /* NeverKeyword */: - case 171 /* LiteralType */: + case 172 /* LiteralType */: return true; - case 162 /* ArrayType */: + case 163 /* ArrayType */: return isIndependentType(node.elementType); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -28209,7 +28689,7 @@ var ts; // A function-like declaration is considered independent (free of this references) if it has a return type // annotation that is considered independent and if each parameter is considered independent. function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 150 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 151 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -28230,12 +28710,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return isIndependentVariableLikeDeclaration(declaration); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -28246,7 +28726,7 @@ var ts; var result = ts.createMap(); for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { var symbol = symbols_1[_i]; - result[symbol.name] = symbol; + result.set(symbol.name, symbol); } return result; } @@ -28256,15 +28736,15 @@ var ts; var result = ts.createMap(); for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { var symbol = symbols_2[_i]; - result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); + result.set(symbol.name, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } function addInheritedMembers(symbols, baseSymbols) { for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { var s = baseSymbols_1[_i]; - if (!symbols[s.name]) { - symbols[s.name] = s; + if (!symbols.has(s.name)) { + symbols.set(s.name, s); } } } @@ -28272,8 +28752,8 @@ var ts; if (!type.declaredProperties) { var symbol = type.symbol; type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members.get("__call")); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members.get("__new")); type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0 /* String */); type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1 /* Number */); } @@ -28281,7 +28761,14 @@ var ts; } function getTypeWithThisArgument(type, thisArgument) { if (getObjectFlags(type) & 4 /* Reference */) { - return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + var target = type.target; + var typeArguments = type.typeArguments; + if (ts.length(target.typeParameters) === ts.length(typeArguments)) { + return createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); + } + } + else if (type.flags & 131072 /* Intersection */) { + return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument); })); } return type; } @@ -28317,7 +28804,7 @@ var ts; for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) { var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0 /* String */); @@ -28360,13 +28847,14 @@ var ts; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); - var typeArgCount = typeArguments ? typeArguments.length : 0; + var typeArgCount = ts.length(typeArguments); var result = []; for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { var baseSig = baseSignatures_1[_i]; - var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; - if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); + var typeParamCount = ts.length(baseSig.typeParameters); + if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -28429,7 +28917,7 @@ var ts; s = cloneSignature(signature); if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return getTypeOfSymbol(sig.thisParameter) || anyType; }), /*subtypeReduction*/ true); - s.thisParameter = createTransientSymbol(signature.thisParameter, thisType); + s.thisParameter = createSymbolWithType(signature.thisParameter, thisType); } // Clear resolved return type we possibly got from cloneSignature s.resolvedReturnType = undefined; @@ -28474,19 +28962,51 @@ var ts; function unionSpreadIndexInfos(info1, info2) { return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); } + function includeMixinType(type, types, index) { + var mixedTypes = []; + for (var i = 0; i < types.length; i++) { + if (i === index) { + mixedTypes.push(type); + } + else if (isMixinConstructorType(types[i])) { + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* Construct */)[0])); + } + } + return getIntersectionType(mixedTypes); + } 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 stringIndexInfo = undefined; - var numberIndexInfo = undefined; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + var stringIndexInfo; + var numberIndexInfo; + var types = type.types; + var mixinCount = ts.countWhere(types, isMixinConstructorType); + var _loop_3 = function (i) { + var t = type.types[i]; + // When an intersection type contains mixin constructor types, the construct signatures from + // those types are discarded and their return types are mixed into the return types of all + // other construct signatures in the intersection type. For example, the intersection type + // '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature + // 'new(s: string) => A & B'. + if (mixinCount === 0 || mixinCount === types.length && i === 0 || !isMixinConstructorType(t)) { + var signatures = getSignaturesOfType(t, 1 /* Construct */); + if (signatures.length && mixinCount > 0) { + signatures = ts.map(signatures, function (s) { + var clone = cloneSignature(s); + clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, i); + return clone; + }); + } + constructSignatures = ts.concatenate(constructSignatures, signatures); + } callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1 /* Construct */)); stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0 /* String */)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); + }; + for (var i = 0; i < types.length; i++) { + _loop_3(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } @@ -28505,8 +29025,8 @@ var ts; } else if (symbol.flags & 2048 /* TypeLiteral */) { var members = symbol.members; - var callSignatures = getSignaturesOfSymbol(members["__call"]); - var constructSignatures = getSignaturesOfSymbol(members["__new"]); + var callSignatures = getSignaturesOfSymbol(members.get("__call")); + var constructSignatures = getSignaturesOfSymbol(members.get("__new")); var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0 /* String */); var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1 /* Number */); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -28520,14 +29040,14 @@ var ts; } if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 32768 /* Object */) { + if (baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */ | 540672 /* TypeVariable */)) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); + addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } } var numberIndexInfo = symbol.flags & 384 /* Enum */ ? enumNumberIndexInfo : undefined; @@ -28552,12 +29072,15 @@ var ts; var typeParameter = getTypeParameterFromMappedType(type); var constraintType = getConstraintTypeFromMappedType(type); var templateType = getTemplateTypeFromMappedType(type); - var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); + var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateReadonly = !!type.declaration.readonlyToken; var templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === 168 /* TypeOperator */) { + if (type.declaration.typeParameter.constraint.kind === 169 /* TypeOperator */) { // We have a { [P in keyof T]: X } - forEachType(getLiteralTypeFromPropertyNames(modifiersType), addMemberForKeyType); + for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { + var propertySymbol = _a[_i]; + addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); + } if (getIndexInfoOfType(modifiersType, 0 /* String */)) { addMemberForKeyType(stringType); } @@ -28571,11 +29094,11 @@ var ts; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t) { + function addMemberForKeyType(t, propertySymbol) { // Create a mapper from T to the current iteration type constituent. Then, if the // mapped type is itself an instantiated type, combine the iteration mapper with the // instantiation mapper. - var iterationMapper = createUnaryTypeMapper(typeParameter, t); + var iterationMapper = createTypeMapper([typeParameter], [t]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; var propType = instantiateType(templateType, templateMapper); // If the current iteration type constituent is a string literal type, create a property. @@ -28583,11 +29106,14 @@ var ts; if (t.flags & 32 /* StringLiteral */) { var propName = t.text; var modifiersProp = getPropertyOfType(modifiersType, propName); - var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 536870912 /* Optional */); - var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | (isOptional ? 536870912 /* Optional */ : 0), propName); + var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 67108864 /* Optional */); + var prop = createSymbol(4 /* Property */ | (isOptional ? 67108864 /* Optional */ : 0), propName); + prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 4 /* Readonly */ : 0; prop.type = propType; - prop.isReadonly = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp); - members[propName] = prop; + if (propertySymbol) { + prop.mappedTypeOrigin = propertySymbol; + } + members.set(propName, prop); } else if (t.flags & 2 /* String */) { stringIndexInfo = createIndexInfo(propType, templateReadonly); @@ -28611,7 +29137,7 @@ var ts; function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { var constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === 168 /* TypeOperator */) { + if (constraintDeclaration.kind === 169 /* TypeOperator */) { // If the constraint declaration is a 'keyof T' node, the modifiers type is T. We check // AST nodes here because, when T is a non-generic type, the logic below eagerly resolves // 'keyof T' to a literal union type and we can't recover T from that type. @@ -28629,9 +29155,6 @@ var ts; } return type.modifiersType; } - function getErasedTemplateTypeFromMappedType(type) { - return instantiateType(getTemplateTypeFromMappedType(type), createUnaryTypeMapper(getTypeParameterFromMappedType(type), anyType)); - } function isGenericMappedType(type) { if (getObjectFlags(type) & 32 /* Mapped */) { var constraintType = getConstraintTypeFromMappedType(type); @@ -28676,38 +29199,35 @@ var ts; function getPropertyOfObjectType(type, name) { if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } } } 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]; - getUnionOrIntersectionProperty(type, prop.name); - } - // 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 & 65536 /* Union */) { - break; - } - } - var props = type.resolvedProperties; - if (props) { - var result = []; - for (var key in props) { - var prop = props[key]; - // We need to filter out partial properties in union types - if (!(prop.flags & 268435456 /* SyntheticProperty */ && prop.isPartial)) { - result.push(prop); + if (!type.resolvedProperties) { + var members = ts.createMap(); + 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]; + if (!members.has(prop.name)) { + var combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.name); + if (combinedProp) { + members.set(prop.name, combinedProp); + } + } + } + // 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 & 65536 /* Union */) { + break; } } - return result; + type.resolvedProperties = getNamedMembers(members); } - return emptyArray; + return type.resolvedProperties; } function getPropertiesOfType(type) { type = getApparentType(type); @@ -28715,19 +29235,99 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } + function getConstraintOfType(type) { + return type.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + } + function getConstraintOfTypeParameter(typeParameter) { + return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; + } + function getBaseConstraintOfType(type) { + var constraint = getResolvedBaseConstraint(type); + return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + } + function hasNonCircularBaseConstraint(type) { + return getResolvedBaseConstraint(type) !== circularConstraintType; + } /** - * The apparent type of a type parameter is the base constraint instantiated with the type parameter - * as the type argument for the 'this' type. + * Return the resolved base constraint of a type variable. The noConstraintType singleton is returned if the + * type variable has no constraint, and the circularConstraintType singleton is returned if the constraint + * circularly references the type variable. */ - function getApparentTypeOfTypeVariable(type) { - if (!type.resolvedApparentType) { - var constraintType = getConstraintOfTypeVariable(type); - while (constraintType && constraintType.flags & 16384 /* TypeParameter */) { - constraintType = getConstraintOfTypeVariable(constraintType); - } - type.resolvedApparentType = getTypeWithThisArgument(constraintType || emptyObjectType, type); + function getResolvedBaseConstraint(type) { + var typeStack; + var circular; + if (!type.resolvedBaseConstraint) { + typeStack = []; + var constraint = getBaseConstraint(type); + type.resolvedBaseConstraint = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type); } - return type.resolvedApparentType; + return type.resolvedBaseConstraint; + function getBaseConstraint(t) { + if (ts.contains(typeStack, t)) { + circular = true; + return undefined; + } + typeStack.push(t); + var result = computeBaseConstraint(t); + typeStack.pop(); + return result; + } + function computeBaseConstraint(t) { + if (t.flags & 16384 /* TypeParameter */) { + var constraint = getConstraintFromTypeParameter(t); + return t.isThisType ? constraint : + constraint ? getBaseConstraint(constraint) : undefined; + } + if (t.flags & 196608 /* UnionOrIntersection */) { + var types = t.types; + var baseTypes = []; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var type_1 = types_2[_i]; + var baseType = getBaseConstraint(type_1); + if (baseType) { + baseTypes.push(baseType); + } + } + return t.flags & 65536 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 131072 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + undefined; + } + if (t.flags & 262144 /* Index */) { + return stringType; + } + if (t.flags & 524288 /* IndexedAccess */) { + var baseObjectType = getBaseConstraint(t.objectType); + var baseIndexType = getBaseConstraint(t.indexType); + var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; + return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + } + return t; + } + } + function getApparentTypeOfIntersectionType(type) { + return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type)); + } + /** + * Gets the default type for a type parameter. + * + * If the type parameter is the result of an instantiation, this gets the instantiated + * default type of its target. If the type parameter has no default type, `undefined` + * is returned. + * + * This function *does not* perform a circularity check. + */ + function getDefaultFromTypeParameter(typeParameter) { + if (!typeParameter.default) { + if (typeParameter.target) { + var targetDefault = getDefaultFromTypeParameter(typeParameter.target); + typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType; + } + else { + var defaultDeclaration = typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameter(decl) && decl.default; }); + typeParameter.default = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType; + } + } + return typeParameter.default === noConstraintType ? undefined : typeParameter.default; } /** * For a type parameter, return the base constraint of the type parameter. For the string, number, @@ -28735,26 +29335,30 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - var t = type.flags & 540672 /* TypeVariable */ ? getApparentTypeOfTypeVariable(type) : type; - return t.flags & 262178 /* StringLike */ ? globalStringType : - t.flags & 340 /* NumberLike */ ? globalNumberType : - t.flags & 136 /* BooleanLike */ ? globalBooleanType : - t.flags & 512 /* ESSymbol */ ? getGlobalESSymbolType() : - t; + var t = type.flags & 540672 /* TypeVariable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; + return t.flags & 131072 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 262178 /* StringLike */ ? globalStringType : + t.flags & 340 /* NumberLike */ ? globalNumberType : + t.flags & 136 /* BooleanLike */ ? globalBooleanType : + t.flags & 512 /* ESSymbol */ ? getGlobalESSymbolType() : + t.flags & 16777216 /* NonPrimitive */ ? emptyObjectType : + t; } function createUnionOrIntersectionProperty(containingType, name) { - var types = containingType.types; var props; + var types = containingType.types; + var isUnion = containingType.flags & 65536 /* Union */; + var excludeModifiers = isUnion ? 24 /* NonPublicAccessibilityModifier */ : 0; // Flags we want to propagate to the result if they exist in all source symbols - var commonFlags = (containingType.flags & 131072 /* Intersection */) ? 536870912 /* Optional */ : 0 /* None */; - var isReadonly = false; - var isPartial = false; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var current = types_2[_i]; + var commonFlags = isUnion ? 0 /* None */ : 67108864 /* Optional */; + var checkFlags = 2 /* SyntheticProperty */; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var current = types_3[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */))) { + var modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0; + if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; if (!props) { props = [prop]; @@ -28762,25 +29366,26 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } - if (isReadonlySymbol(prop)) { - isReadonly = true; - } + checkFlags |= (isReadonlySymbol(prop) ? 4 /* Readonly */ : 0) | + (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 32 /* ContainsPublic */ : 0) | + (modifiers & 16 /* Protected */ ? 64 /* ContainsProtected */ : 0) | + (modifiers & 8 /* Private */ ? 128 /* ContainsPrivate */ : 0) | + (modifiers & 32 /* Static */ ? 256 /* ContainsStatic */ : 0); } - else if (containingType.flags & 65536 /* Union */) { - isPartial = true; + else if (isUnion) { + checkFlags |= 8 /* Partial */; } } } if (!props) { return undefined; } - if (props.length === 1 && !isPartial) { + if (props.length === 1 && !(checkFlags & 8 /* Partial */)) { return props[0]; } var propTypes = []; var declarations = []; var commonType = undefined; - var hasNonUniformType = false; for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; if (prop.declarations) { @@ -28791,17 +29396,15 @@ var ts; commonType = type; } else if (type !== commonType) { - hasNonUniformType = true; + checkFlags |= 16 /* HasNonUniformType */; } propTypes.push(type); } - var result = createSymbol(4 /* Property */ | 67108864 /* Transient */ | 268435456 /* SyntheticProperty */ | commonFlags, name); + var result = createSymbol(4 /* Property */ | commonFlags, name); + result.checkFlags = checkFlags; result.containingType = containingType; - result.hasNonUniformType = hasNonUniformType; - result.isPartial = isPartial; result.declarations = declarations; - result.isReadonly = isReadonly; - result.type = containingType.flags & 65536 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } // Return the symbol for a given property in a union or intersection type, or undefined if the property @@ -28810,12 +29413,12 @@ var ts; // these partial properties when identifying discriminant properties, but otherwise they are filtered out // and do not appear to be present in the union type. function getUnionOrIntersectionProperty(type, name) { - var properties = type.resolvedProperties || (type.resolvedProperties = ts.createMap()); - var property = properties[name]; + var properties = type.propertyCache || (type.propertyCache = ts.createMap()); + var property = properties.get(name); if (!property) { property = createUnionOrIntersectionProperty(type, name); if (property) { - properties[name] = property; + properties.set(name, property); } } return property; @@ -28823,7 +29426,7 @@ var ts; function getPropertyOfUnionOrIntersectionType(type, name) { var property = getUnionOrIntersectionProperty(type, name); // We need to filter out partial properties in union types - return property && !(property.flags & 268435456 /* SyntheticProperty */ && property.isPartial) ? property : undefined; + return property && !(getCheckFlags(property) & 8 /* Partial */) ? property : undefined; } /** * Return the symbol for the property with the given name in the given type. Creates synthetic union properties when @@ -28837,7 +29440,7 @@ var ts; type = getApparentType(type); if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } @@ -28926,16 +29529,16 @@ var ts; } function symbolsToArray(symbols) { var result = []; - for (var id in symbols) { + symbols.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { - result.push(symbols[id]); + result.push(symbol); } - } + }); return result; } function isJSDocOptionalParameter(node) { if (node.flags & 65536 /* JavaScriptFile */) { - if (node.type && node.type.kind === 274 /* JSDocOptionalType */) { + if (node.type && node.type.kind === 277 /* JSDocOptionalType */) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -28946,7 +29549,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 274 /* JSDocOptionalType */; + return paramTag.typeExpression.type.kind === 277 /* JSDocOptionalType */; } } } @@ -28971,6 +29574,12 @@ var ts; ts.Debug.assert(parameterIndex >= 0); return parameterIndex >= signature.minArgumentCount; } + var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); + if (iife) { + return !node.type && + !node.dotDotDotToken && + ts.indexOf(node.parent.parameters, node) >= iife.arguments.length; + } return false; } function createTypePredicateFromTypePredicateNode(node) { @@ -28990,15 +29599,63 @@ var ts; }; } } + /** + * Gets the minimum number of type arguments needed to satisfy all non-optional type + * parameters. + */ + function getMinTypeArgumentCount(typeParameters) { + var minTypeArgumentCount = 0; + if (typeParameters) { + for (var i = 0; i < typeParameters.length; i++) { + if (!getDefaultFromTypeParameter(typeParameters[i])) { + minTypeArgumentCount = i + 1; + } + } + } + return minTypeArgumentCount; + } + /** + * Fill in default types for unsupplied type arguments. If `typeArguments` is undefined + * when a default type is supplied, a new array will be created and returned. + * + * @param typeArguments The supplied type arguments. + * @param typeParameters The requested type parameters. + * @param minTypeArgumentCount The minimum number of required type arguments. + */ + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount) { + var numTypeParameters = ts.length(typeParameters); + if (numTypeParameters) { + var numTypeArguments = ts.length(typeArguments); + if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + if (!typeArguments) { + typeArguments = []; + } + // Map an unsatisfied type parameter with a default type. + // If a type parameter does not have a default type, or if the default type + // is a forward reference, the empty object type is used. + for (var i = numTypeArguments; i < numTypeParameters; i++) { + typeArguments[i] = emptyObjectType; + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + var mapper = createTypeMapper(typeParameters, typeArguments); + var defaultType = getDefaultFromTypeParameter(typeParameters[i]); + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + } + } + } + return typeArguments; + } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; var hasLiteralTypes = false; - var minArgumentCount = -1; + var minArgumentCount = 0; var thisParameter = undefined; var hasThisParameter = void 0; + var iife = ts.getImmediatelyInvokedFunctionExpression(declaration); var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); + var isUntypedSignatureInJSFile = !iife && !isJSConstructSignature && ts.isInJavaScriptFile(declaration) && !ts.hasJSDocParameterTags(declaration); // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct // signature. @@ -29017,43 +29674,36 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 171 /* LiteralType */) { + if (param.type && param.type.kind === 172 /* LiteralType */) { hasLiteralTypes = true; } - if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { - if (minArgumentCount < 0) { - minArgumentCount = i - (hasThisParameter ? 1 : 0); - } - } - else { - // If we see any required parameters, it means the prior ones were not in fact optional. - minArgumentCount = -1; + // Record a new minimum argument count if this is not an optional parameter + var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken || + iife && parameters.length > iife.arguments.length && !param.type || + isJSDocOptionalParameter(param) || + isUntypedSignatureInJSFile; + if (!isOptionalParameter_1) { + minArgumentCount = parameters.length; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 151 /* GetAccessor */ || declaration.kind === 152 /* SetAccessor */) && + if ((declaration.kind === 152 /* GetAccessor */ || declaration.kind === 153 /* SetAccessor */) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 151 /* GetAccessor */ ? 152 /* SetAccessor */ : 151 /* GetAccessor */; + var otherKind = declaration.kind === 152 /* GetAccessor */ ? 153 /* SetAccessor */ : 152 /* GetAccessor */; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); - } - if (isJSConstructSignature) { - minArgumentCount--; - } - var classType = declaration.kind === 150 /* Constructor */ ? + var classType = declaration.kind === 151 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 156 /* TypePredicate */ ? + var typePredicate = declaration.type && declaration.type.kind === 157 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -29078,8 +29728,8 @@ var ts; } // 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 === 151 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 152 /* SetAccessor */); + if (declaration.kind === 152 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 153 /* SetAccessor */); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -29093,20 +29743,20 @@ var ts; for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 226 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 275 /* JSDocFunctionType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 278 /* JSDocFunctionType */: // 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). @@ -29177,9 +29827,14 @@ var ts; return anyType; } function getSignatureInstantiation(signature, typeArguments) { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); - return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + var instantiation = instantiations.get(id); + if (!instantiation) { + instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments)); + } + return instantiation; } function createSignatureInstantiation(signature, typeArguments) { return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), /*eraseTypeParameters*/ true); @@ -29198,7 +29853,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 150 /* Constructor */ || signature.declaration.kind === 154 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 151 /* Constructor */ || signature.declaration.kind === 155 /* ConstructSignature */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = emptyArray; @@ -29209,10 +29864,10 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members["__index"]; + return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 132 /* NumberKeyword */ : 134 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 132 /* NumberKeyword */ : 135 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -29239,21 +29894,9 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 143 /* TypeParameter */).constraint; + return ts.getDeclarationOfKind(type.symbol, 144 /* TypeParameter */).constraint; } - function hasConstraintReferenceTo(type, target) { - var checked; - while (type && type.flags & 16384 /* TypeParameter */ && !(type.isThisType) && !ts.contains(checked, type)) { - if (type === target) { - return true; - } - (checked || (checked = [])).push(type); - var constraintDeclaration = getConstraintDeclaration(type); - type = constraintDeclaration && getTypeFromTypeNode(constraintDeclaration); - } - return false; - } - function getConstraintOfTypeParameter(typeParameter) { + function getConstraintFromTypeParameter(typeParameter) { if (!typeParameter.constraint) { if (typeParameter.target) { var targetConstraint = getConstraintOfTypeParameter(typeParameter.target); @@ -29261,23 +29904,13 @@ var ts; } else { var constraintDeclaration = getConstraintDeclaration(typeParameter); - var constraint = getTypeFromTypeNode(constraintDeclaration); - if (hasConstraintReferenceTo(constraint, typeParameter)) { - error(constraintDeclaration, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); - constraint = unknownType; - } - typeParameter.constraint = constraint; + typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : noConstraintType; } } return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } - function getConstraintOfTypeVariable(type) { - return type.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 524288 /* IndexedAccess */ ? type.constraint : - undefined; - } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 143 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 144 /* TypeParameter */).parent); } function getTypeListId(types) { var result = ""; @@ -29308,8 +29941,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var type = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -29318,9 +29951,10 @@ var ts; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); - var type = target.instantiations[id]; + var type = target.instantiations.get(id); if (!type) { - type = target.instantiations[id] = createObjectType(4 /* Reference */, target.symbol); + type = createObjectType(4 /* Reference */, target.symbol); + target.instantiations.set(id, type); type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; type.typeArguments = typeArguments; @@ -29336,21 +29970,26 @@ var ts; return type; } function getTypeReferenceArity(type) { - return type.target.typeParameters ? type.target.typeParameters.length : 0; + return ts.length(type.target.typeParameters); } // Get type from reference to class or interface function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), minTypeArgumentCount, typeParameters.length); return unknownType; } // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + return createTypeReference(type, typeArguments); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -29363,7 +30002,11 @@ var ts; var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + var instantiation = links.instantiations.get(id); + if (!instantiation) { + links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + } + return instantiation; } // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include // references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the @@ -29372,8 +30015,12 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { - if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return unknownType; } var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); @@ -29395,11 +30042,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 157 /* TypeReference */: + case 158 /* TypeReference */: return node.typeName; - case 273 /* JSDocTypeReference */: + case 276 /* JSDocTypeReference */: return node.name; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -29425,7 +30072,7 @@ var ts; if (symbol.flags & 524288 /* TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 /* Value */ && node.kind === 273 /* JSDocTypeReference */) { + if (symbol.flags & 107455 /* Value */ && node.kind === 276 /* JSDocTypeReference */) { // A JSDocTypeReference may have resolved to a value (as opposed to a type). In // that case, the type of this reference is just the type of the value we resolved // to. @@ -29438,14 +30085,14 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 273 /* JSDocTypeReference */) { + if (node.kind === 276 /* JSDocTypeReference */) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 157 /* TypeReference */ + var typeNameOrExpression = node.kind === 158 /* TypeReference */ ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -29477,12 +30124,12 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var declaration = declarations_4[_i]; switch (declaration.kind) { - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 230 /* EnumDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: return declaration; } } @@ -29495,7 +30142,7 @@ var ts; error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return arity ? emptyGenericType : emptyObjectType; } - if ((type.typeParameters ? type.typeParameters.length : 0) !== arity) { + if (ts.length(type.typeParameters) !== arity) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); return arity ? emptyGenericType : emptyObjectType; } @@ -29567,7 +30214,7 @@ var ts; for (var i = 0; i < arity; i++) { var typeParameter = createType(16384 /* TypeParameter */); typeParameters.push(typeParameter); - var property = createSymbol(4 /* Property */ | 67108864 /* Transient */, "" + i); + var property = createSymbol(4 /* Property */, "" + i); property.type = typeParameter; properties.push(property); } @@ -29576,7 +30223,7 @@ var ts; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384 /* TypeParameter */); @@ -29660,14 +30307,14 @@ var ts; // 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 addTypesToUnion(typeSet, types) { - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var t = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var t = types_6[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -29675,8 +30322,8 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } @@ -29763,10 +30410,11 @@ var ts; return types[0]; } var id = getTypeListId(types); - var type = unionTypes[id]; + var type = unionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 6144 /* Nullable */); - type = unionTypes[id] = createType(65536 /* Union */ | propagatedFlags); + type = createType(65536 /* Union */ | propagatedFlags); + unionTypes.set(id, type); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -29791,14 +30439,17 @@ var ts; if (type.flags & 65536 /* Union */ && typeSet.unionIndex === undefined) { typeSet.unionIndex = typeSet.length; } - typeSet.push(type); + if (!(type.flags & 32768 /* Object */ && type.objectFlags & 16 /* Anonymous */ && + type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */) && containsIdenticalType(typeSet, type))) { + typeSet.push(type); + } } } // 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 addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; addTypeToIntersection(typeSet, type); } } @@ -29833,10 +30484,11 @@ var ts; /*subtypeReduction*/ false, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); - var type = intersectionTypes[id]; + var type = intersectionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 6144 /* Nullable */); - type = intersectionTypes[id] = createType(131072 /* Intersection */ | propagatedFlags); + type = createType(131072 /* Intersection */ | propagatedFlags); + intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -29886,28 +30538,10 @@ var ts; var type = createType(524288 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; - // We eagerly compute the constraint of the indexed access type such that circularity - // errors are immediately caught and reported. For example, class C { x: this["x"] } - // becomes an error only when the constraint is eagerly computed. - if (type.objectType.flags & 229376 /* StructuredType */) { - // The constraint of T[K], where T is an object, union, or intersection type, - // is the type of the string index signature of T, if any. - type.constraint = getIndexTypeOfType(type.objectType, 0 /* String */); - } - else if (type.objectType.flags & 540672 /* TypeVariable */) { - // The constraint of T[K], where T is a type variable, is A[K], where A is the - // apparent type of T. - var apparentType = getApparentTypeOfTypeVariable(type.objectType); - if (apparentType !== emptyObjectType) { - type.constraint = isTypeOfKind(type.indexType, 262178 /* StringLike */) ? - getIndexedAccessType(apparentType, type.indexType) : - getIndexTypeOfType(apparentType, 0 /* String */); - } - } return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 178 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode : undefined; var propName = indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */ | 256 /* EnumLiteral */) ? indexType.text : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -29955,7 +30589,7 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 178 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); } @@ -29969,12 +30603,12 @@ var ts; return unknownType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 178 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode : undefined; if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; } - var mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); + var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } @@ -29986,18 +30620,11 @@ var ts; // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. if (maybeTypeOfKind(indexType, 540672 /* TypeVariable */ | 262144 /* Index */) || - maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && !(accessNode && accessNode.kind === 178 /* ElementAccessExpression */) || + maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && !(accessNode && accessNode.kind === 179 /* ElementAccessExpression */) || isGenericMappedType(objectType)) { if (objectType.flags & 1 /* Any */) { return objectType; } - // We first check that the index type is assignable to 'keyof T' for the object type. - if (accessNode) { - if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { - error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); - return unknownType; - } - } // If the object type is a mapped type { [P in K]: E }, we instantiate E using a mapper that substitutes // the index type for P. For example, for an index access { [P in K]: Box }[X], we construct the // type Box. @@ -30006,7 +30633,11 @@ var ts; } // Otherwise we defer the operation by creating an indexed access type. var id = objectType.id + "," + indexType.id; - return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType)); + var type = indexedAccessTypes.get(id); + if (!type) { + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType)); + } + return type; } // In the following we resolve T[K] to the type of the property in T selected by K. var apparentObjectType = getApparentType(objectType); @@ -30050,7 +30681,7 @@ var ts; if (!links.resolvedType) { // Deferred resolution of members is handled by resolveObjectTypeMembers var aliasSymbol = getAliasSymbolForTypeNode(node); - if (ts.isEmpty(node.symbol.members) && !aliasSymbol) { + if (node.symbol.members.size === 0 && !aliasSymbol) { links.resolvedType = emptyTypeLiteralType; } else { @@ -30063,7 +30694,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 229 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 230 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -30074,7 +30705,7 @@ var ts; * this function should be called in a left folding style, with left = previous result of getSpreadType * and right = the new element to be spread. */ - function getSpreadType(left, right, isFromObjectLiteral) { + function getSpreadType(left, right) { if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { return anyType; } @@ -30087,10 +30718,13 @@ var ts; return left; } if (left.flags & 65536 /* Union */) { - return mapType(left, function (t) { return getSpreadType(t, right, isFromObjectLiteral); }); + return mapType(left, function (t) { return getSpreadType(t, right); }); } if (right.flags & 65536 /* Union */) { - return mapType(right, function (t) { return getSpreadType(left, t, isFromObjectLiteral); }); + return mapType(right, function (t) { return getSpreadType(left, t); }); + } + if (right.flags & 16777216 /* NonPrimitive */) { + return emptyObjectType; } var members = ts.createMap(); var skippedPrivateMembers = ts.createMap(); @@ -30108,42 +30742,45 @@ var ts; for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; // we approximate own properties as non-methods plus methods that are inside the object literal - var isOwnProperty = !(rightProp.flags & 8192 /* Method */) || isFromObjectLiteral; var isSetterWithoutGetter = rightProp.flags & 65536 /* SetAccessor */ && !(rightProp.flags & 32768 /* GetAccessor */); if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { - skippedPrivateMembers[rightProp.name] = true; + skippedPrivateMembers.set(rightProp.name, true); } - else if (isOwnProperty && !isSetterWithoutGetter) { - members[rightProp.name] = rightProp; + else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { + members.set(rightProp.name, rightProp); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { var leftProp = _c[_b]; if (leftProp.flags & 65536 /* SetAccessor */ && !(leftProp.flags & 32768 /* GetAccessor */) - || leftProp.name in skippedPrivateMembers) { + || skippedPrivateMembers.has(leftProp.name) + || isClassMethod(leftProp)) { continue; } - if (leftProp.name in members) { - var rightProp = members[leftProp.name]; + if (members.has(leftProp.name)) { + var rightProp = members.get(leftProp.name); var rightType = getTypeOfSymbol(rightProp); - if (maybeTypeOfKind(rightType, 2048 /* Undefined */) || rightProp.flags & 536870912 /* Optional */) { + if (maybeTypeOfKind(rightType, 2048 /* Undefined */) || rightProp.flags & 67108864 /* Optional */) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 /* Property */ | 67108864 /* Transient */ | (leftProp.flags & 536870912 /* Optional */); + var flags = 4 /* Property */ | (leftProp.flags & 67108864 /* Optional */); var result = createSymbol(flags, leftProp.name); + result.checkFlags = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp) ? 4 /* Readonly */ : 0; result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072 /* NEUndefined */)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; - result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); - members[leftProp.name] = result; + members.set(leftProp.name, result); } } else { - members[leftProp.name] = leftProp; + members.set(leftProp.name, leftProp); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function isClassMethod(prop) { + return prop.flags & 8192 /* Method */ && ts.find(prop.declarations, function (decl) { return ts.isClassLike(decl.parent); }); + } function createLiteralType(flags, text) { var type = createType(flags); type.text = text; @@ -30165,7 +30802,11 @@ var ts; } function getLiteralTypeForText(flags, text) { var map = flags & 32 /* StringLiteral */ ? stringLiteralTypes : numericLiteralTypes; - return map[text] || (map[text] = createLiteralType(flags, text)); + var type = map.get(text); + if (!type) { + map.set(text, type = createLiteralType(flags, text)); + } + return type; } function getTypeFromLiteralTypeNode(node) { var links = getNodeLinks(node); @@ -30193,9 +30834,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 228 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 229 /* InterfaceDeclaration */)) { if (!(ts.getModifierFlags(container) & 32 /* Static */) && - (container.kind !== 150 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 151 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -30212,87 +30853,89 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118 /* AnyKeyword */: - case 264 /* JSDocAllType */: - case 265 /* JSDocUnknownType */: + case 267 /* JSDocAllType */: + case 268 /* JSDocUnknownType */: return anyType; - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: return stringType; case 132 /* NumberKeyword */: return numberType; case 121 /* BooleanKeyword */: return booleanType; - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: return esSymbolType; case 104 /* VoidKeyword */: return voidType; - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: return undefinedType; case 94 /* NullKeyword */: return nullType; case 129 /* NeverKeyword */: return neverType; - case 290 /* JSDocNullKeyword */: + case 133 /* ObjectKeyword */: + return nonPrimitiveType; + case 293 /* JSDocNullKeyword */: return nullType; - case 291 /* JSDocUndefinedKeyword */: + case 294 /* JSDocUndefinedKeyword */: return undefinedType; - case 292 /* JSDocNeverKeyword */: + case 295 /* JSDocNeverKeyword */: return neverType; - case 167 /* ThisType */: + case 168 /* ThisType */: case 98 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 171 /* LiteralType */: + case 172 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 289 /* JSDocLiteralType */: + case 292 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); - case 157 /* TypeReference */: - case 273 /* JSDocTypeReference */: + case 158 /* TypeReference */: + case 276 /* JSDocTypeReference */: return getTypeFromTypeReference(node); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return booleanType; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 162 /* ArrayType */: - case 266 /* JSDocArrayType */: + case 163 /* ArrayType */: + case 269 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); - case 163 /* TupleType */: + case 164 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 164 /* UnionType */: - case 267 /* JSDocUnionType */: + case 165 /* UnionType */: + case 270 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node); - case 165 /* IntersectionType */: + case 166 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 166 /* ParenthesizedType */: - case 269 /* JSDocNullableType */: - case 270 /* JSDocNonNullableType */: - case 277 /* JSDocConstructorType */: - case 278 /* JSDocThisType */: - case 274 /* JSDocOptionalType */: + case 167 /* ParenthesizedType */: + case 272 /* JSDocNullableType */: + case 273 /* JSDocNonNullableType */: + case 280 /* JSDocConstructorType */: + case 281 /* JSDocThisType */: + case 277 /* JSDocOptionalType */: return getTypeFromTypeNode(node.type); - case 271 /* JSDocRecordType */: + case 274 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 161 /* TypeLiteral */: - case 288 /* JSDocTypeLiteral */: - case 275 /* JSDocFunctionType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 162 /* TypeLiteral */: + case 291 /* JSDocTypeLiteral */: + case 278 /* JSDocFunctionType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 168 /* TypeOperator */: + case 169 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 170 /* MappedType */: + case 171 /* MappedType */: return getTypeFromMappedTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 70 /* Identifier */: - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 268 /* JSDocTupleType */: + case 271 /* JSDocTupleType */: return getTypeFromJSDocTupleType(node); - case 276 /* JSDocVariadicType */: + case 279 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -30319,13 +30962,13 @@ var ts; var instantiations = mapper.instantiations || (mapper.instantiations = []); return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); } - function createUnaryTypeMapper(source, target) { + function makeUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } - function createBinaryTypeMapper(source1, target1, source2, target2) { + function makeBinaryTypeMapper(source1, target1, source2, target2) { return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; } - function createArrayTypeMapper(sources, targets) { + function makeArrayTypeMapper(sources, targets) { return function (t) { for (var i = 0; i < sources.length; i++) { if (t === sources[i]) { @@ -30336,16 +30979,24 @@ var ts; }; } function createTypeMapper(sources, targets) { - var count = sources.length; - var mapper = count == 1 ? createUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : - count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - createArrayTypeMapper(sources, targets); + var mapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : + makeArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; return mapper; } function createTypeEraser(sources) { return createTypeMapper(sources, undefined); } + /** + * Maps forward-references to later types parameters to the empty object type. + * This is used during inference when instantiating type parameter defaults. + */ + function createBackreferenceMapper(typeParameters, index) { + var mapper = function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; + mapper.mappedTypes = typeParameters; + return mapper; + } function getInferenceMapper(context) { if (!context.mapper) { var mapper = function (t) { @@ -30369,7 +31020,12 @@ var ts; } function combineTypeMappers(mapper1, mapper2) { var mapper = function (t) { return instantiateType(mapper1(t), mapper2); }; - mapper.mappedTypes = mapper1.mappedTypes; + mapper.mappedTypes = ts.concatenate(mapper1.mappedTypes, mapper2.mappedTypes); + return mapper; + } + function createReplacementMapper(source, target, baseMapper) { + var mapper = function (t) { return t === source ? target : baseMapper(t); }; + mapper.mappedTypes = baseMapper.mappedTypes; return mapper; } function cloneTypeParameter(typeParameter) { @@ -30417,7 +31073,7 @@ var ts; return result; } function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 16777216 /* Instantiated */) { + if (getCheckFlags(symbol) & 1 /* Instantiated */) { var links = getSymbolLinks(symbol); // If symbol being instantiated is itself a instantiation, fetch the original target and combine the // type mappers. This ensures that original type identities are properly preserved and that aliases @@ -30427,7 +31083,8 @@ var ts; } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(16777216 /* Instantiated */ | 67108864 /* Transient */ | symbol.flags, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); + result.checkFlags = 1 /* Instantiated */; result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -30459,10 +31116,7 @@ var ts; if (typeVariable_1 !== mappedTypeVariable) { return mapType(mappedTypeVariable, function (t) { if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); + return instantiateMappedObjectType(type, createReplacementMapper(typeVariable_1, t, mapper)); } return t; }); @@ -30493,23 +31147,23 @@ var ts; var node = symbol.declarations[0]; while (node) { switch (node.kind) { - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 226 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 228 /* InterfaceDeclaration */: - case 229 /* TypeAliasDeclaration */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -30519,14 +31173,19 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 228 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 229 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 275 /* JSDocFunctionType */: + case 171 /* MappedType */: + if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { + return true; + } + break; + case 278 /* JSDocFunctionType */: var func = node; for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { var p = _c[_b]; @@ -30535,8 +31194,8 @@ var ts; } } break; - case 231 /* ModuleDeclaration */: - case 262 /* SourceFile */: + case 232 /* ModuleDeclaration */: + case 264 /* SourceFile */: return false; } node = node.parent; @@ -30546,7 +31205,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 262 /* SourceFile */ || parentKind === 232 /* ModuleBlock */; + return parentKind === 264 /* SourceFile */ || parentKind === 233 /* ModuleBlock */; } return false; } @@ -30623,28 +31282,36 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return node.operatorToken.kind === 53 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return isContextSensitive(node.expression); + case 253 /* JsxAttributes */: + return ts.forEach(node.properties, isContextSensitive); + case 252 /* JsxAttribute */: + // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. + return node.initializer && isContextSensitive(node.initializer); + case 255 /* JsxExpression */: + // It is possible to that node.expression is undefined (e.g
) + return node.expression && isContextSensitive(node.expression); } return false; } @@ -30658,7 +31325,7 @@ var ts; return true; } // For arrow functions we now know we're not context sensitive. - if (node.kind === 185 /* ArrowFunction */) { + if (node.kind === 186 /* ArrowFunction */) { return false; } // If the first parameter is not an explicit 'this' parameter, then the function has @@ -30680,9 +31347,12 @@ var ts; result.properties = resolved.properties; result.callSignatures = emptyArray; result.constructSignatures = emptyArray; - type = result; + return result; } } + else if (type.flags & 131072 /* Intersection */) { + return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); + } return type; } // TYPE CHECKING @@ -30873,13 +31543,15 @@ var ts; return true; } var id = source.id + "," + target.id; - if (enumRelation[id] !== undefined) { - return enumRelation[id]; + var relation = enumRelation.get(id); + if (relation !== undefined) { + return relation; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & 256 /* RegularEnum */) || !(target.symbol.flags & 256 /* RegularEnum */) || (source.flags & 65536 /* Union */) !== (target.flags & 65536 /* Union */)) { - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } var targetEnumType = getTypeOfSymbol(target.symbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(source.symbol)); _i < _a.length; _i++) { @@ -30890,11 +31562,13 @@ var ts; if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, property.name, typeToString(target, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */)); } - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } } } - return enumRelation[id] = true; + enumRelation.set(id, true); + return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { if (target.flags & 8192 /* Never */) @@ -30915,6 +31589,8 @@ var ts; return true; if (source.flags & 4096 /* Null */ && (!strictNullChecks || target.flags & 4096 /* Null */)) return true; + if (source.flags & 32768 /* Object */ && target.flags & 16777216 /* NonPrimitive */) + return true; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & 1 /* Any */) return true; @@ -30946,12 +31622,12 @@ var ts; } if (source.flags & 32768 /* Object */ && target.flags & 32768 /* Object */) { var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { return related === 1 /* Succeeded */; } } - if (source.flags & 507904 /* StructuredOrTypeParameter */ || target.flags & 507904 /* StructuredOrTypeParameter */) { + if (source.flags & 1032192 /* StructuredOrTypeVariable */ || target.flags & 1032192 /* StructuredOrTypeVariable */) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -31130,16 +31806,6 @@ var ts; } } } - else { - // Given a type parameter K with a constraint keyof T, a type S is - // assignable to K if S is assignable to keyof T. - var constraint = getConstraintOfTypeParameter(target); - if (constraint && constraint.flags & 262144 /* Index */) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - return result; - } - } - } } else if (target.flags & 262144 /* Index */) { // A keyof S is related to a keyof T if T is related to S. @@ -31148,14 +31814,12 @@ var ts; return result; } } - // Given a type variable T with a constraint C, a type S is assignable to - // keyof T if S is assignable to keyof C. - if (target.type.flags & 540672 /* TypeVariable */) { - var constraint = getConstraintOfTypeVariable(target.type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } + // A type S is assignable to keyof T if S is assignable to keyof C, where C is the + // constraint of T. + var constraint = getConstraintOfType(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; } } } @@ -31169,8 +31833,9 @@ var ts; } // A type S is related to a type T[K] if S is related to A[K], where K is string-like and // A is the apparent type of S. - if (target.constraint) { - if (result = isRelatedTo(source, target.constraint, reportErrors)) { + var constraint = getBaseConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -31188,24 +31853,28 @@ var ts; } else { var constraint = getConstraintOfTypeParameter(source); - if (!constraint || constraint.flags & 1 /* Any */) { - constraint = emptyObjectType; - } - // The constraint may need to be further instantiated with its 'this' type. - constraint = getTypeWithThisArgument(constraint, source); - // Report constraint errors only if the constraint is not the empty object type - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; + // A type parameter with no constraint is not related to the non-primitive object type. + if (constraint || !(target.flags & 16777216 /* NonPrimitive */)) { + if (!constraint || constraint.flags & 1 /* Any */) { + constraint = emptyObjectType; + } + // The constraint may need to be further instantiated with its 'this' type. + constraint = getTypeWithThisArgument(constraint, source); + // Report constraint errors only if the constraint is not the empty object type + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } } else if (source.flags & 524288 /* IndexedAccess */) { // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and // A is the apparent type of S. - if (source.constraint) { - if (result = isRelatedTo(source.constraint, target, reportErrors)) { + var constraint = getBaseConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -31269,45 +31938,61 @@ var ts; // is considered known if the object type is empty and the check is for assignability, if the object type has // index signatures, or if the property is actually declared in the object type. In a union or intersection // type, a property is considered known if it is known in any constituent type. - function isKnownProperty(type, name) { + function isKnownProperty(type, name, isComparingJsxAttributes) { if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); - if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || - resolved.stringIndexInfo || - (resolved.numberIndexInfo && isNumericLiteralName(name)) || - getPropertyOfType(type, name)) { + if ((relation === assignableRelation || relation === comparableRelation) && + (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) { + return true; + } + else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) { + return true; + } + else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) { + // For JSXAttributes, if the attribute has a hyphenated name, consider that the attribute to be known. return true; } } else if (type.flags & 196608 /* UnionOrIntersection */) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (isKnownProperty(t, name)) { + if (isKnownProperty(t, name, isComparingJsxAttributes)) { return true; } } } return false; } - function isEmptyObjectType(t) { + function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && !t.stringIndexInfo && !t.numberIndexInfo; } + function isEmptyObjectType(type) { + return type.flags & 32768 /* Object */ && isEmptyResolvedType(resolveStructuredTypeMembers(type)); + } function hasExcessProperties(source, target, reportErrors) { if (maybeTypeOfKind(target, 32768 /* Object */) && !(getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + var isComparingJsxAttributes = !!(source.flags & 33554432 /* JsxAttributes */); for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; - if (!isKnownProperty(target, prop.name)) { + if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { if (reportErrors) { // We know *exactly* where things went wrong when comparing the types. // Use this property as the error node as this will be more helpful in // reasoning about what went wrong. ts.Debug.assert(!!errorNode); - errorNode = prop.valueDeclaration; - reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + if (ts.isJsxAttributes(errorNode)) { + // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. + // However, using an object-literal error message will be very confusing to the users so we give different a message. + reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); + } + else { + errorNode = prop.valueDeclaration; + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } } return true; } @@ -31333,20 +32018,42 @@ var ts; if (target.flags & 65536 /* Union */ && containsType(targetTypes, source)) { return -1 /* True */; } - var len = targetTypes.length; - for (var i = 0; i < len; i++) { - var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var type = targetTypes_1[_i]; + var related = isRelatedTo(source, type, /*reportErrors*/ false); if (related) { return related; } } + if (reportErrors) { + var discriminantType = findMatchingDiscriminantType(source, target); + isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); + } return 0 /* False */; } + function findMatchingDiscriminantType(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProperty = sourceProperties_1[_i]; + if (isDiscriminantProperty(target, sourceProperty.name)) { + var sourceType = getTypeOfSymbol(sourceProperty); + for (var _a = 0, _b = target.types; _a < _b.length; _a++) { + var type = _b[_a]; + var targetType = getTypeOfPropertyOfType(type, sourceProperty.name); + if (targetType && isRelatedTo(sourceType, targetType)) { + return type; + } + } + } + } + } + } function typeRelatedToEachType(source, target, reportErrors) { var result = -1 /* True */; var targetTypes = target.types; - for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { - var targetType = targetTypes_1[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var targetType = targetTypes_2[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0 /* False */; @@ -31409,12 +32116,12 @@ var ts; return 0 /* False */; } var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2 /* Failed */) { // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported // failure and continue computing the relation such that errors get reported. - relation[id] = 3 /* FailedAndReported */; + relation.set(id, 3 /* FailedAndReported */); } else { return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; @@ -31423,7 +32130,7 @@ var ts; if (depth > 0) { for (var i = 0; i < depth; i++) { // If source and target are already being compared, consider them related with assumptions - if (maybeStack[i][id]) { + if (maybeStack[i].get(id)) { return 1 /* Maybe */; } } @@ -31441,7 +32148,7 @@ var ts; sourceStack[depth] = source; targetStack[depth] = target; maybeStack[depth] = ts.createMap(); - maybeStack[depth][id] = 1 /* Succeeded */; + maybeStack[depth].set(id, 1 /* Succeeded */); depth++; var saveExpandingFlags = expandingFlags; if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) @@ -31476,41 +32183,43 @@ var ts; var maybeCache = maybeStack[depth]; // If result is definitely true, copy assumptions to global cache, else copy to next level up var destinationCache = (result === -1 /* True */ || depth === 0) ? relation : maybeStack[depth - 1]; - ts.copyProperties(maybeCache, destinationCache); + ts.copyEntries(maybeCache, destinationCache); } else { // A false result goes straight into global cache (when something is false under assumptions it // will also be false without assumptions) - relation[id] = reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */; + relation.set(id, reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */); } return result; } - // A type [P in S]: X is related to a type [P in T]: Y if T is related to S and X is related to Y. + // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is + // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice + // that S and T are contra-variant whereas X and Y are co-variant. function mappedTypeRelatedTo(source, target, reportErrors) { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { - var result_2; - if (relation === identityRelation) { - var readonlyMatches = !source.declaration.readonlyToken === !target.declaration.readonlyToken; - var optionalMatches = !source.declaration.questionToken === !target.declaration.questionToken; - if (readonlyMatches && optionalMatches) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getErasedTemplateTypeFromMappedType(source), getErasedTemplateTypeFromMappedType(target), reportErrors); - } - } - } - else { - if (relation === comparableRelation || !source.declaration.questionToken || target.declaration.questionToken) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors); - } + var sourceReadonly = !!source.declaration.readonlyToken; + var sourceOptional = !!source.declaration.questionToken; + var targetReadonly = !!target.declaration.readonlyToken; + var targetOptional = !!target.declaration.questionToken; + var modifiersRelated = relation === identityRelation ? + sourceReadonly === targetReadonly && sourceOptional === targetOptional : + relation === comparableRelation || !sourceOptional || targetOptional; + if (modifiersRelated) { + var result_2; + if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { + var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); + return result_2 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } + else if (target.declaration.questionToken && isEmptyObjectType(source)) { + return -1 /* True */; + } } else if (relation !== identityRelation) { var resolved = resolveStructuredTypeMembers(target); - if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1 /* Any */) { + if (isEmptyResolvedType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1 /* Any */) { return -1 /* True */; } } @@ -31528,17 +32237,23 @@ var ts; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { - if (!(targetProp.flags & 536870912 /* Optional */) || requireOptionalProperties) { + if (!(targetProp.flags & 67108864 /* Optional */) || requireOptionalProperties) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); } return 0 /* False */; } } - else if (!(targetProp.flags & 134217728 /* Prototype */)) { + else if (!(targetProp.flags & 16777216 /* Prototype */)) { var sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (getCheckFlags(sourceProp) & 128 /* ContainsPrivate */) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); + } + return 0 /* False */; + } if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { @@ -31552,12 +32267,9 @@ var ts; } } else if (targetPropFlags & 16 /* Protected */) { - var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(getParentOfSymbol(sourceProp)) : undefined; - var targetClass = getDeclaredTypeOfSymbol(getParentOfSymbol(targetProp)); - if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { + if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); + reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } return 0 /* False */; } @@ -31577,7 +32289,7 @@ var ts; } result &= related; // When checking for comparability, be more lenient with optional properties. - if (relation !== comparableRelation && sourceProp.flags & 536870912 /* Optional */ && !(targetProp.flags & 536870912 /* Optional */)) { + if (relation !== comparableRelation && sourceProp.flags & 67108864 /* Optional */ && !(targetProp.flags & 67108864 /* Optional */)) { // TypeScript 1.0 spec (April 2014): 3.8.3 // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. @@ -31605,8 +32317,8 @@ var ts; return 0 /* False */; } var result = -1 /* True */; - for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { - var sourceProp = sourceProperties_1[_i]; + for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { + var sourceProp = sourceProperties_2[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0 /* False */; @@ -31779,6 +32491,45 @@ var ts; return false; } } + // Invoke the callback for each underlying property symbol of the given symbol and return the first + // value that isn't undefined. + function forEachProperty(prop, callback) { + if (getCheckFlags(prop) & 2 /* SyntheticProperty */) { + for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var p = getPropertyOfType(t, prop.name); + var result = p && forEachProperty(p, callback); + if (result) { + return result; + } + } + return undefined; + } + return callback(prop); + } + // Return the declaring class type of a property or undefined if property not declared in class + function getDeclaringClass(prop) { + return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + } + // Return true if some underlying source property is declared in a class that derives + // from the given base class. + function isPropertyInClassDerivedFrom(prop, baseClass) { + return forEachProperty(prop, function (sp) { + var sourceClass = getDeclaringClass(sp); + return sourceClass ? hasBaseType(sourceClass, baseClass) : false; + }); + } + // Return true if source property is a valid override of protected parts of target property. + function isValidOverrideOf(sourceProp, targetProp) { + return !forEachProperty(targetProp, function (tp) { return getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? + !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); + } + // Return true if the given class derives from each of the declaring classes of the protected + // constituents of the given property. + function isClassDerivedFromDeclaringClasses(checkClass, prop) { + return forEachProperty(prop, function (p) { return getDeclarationModifierFlagsFromSymbol(p) & 16 /* Protected */ ? + !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; + } // Return true if the given type is the constructor type for an abstract class function isAbstractConstructorType(type) { if (getObjectFlags(type) & 16 /* Anonymous */) { @@ -31834,7 +32585,7 @@ var ts; } } else { - if ((sourceProp.flags & 536870912 /* Optional */) !== (targetProp.flags & 536870912 /* Optional */)) { + if ((sourceProp.flags & 67108864 /* Optional */) !== (targetProp.flags & 67108864 /* Optional */)) { return 0 /* False */; } } @@ -31878,7 +32629,7 @@ var ts; // the constraints with a common set of type arguments to get relatable entities in places where // type parameters occur in the constraints. The complexity of doing that doesn't seem worthwhile, // particularly as we're comparing erased versions of the signatures below. - if ((source.typeParameters ? source.typeParameters.length : 0) !== (target.typeParameters ? target.typeParameters.length : 0)) { + if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { return 0 /* False */; } // Spec 1.0 Section 3.8.3 & 3.8.4: @@ -31918,8 +32669,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -31927,8 +32678,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -32034,8 +32785,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getFalsyFlags(t); } return result; @@ -32067,7 +32818,7 @@ var ts; types.push(undefinedType); if (flags & 4096 /* Null */) types.push(nullType); - return getUnionType(types, /*subtypeReduction*/ true); + return getUnionType(types); } function removeDefinitelyFalsyTypes(type) { return getFalsyFlags(type) & 7392 /* DefinitelyFalsy */ ? @@ -32086,8 +32837,8 @@ var ts; getSignaturesOfType(type, 0 /* Call */).length === 0 && getSignaturesOfType(type, 1 /* Construct */).length === 0; } - function createTransientSymbol(source, type) { - var symbol = createSymbol(source.flags | 67108864 /* Transient */, source.name); + function createSymbolWithType(source, type) { + var symbol = createSymbol(source.flags, source.name); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -32103,7 +32854,7 @@ var ts; var property = _a[_i]; var original = getTypeOfSymbol(property); var updated = f(original); - members[property.name] = updated === original ? property : createTransientSymbol(property, updated); + members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); } ; return members; @@ -32205,25 +32956,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 144 /* Parameter */: + case 145 /* 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 174 /* BindingElement */: + case 175 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 226 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -32316,7 +33067,7 @@ var ts; var typeInferencesArray = [typeInferences]; var templateType = getTemplateTypeFromMappedType(target); var readonlyMask = target.declaration.readonlyToken ? false : true; - var optionalMask = target.declaration.questionToken ? 0 : 536870912 /* Optional */; + var optionalMask = target.declaration.questionToken ? 0 : 67108864 /* Optional */; var members = createSymbolTable(properties); for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var prop = properties_4[_i]; @@ -32324,11 +33075,11 @@ var ts; if (!inferredPropType) { return undefined; } - var inferredProp = createSymbol(4 /* Property */ | 67108864 /* Transient */ | prop.flags & optionalMask, prop.name); + var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.name); + inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 4 /* Readonly */ : 0; inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; - inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); - members[prop.name] = inferredProp; + members.set(prop.name, inferredProp); } if (indexInfo) { var inferredIndexType = inferTargetType(indexInfo.type); @@ -32465,8 +33216,8 @@ var ts; var typeVariableCount = 0; var typeVariable = void 0; // First infer to each type in union or intersection that isn't a type variable - for (var _d = 0, targetTypes_2 = targetTypes; _d < targetTypes_2.length; _d++) { - var t = targetTypes_2[_d]; + for (var _d = 0, targetTypes_3 = targetTypes; _d < targetTypes_3.length; _d++) { + var t = targetTypes_3[_d]; if (t.flags & 540672 /* TypeVariable */ && ts.contains(typeVariables, t)) { typeVariable = t; typeVariableCount++; @@ -32502,10 +33253,10 @@ var ts; return; } var key = source.id + "," + target.id; - if (visited[key]) { + if (visited.get(key)) { return; } - visited[key] = true; + visited.set(key, true); if (depth === 0) { sourceStack = []; targetStack = []; @@ -32603,8 +33354,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -32654,11 +33405,20 @@ var ts; inferenceSucceeded = !!unionOrSuperType; } else { - // Infer the empty object type when no inferences were made. It is important to remember that - // in this case, inference still succeeds, meaning there is no error for not having inference - // candidates. An inference error only occurs when there are *conflicting* candidates, i.e. + // Infer either the default or the empty object type when no inferences were + // made. It is important to remember that in this case, inference still + // succeeds, meaning there is no error for not having inference candidates. An + // inference error only occurs when there are *conflicting* candidates, i.e. // candidates with no common supertype. - inferredType = emptyObjectType; + var defaultType = getDefaultFromTypeParameter(context.signature.typeParameters[index]); + if (defaultType) { + // Instantiate the default type. Any forward reference to a type + // parameter should be instantiated to the empty object type. + inferredType = instantiateType(defaultType, combineTypeMappers(createBackreferenceMapper(context.signature.typeParameters, index), getInferenceMapper(context))); + } + else { + inferredType = emptyObjectType; + } inferenceSucceeded = true; } context.inferredTypes[index] = inferredType; @@ -32701,10 +33461,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 160 /* TypeQuery */: + case 161 /* TypeQuery */: return true; case 70 /* Identifier */: - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: node = node.parent; continue; default: @@ -32725,7 +33485,7 @@ var ts; if (node.kind === 98 /* ThisKeyword */) { return "0"; } - if (node.kind === 177 /* PropertyAccessExpression */) { + if (node.kind === 178 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -32736,7 +33496,7 @@ var ts; case 70 /* Identifier */: case 98 /* ThisKeyword */: return node; - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -32745,19 +33505,19 @@ var ts; switch (source.kind) { case 70 /* Identifier */: return target.kind === 70 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 224 /* VariableDeclaration */ || target.kind === 174 /* BindingElement */) && + (target.kind === 225 /* VariableDeclaration */ || target.kind === 175 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98 /* ThisKeyword */: return target.kind === 98 /* ThisKeyword */; - case 177 /* PropertyAccessExpression */: - return target.kind === 177 /* PropertyAccessExpression */ && + case 178 /* PropertyAccessExpression */: + return target.kind === 178 /* PropertyAccessExpression */ && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 177 /* PropertyAccessExpression */) { + while (source.kind === 178 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -32770,7 +33530,7 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 177 /* PropertyAccessExpression */ && + return target.kind === 178 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -32778,7 +33538,7 @@ var ts; if (expr.kind === 70 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 177 /* PropertyAccessExpression */) { + if (expr.kind === 178 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -32787,9 +33547,9 @@ var ts; function isDiscriminantProperty(type, name) { if (type && type.flags & 65536 /* Union */) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && prop.flags & 268435456 /* SyntheticProperty */) { + if (prop && getCheckFlags(prop) & 2 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.hasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.checkFlags & 16 /* HasNonUniformType */ && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -32808,7 +33568,7 @@ var ts; } } } - if (callExpression.expression.kind === 177 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 178 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -32850,8 +33610,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -32861,7 +33621,7 @@ var ts; // check. This gives us a quicker out in the common case where an object type is not a function. var resolved = resolveStructuredTypeMembers(type); return !!(resolved.callSignatures.length || resolved.constructSignatures.length || - resolved.members["bind"] && isTypeSubtypeOf(type, globalFunctionType)); + resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type) { var flags = type.flags; @@ -32904,6 +33664,9 @@ var ts; if (flags & 512 /* ESSymbol */) { return strictNullChecks ? 1981320 /* SymbolStrictFacts */ : 4193160 /* SymbolFacts */; } + if (flags & 16777216 /* NonPrimitive */) { + return strictNullChecks ? 6166480 /* ObjectStrictFacts */ : 8378320 /* ObjectFacts */; + } if (flags & 16384 /* TypeParameter */) { var constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); @@ -32939,10 +33702,16 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 /* ArrayLiteralExpression */ || node.parent.kind === 258 /* PropertyAssignment */ ? + var isDestructuringDefaultAssignment = node.parent.kind === 176 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 260 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } + function isDestructuringAssignmentTarget(parent) { + return parent.parent.kind === 193 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 215 /* ForOfStatement */ && parent.parent.initializer === parent; + } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); } @@ -32958,21 +33727,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return stringType; - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return undefinedType; - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -32980,7 +33749,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 172 /* ObjectBindingPattern */ ? + var type = pattern.kind === 173 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -32998,35 +33767,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 213 /* ForInStatement */) { + if (node.parent.parent.kind === 214 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 214 /* ForOfStatement */) { + if (node.parent.parent.kind === 215 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 224 /* VariableDeclaration */ ? + return node.kind === 225 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 224 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */ ? + return node.kind === 225 /* VariableDeclaration */ || node.kind === 175 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 224 /* VariableDeclaration */ && node.initializer && + return node.kind === 225 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 174 /* BindingElement */ && node.parent.kind === 192 /* BinaryExpression */ && + node.kind !== 175 /* BindingElement */ && node.parent.kind === 193 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (node.operatorToken.kind) { case 57 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -33038,13 +33807,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 183 /* ParenthesizedExpression */ || - parent.kind === 192 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || - parent.kind === 192 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? + return parent.kind === 184 /* ParenthesizedExpression */ || + parent.kind === 193 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || + parent.kind === 193 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 254 /* CaseClause */) { + if (clause.kind === 256 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -33159,8 +33928,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; if (!(t.flags & 8192 /* Never */)) { if (!(getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -33183,11 +33952,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 177 /* PropertyAccessExpression */ && (parent.name.text === "length" || - parent.parent.kind === 179 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 178 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 178 /* PropertyAccessExpression */ && (parent.name.text === "length" || + parent.parent.kind === 180 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 179 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 192 /* BinaryExpression */ && + parent.parent.kind === 193 /* BinaryExpression */ && parent.parent.operatorToken.kind === 57 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -33216,7 +33985,7 @@ var ts; } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215 /* Narrowable */)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 17810431 /* Narrowable */)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -33230,7 +33999,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 201 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { + if (reference.parent.kind === 202 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { return declaredType; } return resultType; @@ -33247,7 +34016,19 @@ var ts; } } var type = void 0; - if (flow.flags & 16 /* Assignment */) { + if (flow.flags & 4096 /* AfterFinally */) { + // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement + flow.locked = true; + type = getTypeAtFlowNode(flow.antecedent); + flow.locked = false; + } + else if (flow.flags & 2048 /* PreFinally */) { + // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel + // so here just redirect to antecedent + flow = flow.antecedent; + continue; + } + else if (flow.flags & 16 /* Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; @@ -33279,7 +34060,7 @@ var ts; else if (flow.flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 177 /* PropertyAccessExpression */) { + if (container && container !== flowContainer && reference.kind !== 178 /* PropertyAccessExpression */) { flow = container.flowNode; continue; } @@ -33333,7 +34114,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 179 /* CallExpression */ ? + var expr = node.kind === 180 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -33341,7 +34122,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 179 /* CallExpression */) { + if (node.kind === 180 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -33400,6 +34181,12 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; + if (antecedent.flags & 2048 /* PreFinally */ && antecedent.lock.locked) { + // if flow correspond to branch from pre-try to finally and this branch is locked - this means that + // we initially have started following the flow outside the finally block. + // in this case we should ignore this branch. + continue; + } var flowType = getTypeAtFlowNode(antecedent); var type = getTypeFromFlowType(flowType); // If the type at a particular antecedent path is the declared type and the @@ -33432,8 +34219,9 @@ var ts; if (!key) { key = getFlowCacheKey(reference); } - if (cache[key]) { - return cache[key]; + var cached = cache.get(key); + if (cached) { + return cached; } // If this flow loop junction and reference are already being processed, return // the union of the types computed for each branch so far, marked as incomplete. @@ -33468,8 +34256,9 @@ var ts; // If we see a value appear in the cache it is a sign that control flow analysis // was restarted and completed by checkExpressionCached. We can simply pick up // the resulting type and bail out. - if (cache[key]) { - return cache[key]; + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; } if (!ts.contains(antecedentTypes, type)) { antecedentTypes.push(type); @@ -33493,10 +34282,11 @@ var ts; if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } - return cache[key] = result; + cache.set(key, result); + return result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 177 /* PropertyAccessExpression */ && + return expr.kind === 178 /* PropertyAccessExpression */ && declaredType.flags & 65536 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -33530,10 +34320,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 187 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { + if (left_1.kind === 188 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 187 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { + if (right_1.kind === 188 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -33579,7 +34369,7 @@ var ts; assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); } - if (type.flags & 33281 /* NotUnionOrUnit */) { + if (type.flags & 16810497 /* NotUnionOrUnit */) { return type; } if (assumeTrue) { @@ -33610,14 +34400,14 @@ var ts; // We narrow a non-union type to an exact primitive type if the non-union type // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. - var targetType = typeofTypesByName[literal.text]; + var targetType = typeofTypesByName.get(literal.text); if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; } } var facts = assumeTrue ? - typeofEQFacts[literal.text] || 64 /* TypeofEQHostObject */ : - typeofNEFacts[literal.text] || 8192 /* TypeofNEHostObject */; + typeofEQFacts.get(literal.text) || 64 /* TypeofEQHostObject */ : + typeofNEFacts.get(literal.text) || 8192 /* TypeofNEHostObject */; return getTypeWithFacts(type, facts); } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { @@ -33732,7 +34522,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 178 /* ElementAccessExpression */ || invokedExpression.kind === 177 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 179 /* ElementAccessExpression */ || invokedExpression.kind === 178 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -33751,15 +34541,15 @@ var ts; switch (expr.kind) { case 70 /* Identifier */: case 98 /* ThisKeyword */: - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: if (expr.operator === 50 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -33795,9 +34585,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 232 /* ModuleBlock */ || - node.kind === 262 /* SourceFile */ || - node.kind === 147 /* PropertyDeclaration */) { + node.kind === 233 /* ModuleBlock */ || + node.kind === 264 /* SourceFile */ || + node.kind === 148 /* PropertyDeclaration */) { return node; } } @@ -33829,7 +34619,7 @@ var ts; if (node.kind === 70 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 144 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 145 /* Parameter */) { symbol.isAssigned = true; } } @@ -33855,7 +34645,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 185 /* ArrowFunction */) { + if (container.kind === 186 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -33876,7 +34666,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration_1.kind === 227 /* ClassDeclaration */ + if (declaration_1.kind === 228 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -33888,14 +34678,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 197 /* ClassExpression */) { + else if (declaration_1.kind === 198 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 147 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 148 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration_1).flags |= 8388608 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 16777216 /* ConstructorReferenceInClass */; } @@ -33930,15 +34720,15 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 144 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 145 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 184 /* FunctionExpression */ || - flowContainer.kind === 185 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 185 /* FunctionExpression */ || + flowContainer.kind === 186 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -33981,7 +34771,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 257 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 259 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -34006,8 +34796,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 212 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 225 /* VariableDeclarationList */).parent === container && + if (container.kind === 213 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 226 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -34021,7 +34811,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { var current = node; // skip parenthesized nodes - while (current.parent.kind === 183 /* ParenthesizedExpression */) { + while (current.parent.kind === 184 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -34029,7 +34819,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 190 /* PrefixUnaryExpression */ || current.parent.kind === 191 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 191 /* PrefixUnaryExpression */ || current.parent.kind === 192 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 42 /* PlusPlusToken */ || expr.operator === 43 /* MinusMinusToken */; } @@ -34050,7 +34840,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 147 /* PropertyDeclaration */ || container.kind === 150 /* Constructor */) { + if (container.kind === 148 /* PropertyDeclaration */ || container.kind === 151 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -34118,36 +34908,38 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; - if (container.kind === 150 /* Constructor */) { + if (container.kind === 151 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 185 /* ArrowFunction */) { + if (container.kind === 186 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ 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 /* ES2015 */); } switch (container.kind) { - case 231 /* ModuleDeclaration */: + case 232 /* 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 230 /* EnumDeclaration */: + case 231 /* 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 150 /* Constructor */: + case 151 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); + // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: if (ts.getModifierFlags(container) & 32 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); + // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -34159,7 +34951,7 @@ var ts; // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } - if (container.kind === 184 /* FunctionExpression */ && + if (container.kind === 185 /* FunctionExpression */ && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') @@ -34196,28 +34988,28 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 275 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 278 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 278 /* JSDocThisType */) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 281 /* JSDocThisType */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 144 /* Parameter */) { + if (n.kind === 145 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 179 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 180 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 185 /* ArrowFunction */) { + while (container && container.kind === 186 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -34231,16 +35023,16 @@ var ts; // [super.foo()]() {} // } var current = node; - while (current && current !== container && current.kind !== 142 /* ComputedPropertyName */) { + while (current && current !== container && current.kind !== 143 /* ComputedPropertyName */) { current = current.parent; } - if (current && current.kind === 142 /* ComputedPropertyName */) { + if (current && current.kind === 143 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 176 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 177 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -34248,7 +35040,7 @@ var ts; } return unknownType; } - if (!isCallExpression && container.kind === 150 /* Constructor */) { + if (!isCallExpression && container.kind === 151 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if ((ts.getModifierFlags(container) & 32 /* Static */) || isCallExpression) { @@ -34314,7 +35106,7 @@ var ts; // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment // while a property access can. - if (container.kind === 149 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { + if (container.kind === 150 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -34328,7 +35120,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 176 /* ObjectLiteralExpression */) { + if (container.parent.kind === 177 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -34348,7 +35140,7 @@ var ts; } return unknownType; } - if (container.kind === 150 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 151 /* 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); return unknownType; @@ -34363,7 +35155,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 150 /* Constructor */; + return container.kind === 151 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -34371,21 +35163,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 176 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 177 /* ObjectLiteralExpression */) { if (ts.getModifierFlags(container) & 32 /* Static */) { - return container.kind === 149 /* MethodDeclaration */ || - container.kind === 148 /* MethodSignature */ || - container.kind === 151 /* GetAccessor */ || - container.kind === 152 /* SetAccessor */; + return container.kind === 150 /* MethodDeclaration */ || + container.kind === 149 /* MethodSignature */ || + container.kind === 152 /* GetAccessor */ || + container.kind === 153 /* SetAccessor */; } else { - return container.kind === 149 /* MethodDeclaration */ || - container.kind === 148 /* MethodSignature */ || - container.kind === 151 /* GetAccessor */ || - container.kind === 152 /* SetAccessor */ || - container.kind === 147 /* PropertyDeclaration */ || - container.kind === 146 /* PropertySignature */ || - container.kind === 150 /* Constructor */; + return container.kind === 150 /* MethodDeclaration */ || + container.kind === 149 /* MethodSignature */ || + container.kind === 152 /* GetAccessor */ || + container.kind === 153 /* SetAccessor */ || + container.kind === 148 /* PropertyDeclaration */ || + container.kind === 147 /* PropertySignature */ || + container.kind === 151 /* Constructor */; } } } @@ -34393,7 +35185,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 185 /* ArrowFunction */) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 186 /* ArrowFunction */) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -34409,23 +35201,23 @@ var ts; var func = parameter.parent; if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { var iife = ts.getImmediatelyInvokedFunctionExpression(func); - if (iife) { + if (iife && iife.arguments) { var indexOfParameter = ts.indexOf(func.parameters, parameter); - if (iife.arguments && indexOfParameter < iife.arguments.length) { - if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return createArrayType(getUnionType(restTypes)); + if (parameter.dotDotDotToken) { + var restTypes = []; + for (var i = indexOfParameter; i < iife.arguments.length; i++) { + restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); } - var links = getNodeLinks(iife); - var cached = links.resolvedSignature; - links.resolvedSignature = anySignature; - var type = getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])); - links.resolvedSignature = cached; - return type; + return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; } + var links = getNodeLinks(iife); + var cached = links.resolvedSignature; + links.resolvedSignature = anySignature; + var type = indexOfParameter < iife.arguments.length ? + getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + parameter.initializer ? undefined : undefinedWideningType; + links.resolvedSignature = cached; + return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -34459,7 +35251,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 144 /* Parameter */) { + if (declaration.kind === 145 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -34470,11 +35262,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_19 = declaration.propertyName || declaration.name; + var name = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_19)) { - var text = ts.getTextOfPropertyName(name_19); + !ts.isBindingPattern(name)) { + var text = ts.getTextOfPropertyName(name); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -34511,7 +35303,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 144 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 145 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -34522,8 +35314,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 150 /* Constructor */ || - functionDecl.kind === 151 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 152 /* SetAccessor */))) { + functionDecl.kind === 151 /* Constructor */ || + functionDecl.kind === 152 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 153 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -34545,7 +35337,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 181 /* TaggedTemplateExpression */) { + if (template.parent.kind === 182 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -34589,8 +35381,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -34670,19 +35462,19 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxAttribute(attribute) { - var kind = attribute.kind; - var jsxElement = attribute.parent; - var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 251 /* JsxAttribute */) { - if (!attrsType || isTypeAny(attrsType)) { + // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type + // which is a type of the parameter of the signature we are trying out. + // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName + var attributesType = getContextualType(attribute.parent); + if (ts.isJsxAttribute(attribute)) { + if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attrsType, attribute.name.text); + return getTypeOfPropertyOfType(attributesType, attribute.name.text); } - else if (attribute.kind === 252 /* JsxSpreadAttribute */) { - return attrsType; + else { + return attributesType; } - ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); } // 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. @@ -34717,42 +35509,45 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 224 /* VariableDeclaration */: - case 144 /* Parameter */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 174 /* BindingElement */: + case 225 /* VariableDeclaration */: + case 145 /* Parameter */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 175 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 185 /* ArrowFunction */: - case 217 /* ReturnStatement */: + case 186 /* ArrowFunction */: + case 218 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 179 /* CallExpression */: - case 180 /* NewExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 258 /* PropertyAssignment */: - case 259 /* ShorthandPropertyAssignment */: + case 260 /* PropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 203 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 194 /* TemplateExpression */); + case 204 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 195 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return getContextualType(parent); - case 253 /* JsxExpression */: + case 255 /* JsxExpression */: return getContextualType(parent); - case 251 /* JsxAttribute */: - case 252 /* JsxSpreadAttribute */: + case 252 /* JsxAttribute */: + case 254 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); + case 250 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + return getAttributesTypeFromJsxOpeningLikeElement(parent); } return undefined; } @@ -34783,7 +35578,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 184 /* FunctionExpression */ || node.kind === 185 /* ArrowFunction */; + return node.kind === 185 /* FunctionExpression */ || node.kind === 186 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -34802,7 +35597,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 !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -34812,8 +35607,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var current = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -34863,8 +35658,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 174 /* BindingElement */ && !!node.initializer) || - (node.kind === 192 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); + return (node.kind === 175 /* BindingElement */ && !!node.initializer) || + (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -34873,7 +35668,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 196 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 197 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -34897,7 +35692,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 196 /* SpreadElement */; + hasSpreadElement = hasSpreadElement || e.kind === 197 /* SpreadElement */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -34912,7 +35707,7 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (pattern && (pattern.kind === 173 /* ArrayBindingPattern */ || pattern.kind === 175 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 174 /* ArrayBindingPattern */ || pattern.kind === 176 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -34920,7 +35715,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 198 /* OmittedExpression */) { + if (patternElement.kind !== 199 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -34937,7 +35732,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 142 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 143 /* 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, @@ -35009,7 +35804,7 @@ var ts; var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 172 /* ObjectBindingPattern */ || contextualType.pattern.kind === 176 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 173 /* ObjectBindingPattern */ || contextualType.pattern.kind === 177 /* ObjectLiteralExpression */); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -35018,29 +35813,29 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 258 /* PropertyAssignment */ || - memberDecl.kind === 259 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 260 /* PropertyAssignment */ || + memberDecl.kind === 261 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 258 /* PropertyAssignment */) { + if (memberDecl.kind === 260 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 149 /* MethodDeclaration */) { + else if (memberDecl.kind === 150 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 259 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 261 /* ShorthandPropertyAssignment */); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; - var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name); + var prop = createSymbol(4 /* Property */ | member.flags, member.name); if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 258 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 259 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 260 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 261 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 536870912 /* Optional */; + prop.flags |= 67108864 /* Optional */; } if (ts.hasDynamicName(memberDecl)) { patternWithComputedProperties = true; @@ -35051,7 +35846,7 @@ var ts; // binding pattern specifies a default value for the property, make the property optional. var impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { - prop.flags |= impliedProp.flags & 536870912 /* Optional */; + prop.flags |= impliedProp.flags & 67108864 /* Optional */; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0 /* String */)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -35066,12 +35861,12 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 260 /* SpreadAssignment */) { - if (languageVersion < 5 /* ESNext */) { + else if (memberDecl.kind === 262 /* SpreadAssignment */) { + if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + spread = getSpreadType(spread, createObjectLiteralType()); propertiesArray = []; propertiesTable = ts.createMap(); hasComputedStringProperty = false; @@ -35083,7 +35878,7 @@ var ts; error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } - spread = getSpreadType(spread, type, /*isFromObjectLiteral*/ false); + spread = getSpreadType(spread, type); offset = i + 1; continue; } @@ -35093,7 +35888,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 === 151 /* GetAccessor */ || memberDecl.kind === 152 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 152 /* GetAccessor */ || memberDecl.kind === 153 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -35105,7 +35900,7 @@ var ts; } } else { - propertiesTable[member.name] = member; + propertiesTable.set(member.name, member); } propertiesArray.push(member); } @@ -35114,18 +35909,18 @@ var ts; if (contextualTypeHasPattern) { for (var _i = 0, _a = getPropertiesOfType(contextualType); _i < _a.length; _i++) { var prop = _a[_i]; - if (!propertiesTable[prop.name]) { - if (!(prop.flags & 536870912 /* Optional */)) { + if (!propertiesTable.get(prop.name)) { + if (!(prop.flags & 67108864 /* Optional */)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } - propertiesTable[prop.name] = prop; + propertiesTable.set(prop.name, prop); propertiesArray.push(prop); } } } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + spread = getSpreadType(spread, createObjectLiteralType()); } if (spread.flags & 32768 /* Object */) { // only set the symbol and flags if this is a (fresh) object type @@ -35155,7 +35950,7 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (1 /* Any */ | 4096 /* Null */ | 2048 /* Undefined */) || + return !!(type.flags & (1 /* Any */ | 4096 /* Null */ | 2048 /* Undefined */ | 16777216 /* NonPrimitive */) || type.flags & 32768 /* Object */ && !isGenericMappedType(type) || type.flags & 196608 /* UnionOrIntersection */ && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } @@ -35177,13 +35972,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 253 /* JsxExpression */: + case 255 /* JsxExpression */: checkJsxExpression(child); break; - case 247 /* JsxElement */: + case 248 /* JsxElement */: checkJsxElement(child); break; - case 248 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -35202,77 +35997,105 @@ var ts; */ function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment - if (tagName.kind === 177 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { + if (tagName.kind === 178 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { 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 (isUnhyphenatedJsxName(node.name.text)) { - var attributeType = getTypeOfPropertyOfType(elementAttributesType, ts.getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0 /* String */); - if (attributeType) { - correspondingPropType = attributeType; + /** + * Get attributes type of the JSX opening-like element. The result is from resolving "attributes" property of the opening-like element. + * + * @param openingLikeElement a JSX opening-like element + * @param filter a function to remove attributes that will not participate in checking whether attributes are assignable + * @return an anonymous type (similar to the one returned by checkObjectLiteral) in which its properties are attributes property. + */ + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, contextualMapper) { + var attributes = openingLikeElement.attributes; + var attributesTable = ts.createMap(); + var spread = emptyObjectType; + var attributesArray = []; + for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { + var attributeDecl = _a[_i]; + var member = attributeDecl.symbol; + if (ts.isJsxAttribute(attributeDecl)) { + var exprType = attributeDecl.initializer ? + checkExpression(attributeDecl.initializer, contextualMapper) : + trueType; // is sugar for + var attributeSymbol = createSymbol(4 /* Property */ | 134217728 /* Transient */ | member.flags, member.name); + attributeSymbol.declarations = member.declarations; + attributeSymbol.parent = member.parent; + if (member.valueDeclaration) { + attributeSymbol.valueDeclaration = member.valueDeclaration; } - else { - // If there's no corresponding property with this name, error - if (!correspondingPropType) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; - } + attributeSymbol.type = exprType; + attributeSymbol.target = member; + attributesTable.set(attributeSymbol.name, attributeSymbol); + attributesArray.push(attributeSymbol); + } + else { + ts.Debug.assert(attributeDecl.kind === 254 /* JsxSpreadAttribute */); + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); } + var exprType = checkExpression(attributeDecl.expression); + if (!(exprType.flags & (32768 /* Object */ | 1 /* Any */))) { + error(attributeDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + return anyType; + } + if (isTypeAny(exprType)) { + return anyType; + } + spread = getSpreadType(spread, exprType); } } - var exprType; - if (node.initializer) { - exprType = checkExpression(node.initializer); + if (spread !== emptyObjectType) { + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); + } + attributesArray = getPropertiesOfType(spread); } - else { - // is sugar for - exprType = booleanType; + attributesTable = ts.createMap(); + if (attributesArray) { + ts.forEach(attributesArray, function (attr) { + if (!filter || filter(attr)) { + attributesTable.set(attr.name, attr); + } + }); } - if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, node); + return createJsxAttributesType(attributes.symbol, attributesTable); + /** + * Create anonymous type from given attributes symbol table. + * @param symbol a symbol of JsxAttributes containing attributes corresponding to attributesTable + * @param attributesTable a symbol table of attributes property + */ + function createJsxAttributesType(symbol, attributesTable) { + var result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshLiteral */; + result.flags |= 33554432 /* JsxAttributes */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag; + result.objectFlags |= 128 /* ObjectLiteral */; + return result; } - nameTable[node.name.text] = true; - return exprType; } - function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { - if (compilerOptions.jsx === 2 /* React */) { - checkExternalEmitHelpers(node, 2 /* Assign */); - } - var type = checkExpression(node.expression); - var props = getPropertiesOfType(type); - for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { - var prop = props_2[_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; + /** + * Check attributes property of opening-like element. This function is called during chooseOverload to get call signature of a JSX opening-like element. + * (See "checkApplicableSignatureForJsxOpeningLikeElement" for how the function is used) + * @param node a JSXAttributes to be resolved of its type + */ + function checkJsxAttributes(node, contextualMapper) { + return createJsxAttributesTypeFromAttributesProperty(node.parent, /*filter*/ undefined, contextualMapper); } function getJsxType(name) { - if (jsxTypes[name] === undefined) { - return jsxTypes[name] = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType; + var jsxType = jsxTypes.get(name); + if (jsxType === undefined) { + jsxTypes.set(name, jsxType = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType); } - return jsxTypes[name]; + return jsxType; } /** * Looks up an intrinsic tag name and returns a symbol that either points to an intrinsic @@ -35367,28 +36190,131 @@ var ts; } } /** - * Given React element instance type and the class type, resolve the Jsx type - * Pass elemType to handle individual type in the union typed element type. + * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. + * Return only attributes type of successfully resolved call signature. + * This function assumes that the caller handled other possible element type of the JSX element (e.g. stateful component) + * Unlike tryGetAllJsxStatelessFunctionAttributesType, this function is a default behavior of type-checkers. + * @param openingLikeElement a JSX opening-like element to find attributes type + * @param elementType a type of the opening-like element. This elementType can't be an union type + * @param elemInstanceType an element instance type (the result of newing or invoking this tag) + * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global */ - function getResolvedJsxType(node, elemType, elemClassType) { - if (!elemType) { - elemType = checkExpression(node.tagName); + function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536 /* Union */)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + // We don't call getResolvedSignature here because we have already resolve the type of JSX Element. + var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, /*candidatesOutArray*/ undefined); + if (callSignature !== unknownSignature) { + var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); + var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + // Intersect in JSX.IntrinsicAttributes if it exists + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + paramType = intersectTypes(intrinsicAttributes, paramType); + } + return paramType; + } + } + } } - if (elemType.flags & 65536 /* Union */) { - var types = elemType.types; - return getUnionType(ts.map(types, function (type) { - return getResolvedJsxType(node, type, elemClassType); + return undefined; + } + /** + * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. + * Return all attributes type of resolved call signature including candidate signatures. + * This function assumes that the caller handled other possible element type of the JSX element. + * This function is a behavior used by language service when looking up completion in JSX element. + * @param openingLikeElement a JSX opening-like element to find attributes type + * @param elementType a type of the opening-like element. This elementType can't be an union type + * @param elemInstanceType an element instance type (the result of newing or invoking this tag) + * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global + */ + function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536 /* Union */)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type + if (jsxElementType) { + // We don't call getResolvedSignature because here we have already resolve the type of JSX Element. + var candidatesOutArray = []; + getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); + var result = void 0; + var allMatchingAttributesType = void 0; + for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { + var candidate = candidatesOutArray_1[_i]; + var callReturnType = getReturnTypeOfSignature(candidate); + var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var shouldBeCandidate = true; + for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { + var attribute = _b[_a]; + if (ts.isJsxAttribute(attribute) && + isUnhyphenatedJsxName(attribute.name.text) && + !getPropertyOfType(paramType, attribute.name.text)) { + shouldBeCandidate = false; + break; + } + } + if (shouldBeCandidate) { + result = intersectTypes(result, paramType); + } + allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); + } + } + // If we can't find any matching, just return everything. + if (!result) { + result = allMatchingAttributesType; + } + // Intersect in JSX.IntrinsicAttributes if it exists + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + result = intersectTypes(intrinsicAttributes, result); + } + return result; + } + } + return undefined; + } + /** + * Resolve attributes type of the given opening-like element. The attributes type is a type of attributes associated with the given elementType. + * For instance: + * declare function Foo(attr: { p1: string}): JSX.Element; + * ; // This function will try resolve "Foo" and return an attributes type of "Foo" which is "{ p1: string }" + * + * The function is intended to initially be called from getAttributesTypeFromJsxOpeningLikeElement which already handle JSX-intrinsic-element.. + * This function will try to resolve custom JSX attributes type in following order: string literal, stateless function, and stateful component + * + * @param openingLikeElement a non-intrinsic JSXOPeningLikeElement + * @param shouldIncludeAllStatelessAttributesType a boolean indicating whether to include all attributes types from all stateless function signature + * @param elementType an instance type of the given opening-like element. If undefined, the function will check type openinglikeElement's tagname. + * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global (imported from react.d.ts) + * @return attributes type if able to resolve the type of node + * anyType if there is no type ElementAttributesProperty or there is an error + * emptyObjectType if there is no "prop" in the element instance type + **/ + function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { + if (!elementType) { + elementType = checkExpression(openingLikeElement.tagName); + } + if (elementType.flags & 65536 /* Union */) { + var types = elementType.types; + return getUnionType(types.map(function (type) { + return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); }), /*subtypeReduction*/ true); } // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - if (elemType.flags & 2 /* String */) { + if (elementType.flags & 2 /* String */) { return anyType; } - else if (elemType.flags & 32 /* StringLiteral */) { + else if (elementType.flags & 32 /* StringLiteral */) { // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type + // For example: + // var CustomTag: "h1" = "h1"; + // Hello World var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { - var stringLiteralTypeName = elemType.text; + var stringLiteralTypeName = elementType.text; var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); if (intrinsicProp) { return getTypeOfSymbol(intrinsicProp); @@ -35397,34 +36323,24 @@ var ts; if (indexSignatureType) { return indexSignatureType; } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + error(openingLikeElement, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); } // If we need to report an error, we already done so here. So just return any to prevent any more error downstream return anyType; } // Get the element instance type (the result of newing or invoking this tag) - var elemInstanceType = getJsxElementInstanceType(node, elemType); - if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { - // Is this is a stateless function component? See if its single signature's return type is - // assignable to the JSX Element Type - if (jsxElementType) { - var callSignatures = elemType && getSignaturesOfType(elemType, 0 /* Call */); - var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { - // Intersect in JSX.IntrinsicAttributes if it exists - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); - if (intrinsicAttributes !== unknownType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } + var elemInstanceType = getJsxElementInstanceType(openingLikeElement, elementType); + // If we should include all stateless attributes type, then get all attributes type from all stateless function signature. + // Otherwise get only attributes type from the signature picked by choose-overload logic. + var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? + tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : + defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); + if (statelessAttributesType) { + return statelessAttributesType; } // Issue an error if this return type isn't assignable to JSX.ElementClass - if (elemClassType) { - checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + if (elementClassType) { + checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } if (isTypeAny(elemInstanceType)) { return elemInstanceType; @@ -35450,7 +36366,7 @@ var ts; } else if (attributesType.flags & 65536 /* Union */) { // Props cannot be a union type - error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); + error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); return anyType; } else { @@ -35477,30 +36393,68 @@ var ts; } } /** - * 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. + * Get attributes type of the given intrinsic opening-like Jsx element by resolving the tag name. + * The function is intended to be called from a function which has checked that the opening element is an intrinsic element. + * @param node an intrinsic JSX opening-like element */ - function getJsxElementAttributesType(node) { + function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) { + ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName)); var links = getNodeLinks(node); - if (!links.resolvedJsxType) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { - return links.resolvedJsxType = getTypeOfSymbol(symbol); - } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { - return links.resolvedJsxType = getIndexInfoOfSymbol(symbol, 0 /* String */).type; - } - else { - return links.resolvedJsxType = unknownType; - } + if (!links.resolvedJsxElementAttributesType) { + var symbol = getIntrinsicTagSymbol(node); + if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + } + else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, 0 /* String */).type; } else { - var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxType = getResolvedJsxType(node, undefined, elemClassType); + return links.resolvedJsxElementAttributesType = unknownType; } } - return links.resolvedJsxType; + return links.resolvedJsxElementAttributesType; + } + /** + * Get attributes type of the given custom opening-like JSX element. + * This function is intended to be called from a caller that handles intrinsic JSX element already. + * @param node a custom JSX opening-like element + * @param shouldIncludeAllStatelessAttributesType a boolean value used by language service to get all possible attributes type from an overload stateless function component + */ + function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { + var links = getNodeLinks(node); + if (!links.resolvedJsxElementAttributesType) { + var elemClassType = getJsxGlobalElementClassType(); + return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); + } + return links.resolvedJsxElementAttributesType; + } + /** + * Get all possible attributes type, especially from an overload stateless function component, of the given JSX opening-like element. + * This function is called by language service (see: completions-tryGetGlobalSymbols). + * @param node a JSX opening-like element to get attributes type for + */ + function getAllAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + // Because in language service, the given JSX opening-like element may be incomplete and therefore, + // we can't resolve to exact signature if the element is a stateless function component so the best thing to do is return all attributes type from all overloads. + return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ true); + } + } + /** + * Get the attributes type, which indicates the attributes that are valid on the given JSXOpeningLikeElement. + * @param node a JSXOpeningLikeElement node + * @return an attributes type of the given node + */ + function getAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ false); + } } /** * Given a JSX attribute, returns the symbol for the corresponds property @@ -35508,7 +36462,7 @@ var ts; * that have no matching element attributes type property. */ function getJsxAttributePropertySymbol(attrib) { - var attributesType = getJsxElementAttributesType(attrib.parent); + var attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent); var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } @@ -35518,7 +36472,9 @@ var ts; } return jsxElementClassType; } - /// Returns all the properties of the Jsx.IntrinsicElements interface + /** + * Returns all the properties of the Jsx.IntrinsicElements interface + */ function getJsxIntrinsicTagNames() { var intrinsics = getJsxType(JsxNames.IntrinsicElements); return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; @@ -35551,39 +36507,42 @@ var ts; markAliasSymbolAsReferenced(reactSym); } } - var targetAttributesType = getJsxElementAttributesType(node); - var nameTable = ts.createMap(); - // 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 === 251 /* JsxAttribute */) { - checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); - } - else { - ts.Debug.assert(node.attributes[i].kind === 252 /* JsxSpreadAttribute */); - var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if (isTypeAny(spreadType)) { - sawSpreadedAny = true; - } - } + checkJsxAttributesAssignableToTagNameAttributes(node); + } + /** + * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. + * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" + * Check assignablity between given attributes property, "source attributes", and the "target attributes" + * @param openingLikeElement an opening-like JSX element to check its JSXAttributes + */ + function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement) { + // The function involves following steps: + // 1. Figure out expected attributes type by resolving tagName of the JSX opening-like element, targetAttributesType. + // During these steps, we will try to resolve the tagName as intrinsic name, stateless function, stateful component (in the order) + // 2. Solved JSX attributes type given by users, sourceAttributesType, which is by resolving "attributes" property of the JSX opening-like element. + // 3. Check if the two are assignable to each other + // targetAttributesType is a type of an attributes from resolving tagName of an opening-like JSX element. + var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? + getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : + getCustomJsxElementAttributesType(openingLikeElement, /*shouldIncludeAllStatelessAttributesType*/ false); + // sourceAttributesType is a type of an attributes properties. + // i.e
+ // attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes". + var sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, function (attribute) { + return isUnhyphenatedJsxName(attribute.name) || !!(getPropertyOfType(targetAttributesType, attribute.name)); + }); + // If the targetAttributesType is an emptyObjectType, indicating that there is no property named 'props' on this instance type. + // but there exists a sourceAttributesType, we need to explicitly give an error as normal assignability check allow excess properties and will pass. + if (targetAttributesType === emptyObjectType && (isTypeAny(sourceAttributesType) || sourceAttributesType.properties.length > 0)) { + error(openingLikeElement, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); } - // 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]) { - error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); - } - } + else { + checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); } } - function checkJsxExpression(node) { + function checkJsxExpression(node, contextualMapper) { if (node.expression) { - var type = checkExpression(node.expression); + var type = checkExpression(node.expression, contextualMapper); if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); } @@ -35596,10 +36555,25 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 147 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 148 /* PropertyDeclaration */; } function getDeclarationModifierFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 4 /* Public */ | 32 /* Static */ : 0; + if (s.valueDeclaration) { + var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + } + if (getCheckFlags(s) & 2 /* SyntheticProperty */) { + var checkFlags = s.checkFlags; + var accessModifier = checkFlags & 128 /* ContainsPrivate */ ? 8 /* Private */ : + checkFlags & 32 /* ContainsPublic */ ? 4 /* Public */ : + 16 /* Protected */; + var staticModifier = checkFlags & 256 /* ContainsStatic */ ? 32 /* Static */ : 0; + return accessModifier | staticModifier; + } + if (s.flags & 16777216 /* Prototype */) { + return 4 /* Public */ | 32 /* Static */; + } + return 0; } function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; @@ -35612,12 +36586,16 @@ var ts; * @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) { + function checkPropertyAccessibility(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 /* PropertyAccessExpression */ || node.kind === 224 /* VariableDeclaration */ ? + var errorNode = node.kind === 178 /* PropertyAccessExpression */ || node.kind === 225 /* VariableDeclaration */ ? node.name : node.right; + if (getCheckFlags(prop) & 128 /* ContainsPrivate */) { + // Synthetic property with private constituent property + error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); + return false; + } if (left.kind === 96 /* SuperKeyword */) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or @@ -35626,18 +36604,21 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES2015 */ && getDeclarationKindFromSymbol(prop) !== 149 /* 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 (languageVersion < 2 /* ES2015 */) { + var propKind = getDeclarationKindFromSymbol(prop); + if (propKind !== 150 /* MethodDeclaration */ && propKind !== 149 /* MethodSignature */) { + // `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 & 128 /* 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)); + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } } @@ -35650,7 +36631,7 @@ var ts; if (flags & 8 /* Private */) { var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } return true; @@ -35660,14 +36641,15 @@ var ts; if (left.kind === 96 /* SuperKeyword */) { return true; } - // Get the enclosing class that has the declaring class as its base type + // Find the first enclosing class that has the declaring classes of the protected constituents + // of the property as base classes var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return hasBaseType(enclosingClass, declaringClass) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; }); // A protected property is accessible if the property is within the declaring class or classes derived from it if (!enclosingClass) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); return false; } // No further restrictions for static properties @@ -35679,7 +36661,6 @@ var ts; // get the original type -- represented as the type constraint of the 'this' type type = getConstraintOfTypeParameter(type); } - // TODO: why is the first part of this check here? if (!(getObjectFlags(getTargetType(type)) & 3 /* ClassOrInterface */ && hasBaseType(type, enclosingClass))) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; @@ -35687,16 +36668,17 @@ var ts; return true; } function checkNonNullExpression(node) { - var type = checkExpression(node); - if (strictNullChecks) { - var kind = getFalsyFlags(type) & 6144 /* Nullable */; - if (kind) { - error(node, kind & 2048 /* Undefined */ ? kind & 4096 /* Null */ ? - ts.Diagnostics.Object_is_possibly_null_or_undefined : - ts.Diagnostics.Object_is_possibly_undefined : - ts.Diagnostics.Object_is_possibly_null); - } - return getNonNullableType(type); + return checkNonNullType(checkExpression(node), node); + } + function checkNonNullType(type, errorNode) { + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 6144 /* Nullable */; + if (kind) { + error(errorNode, kind & 2048 /* Undefined */ ? kind & 4096 /* Null */ ? + ts.Diagnostics.Object_is_possibly_null_or_undefined : + ts.Diagnostics.Object_is_possibly_undefined : + ts.Diagnostics.Object_is_possibly_null); + var t = getNonNullableType(type); + return t.flags & (6144 /* Nullable */ | 8192 /* Never */) ? unknownType : t; } return type; } @@ -35725,7 +36707,7 @@ var ts; noUnusedIdentifiers && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8 /* Private */)) { - if (prop.flags & 16777216 /* Instantiated */) { + if (getCheckFlags(prop) & 1 /* Instantiated */) { getSymbolLinks(prop).target.isReferenced = true; } else { @@ -35733,6 +36715,15 @@ var ts; } } } + function isInPropertyInitializer(node) { + while (node) { + if (node.parent && node.parent.kind === 148 /* PropertyDeclaration */ && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { var type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -35745,16 +36736,23 @@ var ts; } var prop = getPropertyOfType(apparentType, right.text); if (!prop) { + var stringIndexType = getIndexTypeOfType(apparentType, 0 /* String */); + if (stringIndexType) { + return stringIndexType; + } if (right.text && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & 16384 /* TypeParameter */ && type.isThisType ? apparentType : type); } return unknownType; } + if (prop.valueDeclaration && + isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; - if (prop.parent && prop.parent.flags & 32 /* Class */) { - checkClassPropertyAccess(node, left, apparentType, prop); - } + checkPropertyAccessibility(node, left, apparentType, prop); var propType = getTypeOfSymbol(prop); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { @@ -35766,7 +36764,7 @@ var ts; // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 177 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || + if (node.kind !== 178 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 65536 /* Union */)) { return propType; @@ -35775,14 +36773,14 @@ var ts; return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 177 /* PropertyAccessExpression */ + var left = node.kind === 178 /* 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 */) { - return checkClassPropertyAccess(node, left, type, prop); + if (prop) { + return checkPropertyAccessibility(node, left, type, prop); } } return true; @@ -35792,7 +36790,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 225 /* VariableDeclarationList */) { + if (initializer.kind === 226 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -35821,7 +36819,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 213 /* ForInStatement */ && + if (node.kind === 214 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -35839,7 +36837,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 180 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 181 /* 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); @@ -35859,7 +36857,7 @@ var ts; error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } - return getIndexedAccessType(objectType, indexType, node); + return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === unknownType) { @@ -35897,10 +36895,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 181 /* TaggedTemplateExpression */) { + if (node.kind === 182 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 145 /* Decorator */) { + else if (node.kind !== 146 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -35930,13 +36928,13 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_9 = signature.declaration && signature.declaration.parent; + var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_9 === lastParent) { + if (lastParent && parent === lastParent) { index++; } else { - lastParent = parent_9; + lastParent = parent; index = cutoffIndex; } } @@ -35944,7 +36942,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_9; + lastParent = parent; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -35966,7 +36964,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 196 /* SpreadElement */) { + if (arg && arg.kind === 197 /* SpreadElement */) { return i; } } @@ -35979,13 +36977,17 @@ 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 === 181 /* TaggedTemplateExpression */) { + if (ts.isJsxOpeningLikeElement(node)) { + // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". + return true; + } + if (node.kind === 182 /* 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 argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 194 /* TemplateExpression */) { + if (tagExpression.template.kind === 195 /* 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; @@ -36002,7 +37004,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 145 /* Decorator */) { + else if (node.kind === 146 /* Decorator */) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -36011,19 +37013,21 @@ 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 === 180 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 181 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; - // If we are missing the close paren, the call is incomplete. + // If we are missing the close parenthesis, the call is incomplete. callIsIncomplete = callExpression.arguments.end === callExpression.end; typeArguments = callExpression.typeArguments; spreadArgIndex = getSpreadArgumentIndex(args); } // If the user supplied type arguments, but the number of type arguments does not match // the declared number of type parameters, the call has an incorrect arity. + var numTypeParameters = ts.length(signature.typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters); var hasRightNumberOfTypeArgs = !typeArguments || - (signature.typeParameters && typeArguments.length === signature.typeParameters.length); + (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters); if (!hasRightNumberOfTypeArgs) { return false; } @@ -36095,7 +37099,7 @@ 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 !== 198 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 199 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -36130,7 +37134,7 @@ var ts; var typeParameters = signature.typeParameters; var typeArgumentsAreAssignable = true; var mapper; - for (var i = 0; i < typeParameters.length; i++) { + for (var i = 0; i < typeArgumentNodes.length; i++) { if (typeArgumentsAreAssignable /* so far */) { var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { @@ -36150,9 +37154,44 @@ var ts; } return typeArgumentsAreAssignable; } + /** + * Check if the given signature can possibly be a signature called by the JSX opening-like element. + * @param node a JSX opening-like element we are trying to figure its call signature + * @param signature a candidate signature we are trying whether it is a call signature + * @param relation a relationship to check parameter and argument type + * @param excludeArgument + */ + function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { + // JSX opening-like element has correct arity for stateless-function component if the one of the following condition is true: + // 1. callIsIncomplete + // 2. attributes property has same number of properties as the parameter object type. + // We can figure that out by resolving attributes property and check number of properties in the resolved type + // If the call has correct arity, we will then check if the argument type and parameter type is assignable + var callIsIncomplete = node.attributes.end === node.end; // If we are missing the close "/>", the call is incomplete + if (callIsIncomplete) { + return true; + } + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + // Stateless function components can have maximum of three arguments: "props", "context", and "updater". + // However "context" and "updater" are implicit and can't be specify by users. Only the first parameter, props, + // can be specified by users through attributes property. + var paramType = getTypeAtPosition(signature, 0); + var attributesType = checkExpressionWithContextualType(node.attributes, paramType, /*contextualMapper*/ undefined); + var argProperties = getPropertiesOfType(attributesType); + for (var _i = 0, argProperties_1 = argProperties; _i < argProperties_1.length; _i++) { + var arg = argProperties_1[_i]; + if (!getPropertyOfType(paramType, arg.name) && isUnhyphenatedJsxName(arg.name)) { + return false; + } + } + return checkTypeRelatedTo(attributesType, paramType, relation, /*errorNode*/ undefined, headMessage); + } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { + if (ts.isJsxOpeningLikeElement(node)) { + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 180 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 181 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -36169,7 +37208,7 @@ 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 !== 198 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 199 /* 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); @@ -36191,12 +37230,12 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 179 /* CallExpression */) { + if (node.kind === 180 /* CallExpression */) { var callee = node.expression; - if (callee.kind === 177 /* PropertyAccessExpression */) { + if (callee.kind === 178 /* PropertyAccessExpression */) { return callee.expression; } - else if (callee.kind === 178 /* ElementAccessExpression */) { + else if (callee.kind === 179 /* ElementAccessExpression */) { return callee.expression; } } @@ -36212,21 +37251,24 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 181 /* TaggedTemplateExpression */) { + if (node.kind === 182 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 194 /* TemplateExpression */) { + if (template.kind === 195 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 145 /* Decorator */) { + else if (node.kind === 146 /* 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. return undefined; } + else if (ts.isJsxOpeningLikeElement(node)) { + args = node.attributes.properties.length > 0 ? [node.attributes] : emptyArray; + } else { args = node.arguments || emptyArray; } @@ -36246,19 +37288,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 145 /* Decorator */) { + if (node.kind === 146 /* Decorator */) { switch (node.parent.kind) { - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) // If we are emitting decorators for ES3, we will only pass two arguments. @@ -36268,7 +37310,7 @@ var ts; // 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 144 /* Parameter */: + case 145 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -36292,25 +37334,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 227 /* ClassDeclaration */) { + if (node.kind === 228 /* ClassDeclaration */) { // 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); } - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 150 /* Constructor */) { + if (node.kind === 151 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 147 /* PropertyDeclaration */ || - node.kind === 149 /* MethodDeclaration */ || - node.kind === 151 /* GetAccessor */ || - node.kind === 152 /* SetAccessor */) { + if (node.kind === 148 /* PropertyDeclaration */ || + node.kind === 150 /* MethodDeclaration */ || + node.kind === 152 /* GetAccessor */ || + node.kind === 153 /* 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 @@ -36337,21 +37379,23 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 227 /* ClassDeclaration */) { + if (node.kind === 228 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { node = node.parent; - if (node.kind === 150 /* Constructor */) { + if (node.kind === 151 /* 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. } - if (node.kind === 147 /* PropertyDeclaration */ || - node.kind === 149 /* MethodDeclaration */ || - node.kind === 151 /* GetAccessor */ || - node.kind === 152 /* SetAccessor */) { + if (node.kind === 148 /* PropertyDeclaration */ || + node.kind === 150 /* MethodDeclaration */ || + node.kind === 152 /* GetAccessor */ || + node.kind === 153 /* 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; // otherwise, if the member name is a computed property name it will @@ -36362,7 +37406,7 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getLiteralTypeForText(32 /* StringLiteral */, element.name.text); - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512 /* ESSymbol */)) { return nameType; @@ -36388,21 +37432,21 @@ var ts; function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 227 /* ClassDeclaration */) { + if (node.kind === 228 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 147 /* PropertyDeclaration */) { + if (node.kind === 148 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 149 /* MethodDeclaration */ || - node.kind === 151 /* GetAccessor */ || - node.kind === 152 /* SetAccessor */) { + if (node.kind === 150 /* MethodDeclaration */ || + node.kind === 152 /* GetAccessor */ || + node.kind === 153 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -36434,10 +37478,10 @@ var ts; // 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 === 145 /* Decorator */) { + if (node.kind === 146 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 181 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -36449,8 +37493,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 === 145 /* Decorator */ || - (argIndex === 0 && node.kind === 181 /* TaggedTemplateExpression */)) { + if (node.kind === 146 /* Decorator */ || + (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -36459,11 +37503,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 145 /* Decorator */) { + if (node.kind === 146 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 181 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -36472,10 +37516,11 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 181 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 145 /* Decorator */; + var isTaggedTemplate = node.kind === 182 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 146 /* Decorator */; + var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; - if (!isTaggedTemplate && !isDecorator) { + if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. if (node.expression.kind !== 96 /* SuperKeyword */) { @@ -36544,7 +37589,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 179 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 180 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -36573,6 +37618,10 @@ var ts; // If candidate is undefined, it means that no candidates had a suitable arity. In that case, // skip the checkApplicableSignature check. if (candidateForArgumentError) { + if (isJsxOpeningOrSelfClosingElement) { + // We do not report any error here because any error will be handled in "resolveCustomJsxElementAttributesType". + return candidateForArgumentError; + } // excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...] // The importance of excludeArgument is to prevent us from typing function expression parameters // in arguments too early. If possible, we'd like to only type them once we know the correct @@ -36594,7 +37643,7 @@ var ts; if (headMessage) { diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); } - reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); + reportNoCommonSupertypeError(inferenceCandidates, node.tagName || node.expression || node.tag, diagnosticChainHead); } } else { @@ -36642,13 +37691,13 @@ var ts; if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNode); + typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); - typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; } if (!typeArgumentsAreValid) { break; @@ -36893,16 +37942,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 144 /* Parameter */: + case 145 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -36930,21 +37979,73 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray, headMessage); } + /** + * This function is similar to getResolvedSignature but is exclusively for trying to resolve JSX stateless-function component. + * The main reason we have to use this function instead of getResolvedSignature because, the caller of this function will already check the type of openingLikeElement's tagName + * and pass the type as elementType. The elementType can not be a union (as such case should be handled by the caller of this function) + * Note: at this point, we are still not sure whether the opening-like element is a stateless function component or not. + * @param openingLikeElement an opening-like JSX element to try to resolve as JSX stateless function + * @param elementType an element type of the opneing-like element by checking opening-like element's tagname. + * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; + * the function will fill it up with appropriate candidate signatures + */ + function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray) { + ts.Debug.assert(!(elementType.flags & 65536 /* Union */)); + var callSignature = resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray); + return callSignature; + } + /** + * Try treating a given opening-like element as stateless function component and resolve a tagName to a function signature. + * @param openingLikeElement an JSX opening-like element we want to try resolve its stateless function if possible + * @param elementType a type of the opening-like JSX element, a result of resolving tagName in opening-like element. + * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; + * the function will fill it up with appropriate candidate signatures + * @return a resolved signature if we can find function matching function signature through resolve call or a first signature in the list of functions. + * otherwise return undefined if tag-name of the opening-like element doesn't have call signatures + */ + function resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray) { + // If this function is called from language service, elementType can be a union type. This is not possible if the function is called from compiler (see: resolveCustomJsxElementAttributesType) + if (elementType.flags & 65536 /* Union */) { + var types = elementType.types; + var result = void 0; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); + } + return result; + } + var callSignatures = elementType && getSignaturesOfType(elementType, 0 /* Call */); + if (callSignatures && callSignatures.length > 0) { + var callSignature = void 0; + callSignature = resolveCall(openingLikeElement, callSignatures, candidatesOutArray); + return callSignature; + } + return undefined; + } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 179 /* CallExpression */: + case 180 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 145 /* Decorator */: + case 146 /* Decorator */: return resolveDecorator(node, candidatesOutArray); + case 250 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + // This code-path is called by language service + return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); } - // candidatesOutArray is passed by signature help in the language service, and collectCandidates - // must fill it up with the appropriate candidate signatures + /** + * Resolve a signature of a given call-like expression. + * @param node a call-like expression to try resolve a signature for + * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; + * the function will fill it up with appropriate candidate signatures + * @return a signature of the call-like expression or undefined if one can't be found + */ function getResolvedSignature(node, candidatesOutArray) { var links = getNodeLinks(node); // If getResolvedSignature has already been called, we will have cached the resolvedSignature. @@ -36987,12 +38088,12 @@ var ts; if (node.expression.kind === 96 /* SuperKeyword */) { return voidType; } - if (node.kind === 180 /* NewExpression */) { + if (node.kind === 181 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 150 /* Constructor */ && - declaration.kind !== 154 /* ConstructSignature */ && - declaration.kind !== 159 /* ConstructorType */ && + declaration.kind !== 151 /* Constructor */ && + declaration.kind !== 155 /* ConstructSignature */ && + declaration.kind !== 160 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations @@ -37032,9 +38133,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 226 /* FunctionDeclaration */ + ? 227 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 224 /* VariableDeclaration */ + ? 225 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -37069,7 +38170,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return unknownType; } - else if (container.kind === 150 /* Constructor */) { + else if (container.kind === 151 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -37107,7 +38208,7 @@ var ts; var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { if (!parameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); } assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } @@ -37148,8 +38249,8 @@ var ts; links.type = instantiateType(contextualType, mapper); // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 172 /* ObjectBindingPattern */ || - parameter.valueDeclaration.name.kind === 173 /* ArrayBindingPattern */)) { + (parameter.valueDeclaration.name.kind === 173 /* ObjectBindingPattern */ || + parameter.valueDeclaration.name.kind === 174 /* ArrayBindingPattern */)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -37210,6 +38311,9 @@ var ts; error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } + else if (!getGlobalPromiseConstructorSymbol()) { + error(func, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } return promiseType; } function getReturnTypeFromBody(func, contextualMapper) { @@ -37219,7 +38323,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 205 /* Block */) { + if (func.body.kind !== 206 /* 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 @@ -37309,7 +38413,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 219 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 220 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -37342,7 +38446,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 184 /* FunctionExpression */ || func.kind === 185 /* ArrowFunction */)) { + func.kind === 185 /* FunctionExpression */ || func.kind === 186 /* ArrowFunction */)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -37371,7 +38475,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (ts.nodeIsMissing(func.body) || func.body.kind !== 205 /* Block */ || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 206 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -37404,10 +38508,10 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 184 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 185 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -37448,7 +38552,7 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 149 /* MethodDeclaration */) { + if (produceDiagnostics && node.kind !== 150 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithCapturedNewTargetVariable(node, node.name); @@ -37456,7 +38560,7 @@ var ts; return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -37472,7 +38576,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 205 /* Block */) { + if (node.body.kind === 206 /* Block */) { checkSourceElement(node.body); } else { @@ -37509,21 +38613,21 @@ var ts; // Get accessors without matching set accessors // Enum members // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return symbol.isReadonly || - symbol.flags & 4 /* Property */ && (getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */) !== 0 || - symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0 || + return !!(getCheckFlags(symbol) & 4 /* Readonly */ || + symbol.flags & 4 /* Property */ && getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || + symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ || symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || - (symbol.flags & 8 /* EnumMember */) !== 0; + symbol.flags & 8 /* EnumMember */); } function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 177 /* PropertyAccessExpression */ || expr.kind === 178 /* ElementAccessExpression */) && + (expr.kind === 178 /* PropertyAccessExpression */ || expr.kind === 179 /* ElementAccessExpression */) && expr.expression.kind === 98 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 150 /* Constructor */)) + if (!(func && func.kind === 151 /* Constructor */)) return true; // If func.parent is a class and symbol is a (readonly) property of that class, or // if func is a constructor and symbol is a (readonly) parameter property declared in it, @@ -37535,13 +38639,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 177 /* PropertyAccessExpression */ || expr.kind === 178 /* ElementAccessExpression */) { + if (expr.kind === 178 /* PropertyAccessExpression */ || expr.kind === 179 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); if (node.kind === 70 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 238 /* NamespaceImport */; + return declaration && declaration.kind === 239 /* NamespaceImport */; } } } @@ -37550,7 +38654,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipParentheses(expr); - if (node.kind !== 70 /* Identifier */ && node.kind !== 177 /* PropertyAccessExpression */ && node.kind !== 178 /* ElementAccessExpression */) { + if (node.kind !== 70 /* Identifier */ && node.kind !== 178 /* PropertyAccessExpression */ && node.kind !== 179 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -37559,7 +38663,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 177 /* PropertyAccessExpression */ && expr.kind !== 178 /* ElementAccessExpression */) { + if (expr.kind !== 178 /* PropertyAccessExpression */ && expr.kind !== 179 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -37572,7 +38676,7 @@ var ts; } function checkTypeOfExpression(node) { checkExpression(node.expression); - return stringType; + return typeofType; } function checkVoidExpression(node) { checkExpression(node.expression); @@ -37603,6 +38707,7 @@ var ts; case 36 /* PlusToken */: case 37 /* MinusToken */: case 51 /* TildeToken */: + checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 512 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } @@ -37614,7 +38719,7 @@ var ts; booleanType; case 42 /* PlusPlusToken */: case 43 /* MinusMinusToken */: - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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 checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); @@ -37628,7 +38733,7 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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 checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); @@ -37643,8 +38748,8 @@ var ts; } if (type.flags & 196608 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -37661,8 +38766,8 @@ var ts; } if (type.flags & 65536 /* Union */) { var types = type.types; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var t = types_19[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -37671,8 +38776,8 @@ var ts; } if (type.flags & 131072 /* Intersection */) { var types = type.types; - for (var _a = 0, types_18 = types; _a < types_18.length; _a++) { - var t = types_18[_a]; + for (var _a = 0, types_20 = types; _a < types_20.length; _a++) { + var t = types_20[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -37692,14 +38797,17 @@ var ts; } // TypeScript 1.0 spec (April 2014): 4.15.4 // The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, - // and the right operand to be of type Any or a subtype of the 'Function' interface type. + // and the right operand to be of type Any, a subtype of the 'Function' interface type, or have a call or construct signature. // 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 (isTypeOfKind(leftType, 8190 /* Primitive */)) { error(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 - if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { + if (!(isTypeAny(rightType) || + getSignaturesOfType(rightType, 0 /* Call */).length || + getSignaturesOfType(rightType, 1 /* Construct */).length || + isTypeSubtypeOf(rightType, globalFunctionType))) { error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; @@ -37708,6 +38816,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); // TypeScript 1.0 spec (April 2014): 4.15.5 // 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. @@ -37730,22 +38840,22 @@ var ts; } /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 258 /* PropertyAssignment */ || property.kind === 259 /* ShorthandPropertyAssignment */) { - var name_20 = property.name; - if (name_20.kind === 142 /* ComputedPropertyName */) { - checkComputedPropertyName(name_20); + if (property.kind === 260 /* PropertyAssignment */ || property.kind === 261 /* ShorthandPropertyAssignment */) { + var name = property.name; + if (name.kind === 143 /* ComputedPropertyName */) { + checkComputedPropertyName(name); } - if (isComputedNonLiteralName(name_20)) { + if (isComputedNonLiteralName(name)) { return undefined; } - var text = ts.getTextOfPropertyName(name_20); + var text = ts.getTextOfPropertyName(name); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 259 /* ShorthandPropertyAssignment */) { + if (property.kind === 261 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -37754,10 +38864,10 @@ var ts; } } else { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 260 /* SpreadAssignment */) { + else if (property.kind === 262 /* SpreadAssignment */) { if (languageVersion < 5 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -37788,8 +38898,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 198 /* OmittedExpression */) { - if (element.kind !== 196 /* SpreadElement */) { + if (element.kind !== 199 /* OmittedExpression */) { + if (element.kind !== 197 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -37817,7 +38927,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 192 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { + if (restExpression.kind === 193 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -37830,7 +38940,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 259 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 261 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -37846,21 +38956,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 192 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { + if (target.kind === 193 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 176 /* ObjectLiteralExpression */) { + if (target.kind === 177 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 175 /* ArrayLiteralExpression */) { + if (target.kind === 176 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 260 /* SpreadAssignment */ ? + var error = target.parent.kind === 262 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -37882,35 +38992,35 @@ var ts; case 70 /* Identifier */: case 9 /* StringLiteral */: case 11 /* RegularExpressionLiteral */: - case 181 /* TaggedTemplateExpression */: - case 194 /* TemplateExpression */: + case 182 /* TaggedTemplateExpression */: + case 195 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: case 94 /* NullKeyword */: - case 137 /* UndefinedKeyword */: - case 184 /* FunctionExpression */: - case 197 /* ClassExpression */: - case 185 /* ArrowFunction */: - case 175 /* ArrayLiteralExpression */: - case 176 /* ObjectLiteralExpression */: - case 187 /* TypeOfExpression */: - case 201 /* NonNullExpression */: - case 248 /* JsxSelfClosingElement */: - case 247 /* JsxElement */: + case 138 /* UndefinedKeyword */: + case 185 /* FunctionExpression */: + case 198 /* ClassExpression */: + case 186 /* ArrowFunction */: + case 176 /* ArrayLiteralExpression */: + case 177 /* ObjectLiteralExpression */: + case 188 /* TypeOfExpression */: + case 202 /* NonNullExpression */: + case 249 /* JsxSelfClosingElement */: + case 248 /* JsxElement */: return true; - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -37922,9 +39032,9 @@ var ts; } return false; // Some forms listed here for clarity - case 188 /* VoidExpression */: // Explicit opt-out - case 182 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 200 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 189 /* VoidExpression */: // Explicit opt-out + case 183 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 201 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -37944,7 +39054,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 57 /* EqualsToken */ && (left.kind === 176 /* ObjectLiteralExpression */ || left.kind === 175 /* ArrayLiteralExpression */)) { + if (operator === 57 /* EqualsToken */ && (left.kind === 177 /* ObjectLiteralExpression */ || left.kind === 176 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -37975,18 +39085,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - // TypeScript 1.0 spec (April 2014): 4.19.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 - // as having the primitive type Number. If one operand is the null or undefined value, - // it is treated as having the type of the other operand. - // The result is always of the Number primitive type. - if (leftType.flags & 6144 /* Nullable */) - leftType = rightType; - if (rightType.flags & 6144 /* Nullable */) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion @@ -38009,16 +39109,10 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - // TypeScript 1.0 spec (April 2014): 4.19.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. - // If one operand is the null or undefined value, it is treated as having the type of the other operand. - if (leftType.flags & 6144 /* Nullable */) - leftType = rightType; - if (rightType.flags & 6144 /* Nullable */) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + if (!isTypeOfKind(leftType, 1 /* Any */ | 262178 /* StringLike */) && !isTypeOfKind(rightType, 1 /* Any */ | 262178 /* StringLike */)) { + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); + } var resultType = void 0; if (isTypeOfKind(leftType, 340 /* NumberLike */) && isTypeOfKind(rightType, 340 /* NumberLike */)) { // Operands of an enum type are treated as having the primitive type Number. @@ -38053,8 +39147,8 @@ var ts; case 29 /* LessThanEqualsToken */: case 30 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { - leftType = getBaseTypeOfLiteralType(leftType); - rightType = getBaseTypeOfLiteralType(rightType); + leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); + rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } @@ -38246,7 +39340,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 182 /* TypeAssertionExpression */ || node.kind === 200 /* AsExpression */; + return node.kind === 183 /* TypeAssertionExpression */ || node.kind === 201 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -38257,14 +39351,14 @@ var ts; function isLiteralContextualType(contextualType) { if (contextualType) { if (contextualType.flags & 540672 /* TypeVariable */) { - var apparentType = getApparentTypeOfTypeVariable(contextualType); + var constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; // If the type parameter is constrained to the base primitive type we're checking for, // consider this a literal context. For example, given a type parameter 'T extends string', // this causes us to infer string literal types for T. - if (apparentType.flags & (2 /* String */ | 4 /* Number */ | 8 /* Boolean */ | 16 /* Enum */)) { + if (constraint.flags & (2 /* String */ | 4 /* Number */ | 8 /* Boolean */ | 16 /* Enum */)) { return true; } - contextualType = apparentType; + contextualType = constraint; } return maybeTypeOfKind(contextualType, (480 /* Literal */ | 262144 /* Index */)); } @@ -38278,7 +39372,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 === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); @@ -38289,7 +39383,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 === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -38315,7 +39409,7 @@ var ts; function getTypeOfExpression(node) { // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (node.kind === 179 /* CallExpression */ && node.expression.kind !== 96 /* SuperKeyword */) { + if (node.kind === 180 /* CallExpression */ && node.expression.kind !== 96 /* SuperKeyword */) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -38336,7 +39430,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 141 /* QualifiedName */) { + if (node.kind === 142 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -38348,9 +39442,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 177 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 178 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 179 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 70 /* Identifier */ || node.kind === 142 /* 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); } @@ -38372,68 +39466,70 @@ var ts; case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: return checkLiteralExpression(node); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* NoSubstitutionTemplateLiteral */: return stringType; case 11 /* RegularExpressionLiteral */: return globalRegExpType; - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 179 /* CallExpression */: - case 180 /* NewExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: return checkCallExpression(node); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return checkClassExpression(node); - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 187 /* TypeOfExpression */: + case 188 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: return checkAssertion(node); - case 201 /* NonNullExpression */: + case 202 /* NonNullExpression */: return checkNonNullAssertion(node); - case 202 /* MetaProperty */: + case 203 /* MetaProperty */: return checkMetaProperty(node); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return checkDeleteExpression(node); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return checkVoidExpression(node); - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: return checkAwaitExpression(node); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return checkSpreadExpression(node, contextualMapper); - case 198 /* OmittedExpression */: + case 199 /* OmittedExpression */: return undefinedWideningType; - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return checkYieldExpression(node); - case 253 /* JsxExpression */: - return checkJsxExpression(node); - case 247 /* JsxElement */: + case 255 /* JsxExpression */: + return checkJsxExpression(node, contextualMapper); + case 248 /* JsxElement */: return checkJsxElement(node); - case 248 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 249 /* JsxOpeningElement */: + case 253 /* JsxAttributes */: + return checkJsxAttributes(node, contextualMapper); + case 250 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -38445,7 +39541,16 @@ var ts; grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } checkSourceElement(node.constraint); - getConstraintOfTypeParameter(getDeclaredTypeOfTypeParameter(getSymbolOfNode(node))); + checkSourceElement(node.default); + var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); + if (!hasNonCircularBaseConstraint(typeParameter)) { + error(node.constraint, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); + } + var constraintType = getConstraintOfTypeParameter(typeParameter); + var defaultType = getDefaultFromTypeParameter(typeParameter); + if (constraintType && defaultType) { + checkTypeAssignableTo(defaultType, getTypeWithThisArgument(constraintType, defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } @@ -38461,7 +39566,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92 /* ParameterPropertyModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 150 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 151 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -38472,7 +39577,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 150 /* Constructor */ || func.kind === 154 /* ConstructSignature */ || func.kind === 159 /* ConstructorType */) { + if (func.kind === 151 /* Constructor */ || func.kind === 155 /* ConstructSignature */ || func.kind === 160 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -38486,9 +39591,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 149 /* MethodDeclaration */ || - node.kind === 226 /* FunctionDeclaration */ || - node.kind === 184 /* FunctionExpression */; + return node.kind === 150 /* MethodDeclaration */ || + node.kind === 227 /* FunctionDeclaration */ || + node.kind === 185 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -38531,9 +39636,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_21 = _a[_i].name; - if (ts.isBindingPattern(name_21) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_21, parameterName, typePredicate.parameterName)) { + var name = _a[_i].name; + if (ts.isBindingPattern(name) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -38546,16 +39651,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 185 /* ArrowFunction */: - case 153 /* CallSignature */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 158 /* FunctionType */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - var parent_10 = node.parent; - if (node === parent_10.type) { - return parent_10; + case 186 /* ArrowFunction */: + case 154 /* CallSignature */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 159 /* FunctionType */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + var parent = node.parent; + if (node === parent.type) { + return parent; } } } @@ -38565,15 +39670,15 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_22 = element.name; - if (name_22.kind === 70 /* Identifier */ && - name_22.text === predicateVariableName) { + var name = element.name; + if (name.kind === 70 /* Identifier */ && + name.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_22.kind === 173 /* ArrayBindingPattern */ || - name_22.kind === 172 /* ObjectBindingPattern */) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, predicateVariableNode, predicateVariableName)) { + else if (name.kind === 174 /* ArrayBindingPattern */ || + name.kind === 173 /* ObjectBindingPattern */) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } } @@ -38581,12 +39686,12 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 155 /* IndexSignature */) { + if (node.kind === 156 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 /* FunctionType */ || node.kind === 226 /* FunctionDeclaration */ || node.kind === 159 /* ConstructorType */ || - node.kind === 153 /* CallSignature */ || node.kind === 150 /* Constructor */ || - node.kind === 154 /* ConstructSignature */) { + else if (node.kind === 159 /* FunctionType */ || node.kind === 227 /* FunctionDeclaration */ || node.kind === 160 /* ConstructorType */ || + node.kind === 154 /* CallSignature */ || node.kind === 151 /* Constructor */ || + node.kind === 155 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } if (ts.isAsyncFunctionLike(node) && languageVersion < 4 /* ES2017 */) { @@ -38604,10 +39709,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 153 /* CallSignature */: + case 154 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -38640,17 +39745,18 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { - var Accessor; - (function (Accessor) { - Accessor[Accessor["Getter"] = 1] = "Getter"; - Accessor[Accessor["Setter"] = 2] = "Setter"; - Accessor[Accessor["Property"] = 3] = "Property"; - })(Accessor || (Accessor = {})); + var Declaration; + (function (Declaration) { + Declaration[Declaration["Getter"] = 1] = "Getter"; + Declaration[Declaration["Setter"] = 2] = "Setter"; + Declaration[Declaration["Method"] = 4] = "Method"; + Declaration[Declaration["Property"] = 3] = "Property"; + })(Declaration || (Declaration = {})); var instanceNames = ts.createMap(); var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150 /* Constructor */) { + if (member.kind === 151 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -38659,36 +39765,76 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114 /* StaticKeyword */; }); + var isStatic = ts.getModifierFlags(member) & 32 /* Static */; var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: addName(names, member.name, memberName, 1 /* Getter */); break; - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: addName(names, member.name, memberName, 2 /* Setter */); break; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: addName(names, member.name, memberName, 3 /* Property */); break; + case 150 /* MethodDeclaration */: + addName(names, member.name, memberName, 4 /* Method */); + break; } } } } function addName(names, location, name, meaning) { - var prev = names[name]; + var prev = names.get(name); if (prev) { - if (prev & meaning) { + if (prev & 4 /* Method */) { + if (meaning !== 4 /* Method */) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + } + else if (prev & meaning) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { - names[name] = prev | meaning; + names.set(name, prev | meaning); } } else { - names[name] = meaning; + names.set(name, meaning); + } + } + } + /** + * Static members being set on a constructor function may conflict with built-in properties + * of Function. Esp. in ECMAScript 5 there are non-configurable and non-writable + * built-in properties. This check issues a transpile error when a class has a static + * member with the same name as a non-writable built-in property. + * + * @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.3 + * @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5 + * @see http://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-function-constructor + * @see http://www.ecma-international.org/ecma-262/6.0/#sec-function-instances + */ + function checkClassForStaticPropertyNameConflicts(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + var memberNameNode = member.name; + var isStatic = ts.getModifierFlags(member) & 32 /* Static */; + if (isStatic && memberNameNode) { + var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode); + switch (memberName) { + case "name": + case "length": + case "caller": + case "arguments": + case "prototype": + var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; + var className = getNameOfSymbol(getSymbolOfNode(node)); + error(memberNameNode, message, memberName, className); + break; + } } } } @@ -38696,7 +39842,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 146 /* PropertySignature */) { + if (member.kind == 147 /* PropertySignature */) { var memberName = void 0; switch (member.name.kind) { case 9 /* StringLiteral */: @@ -38707,18 +39853,18 @@ var ts; default: continue; } - if (names[memberName]) { + if (names.get(memberName)) { error(member.symbol.valueDeclaration.name, ts.Diagnostics.Duplicate_identifier_0, memberName); error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName); } else { - names[memberName] = true; + names.set(memberName, true); } } } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 228 /* InterfaceDeclaration */) { + if (node.kind === 229 /* 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 @@ -38738,7 +39884,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -38814,12 +39960,12 @@ var ts; if (n.kind === 98 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 /* FunctionExpression */ && n.kind !== 226 /* FunctionDeclaration */) { + else if (n.kind !== 185 /* FunctionExpression */ && n.kind !== 227 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 147 /* PropertyDeclaration */ && + return n.kind === 148 /* PropertyDeclaration */ && !(ts.getModifierFlags(n) & 32 /* Static */) && !!n.initializer; } @@ -38849,7 +39995,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -38873,7 +40019,7 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 151 /* GetAccessor */) { + if (node.kind === 152 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -38883,13 +40029,13 @@ 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 === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } 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 === 151 /* GetAccessor */ ? 152 /* SetAccessor */ : 151 /* GetAccessor */; + var otherKind = node.kind === 152 /* GetAccessor */ ? 153 /* SetAccessor */ : 152 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28 /* AccessibilityModifier */) !== (ts.getModifierFlags(otherAccessor) & 28 /* AccessibilityModifier */)) { @@ -38905,11 +40051,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 151 /* GetAccessor */) { + if (node.kind === 152 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 176 /* ObjectLiteralExpression */) { + if (node.parent.kind !== 177 /* ObjectLiteralExpression */) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -38932,6 +40078,7 @@ var ts; checkDecorators(node); } function checkTypeArgumentConstraints(typeParameters, typeArgumentNodes) { + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); var typeArguments; var mapper; var result = true; @@ -38939,7 +40086,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -38992,16 +40139,36 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessIndexType(type, accessNode) { + if (!(type.flags & 524288 /* IndexedAccess */)) { + return type; + } + // Check if the index type is assignable to 'keyof T' for the object type. + var objectType = type.objectType; + var indexType = type.indexType; + if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + return type; + } + // Check if we're indexing with a numeric type and the object type is a generic + // type with a constraint that has a numeric index signature. + if (maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && isTypeOfKind(indexType, 340 /* NumberLike */)) { + var constraint = getBaseConstraintOfType(objectType); + if (constraint && getIndexInfoOfType(constraint, 1 /* Number */)) { + return type; + } + } + error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); + return type; + } function checkIndexedAccessType(node) { - getTypeFromIndexedAccessTypeNode(node); + checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node) { checkSourceElement(node.typeParameter); checkSourceElement(node.type); var type = getTypeFromMappedTypeNode(node); var constraintType = getConstraintTypeFromMappedType(type); - var keyType = constraintType.flags & 540672 /* TypeVariable */ ? getApparentTypeOfTypeVariable(constraintType) : constraintType; - checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint); + checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8 /* Private */) && ts.isInAmbientContext(node); @@ -39010,9 +40177,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 228 /* InterfaceDeclaration */ && - n.parent.kind !== 227 /* ClassDeclaration */ && - n.parent.kind !== 197 /* ClassExpression */ && + if (n.parent.kind !== 229 /* InterfaceDeclaration */ && + n.parent.kind !== 228 /* ClassDeclaration */ && + n.parent.kind !== 198 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported @@ -39100,7 +40267,7 @@ var ts; var errorNode_1 = subsequentNode.name || subsequentNode; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */) && + var reportError = (node.kind === 150 /* MethodDeclaration */ || node.kind === 149 /* MethodSignature */) && (ts.getModifierFlags(node) & 32 /* Static */) !== (ts.getModifierFlags(subsequentNode) & 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -39135,11 +40302,11 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var current = declarations_5[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 228 /* InterfaceDeclaration */ || node.parent.kind === 161 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 229 /* InterfaceDeclaration */ || node.parent.kind === 162 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -39150,7 +40317,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 === 226 /* FunctionDeclaration */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */ || node.kind === 150 /* Constructor */) { + if (node.kind === 227 /* FunctionDeclaration */ || node.kind === 150 /* MethodDeclaration */ || node.kind === 149 /* MethodSignature */ || node.kind === 151 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -39272,16 +40439,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 227 /* ClassDeclaration */: - case 230 /* EnumDeclaration */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -39510,7 +40677,12 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; if (promiseConstructorType === unknownType) { - error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + if (promiseConstructorName.kind === 70 /* Identifier */ && promiseConstructorName.text === "Promise" && getTargetType(returnType) === tryGetGlobalPromiseType()) { + error(node.type, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } + else { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + } return unknownType; } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); @@ -39545,22 +40717,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 144 /* Parameter */: + case 145 /* 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 147 /* PropertyDeclaration */: + case 148 /* 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 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -39601,14 +40773,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -39617,19 +40789,19 @@ var ts; } } break; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markTypeNodeAsReferenced(node.type); break; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); break; - case 144 /* Parameter */: + case 145 /* Parameter */: markTypeNodeAsReferenced(node.type); break; } @@ -39653,7 +40825,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 && node.name.kind === 142 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 143 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -39713,43 +40885,43 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 262 /* SourceFile */: - case 231 /* ModuleDeclaration */: + case 264 /* SourceFile */: + case 232 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 205 /* Block */: - case 233 /* CaseBlock */: - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: + case 206 /* Block */: + case 234 /* CaseBlock */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: checkUnusedLocalsAndParameters(node); break; - case 150 /* Constructor */: - case 184 /* FunctionExpression */: - case 226 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 151 /* Constructor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: checkUnusedTypeParameters(node); break; } @@ -39758,11 +40930,10 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 228 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_2 = function (key) { - var local = node.locals[key]; + if (node.parent.kind !== 229 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + node.locals.forEach(function (local) { if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144 /* Parameter */) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 145 /* Parameter */) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -39775,10 +40946,7 @@ var ts; ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d.name || d, local.name); }); } } - }; - for (var key in node.locals) { - _loop_2(key); - } + }); } } function isRemovedPropertyFromObjectSpread(node) { @@ -39791,9 +40959,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 224 /* VariableDeclaration */ && - (declaration.parent.parent.kind === 213 /* ForInStatement */ || - declaration.parent.parent.kind === 214 /* ForOfStatement */)) { + if (declaration.kind === 225 /* VariableDeclaration */ && + (declaration.parent.parent.kind === 214 /* ForInStatement */ || + declaration.parent.parent.kind === 215 /* ForOfStatement */)) { return; } } @@ -39812,12 +40980,12 @@ var ts; if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149 /* MethodDeclaration */ || member.kind === 147 /* PropertyDeclaration */) { + if (member.kind === 150 /* MethodDeclaration */ || member.kind === 148 /* PropertyDeclaration */) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8 /* Private */) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 150 /* Constructor */) { + else if (member.kind === 151 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8 /* Private */) { @@ -39850,8 +41018,7 @@ var ts; } function checkUnusedModuleMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { - for (var key in node.locals) { - var local = node.locals[key]; + node.locals.forEach(function (local) { if (!local.isReferenced && !local.exportSymbol) { for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; @@ -39860,12 +41027,12 @@ var ts; } } } - } + }); } } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 205 /* Block */) { + if (node.kind === 206 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -39888,12 +41055,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 147 /* PropertyDeclaration */ || - node.kind === 146 /* PropertySignature */ || - node.kind === 149 /* MethodDeclaration */ || - node.kind === 148 /* MethodSignature */ || - node.kind === 151 /* GetAccessor */ || - node.kind === 152 /* SetAccessor */) { + if (node.kind === 148 /* PropertyDeclaration */ || + node.kind === 147 /* PropertySignature */ || + node.kind === 150 /* MethodDeclaration */ || + node.kind === 149 /* MethodSignature */ || + node.kind === 152 /* GetAccessor */ || + node.kind === 153 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -39902,7 +41069,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 144 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 145 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -39980,12 +41147,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 231 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 232 /* 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 === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 264 /* SourceFile */ && ts.isExternalOrCommonJsModule(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)); } @@ -39995,12 +41162,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 231 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 232 /* 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 === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 264 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -40035,7 +41202,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 224 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 225 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -40045,24 +41212,24 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 225 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 206 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 226 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 207 /* 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 === 205 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 232 /* ModuleBlock */ || - container.kind === 231 /* ModuleDeclaration */ || - container.kind === 262 /* SourceFile */); + (container.kind === 206 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 233 /* ModuleBlock */ || + container.kind === 232 /* ModuleDeclaration */ || + container.kind === 264 /* 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_23 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_23, name_23); + var name = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); } } } @@ -40070,7 +41237,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 144 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 145 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -40081,7 +41248,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 177 /* PropertyAccessExpression */) { + if (n.kind === 178 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -40100,8 +41267,8 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144 /* Parameter */ || - symbol.valueDeclaration.kind === 174 /* BindingElement */) { + if (symbol.valueDeclaration.kind === 145 /* Parameter */ || + symbol.valueDeclaration.kind === 175 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -40115,13 +41282,14 @@ var ts; } // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - if (current.parent.kind === 147 /* PropertyDeclaration */ && + if (current.parent.kind === 148 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)) { return; } current = current.parent; } + // fall through to report error } error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); } @@ -40142,28 +41310,28 @@ 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 === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 174 /* BindingElement */) { - if (node.parent.kind === 172 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */ && !ts.isInAmbientContext(node)) { + if (node.kind === 175 /* BindingElement */) { + if (node.parent.kind === 173 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */ && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 142 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access - var parent_11 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_11); - var name_24 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_24)); + var parent = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent); + var name = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); markPropertyAsReferenced(property); - if (parent_11.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); + if (parent.initializer && property) { + checkPropertyAccessibility(parent, parent.initializer, parentType, property); } } // For a binding pattern, check contained binding elements @@ -40171,14 +41339,14 @@ 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 === 144 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 145 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 213 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 214 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -40189,7 +41357,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 213 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 214 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -40209,10 +41377,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 146 /* PropertySignature */) { + if (node.kind !== 148 /* PropertyDeclaration */ && node.kind !== 147 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 224 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */) { + if (node.kind === 225 /* VariableDeclaration */ || node.kind === 175 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -40223,8 +41391,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 /* Parameter */ && right.kind === 224 /* VariableDeclaration */) || - (left.kind === 224 /* VariableDeclaration */ && right.kind === 144 /* Parameter */)) { + if ((left.kind === 145 /* Parameter */ && right.kind === 225 /* VariableDeclaration */) || + (left.kind === 225 /* VariableDeclaration */ && right.kind === 145 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -40254,7 +41422,7 @@ var ts; } 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 === 176 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 177 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -40275,7 +41443,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 207 /* EmptyStatement */) { + if (node.thenStatement.kind === 208 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -40295,12 +41463,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 225 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 226 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 225 /* VariableDeclarationList */) { + if (node.initializer.kind === 226 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -40323,14 +41491,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 === 225 /* VariableDeclarationList */) { + if (node.initializer.kind === 226 /* 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 === 175 /* ArrayLiteralExpression */ || varExpr.kind === 176 /* ObjectLiteralExpression */) { + if (varExpr.kind === 176 /* ArrayLiteralExpression */ || varExpr.kind === 177 /* 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. @@ -40362,7 +41530,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 === 225 /* VariableDeclarationList */) { + if (node.initializer.kind === 226 /* 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); @@ -40376,7 +41544,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 === 175 /* ArrayLiteralExpression */ || varExpr.kind === 176 /* ObjectLiteralExpression */) { + if (varExpr.kind === 176 /* ArrayLiteralExpression */ || varExpr.kind === 177 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -40629,7 +41797,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 151 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 152 /* SetAccessor */))); + return !!(node.kind === 152 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 153 /* SetAccessor */))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -40656,33 +41824,33 @@ var ts; // for generators. return; } - if (func.kind === 152 /* SetAccessor */) { + if (func.kind === 153 /* SetAccessor */) { if (node.expression) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); + error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 150 /* Constructor */) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { - error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + else if (func.kind === 151 /* Constructor */) { + if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node.expression || node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); if (promisedType) { // If the function has a return type, but promisedType is // undefined, an error will be reported in checkAsyncFunctionReturnType // so we don't need to report one here. - checkTypeAssignableTo(awaitedType, promisedType, node.expression || node); + checkTypeAssignableTo(awaitedType, promisedType, node); } } else { - checkTypeAssignableTo(exprType, returnType, node.expression || node); + checkTypeAssignableTo(exprType, returnType, node); } } } - else if (func.kind !== 150 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 151 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -40712,7 +41880,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 255 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 257 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -40724,7 +41892,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 254 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 256 /* 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 comparable @@ -40755,7 +41923,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 220 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 221 /* 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; @@ -40792,14 +41960,14 @@ var ts; grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - var blockLocals = catchClause.block.locals; - if (blockLocals) { - for (var caughtName in catchClause.locals) { - var blockLocal = blockLocals[caughtName]; + var blockLocals_1 = catchClause.block.locals; + if (blockLocals_1) { + ts.forEachKey(catchClause.locals, function (caughtName) { + var blockLocal = blockLocals_1.get(caughtName); if (blockLocal && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } - } + }); } } } @@ -40851,15 +42019,16 @@ var ts; if (!indexType) { return; } + var propDeclaration = prop.valueDeclaration; // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !isNumericName(prop.valueDeclaration.name)) { + if (indexKind === 1 /* Number */ && !(propDeclaration ? isNumericName(propDeclaration.name) : isNumericLiteralName(prop.name))) { return; } // 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 === 142 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { - errorNode = prop.valueDeclaration; + if (propDeclaration && (propDeclaration.name.kind === 143 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { + errorNode = propDeclaration; } else if (indexDeclaration) { errorNode = indexDeclaration; @@ -40889,16 +42058,26 @@ var ts; case "string": case "symbol": case "void": + case "object": error(name, message, name.text); } } - /** Check each type parameter and check that type parameters have no duplicate type parameter declarations */ + /** + * Check each type parameter and check that type parameters have no duplicate type parameter declarations + */ function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { + var seenDefault = false; for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { + if (node.default) { + seenDefault = true; + } + else if (seenDefault) { + error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters); + } for (var j = 0; j < i; j++) { if (typeParameterDeclarations[j].symbol === node.symbol) { error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name)); @@ -40909,23 +42088,65 @@ var ts; } } /** Check that type parameter lists are identical across multiple declarations */ - function checkTypeParameterListsIdentical(node, symbol) { + function checkTypeParameterListsIdentical(symbol) { if (symbol.declarations.length === 1) { return; } - var firstDecl; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 227 /* ClassDeclaration */ || declaration.kind === 228 /* InterfaceDeclaration */) { - if (!firstDecl) { - firstDecl = declaration; - } - else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); + var links = getSymbolLinks(symbol); + if (!links.typeParametersChecked) { + links.typeParametersChecked = true; + var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); + if (declarations.length <= 1) { + return; + } + var type = getDeclaredTypeOfSymbol(symbol); + if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { + // Report an error on every conflicting declaration. + var name = symbolToString(symbol); + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; + error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } } } + function areTypeParametersIdentical(declarations, typeParameters) { + var maxTypeArgumentCount = ts.length(typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; + // If this declaration has too few or too many type parameters, we report an error + var numTypeParameters = ts.length(declaration.typeParameters); + if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { + return false; + } + for (var i = 0; i < numTypeParameters; i++) { + var source = declaration.typeParameters[i]; + var target = typeParameters[i]; + // If the type parameter node does not have the same as the resolved type + // parameter at this position, we report an error. + if (source.name.text !== target.symbol.name) { + return false; + } + // If the type parameter node does not have an identical constraint as the resolved + // type parameter at this position, we report an error. + var sourceConstraint = source.constraint && getTypeFromTypeNode(source.constraint); + var targetConstraint = getConstraintFromTypeParameter(target); + if ((sourceConstraint || targetConstraint) && + (!sourceConstraint || !targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint))) { + return false; + } + // If the type parameter node has a default and it is not identical to the default + // for the type parameter at this position, we report an error. + var sourceDefault = source.default && getTypeFromTypeNode(source.default); + var targetDefault = getDefaultFromTypeParameter(target); + if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) { + return false; + } + } + } + return true; + } function checkClassExpression(node) { checkClassLikeDeclaration(node); checkNodeDeferred(node); @@ -40959,8 +42180,12 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); + // Only check for reserved static identifiers on non-ambient context. + if (!ts.isInAmbientContext(node)) { + checkClassForStaticPropertyNameConflicts(node); + } var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { if (languageVersion < 2 /* ES2015 */ && !ts.isInAmbientContext(node)) { @@ -40969,7 +42194,8 @@ var ts; var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType_1 = baseTypes[0]; - var staticBaseType = getBaseConstructorTypeOfClass(type); + var baseConstructorType = getBaseConstructorTypeOfClass(type); + var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { @@ -40983,14 +42209,17 @@ var ts; } checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType_1.symbol.valueDeclaration && + if (baseConstructorType.flags & 540672 /* TypeVariable */ && !isMixinConstructorType(staticType)) { + error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); + } + if (baseType_1.symbol && baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 227 /* ClassDeclaration */) { + baseType_1.symbol.valueDeclaration.kind === 228 /* ClassDeclaration */) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 540672 /* TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. We can simply compare the type // references (as opposed to checking the structure of the types) because elsewhere we have already checked @@ -41014,8 +42243,7 @@ var ts; if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - var declaredType = getObjectFlags(t) & 4 /* Reference */ ? t.target : t; - if (getObjectFlags(declaredType) & 3 /* ClassOrInterface */) { + if (isValidBaseType(t)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -41045,11 +42273,16 @@ var ts; function getTargetSymbol(s) { // if symbol is instantiated its flags are not copied from the 'target' // so we'll need to get back original 'target' symbol to work with correct set of flags - return s.flags & 16777216 /* Instantiated */ ? getSymbolLinks(s).target : s; + return getCheckFlags(s) & 1 /* Instantiated */ ? s.target : s; } function getClassLikeDeclarationOfSymbol(symbol) { return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); } + function getClassOrInterfaceDeclarationsOfSymbol(symbol) { + return ts.filter(symbol.declarations, function (d) { + return d.kind === 228 /* ClassDeclaration */ || d.kind === 229 /* InterfaceDeclaration */; + }); + } function checkKindsOfPropertyMemberOverrides(type, baseType) { // TypeScript 1.0 spec (April 2014): 8.2.3 // A derived class inherits all members from its base class it doesn't override. @@ -41065,11 +42298,11 @@ var ts; // Base class instance member variables and accessors can be overridden by // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration - var baseProperties = getPropertiesOfObjectType(baseType); + var baseProperties = getPropertiesOfType(baseType); for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); - if (base.flags & 134217728 /* Prototype */) { + if (base.flags & 16777216 /* Prototype */) { continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); @@ -41086,7 +42319,7 @@ var ts; // 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 & 128 /* Abstract */ && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128 /* Abstract */))) { - if (derivedClassDecl.kind === 197 /* ClassExpression */) { + if (derivedClassDecl.kind === 198 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -41134,35 +42367,7 @@ var ts; } } function isAccessor(kind) { - return kind === 151 /* GetAccessor */ || kind === 152 /* SetAccessor */; - } - function areTypeParametersIdentical(list1, list2) { - if (!list1 && !list2) { - return true; - } - if (!list1 || !list2 || list1.length !== list2.length) { - return false; - } - // TypeScript 1.0 spec (April 2014): - // When a generic interface has multiple declarations, all declarations must have identical type parameter - // lists, i.e. identical type parameter names with identical constraints in identical order. - for (var i = 0; i < list1.length; i++) { - var tp1 = list1[i]; - var tp2 = list2[i]; - if (tp1.name.text !== tp2.name.text) { - return false; - } - if (!tp1.constraint && !tp2.constraint) { - continue; - } - if (!tp1.constraint || !tp2.constraint) { - return false; - } - if (!isTypeIdenticalTo(getTypeFromTypeNode(tp1.constraint), getTypeFromTypeNode(tp2.constraint))) { - return false; - } - } - return true; + return kind === 152 /* GetAccessor */ || kind === 153 /* SetAccessor */; } function checkInheritedPropertiesAreIdentical(type, typeNode) { var baseTypes = getBaseTypes(type); @@ -41170,16 +42375,16 @@ var ts; return true; } var seen = ts.createMap(); - ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.name, { prop: p, containingType: type }); }); var ok = true; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; - var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { var prop = properties_7[_a]; - var existing = seen[prop.name]; + var existing = seen.get(prop.name); if (!existing) { - seen[prop.name] = { prop: prop, containingType: base }; + seen.set(prop.name, { prop: prop, containingType: base }); } else { var isInheritedProperty = existing.containingType !== type; @@ -41204,9 +42409,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 228 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 229 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -41313,7 +42518,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -41324,7 +42529,7 @@ var ts; case 51 /* TildeToken */: return ~value_1; } return undefined; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -41350,11 +42555,11 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(e); return +e.text; - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return evalConstant(e.expression); case 70 /* Identifier */: - case 178 /* ElementAccessExpression */: - case 177 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: + case 178 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -41367,7 +42572,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 178 /* ElementAccessExpression */) { + if (e.kind === 179 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -41385,7 +42590,7 @@ var ts; if (current.kind === 70 /* Identifier */) { break; } - else if (current.kind === 177 /* PropertyAccessExpression */) { + else if (current.kind === 178 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -41458,7 +42663,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 230 /* EnumDeclaration */) { + if (declaration.kind !== 231 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -41479,10 +42684,10 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var declaration = declarations_5[_i]; - if ((declaration.kind === 227 /* ClassDeclaration */ || - (declaration.kind === 226 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 228 /* ClassDeclaration */ || + (declaration.kind === 227 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -41546,7 +42751,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 227 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 228 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -41559,7 +42764,7 @@ var ts; // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Merged */); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 134217728 /* Transient */); if (checkBody && node.body) { // body of ambient external module is always a module block for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { @@ -41597,26 +42802,26 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 241 /* ExportAssignment */: - case 242 /* ExportDeclaration */: + case 242 /* ExportAssignment */: + case 243 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 235 /* ImportEqualsDeclaration */: - case 236 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 174 /* BindingElement */: - case 224 /* VariableDeclaration */: - var name_25 = node.name; - if (ts.isBindingPattern(name_25)) { - for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { + case 175 /* BindingElement */: + case 225 /* VariableDeclaration */: + var name = node.name; + if (ts.isBindingPattern(name)) { + for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { var el = _c[_b]; // mark individual names in binding pattern checkModuleAugmentationElement(el, isGlobalAugmentation); @@ -41624,12 +42829,12 @@ var ts; break; } // fallthrough - case 227 /* ClassDeclaration */: - case 230 /* EnumDeclaration */: - case 226 /* FunctionDeclaration */: - case 228 /* InterfaceDeclaration */: - case 231 /* ModuleDeclaration */: - case 229 /* TypeAliasDeclaration */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 227 /* FunctionDeclaration */: + case 229 /* InterfaceDeclaration */: + case 232 /* ModuleDeclaration */: + case 230 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -41639,7 +42844,7 @@ var ts; // this is done it two steps // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error // 2. main check - report error if value declaration of the parent symbol is module augmentation) - var reportError = !(symbol.flags & 33554432 /* Merged */); + var reportError = !(symbol.flags & 134217728 /* Transient */); if (!reportError) { // symbol should not originate in augmentation reportError = ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); @@ -41652,12 +42857,12 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return node; - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: do { node = node.left; } while (node.kind !== 70 /* Identifier */); return node; - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 70 /* Identifier */); @@ -41670,9 +42875,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 232 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 262 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 242 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 233 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 264 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 243 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -41705,7 +42910,7 @@ var ts; (symbol.flags & 793064 /* Type */ ? 793064 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 244 /* ExportSpecifier */ ? + var message = node.kind === 245 /* 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)); @@ -41733,7 +42938,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 238 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 239 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -41790,8 +42995,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 232 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 262 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 233 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 233 /* ModuleBlock */ && + !node.moduleSpecifier && ts.isInAmbientContext(node); + if (node.parent.kind !== 264 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -41805,7 +43012,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 262 /* SourceFile */ || node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 231 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 264 /* SourceFile */ || node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 232 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -41831,8 +43038,8 @@ 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 === 262 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 231 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 264 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 232 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -41864,18 +43071,13 @@ var ts; } } function hasExportedMembers(moduleSymbol) { - for (var id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; + return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; }); } function checkExternalModuleExports(node) { var moduleSymbol = getSymbolOfNode(node); var links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - var exportEqualsSymbol = moduleSymbol.exports["export="]; + var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; if (!isTopLevelInExternalModuleAugmentation(declaration)) { @@ -41884,35 +43086,35 @@ var ts; } // Checks for export * conflicts var exports = getExportsOfModule(moduleSymbol); - for (var id in exports) { + exports && exports.forEach(function (_a, id) { + var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { - continue; + return; } - var _a = exports[id], declarations = _a.declarations, flags = _a.flags; // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) if (flags & (1920 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) { - continue; + return; } var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) - continue; + return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, id)); } } } - } + }); links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 226 /* FunctionDeclaration */ && declaration.kind !== 149 /* MethodDeclaration */) || + return (declaration.kind !== 227 /* FunctionDeclaration */ && declaration.kind !== 150 /* MethodDeclaration */) || !!declaration.body; } } @@ -41925,123 +43127,123 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 231 /* ModuleDeclaration */: - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 226 /* FunctionDeclaration */: + case 232 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 227 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return checkTypeParameter(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return checkParameter(node); - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return checkPropertyDeclaration(node); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: return checkSignatureDeclaration(node); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: return checkMethodDeclaration(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return checkConstructorDeclaration(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return checkAccessorDeclaration(node); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return checkTypeReferenceNode(node); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return checkTypePredicate(node); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return checkTypeQuery(node); - case 161 /* TypeLiteral */: + case 162 /* TypeLiteral */: return checkTypeLiteral(node); - case 162 /* ArrayType */: + case 163 /* ArrayType */: return checkArrayType(node); - case 163 /* TupleType */: + case 164 /* TupleType */: return checkTupleType(node); - case 164 /* UnionType */: - case 165 /* IntersectionType */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 166 /* ParenthesizedType */: - case 168 /* TypeOperator */: + case 167 /* ParenthesizedType */: + case 169 /* TypeOperator */: return checkSourceElement(node.type); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 170 /* MappedType */: + case 171 /* MappedType */: return checkMappedType(node); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 205 /* Block */: - case 232 /* ModuleBlock */: + case 206 /* Block */: + case 233 /* ModuleBlock */: return checkBlock(node); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return checkVariableStatement(node); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return checkExpressionStatement(node); - case 209 /* IfStatement */: + case 210 /* IfStatement */: return checkIfStatement(node); - case 210 /* DoStatement */: + case 211 /* DoStatement */: return checkDoStatement(node); - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: return checkWhileStatement(node); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return checkForStatement(node); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return checkForInStatement(node); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return checkForOfStatement(node); - case 215 /* ContinueStatement */: - case 216 /* BreakStatement */: + case 216 /* ContinueStatement */: + case 217 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: return checkReturnStatement(node); - case 218 /* WithStatement */: + case 219 /* WithStatement */: return checkWithStatement(node); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: return checkSwitchStatement(node); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return checkLabeledStatement(node); - case 221 /* ThrowStatement */: + case 222 /* ThrowStatement */: return checkThrowStatement(node); - case 222 /* TryStatement */: + case 223 /* TryStatement */: return checkTryStatement(node); - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 174 /* BindingElement */: + case 175 /* BindingElement */: return checkBindingElement(node); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return checkClassDeclaration(node); - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return checkImportDeclaration(node); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return checkExportDeclaration(node); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return checkExportAssignment(node); - case 207 /* EmptyStatement */: + case 208 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 223 /* DebuggerStatement */: + case 224 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 245 /* MissingDeclaration */: + case 246 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -42063,17 +43265,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: checkAccessorDeferred(node); break; - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -42179,7 +43381,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 218 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 219 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -42202,25 +43404,25 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 262 /* SourceFile */: + case 264 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } // 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 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* 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. @@ -42229,7 +43431,7 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793064 /* Type */); } break; - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -42257,17 +43459,16 @@ var ts; // 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 (!symbols[id]) { - symbols[id] = symbol; + if (!symbols.has(id)) { + symbols.set(id, symbol); } } } function copySymbols(source, meaning) { if (meaning) { - for (var id in source) { - var symbol = source[id]; + source.forEach(function (symbol) { copySymbol(symbol, meaning); - } + }); } } } @@ -42278,28 +43479,28 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 143 /* TypeParameter */: - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 230 /* EnumDeclaration */: + case 144 /* TypeParameter */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 231 /* 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 === 141 /* QualifiedName */) { + while (node.parent && node.parent.kind === 142 /* QualifiedName */) { node = node.parent; } - return node.parent && (node.parent.kind === 157 /* TypeReference */ || node.parent.kind === 273 /* JSDocTypeReference */); + return node.parent && (node.parent.kind === 158 /* TypeReference */ || node.parent.kind === 276 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 177 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 178 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 199 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 200 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -42316,13 +43517,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 141 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 142 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 235 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 236 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 241 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 242 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -42334,7 +43535,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 177 /* PropertyAccessExpression */) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 178 /* PropertyAccessExpression */) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1 /* ExportsProperty */: @@ -42346,13 +43547,13 @@ var ts; default: } } - if (entityName.parent.kind === 241 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 242 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 177 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { + if (entityName.kind !== 178 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 235 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 236 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -42362,7 +43563,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 199 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 200 /* ExpressionWithTypeArguments */) { meaning = 793064 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -42386,14 +43587,14 @@ var ts; } return resolveEntityName(entityName, 107455 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 177 /* PropertyAccessExpression */) { + else if (entityName.kind === 178 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 141 /* QualifiedName */) { + else if (entityName.kind === 142 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -42402,20 +43603,20 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 /* TypeReference */ || entityName.parent.kind === 273 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = (entityName.parent.kind === 158 /* TypeReference */ || entityName.parent.kind === 276 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 251 /* JsxAttribute */) { + else if (entityName.parent.kind === 252 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 156 /* TypePredicate */) { + if (entityName.parent.kind === 157 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 262 /* SourceFile */) { + if (node.kind === 264 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -42433,8 +43634,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 174 /* BindingElement */ && - node.parent.parent.kind === 172 /* ObjectBindingPattern */ && + else if (node.parent.kind === 175 /* BindingElement */ && + node.parent.parent.kind === 173 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -42445,8 +43646,8 @@ var ts; } switch (node.kind) { case 70 /* Identifier */: - case 177 /* PropertyAccessExpression */: - case 141 /* QualifiedName */: + case 178 /* PropertyAccessExpression */: + case 142 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -42460,12 +43661,12 @@ var ts; case 96 /* SuperKeyword */: var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 167 /* ThisType */: + case 168 /* ThisType */: return getTypeFromTypeNode(node).symbol; case 122 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 150 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 151 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -42473,7 +43674,7 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 236 /* ImportDeclaration */ || node.parent.kind === 242 /* ExportDeclaration */) && + ((node.parent.kind === 237 /* ImportDeclaration */ || node.parent.kind === 243 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -42483,7 +43684,7 @@ var ts; // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 178 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 179 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -42500,7 +43701,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 === 259 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 261 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; @@ -42562,28 +43763,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 176 /* ObjectLiteralExpression */ || expr.kind === 175 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 177 /* ObjectLiteralExpression */ || expr.kind === 176 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 214 /* ForOfStatement */) { + if (expr.parent.kind === 215 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 192 /* BinaryExpression */) { + if (expr.parent.kind === 193 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 258 /* PropertyAssignment */) { + if (expr.parent.kind === 260 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 175 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 176 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false) || unknownType; @@ -42623,30 +43824,33 @@ var ts; var propsByName = createSymbolTable(getPropertiesOfType(type)); if (getSignaturesOfType(type, 0 /* Call */).length || getSignaturesOfType(type, 1 /* Construct */).length) { ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { - if (!propsByName[p.name]) { - propsByName[p.name] = p; + if (!propsByName.has(p.name)) { + propsByName.set(p.name, p); } }); } return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (symbol.flags & 268435456 /* SyntheticProperty */) { + if (getCheckFlags(symbol) & 2 /* SyntheticProperty */) { var symbols_3 = []; - var name_26 = symbol.name; + var name_2 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_26); + var symbol = getPropertyOfType(t, name_2); if (symbol) { symbols_3.push(symbol); } }); return symbols_3; } - else if (symbol.flags & 67108864 /* Transient */) { + else if (symbol.flags & 134217728 /* Transient */) { if (symbol.leftSpread) { var links = symbol; return [links.leftSpread, links.rightSpread]; } + if (symbol.mappedTypeOrigin) { + return getRootSymbols(symbol.mappedTypeOrigin); + } var target = void 0; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -42663,7 +43867,8 @@ var ts; if (!ts.isGeneratedIdentifier(node)) { node = ts.getParseTreeNode(node, ts.isIdentifier); if (node) { - return getReferencedValueSymbol(node) === argumentsSymbol; + var isPropertyName_1 = node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node; + return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } return false; @@ -42684,7 +43889,7 @@ var ts; // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & 107455 /* Value */) - : ts.forEachProperty(getExportsOfModule(moduleSymbol), isValue); + : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { @@ -42719,7 +43924,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 262 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 264 /* SourceFile */) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -42776,7 +43981,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 205 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 206 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -42822,16 +44027,16 @@ var ts; return true; } switch (node.kind) { - case 235 /* ImportEqualsDeclaration */: - case 237 /* ImportClause */: - case 238 /* NamespaceImport */: - case 240 /* ImportSpecifier */: - case 244 /* ExportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 238 /* ImportClause */: + case 239 /* NamespaceImport */: + case 241 /* ImportSpecifier */: + case 245 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return node.expression && node.expression.kind === 70 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -42841,7 +44046,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 262 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 264 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -42898,6 +44103,12 @@ var ts; } return false; } + function isRequiredInitializedParameter(parameter) { + return strictNullChecks && + !isOptionalParameter(parameter) && + parameter.initializer && + !(ts.getModifierFlags(parameter) & 92 /* ParameterPropertyModifier */); + } function getNodeCheckFlags(node) { node = ts.getParseTreeNode(node); return node ? getNodeLinks(node).flags : undefined; @@ -42907,7 +44118,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 261 /* EnumMember */) { + if (node.kind === 263 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -42925,16 +44136,18 @@ var ts; function getTypeReferenceSerializationKind(typeName, location) { // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. var valueSymbol = resolveEntityName(typeName, 107455 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); - var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); - if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { - return ts.TypeReferenceSerializationKind.Promise; - } - var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; - if (constructorType && isConstructorType(constructorType)) { - return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; - } // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. var typeSymbol = resolveEntityName(typeName, 793064 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + if (valueSymbol && valueSymbol === typeSymbol) { + var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); + if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { + return ts.TypeReferenceSerializationKind.Promise; + } + var constructorType = getTypeOfSymbol(valueSymbol); + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + } // We might not be able to resolve type symbol so use unknown type in that case (eg error case) if (!typeSymbol) { return ts.TypeReferenceSerializationKind.ObjectType; @@ -42980,6 +44193,9 @@ var ts; var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : unknownType; + if (flags & 4096 /* AddUndefined */) { + type = includeFalsyTypes(type, 2048 /* Undefined */); + } getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { @@ -42994,10 +44210,13 @@ var ts; var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(node)); resolveBaseTypesOfClass(classType); var baseType = classType.resolvedBaseTypes.length ? classType.resolvedBaseTypes[0] : unknownType; + if (!baseType.symbol) { + writer.reportIllegalExtends(); + } getSymbolDisplayBuilder().buildTypeDisplay(baseType, writer, enclosingDeclaration, flags); } function hasGlobalName(name) { - return !!globals[name]; + return globals.has(name); } function getReferencedValueSymbol(reference, startInDeclarationContainer) { var resolvedSymbol = getNodeLinks(reference).resolvedSymbol; @@ -43008,9 +44227,9 @@ var ts; if (startInDeclarationContainer) { // When resolving the name of a declaration as a value, we need to start resolution // at a point outside of the declaration. - var parent_12 = reference.parent; - if (ts.isDeclaration(parent_12) && reference === parent_12.name) { - location = getDeclarationContainer(parent_12); + var parent = reference.parent; + if (ts.isDeclaration(parent) && reference === parent.name) { + location = getDeclarationContainer(parent); } } return resolveName(location, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -43046,14 +44265,13 @@ var ts; if (resolvedTypeReferenceDirectives) { // populate reverse mapping: file path -> type reference directive that was resolved to this file fileToDirective = ts.createFileMap(); - for (var key in resolvedTypeReferenceDirectives) { - var resolvedDirective = resolvedTypeReferenceDirectives[key]; + resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) { if (!resolvedDirective) { - continue; + return; } var file = host.getSourceFile(resolvedDirective.resolvedFileName); fileToDirective.set(file.path, key); - } + }); } return { getReferencedExportContainer: getReferencedExportContainer, @@ -43067,6 +44285,7 @@ var ts; isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, + isRequiredInitializedParameter: isRequiredInitializedParameter, writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, writeTypeOfExpression: writeTypeOfExpression, @@ -43096,7 +44315,7 @@ var ts; // property access can only be used as values // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = (node.kind === 177 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) + var meaning = (node.kind === 178 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) ? 107455 /* Value */ | 1048576 /* ExportValue */ : 793064 /* Type */ | 1920 /* Namespace */; var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -43139,15 +44358,15 @@ var ts; // external modules cannot define or contribute to type declaration files var current = symbol; while (true) { - var parent_13 = getParentOfSymbol(current); - if (parent_13) { - current = parent_13; + var parent = getParentOfSymbol(current); + if (parent) { + current = parent; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 262 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 264 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -43167,7 +44386,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 262 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 264 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -43191,11 +44410,11 @@ var ts; if (file.symbol && file.symbol.globalExports) { // Merge in UMD exports with first-in-wins semantics (see #9771) var source = file.symbol.globalExports; - for (var id in source) { - if (!(id in globals)) { - globals[id] = source[id]; + source.forEach(function (sourceSymbol, id) { + if (!globals.has(id)) { + globals.set(id, sourceSymbol); } - } + }); } } if (augmentations) { @@ -43265,10 +44484,10 @@ var ts; var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1 /* FirstEmitHelper */; helper <= 128 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { - var name_27 = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_27), 107455 /* Value */); + var name = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name), 107455 /* Value */); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_27); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); } } } @@ -43304,7 +44523,7 @@ var ts; } 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"); + var thenPropertySymbol = createSymbol(4 /* Property */, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; var thenableType = createObjectType(16 /* Anonymous */); thenableType.properties = [thenPropertySymbol]; @@ -43319,14 +44538,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 149 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 150 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 151 /* GetAccessor */ || node.kind === 152 /* SetAccessor */) { + else if (node.kind === 152 /* GetAccessor */ || node.kind === 153 /* 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); @@ -43344,16 +44563,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 130 /* ReadonlyKeyword */) { - if (node.kind === 146 /* PropertySignature */ || node.kind === 148 /* MethodSignature */) { + if (node.kind === 147 /* PropertySignature */ || node.kind === 149 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 155 /* IndexSignature */) { + if (node.kind === 156 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 75 /* ConstKeyword */: - if (node.kind !== 230 /* EnumDeclaration */ && node.parent.kind === 227 /* ClassDeclaration */) { + if (node.kind !== 231 /* EnumDeclaration */ && node.parent.kind === 228 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); } break; @@ -43379,7 +44598,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { + else if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -43402,10 +44621,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { + else if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 144 /* Parameter */) { + else if (node.kind === 145 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -43418,7 +44637,7 @@ var ts; if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 146 /* PropertySignature */ && node.kind !== 155 /* IndexSignature */ && node.kind !== 144 /* Parameter */) { + else if (node.kind !== 148 /* PropertyDeclaration */ && node.kind !== 147 /* PropertySignature */ && node.kind !== 156 /* IndexSignature */ && node.kind !== 145 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } @@ -43438,10 +44657,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 227 /* ClassDeclaration */) { + else if (node.parent.kind === 228 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 144 /* Parameter */) { + else if (node.kind === 145 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; @@ -43453,13 +44672,13 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 227 /* ClassDeclaration */) { + else if (node.parent.kind === 228 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 144 /* Parameter */) { + else if (node.kind === 145 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 232 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 233 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -43469,14 +44688,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 227 /* ClassDeclaration */) { - if (node.kind !== 149 /* MethodDeclaration */ && - node.kind !== 147 /* PropertyDeclaration */ && - node.kind !== 151 /* GetAccessor */ && - node.kind !== 152 /* SetAccessor */) { + if (node.kind !== 228 /* ClassDeclaration */) { + if (node.kind !== 150 /* MethodDeclaration */ && + node.kind !== 148 /* PropertyDeclaration */ && + node.kind !== 152 /* GetAccessor */ && + node.kind !== 153 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 227 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 228 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -43495,7 +44714,7 @@ var ts; 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 === 144 /* Parameter */) { + else if (node.kind === 145 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -43503,7 +44722,7 @@ var ts; break; } } - if (node.kind === 150 /* Constructor */) { + if (node.kind === 151 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -43518,13 +44737,13 @@ var ts; } return; } - else if ((node.kind === 236 /* ImportDeclaration */ || node.kind === 235 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 237 /* ImportDeclaration */ || node.kind === 236 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 144 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 145 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 144 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 145 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -43544,37 +44763,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 150 /* Constructor */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 155 /* IndexSignature */: - case 231 /* ModuleDeclaration */: - case 236 /* ImportDeclaration */: - case 235 /* ImportEqualsDeclaration */: - case 242 /* ExportDeclaration */: - case 241 /* ExportAssignment */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 144 /* Parameter */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 151 /* Constructor */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 156 /* IndexSignature */: + case 232 /* ModuleDeclaration */: + case 237 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 243 /* ExportDeclaration */: + case 242 /* ExportAssignment */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 145 /* Parameter */: return false; default: - if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { + if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { return false; } switch (node.kind) { - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); - case 228 /* InterfaceDeclaration */: - case 206 /* VariableStatement */: - case 229 /* TypeAliasDeclaration */: + case 229 /* InterfaceDeclaration */: + case 207 /* VariableStatement */: + case 230 /* TypeAliasDeclaration */: return true; - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); default: ts.Debug.fail(); @@ -43587,10 +44806,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 149 /* MethodDeclaration */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -43653,7 +44872,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 185 /* ArrowFunction */) { + if (node.kind === 186 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -43688,7 +44907,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 !== 134 /* StringKeyword */ && parameter.type.kind !== 132 /* NumberKeyword */) { + if (parameter.type.kind !== 135 /* StringKeyword */ && parameter.type.kind !== 132 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -43716,7 +44935,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 198 /* OmittedExpression */) { + if (arg.kind === 199 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -43789,19 +45008,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 142 /* ComputedPropertyName */) { + if (node.kind !== 143 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 192 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* CommaToken */) { + if (computedPropertyName.expression.kind === 193 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* 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 === 226 /* FunctionDeclaration */ || - node.kind === 184 /* FunctionExpression */ || - node.kind === 149 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 227 /* FunctionDeclaration */ || + node.kind === 185 /* FunctionExpression */ || + node.kind === 150 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -43826,15 +45045,15 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 260 /* SpreadAssignment */) { + if (prop.kind === 262 /* SpreadAssignment */) { continue; } - var name_28 = prop.name; - if (name_28.kind === 142 /* ComputedPropertyName */) { + var name = prop.name; + if (name.kind === 143 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_28); + checkGrammarComputedPropertyName(name); } - if (prop.kind === 259 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 261 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -43843,7 +45062,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 149 /* MethodDeclaration */) { + if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 150 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -43857,69 +45076,69 @@ 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 === 258 /* PropertyAssignment */ || prop.kind === 259 /* ShorthandPropertyAssignment */) { + if (prop.kind === 260 /* PropertyAssignment */ || prop.kind === 261 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_28.kind === 8 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_28); + if (name.kind === 8 /* NumericLiteral */) { + checkGrammarNumericLiteral(name); } currentKind = Property; } - else if (prop.kind === 149 /* MethodDeclaration */) { + else if (prop.kind === 150 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 151 /* GetAccessor */) { + else if (prop.kind === 152 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 152 /* SetAccessor */) { + else if (prop.kind === 153 /* SetAccessor */) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_28); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { continue; } - if (!seen[effectiveName]) { - seen[effectiveName] = currentKind; + var existingKind = seen.get(effectiveName); + if (!existingKind) { + seen.set(effectiveName, currentKind); } else { - var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_28, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_28)); + grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[effectiveName] = currentKind | existingKind; + seen.set(effectiveName, currentKind | existingKind); } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } } function checkGrammarJsxElement(node) { var seen = ts.createMap(); - for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 252 /* JsxSpreadAttribute */) { + if (attr.kind === 254 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; - var name_29 = jsxAttr.name; - if (!seen[name_29.text]) { - seen[name_29.text] = true; + var name = jsxAttr.name; + if (!seen.get(name.text)) { + seen.set(name.text, true); } else { - return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 253 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 255 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -43928,7 +45147,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 225 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 226 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -43943,20 +45162,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 213 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 214 /* 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 = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 213 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 214 /* 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 === 213 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 214 /* 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); @@ -43983,11 +45202,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 151 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 152 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 152 /* SetAccessor */) { + else if (kind === 153 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -44010,10 +45229,10 @@ var ts; A get accessor has no parameters or a single `this` parameter. A set accessor has one parameter or a `this` parameter and one more parameter */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 151 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 152 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 151 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 152 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -44028,7 +45247,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 176 /* ObjectLiteralExpression */) { + if (node.parent.kind === 177 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -44049,10 +45268,10 @@ 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 === 228 /* InterfaceDeclaration */) { + else if (node.parent.kind === 229 /* 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 === 161 /* TypeLiteral */) { + else if (node.parent.kind === 162 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -44063,11 +45282,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 220 /* LabeledStatement */: + case 221 /* 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 === 215 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 216 /* ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -44075,8 +45294,8 @@ var ts; return false; } break; - case 219 /* SwitchStatement */: - if (node.kind === 216 /* BreakStatement */ && !node.label) { + case 220 /* SwitchStatement */: + if (node.kind === 217 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -44091,13 +45310,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 216 /* BreakStatement */ + var message = node.kind === 217 /* 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 === 216 /* BreakStatement */ + var message = node.kind === 217 /* 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); @@ -44109,7 +45328,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 173 /* ArrayBindingPattern */ || node.name.kind === 172 /* ObjectBindingPattern */) { + if (node.name.kind === 174 /* ArrayBindingPattern */ || node.name.kind === 173 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -44120,11 +45339,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 190 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 191 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 213 /* ForInStatement */ && node.parent.parent.kind !== 214 /* ForOfStatement */) { + if (node.parent.parent.kind !== 214 /* ForInStatement */ && node.parent.parent.kind !== 215 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -44153,6 +45372,10 @@ var ts; } } } + if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && + !ts.isInAmbientContext(node.parent.parent) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { + checkESModuleMarker(node.name); + } var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". @@ -44162,6 +45385,22 @@ var ts; // and its Identifier is eval or arguments return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } + function checkESModuleMarker(name) { + if (name.kind === 70 /* Identifier */) { + if (ts.unescapeIdentifier(name.text) === "__esModule") { + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); + } + } + else { + var elements = name.elements; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; + if (!ts.isOmittedExpression(element)) { + return checkESModuleMarker(element.name); + } + } + } + } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 70 /* Identifier */) { if (name.originalKeywordKind === 109 /* LetKeyword */) { @@ -44170,8 +45409,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { - var element = elements_2[_i]; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var element = elements_3[_i]; if (!ts.isOmittedExpression(element)) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -44189,15 +45428,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 209 /* IfStatement */: - case 210 /* DoStatement */: - case 211 /* WhileStatement */: - case 218 /* WithStatement */: - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: + case 210 /* IfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 219 /* WithStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: return false; - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -44259,7 +45498,7 @@ var ts; return true; } } - else if (node.parent.kind === 228 /* InterfaceDeclaration */) { + else if (node.parent.kind === 229 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -44267,7 +45506,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 161 /* TypeLiteral */) { + else if (node.parent.kind === 162 /* 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; } @@ -44292,13 +45531,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 228 /* InterfaceDeclaration */ || - node.kind === 229 /* TypeAliasDeclaration */ || - node.kind === 236 /* ImportDeclaration */ || - node.kind === 235 /* ImportEqualsDeclaration */ || - node.kind === 242 /* ExportDeclaration */ || - node.kind === 241 /* ExportAssignment */ || - node.kind === 234 /* NamespaceExportDeclaration */ || + if (node.kind === 229 /* InterfaceDeclaration */ || + node.kind === 230 /* TypeAliasDeclaration */ || + node.kind === 237 /* ImportDeclaration */ || + node.kind === 236 /* ImportEqualsDeclaration */ || + node.kind === 243 /* ExportDeclaration */ || + node.kind === 242 /* ExportAssignment */ || + node.kind === 235 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -44307,7 +45546,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 === 206 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 207 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -44333,7 +45572,7 @@ var ts; // to prevent noisiness. 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 === 205 /* Block */ || node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { + if (node.parent.kind === 206 /* Block */ || node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -44341,6 +45580,9 @@ var ts; } } else { + // We must be parented by a statement. If so, there's no need + // to report the error as our parent will have already done it. + // Debug.assert(isStatement(node.parent)); } } } @@ -44351,10 +45593,10 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 171 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 172 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 261 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 263 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -44374,11 +45616,11 @@ var ts; } function getAmbientModules() { var result = []; - for (var sym in globals) { + globals.forEach(function (global, sym) { if (ambientModuleSymbolRegex.test(sym)) { - result.push(globals[sym]); + result.push(global); } - } + }); return result; } } @@ -44390,70 +45632,6 @@ var ts; /* @internal */ var ts; (function (ts) { - ; - /** - * This map contains information about the shape of each Node in "types.ts" pertaining to how - * each node should be traversed during a transformation. - * - * Each edge corresponds to a property in a Node subtype that should be traversed when visiting - * each child. The properties are assigned in the order in which traversal should occur. - * - * We only add entries for nodes that do not have a create/update pair defined in factory.ts - * - * NOTE: This needs to be kept up to date with changes to nodes in "types.ts". Currently, this - * map is not comprehensive. Only node edges relevant to tree transformation are - * currently defined. We may extend this to be more comprehensive, and eventually - * supplant the existing `forEachChild` implementation if performance is not - * significantly impacted. - */ - var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[141 /* QualifiedName */] = [ - { name: "left", test: ts.isEntityName }, - { name: "right", test: ts.isIdentifier } - ], - _a[145 /* Decorator */] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[182 /* TypeAssertionExpression */] = [ - { name: "type", test: ts.isTypeNode }, - { name: "expression", test: ts.isUnaryExpression } - ], - _a[200 /* AsExpression */] = [ - { name: "expression", test: ts.isExpression }, - { name: "type", test: ts.isTypeNode } - ], - _a[201 /* NonNullExpression */] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[230 /* EnumDeclaration */] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "members", test: ts.isEnumMember } - ], - _a[231 /* ModuleDeclaration */] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isModuleName }, - { name: "body", test: ts.isModuleBody } - ], - _a[232 /* ModuleBlock */] = [ - { name: "statements", test: ts.isStatement } - ], - _a[235 /* ImportEqualsDeclaration */] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "moduleReference", test: ts.isModuleReference } - ], - _a[246 /* ExternalModuleReference */] = [ - { name: "expression", test: ts.isExpression, optional: true } - ], - _a[261 /* EnumMember */] = [ - { name: "name", test: ts.isPropertyName }, - { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } - ], - _a)); function reduceNode(node, f, initial) { return node ? f(initial, node) : initial; } @@ -44462,8 +45640,7 @@ var ts; } /** * Similar to `reduceLeft`, performs a reduction against each child of a node. - * NOTE: Unlike `forEachChild`, this does *not* visit every node. Only nodes added to the - * `nodeEdgeTraversalMap` above will be visited. + * NOTE: Unlike `forEachChild`, this does *not* visit every node. * * @param node The node containing the children to reduce. * @param initial The initial value to supply to the reduction. @@ -44477,47 +45654,51 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 140 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 141 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 156 /* TypePredicate */ && kind <= 171 /* LiteralType */)) { + if ((kind >= 157 /* TypePredicate */ && kind <= 172 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 204 /* SemicolonClassElement */: - case 207 /* EmptyStatement */: - case 198 /* OmittedExpression */: - case 223 /* DebuggerStatement */: - case 294 /* NotEmittedStatement */: + case 205 /* SemicolonClassElement */: + case 208 /* EmptyStatement */: + case 199 /* OmittedExpression */: + case 224 /* DebuggerStatement */: + case 297 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 142 /* ComputedPropertyName */: + case 142 /* QualifiedName */: + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); + break; + case 143 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 144 /* Parameter */: + case 145 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 145 /* Decorator */: + case 146 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44526,12 +45707,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 150 /* Constructor */: + case 151 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44539,7 +45720,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44547,45 +45728,49 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 174 /* BindingElement */: + case 175 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 179 /* CallExpression */: + case 180 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 180 /* NewExpression */: + case 181 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 184 /* FunctionExpression */: + case 183 /* TypeAssertionExpression */: + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 185 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -44593,119 +45778,126 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 183 /* ParenthesizedExpression */: - case 186 /* DeleteExpression */: - case 187 /* TypeOfExpression */: - case 188 /* VoidExpression */: - case 189 /* AwaitExpression */: - case 195 /* YieldExpression */: - case 196 /* SpreadElement */: - case 201 /* NonNullExpression */: + case 184 /* ParenthesizedExpression */: + case 187 /* DeleteExpression */: + case 188 /* TypeOfExpression */: + case 189 /* VoidExpression */: + case 190 /* AwaitExpression */: + case 196 /* YieldExpression */: + case 197 /* SpreadElement */: + case 202 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; + case 201 /* AsExpression */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.type, cbNode, result); + break; + case 202 /* NonNullExpression */: + result = reduceNode(node.expression, cbNode, result); + break; // Misc - case 203 /* TemplateSpan */: + case 204 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 205 /* Block */: + case 206 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 209 /* IfStatement */: + case 210 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 210 /* DoStatement */: + case 211 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 211 /* WhileStatement */: - case 218 /* WithStatement */: + case 212 /* WhileStatement */: + case 219 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212 /* ForStatement */: + case 213 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 217 /* ReturnStatement */: - case 221 /* ThrowStatement */: + case 218 /* ReturnStatement */: + case 222 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 222 /* TryStatement */: + case 223 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 225 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44714,7 +45906,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44722,118 +45914,148 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 233 /* CaseBlock */: + case 231 /* EnumDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 232 /* ModuleDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 233 /* ModuleBlock */: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 234 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 236 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.moduleReference, cbNode, result); + break; + case 237 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 237 /* ImportClause */: + case 238 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 238 /* NamespaceImport */: + case 239 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 239 /* NamedImports */: - case 243 /* NamedExports */: + case 240 /* NamedImports */: + case 244 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 240 /* ImportSpecifier */: - case 244 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: + case 245 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; + // Module references + case 247 /* ExternalModuleReference */: + result = reduceNode(node.expression, cbNode, result); + break; // JSX - case 247 /* JsxElement */: + case 248 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 248 /* JsxSelfClosingElement */: - case 249 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + case 250 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); - result = reduceNodes(node.attributes, cbNodes, result); + result = reduceNode(node.attributes, cbNode, result); break; - case 250 /* JsxClosingElement */: + case 251 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 251 /* JsxAttribute */: + case 253 /* JsxAttributes */: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 252 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 252 /* JsxSpreadAttribute */: + case 254 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 253 /* JsxExpression */: + case 255 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 254 /* CaseClause */: + case 256 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // fall-through - case 255 /* DefaultClause */: + case 257 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 256 /* HeritageClause */: + case 258 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 257 /* CatchClause */: + case 259 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 260 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; + // Enum + case 263 /* EnumMember */: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); // Top-level nodes - case 262 /* SourceFile */: + case 264 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; - case 295 /* PartiallyEmittedExpression */: + // Transformation nodes + case 298 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; default: - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_1 = edgeTraversalPath; _i < edgeTraversalPath_1.length; _i++) { - var edge = edgeTraversalPath_1[_i]; - var value = node[edge.name]; - if (value !== undefined) { - result = ts.isArray(value) - ? reduceNodes(value, cbNodes, result) - : cbNode(result, value); - } - } - } break; } return result; } ts.reduceEachChild = reduceEachChild; - function visitNode(node, visitor, test, optional, lift, parenthesize, parentNode) { + /** + * Visits a Node using the supplied visitor, possibly returning a new Node in its place. + * + * @param node The Node to visit. + * @param visitor The callback used to visit the Node. + * @param test A callback to execute to verify the Node is valid. + * @param optional An optional value indicating whether the Node is itself optional. + * @param lift An optional callback to execute to lift a NodeArray into a valid Node. + */ + function visitNode(node, visitor, test, optional, lift) { if (node === undefined || visitor === undefined) { return node; } @@ -44855,15 +46077,21 @@ var ts; else { visitedNode = visited; } - if (parenthesize !== undefined) { - visitedNode = parenthesize(visitedNode, parentNode); - } Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); return visitedNode; } ts.visitNode = visitNode; - function visitNodes(nodes, visitor, test, start, count, parenthesize, parentNode) { + /** + * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. + * + * @param nodes The NodeArray to visit. + * @param visitor The callback used to visit a Node. + * @param test A node test to execute for each node. + * @param start An optional value indicating the starting offset at which to start visiting. + * @param count An optional value indicating the maximum number of nodes to visit. + */ + function visitNodes(nodes, visitor, test, start, count) { if (nodes === undefined) { return undefined; } @@ -44880,8 +46108,7 @@ var ts; // If we are not visiting all of the original nodes, we must always create a new array. // Since this is a fragment of a node array, we do not copy over the previous location // and will only copy over `hasTrailingComma` if we are including the last element. - updated = ts.createNodeArray([], /*location*/ undefined, - /*hasTrailingComma*/ nodes.hasTrailingComma && start + count === length); + updated = ts.createNodeArray([], /*hasTrailingComma*/ nodes.hasTrailingComma && start + count === length); } // Visit each original node. for (var i = 0; i < count; i++) { @@ -44891,27 +46118,22 @@ var ts; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { // Ensure we have a copy of `nodes`, up to the current index. - updated = ts.createNodeArray(nodes.slice(0, i), /*location*/ nodes, nodes.hasTrailingComma); + updated = ts.createNodeArray(nodes.slice(0, i), nodes.hasTrailingComma); + ts.setTextRange(updated, nodes); } if (visited) { if (ts.isArray(visited)) { for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) { var visitedNode = visited_1[_i]; - visitedNode = parenthesize - ? parenthesize(visitedNode, parentNode) - : visitedNode; Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); updated.push(visitedNode); } } else { - var visitedNode = parenthesize - ? parenthesize(visited, parentNode) - : visited; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); - updated.push(visitedNode); + Debug.assertNode(visited, test); + aggregateTransformFlags(visited); + updated.push(visited); } } } @@ -44927,10 +46149,10 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); - return ts.createNodeArray(ts.concatenate(statements, declarations), statements); + return ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements); } ts.visitLexicalEnvironment = visitLexicalEnvironment; /** @@ -44962,219 +46184,223 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 140 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 141 /* LastToken */)) { return node; } // We do not yet support types. - if ((kind >= 156 /* TypePredicate */ && kind <= 171 /* LiteralType */)) { + if ((kind >= 157 /* TypePredicate */ && kind <= 172 /* LiteralType */)) { return node; } switch (node.kind) { - case 204 /* SemicolonClassElement */: - case 207 /* EmptyStatement */: - case 198 /* OmittedExpression */: - case 223 /* DebuggerStatement */: + case 205 /* SemicolonClassElement */: + case 208 /* EmptyStatement */: + case 199 /* OmittedExpression */: + case 224 /* DebuggerStatement */: // No need to visit nodes with no children. return node; // Names - case 142 /* ComputedPropertyName */: + case 142 /* QualifiedName */: + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); + case 143 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 144 /* Parameter */: + case 145 /* Parameter */: return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), node.dotDotDotToken, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); + case 146 /* Decorator */: + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type member - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 150 /* Constructor */: + case 151 /* Constructor */: return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); // Binding patterns - case 172 /* ObjectBindingPattern */: + case 173 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 173 /* ArrayBindingPattern */: + case 174 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 174 /* BindingElement */: + case 175 /* BindingElement */: return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, /*optional*/ true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Expression - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 183 /* ParenthesizedExpression */: + case 183 /* TypeAssertionExpression */: + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 184 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 187 /* TypeOfExpression */: + case 188 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 201 /* AsExpression */: + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); + case 202 /* NonNullExpression */: + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 203 /* TemplateSpan */: + case 204 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 205 /* Block */: + case 206 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* IfStatement */: + case 210 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, /*optional*/ true, liftToBlock)); - case 210 /* DoStatement */: + case 211 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 215 /* ContinueStatement */: + case 216 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 216 /* BreakStatement */: + case 217 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 218 /* WithStatement */: + case 219 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 221 /* ThrowStatement */: + case 222 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 222 /* TryStatement */: + case 223 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, /*optional*/ true), visitNode(node.finallyBlock, visitor, ts.isBlock, /*optional*/ true)); - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 225 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 233 /* CaseBlock */: + case 231 /* EnumDeclaration */: + return ts.updateEnumDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNodes(node.members, visitor, ts.isEnumMember)); + case 232 /* ModuleDeclaration */: + return ts.updateModuleDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); + case 233 /* ModuleBlock */: + return ts.updateModuleBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 234 /* CaseBlock */: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 236 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + return ts.updateImportEqualsDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); + case 237 /* ImportDeclaration */: return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 237 /* ImportClause */: + case 238 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true)); - case 238 /* NamespaceImport */: + case 239 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 239 /* NamedImports */: + case 240 /* NamedImports */: return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 240 /* ImportSpecifier */: + case 241 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, /*optional*/ true)); - case 243 /* NamedExports */: + case 244 /* NamedExports */: return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 244 /* ExportSpecifier */: + case 245 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); + // Module references + case 247 /* ExternalModuleReference */: + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 247 /* JsxElement */: + case 248 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 248 /* JsxSelfClosingElement */: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 249 /* JsxOpeningElement */: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 250 /* JsxClosingElement */: + case 253 /* JsxAttributes */: + return ts.updateJsxAttributes(node, visitNodes(node.properties, visitor, ts.isJsxAttributeLike)); + case 249 /* JsxSelfClosingElement */: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 250 /* JsxOpeningElement */: + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 251 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 251 /* JsxAttribute */: + case 252 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 252 /* JsxSpreadAttribute */: + case 254 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 253 /* JsxExpression */: + case 255 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 254 /* CaseClause */: + case 256 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 255 /* DefaultClause */: + case 257 /* DefaultClause */: return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 256 /* HeritageClause */: + case 258 /* HeritageClause */: return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 260 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + // Enum + case 263 /* EnumMember */: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Top-level nodes - case 262 /* SourceFile */: + case 264 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 295 /* PartiallyEmittedExpression */: + case 298 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: - var updated = void 0; - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_2 = edgeTraversalPath; _i < edgeTraversalPath_2.length; _i++) { - var edge = edgeTraversalPath_2[_i]; - var value = node[edge.name]; - if (value !== undefined) { - var visited = ts.isArray(value) - ? visitNodes(value, visitor, edge.test, 0, value.length, edge.parenthesize, node) - : visitNode(value, visitor, edge.test, edge.optional, edge.lift, edge.parenthesize, node); - if (updated !== undefined || visited !== value) { - if (updated === undefined) { - updated = ts.getMutableClone(node); - } - if (visited !== value) { - updated[edge.name] = visited; - } - } - } - } - } - return updated ? ts.updateNode(updated, node) : node; + return node; } - // return node; } ts.visitEachChild = visitEachChild; function mergeLexicalEnvironment(statements, declarations) { @@ -45182,19 +46408,19 @@ var ts; return statements; } return ts.isNodeArray(statements) - ? ts.createNodeArray(ts.concatenate(statements, declarations), statements) + ? ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements) : ts.addRange(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; function mergeFunctionBodyLexicalEnvironment(body, declarations) { if (body && declarations !== undefined && declarations.length > 0) { if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.createNodeArray(ts.concatenate(body.statements, declarations), body.statements)); + return ts.updateBlock(body, ts.setTextRange(ts.createNodeArray(ts.concatenate(body.statements, declarations)), body.statements)); } else { - return ts.createBlock(ts.createNodeArray([ts.createReturn(body, /*location*/ body)].concat(declarations), body), - /*location*/ body, - /*multiLine*/ true); + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray([ts.setTextRange(ts.createReturn(body), body)].concat(declarations)), body), + /*multiLine*/ true), + /*location*/ body); } } return body; @@ -45264,7 +46490,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 199 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 200 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -45317,7 +46543,6 @@ var ts; } } })(Debug = ts.Debug || (ts.Debug = {})); - var _a; })(ts || (ts = {})); /// /// @@ -45407,7 +46632,7 @@ var ts; ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression); var expression = createAssignmentCallback ? createAssignmentCallback(target, value, location) - : ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value, location); + : ts.setTextRange(ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location); expression.original = original; emitExpression(expression); } @@ -45456,11 +46681,12 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_30 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_30, - /*type*/ undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name, + /*type*/ undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value); variable.original = original; - if (ts.isIdentifier(name_30)) { + ts.setTextRange(variable, location); + if (ts.isIdentifier(name)) { ts.setEmitFlags(variable, 64 /* NoNestedSourceMaps */); } ts.aggregateTransformFlags(variable); @@ -45664,8 +46890,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_31 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_31); + var name = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name); } } /** @@ -45687,7 +46913,7 @@ var ts; var temp = ts.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { flattenContext.context.hoistVariableDeclaration(temp); - flattenContext.emitExpression(ts.createAssignment(temp, value, location)); + flattenContext.emitExpression(ts.setTextRange(ts.createAssignment(temp, value), location)); } else { flattenContext.emitBindingOrAssignment(temp, value, location, /*original*/ undefined); @@ -45740,7 +46966,10 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), undefined, [value, ts.createArrayLiteral(propertyNames, location)]); + return ts.createCall(ts.getHelperName("__rest"), undefined, [ + value, + ts.setTextRange(ts.createArrayLiteral(propertyNames), location) + ]); } })(ts || (ts = {})); /// @@ -45775,8 +47004,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(177 /* PropertyAccessExpression */); - context.enableSubstitution(178 /* ElementAccessExpression */); + context.enableSubstitution(178 /* PropertyAccessExpression */); + context.enableSubstitution(179 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -45840,15 +47069,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 262 /* SourceFile */: - case 233 /* CaseBlock */: - case 232 /* ModuleBlock */: - case 205 /* Block */: + case 264 /* SourceFile */: + case 234 /* CaseBlock */: + case 233 /* ModuleBlock */: + case 206 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 227 /* ClassDeclaration */: - case 226 /* FunctionDeclaration */: + case 228 /* ClassDeclaration */: + case 227 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -45895,13 +47124,13 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return visitImportDeclaration(node); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return visitExportAssignment(node); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -45921,11 +47150,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 242 /* ExportDeclaration */ || - node.kind === 236 /* ImportDeclaration */ || - node.kind === 237 /* ImportClause */ || - (node.kind === 235 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 246 /* ExternalModuleReference */)) { + if (node.kind === 243 /* ExportDeclaration */ || + node.kind === 237 /* ImportDeclaration */ || + node.kind === 238 /* ImportClause */ || + (node.kind === 236 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 247 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -45955,19 +47184,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 150 /* Constructor */: + case 151 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 147 /* PropertyDeclaration */: - case 155 /* IndexSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 149 /* MethodDeclaration */: + case 148 /* PropertyDeclaration */: + case 156 /* IndexSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 150 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 204 /* SemicolonClassElement */: + case 205 /* SemicolonClassElement */: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -46007,47 +47236,47 @@ var ts; case 123 /* DeclareKeyword */: case 130 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 162 /* ArrayType */: - case 163 /* TupleType */: - case 161 /* TypeLiteral */: - case 156 /* TypePredicate */: - case 143 /* TypeParameter */: + case 163 /* ArrayType */: + case 164 /* TupleType */: + case 162 /* TypeLiteral */: + case 157 /* TypePredicate */: + case 144 /* TypeParameter */: case 118 /* AnyKeyword */: case 121 /* BooleanKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 129 /* NeverKeyword */: case 104 /* VoidKeyword */: - case 135 /* SymbolKeyword */: - case 159 /* ConstructorType */: - case 158 /* FunctionType */: - case 160 /* TypeQuery */: - case 157 /* TypeReference */: - case 164 /* UnionType */: - case 165 /* IntersectionType */: - case 166 /* ParenthesizedType */: - case 167 /* ThisType */: - case 168 /* TypeOperator */: - case 169 /* IndexedAccessType */: - case 170 /* MappedType */: - case 171 /* LiteralType */: + case 136 /* SymbolKeyword */: + case 160 /* ConstructorType */: + case 159 /* FunctionType */: + case 161 /* TypeQuery */: + case 158 /* TypeReference */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: + case 167 /* ParenthesizedType */: + case 168 /* ThisType */: + case 169 /* TypeOperator */: + case 170 /* IndexedAccessType */: + case 171 /* MappedType */: + case 172 /* LiteralType */: // TypeScript type nodes are elided. - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: // TypeScript index signatures are elided. - case 145 /* Decorator */: + case 146 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: // TypeScript property declarations are elided. return undefined; - case 150 /* Constructor */: + case 151 /* Constructor */: return visitConstructor(node); - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -46058,7 +47287,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -46069,35 +47298,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 256 /* HeritageClause */: + case 258 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 144 /* Parameter */: + case 145 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -46107,33 +47336,33 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return visitCallExpression(node); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return visitNewExpression(node); - case 201 /* NonNullExpression */: + case 202 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -46238,13 +47467,14 @@ var ts; // } var classDeclaration = ts.createClassDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); - var emitFlags = ts.getEmitFlags(node); + /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause)); // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. + var emitFlags = ts.getEmitFlags(node); if (hasStaticProperties) { emitFlags |= 32 /* NoTrailingSourceMap */; } + ts.setTextRange(classDeclaration, node); ts.setOriginalNode(classDeclaration, node); ts.setEmitFlags(classDeclaration, emitFlags); return classDeclaration; @@ -46352,12 +47582,18 @@ var ts; // } var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, hasExtendsClause); - var classExpression = ts.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members, location); + var classExpression = ts.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); + ts.setTextRange(classExpression, location); // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference // or decoratedClassAlias if the class contain self-reference. - var statement = ts.createLetStatement(declName, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression, location); + var statement = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declName, + /*type*/ undefined, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression) + ], 1 /* Let */)); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, location); ts.setCommentRange(statement, node); return statement; } @@ -46374,10 +47610,11 @@ var ts; var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84 /* ExtendsKeyword */; })); - var classExpression = ts.setOriginalNode(ts.createClassExpression( + var classExpression = ts.createClassExpression( /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, heritageClauses, members, - /*location*/ node), node); + /*typeParameters*/ undefined, heritageClauses, members); + ts.setOriginalNode(classExpression, node); + ts.setTextRange(classExpression, node); if (staticProperties.length > 0) { var expressions = []; var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -46409,7 +47646,7 @@ var ts; members.push(constructor); } ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); - return ts.createNodeArray(members, /*location*/ node.members); + return ts.setTextRange(ts.createNodeArray(members), /*location*/ node.members); } /** * Transforms (or creates) a constructor for a class. @@ -46434,10 +47671,9 @@ var ts; // constructor(${parameters}) { // ${body} // } - return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor( + return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor( /*decorators*/ undefined, - /*modifiers*/ undefined, parameters, body, - /*location*/ constructor || node), constructor)); + /*modifiers*/ undefined, parameters, body), constructor || node), constructor)); } /** * Transforms (or creates) the parameters for the constructor of a class with @@ -46520,10 +47756,10 @@ var ts; } // End the lexical environment. ts.addRange(statements, endLexicalEnvironment()); - return ts.createBlock(ts.createNodeArray(statements, + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ constructor ? constructor.body.statements : node.members), - /*location*/ constructor ? constructor.body : undefined, - /*multiLine*/ true); + /*multiLine*/ true), + /*location*/ constructor ? constructor.body : undefined); } /** * Adds super call and preceding prologue directives into the list of statements. @@ -46541,7 +47777,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -46578,9 +47814,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536 /* NoComments */); - return ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), propertyName, - /*location*/ node.name), localName), - /*location*/ ts.moveRangePos(node, -1))); + return ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1))); } /** * Gets all property declarations with initializers on either the static or instance side of a class. @@ -46614,7 +47848,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 147 /* PropertyDeclaration */ + return member.kind === 148 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } @@ -46749,12 +47983,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -46907,7 +48141,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 147 /* PropertyDeclaration */ + ? member.kind === 148 /* PropertyDeclaration */ ? ts.createVoidZero() : ts.createNull() : undefined; @@ -47013,7 +48247,7 @@ var ts; (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(35 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true))); + decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); } } } @@ -47026,10 +48260,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */ - || kind === 147 /* PropertyDeclaration */; + return kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */ + || kind === 148 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -47039,7 +48273,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 149 /* MethodDeclaration */; + return node.kind === 150 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -47050,12 +48284,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return true; } return false; @@ -47067,15 +48301,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 147 /* PropertyDeclaration */: - case 144 /* Parameter */: - case 151 /* GetAccessor */: + case 148 /* PropertyDeclaration */: + case 145 /* Parameter */: + case 152 /* GetAccessor */: return serializeTypeNode(node.type); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 149 /* MethodDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 150 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -47112,7 +48346,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 151 /* GetAccessor */) { + if (container && node.kind === 152 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -47158,24 +48392,24 @@ var ts; } switch (node.kind) { case 104 /* VoidKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 94 /* NullKeyword */: case 129 /* NeverKeyword */: return ts.createVoidZero(); - case 166 /* ParenthesizedType */: + case 167 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return ts.createIdentifier("Function"); - case 162 /* ArrayType */: - case 163 /* TupleType */: + case 163 /* ArrayType */: + case 164 /* TupleType */: return ts.createIdentifier("Array"); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: case 121 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: return ts.createIdentifier("String"); - case 171 /* LiteralType */: + case 172 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -47191,22 +48425,22 @@ var ts; break; case 132 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return serializeTypeReferenceNode(node); - case 165 /* IntersectionType */: - case 164 /* UnionType */: + case 166 /* IntersectionType */: + case 165 /* UnionType */: return serializeUnionOrIntersectionType(node); - case 160 /* TypeQuery */: - case 168 /* TypeOperator */: - case 169 /* IndexedAccessType */: - case 170 /* MappedType */: - case 161 /* TypeLiteral */: + case 161 /* TypeQuery */: + case 169 /* TypeOperator */: + case 170 /* IndexedAccessType */: + case 171 /* MappedType */: + case 162 /* TypeLiteral */: case 118 /* AnyKeyword */: - case 167 /* ThisType */: + case 168 /* ThisType */: break; default: ts.Debug.failBadSyntaxKind(node); @@ -47294,15 +48528,15 @@ var ts; case 70 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. - var name_32 = ts.getMutableClone(node); - name_32.flags &= ~8 /* Synthesized */; - name_32.original = undefined; - name_32.parent = currentScope; + var name = ts.getMutableClone(node); + name.flags &= ~8 /* Synthesized */; + name.original = undefined; + name.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_32), ts.createLiteral("undefined")), name_32); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } - return name_32; - case 141 /* QualifiedName */: + return name; + case 142 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -47370,7 +48604,7 @@ var ts; hoistVariableDeclaration(generatedName); expression = ts.createAssignment(generatedName, expression); } - return ts.setOriginalNode(ts.createComputedPropertyName(expression, /*location*/ name), name); + return ts.updateComputedPropertyName(name, expression); } else { return name; @@ -47388,7 +48622,7 @@ var ts; function visitHeritageClause(node) { if (node.token === 84 /* ExtendsKeyword */) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(84 /* ExtendsKeyword */, types, node); + return ts.setTextRange(ts.createHeritageClause(84 /* ExtendsKeyword */, types), node); } return undefined; } @@ -47401,9 +48635,8 @@ var ts; * @param node The ExpressionWithTypeArguments to transform. */ function visitExpressionWithTypeArguments(node) { - var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); - return ts.createExpressionWithTypeArguments( - /*typeArguments*/ undefined, expression, node); + return ts.updateExpressionWithTypeArguments(node, + /*typeArguments*/ undefined, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); } /** * Determines whether to emit a function-like declaration. We should not emit the @@ -47573,11 +48806,11 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), /*questionToken*/ undefined, - /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), - /*location*/ ts.moveRangePastModifiers(node)); + /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. ts.setOriginalNode(parameter, node); + ts.setTextRange(parameter, ts.moveRangePastModifiers(node)); ts.setCommentRange(parameter, node); ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); ts.setEmitFlags(parameter.name, 32 /* NoTrailingSourceMap */); @@ -47596,8 +48829,7 @@ var ts; // elide statement if there are no initialized variables. return undefined; } - return ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), - /*location*/ node); + return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -47610,7 +48842,7 @@ var ts; /*needsValue*/ false, createNamespaceExportExpression); } else { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), /*location*/ node); } } @@ -47724,9 +48956,9 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, transformEnumBody(node, containerName)), - /*typeArguments*/ undefined, [moduleArg]), - /*location*/ node); + /*typeArguments*/ undefined, [moduleArg])); ts.setOriginalNode(enumStatement, node); + ts.setTextRange(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); // Add a DeclarationMarker for the enum to preserve trailing comments and mark @@ -47747,8 +48979,7 @@ var ts; ts.addRange(statements, ts.map(node.members, transformEnumMember)); ts.addRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceLocalName; - return ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), - /*location*/ undefined, + return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); } /** @@ -47761,9 +48992,7 @@ var ts; // we pass false as 'generateNameForComputedPropertyName' for a backward compatibility purposes // old emitter always generate 'expression' part of the name as-is. var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); - return ts.createStatement(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name, - /*location*/ member), - /*location*/ member); + return ts.setTextRange(ts.createStatement(ts.setTextRange(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name), member)), member); } /** * Transforms the value of an enum member. @@ -47816,8 +49045,8 @@ var ts; if (!currentScopeFirstDeclarationsOfName) { currentScopeFirstDeclarationsOfName = ts.createMap(); } - if (!(name in currentScopeFirstDeclarationsOfName)) { - currentScopeFirstDeclarationsOfName[name] = node; + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } } @@ -47827,9 +49056,9 @@ var ts; */ function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_33 = node.symbol && node.symbol.name; - if (name_33) { - return currentScopeFirstDeclarationsOfName[name_33] === node; + var name = node.symbol && node.symbol.name; + if (name) { + return currentScopeFirstDeclarationsOfName.get(name) === node; } } return false; @@ -47846,7 +49075,7 @@ var ts; recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 230 /* EnumDeclaration */) { + if (node.kind === 231 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -47938,9 +49167,9 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, transformModuleBody(node, containerName)), - /*typeArguments*/ undefined, [moduleArg]), - /*location*/ node); + /*typeArguments*/ undefined, [moduleArg])); ts.setOriginalNode(moduleStatement, node); + ts.setTextRange(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); // Add a DeclarationMarker for the namespace to preserve trailing comments and mark @@ -47965,7 +49194,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 232 /* ModuleBlock */) { + if (body.kind === 233 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -47987,10 +49216,10 @@ var ts; currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; - var block = ts.createBlock(ts.createNodeArray(statements, + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ statementsLocation), - /*location*/ blockLocation, /*multiLine*/ true); + ts.setTextRange(block, blockLocation); // namespace hello.hi.world { // function foo() {} // @@ -48011,13 +49240,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 232 /* ModuleBlock */) { + if (body.kind !== 233 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 231 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 232 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -48058,7 +49287,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 238 /* NamespaceImport */) { + if (node.kind === 239 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -48165,10 +49394,10 @@ var ts; if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; - return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ + return ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.setOriginalNode(ts.createVariableDeclaration(node.name, /*type*/ undefined, moduleReference), node) - ]), node), node); + ])), node), node); } else { // exports.${name} = ${moduleReference}; @@ -48213,7 +49442,7 @@ var ts; * Creates a statement for the provided expression. This is used in calls to `map`. */ function expressionToStatement(expression) { - return ts.createStatement(expression, /*location*/ undefined); + return ts.createStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), ts.getLocalName(node)); @@ -48223,10 +49452,10 @@ var ts; statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue), location); + return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue, location); + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); } function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) { return ts.getNamespaceMemberName(currentNamespaceContainerName, name, /*allowComments*/ false, /*allowSourceMaps*/ true); @@ -48254,7 +49483,7 @@ var ts; function getClassAliasIfNeeded(node) { if (resolver.getNodeCheckFlags(node) & 8388608 /* ClassWithConstructorReference */) { enableSubstitutionForClassAliases(); - var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); + var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.unescapeIdentifier(node.name.text) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; hoistVariableDeclaration(classAlias); return classAlias; @@ -48281,7 +49510,7 @@ var ts; // substitute class names inside of a class declaration. context.enableSubstitution(70 /* Identifier */); // Keep track of class aliases. - classAliases = ts.createMap(); + classAliases = []; } } function enableSubstitutionForNamespaceExports() { @@ -48290,25 +49519,25 @@ var ts; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. context.enableSubstitution(70 /* Identifier */); - context.enableSubstitution(259 /* ShorthandPropertyAssignment */); + context.enableSubstitution(261 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(231 /* ModuleDeclaration */); + context.enableEmitNotification(232 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 231 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 232 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 230 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 231 /* EnumDeclaration */; } /** * Hook for node emit. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2 /* NamespaceExports */; @@ -48316,18 +49545,18 @@ var ts; if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; } /** * Hooks node substitutions. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -48337,16 +49566,16 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2 /* NamespaceExports */) { - var name_34 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_34); + var name = node.name; + var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { // A shorthand property with an assignment initializer is probably part of a // destructuring assignment if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_34, initializer, /*location*/ node); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); } - return ts.createPropertyAssignment(name_34, exportedName, /*location*/ node); + return ts.setTextRange(ts.createPropertyAssignment(name, exportedName), node); } } return node; @@ -48355,9 +49584,9 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -48395,11 +49624,12 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 262 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 231 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 230 /* EnumDeclaration */); + if (container && container.kind !== 264 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 232 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 231 /* EnumDeclaration */); if (substitute) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, /*location*/ node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), + /*location*/ node); } } } @@ -48446,11 +49676,11 @@ var ts; }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(paramHelper); - return ts.createCall(ts.getHelperName("__param"), + return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression - ], location); + ]), location); } var metadataHelper = { name: "typescript:metadata", @@ -48475,7 +49705,7 @@ var ts; function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) { context.requestEmitHelper(decorateHelper); var argumentsArray = []; - argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, /*location*/ undefined, /*multiLine*/ true)); + argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, /*multiLine*/ true)); argumentsArray.push(target); if (memberName) { argumentsArray.push(memberName); @@ -48483,7 +49713,8 @@ var ts; argumentsArray.push(descriptor); } } - return ts.createCall(ts.getHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray, location); + return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), + /*typeArguments*/ undefined, argumentsArray), location); } })(ts || (ts = {})); /// @@ -48513,37 +49744,37 @@ var ts; return node; } switch (node.kind) { - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return visitForOfStatement(node); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return visitForStatement(node); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return visitVoidExpression(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return visitConstructorDeclaration(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: return visitGetAccessorDeclaration(node); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return visitFunctionExpression(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return visitArrowFunction(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return visitParameter(node); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return visitExpressionStatement(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); default: return ts.visitEachChild(node, visitor, context); @@ -48552,9 +49783,9 @@ var ts; function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; - for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { - var e = elements_3[_i]; - if (e.kind === 260 /* SpreadAssignment */) { + for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { + var e = elements_4[_i]; + if (e.kind === 262 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -48566,7 +49797,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 258 /* PropertyAssignment */) { + if (e.kind === 260 /* PropertyAssignment */) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -48588,7 +49819,7 @@ var ts; // If the first element is a spread element, then the first argument to __assign is {}: // { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2) var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 176 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 177 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -48651,26 +49882,26 @@ var ts; /*skipInitializer*/ true); if (ts.some(declarations)) { var statement = ts.createVariableStatement( - /*modifiers*/ undefined, ts.updateVariableDeclarationList(initializer, declarations), - /*location*/ initializer); + /*modifiers*/ undefined, ts.updateVariableDeclarationList(initializer, declarations)); + ts.setTextRange(statement, initializer); leadingStatements = ts.append(leadingStatements, statement); } } else if (ts.isAssignmentPattern(initializer)) { temp = ts.createTempVariable(/*recordTempVariable*/ undefined); - var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.createAssignment(initializer, temp, /*location*/ node.initializer)), visitor, context, 1 /* ObjectRest */); - leadingStatements = ts.append(leadingStatements, ts.createStatement(expression, /*location*/ node.initializer)); + var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.setTextRange(ts.createAssignment(initializer, temp), node.initializer)), visitor, context, 1 /* ObjectRest */); + leadingStatements = ts.append(leadingStatements, ts.setTextRange(ts.createStatement(expression), node.initializer)); } } if (temp) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var statement = ts.visitNode(node.statement, visitor, ts.isStatement); var block = ts.isBlock(statement) - ? ts.updateBlock(statement, ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements), statement.statements)) - : ts.createBlock(ts.append(leadingStatements, statement), statement, /*multiLine*/ true); - return ts.updateForOf(node, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, /*type*/ undefined, /*initializer*/ undefined, node.initializer) - ], node.initializer, 1 /* Let */), expression, block); + ? ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements)), statement.statements)) + : ts.setTextRange(ts.createBlock(ts.append(leadingStatements, statement), /*multiLine*/ true), statement); + return ts.updateForOf(node, ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer) + ], 1 /* Let */), node.initializer), expression, block); } return ts.visitEachChild(node, visitor, context); } @@ -48742,7 +49973,7 @@ var ts; var trailingStatements = endLexicalEnvironment(); if (ts.some(leadingStatements) || ts.some(trailingStatements)) { var block = ts.convertToFunctionBody(body, /*multiLine*/ true); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements)), block.statements)); } return body; } @@ -48755,6 +49986,10 @@ var ts; text: "\n var __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };" }; function createAssignHelper(context, attributesSegments) { + if (context.getCompilerOptions().target >= 2 /* ES2015 */) { + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), + /*typeArguments*/ undefined, attributesSegments); + } context.requestEmitHelper(assignHelper); return ts.createCall(ts.getHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); @@ -48796,11 +50031,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 247 /* JsxElement */: + case 248 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 248 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 253 /* JsxExpression */: + case 255 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -48810,11 +50045,11 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 253 /* JsxExpression */: + case 255 /* JsxExpression */: return visitJsxExpression(node); - case 247 /* JsxElement */: + case 248 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 248 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); default: ts.Debug.failBadSyntaxKind(node); @@ -48830,7 +50065,7 @@ var ts; function visitJsxOpeningLikeElement(node, children, isChild, location) { var tagName = getTagName(node); var objectProperties; - var attrs = node.attributes; + var attrs = node.attributes.properties; if (attrs.length === 0) { // When there are no attributes, React wants "null" objectProperties = ts.createNull(); @@ -48869,15 +50104,15 @@ var ts; } function transformJsxAttributeInitializer(node) { if (node === undefined) { - return ts.createLiteral(true); + return ts.createTrue(); } else if (node.kind === 9 /* StringLiteral */) { var decoded = tryDecodeEntities(node.text); - return decoded ? ts.createLiteral(decoded, /*location*/ node) : node; + return decoded ? ts.setTextRange(ts.createLiteral(decoded), node) : node; } - else if (node.kind === 253 /* JsxExpression */) { + else if (node.kind === 255 /* JsxExpression */) { if (node.expression === undefined) { - return ts.createLiteral(true); + return ts.createTrue(); } return visitJsxExpression(node); } @@ -48886,54 +50121,61 @@ var ts; } } function visitJsxText(node) { - var text = ts.getTextOfNode(node, /*includeTrivia*/ true); - var parts; + var fixed = fixupWhitespaceAndDecodeEntities(ts.getTextOfNode(node, /*includeTrivia*/ true)); + return fixed === undefined ? undefined : ts.createLiteral(fixed); + } + /** + * 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 + * See also https://www.w3.org/TR/html4/struct/text.html#h-9.1 and https://www.w3.org/TR/CSS2/text.html#white-space-model + * + * An equivalent algorithm would be: + * - If there is only one line, return it. + * - If there is only whitespace (but multiple lines), return `undefined`. + * - Split the text into lines. + * - 'trimRight' the first line, 'trimLeft' the last line, 'trim' middle lines. + * - Decode entities on each line (individually). + * - Remove empty lines and join the rest with " ". + */ + function fixupWhitespaceAndDecodeEntities(text) { + var acc; + // First non-whitespace character on this line. var firstNonWhitespace = 0; + // Last non-whitespace character on this line. 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 + // These initial values are special because the first line is: + // firstNonWhitespace = 0 to indicate that we want leading whitsepace, + // but lastNonWhitespace = -1 as a special flag to indicate that we *don't* include the line if it's all whitespace. 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); - if (!parts) { - parts = []; - } - // We do not escape the string here as that is handled by the printer - // when it emits the literal. We do, however, need to decode JSX entities. - parts.push(ts.createLiteral(decodeEntities(part))); + // If we've seen any non-whitespace characters on this line, add the 'trim' of the line. + // (lastNonWhitespace === -1 is a special flag to detect whether the first line is all whitespace.) + if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) { + acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); } + // Reset firstNonWhitespace for the next line. + // Don't bother to reset lastNonWhitespace because we ignore it if firstNonWhitespace = -1. firstNonWhitespace = -1; } - else if (!ts.isWhiteSpace(c)) { + else if (!ts.isWhiteSpaceSingleLine(c)) { lastNonWhitespace = i; if (firstNonWhitespace === -1) { firstNonWhitespace = i; } } } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - if (!parts) { - parts = []; - } - // We do not escape the string here as that is handled by the printer - // when it emits the literal. We do, however, need to decode JSX entities. - parts.push(ts.createLiteral(decodeEntities(part))); - } - if (parts) { - return ts.reduceLeft(parts, aggregateJsxTextParts); - } - return undefined; + return firstNonWhitespace !== -1 + ? addLineOfJsxText(acc, text.substr(firstNonWhitespace)) + : acc; } - /** - * Aggregates two expressions by interpolating them with a whitespace literal. - */ - function aggregateJsxTextParts(left, right) { - return ts.createAdd(ts.createAdd(left, ts.createLiteral(" ")), right); + function addLineOfJsxText(acc, trimmedLine) { + // We do not escape the string here as that is handled by the printer + // when it emits the literal. We do, however, need to decode JSX entities. + var decoded = decodeEntities(trimmedLine); + return acc === undefined ? decoded : acc + " " + decoded; } /** * Replace entities like " ", "{", and "�" with the characters they encode. @@ -48948,7 +50190,7 @@ var ts; return String.fromCharCode(parseInt(hex, 16)); } else { - var ch = entities[word]; + var ch = entities.get(word); // If this is not a valid entity, then just use `match` (replace it with itself, i.e. don't replace) return ch ? String.fromCharCode(ch) : match; } @@ -48960,16 +50202,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 247 /* JsxElement */) { + if (node.kind === 248 /* JsxElement */) { return getTagName(node.openingElement); } else { - var name_35 = node.tagName; - if (ts.isIdentifier(name_35) && ts.isIntrinsicJsxName(name_35.text)) { - return ts.createLiteral(name_35.text); + var name = node.tagName; + if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.text)) { + return ts.createLiteral(name.text); } else { - return ts.createExpressionFromEntityName(name_35); + return ts.createExpressionFromEntityName(name); } } } @@ -48992,7 +50234,7 @@ var ts; } } ts.transformJsx = transformJsx; - var entities = ts.createMap({ + var entities = ts.createMapFromTemplate({ "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, @@ -49300,19 +50542,19 @@ var ts; case 119 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: // ES2017 'await' expressions must be transformed for targets < ES2017. return visitAwaitExpression(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: // ES2017 method declarations may be 'async' return visitMethodDeclaration(node); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: // ES2017 function declarations may be 'async' return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: // ES2017 function expressions may be 'async' return visitFunctionExpression(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: // ES2017 arrow functions may be 'async' return visitArrowFunction(node); default: @@ -49327,9 +50569,8 @@ var ts; * @param node The node to visit. */ function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield( - /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression), - /*location*/ node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createYield( + /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); } /** * Visits a MethodDeclaration node. @@ -49402,7 +50643,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 185 /* ArrowFunction */; + var isArrowFunction = node.kind === 186 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current @@ -49414,7 +50655,8 @@ var ts; var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(statements, /*location*/ node.body, /*multiLine*/ true); + var block = ts.createBlock(statements, /*multiLine*/ true); + ts.setTextRange(block, node.body); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. if (languageVersion >= 2 /* ES2015 */) { @@ -49434,7 +50676,7 @@ var ts; var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(block.statements, declarations), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); } return expression; } @@ -49447,7 +50689,7 @@ var ts; startLexicalEnvironment(); var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); var declarations = endLexicalEnvironment(); - return ts.updateBlock(visited, ts.createNodeArray(ts.concatenate(visited.statements, declarations), visited.statements)); + return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); } } function getPromiseConstructor(type) { @@ -49466,24 +50708,24 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(179 /* CallExpression */); - context.enableSubstitution(177 /* PropertyAccessExpression */); - context.enableSubstitution(178 /* ElementAccessExpression */); + context.enableSubstitution(180 /* CallExpression */); + context.enableSubstitution(178 /* PropertyAccessExpression */); + context.enableSubstitution(179 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(227 /* ClassDeclaration */); - context.enableEmitNotification(149 /* MethodDeclaration */); - context.enableEmitNotification(151 /* GetAccessor */); - context.enableEmitNotification(152 /* SetAccessor */); - context.enableEmitNotification(150 /* Constructor */); + context.enableEmitNotification(228 /* ClassDeclaration */); + context.enableEmitNotification(150 /* MethodDeclaration */); + context.enableEmitNotification(152 /* GetAccessor */); + context.enableEmitNotification(153 /* SetAccessor */); + context.enableEmitNotification(151 /* Constructor */); } } function substituteExpression(node) { switch (node.kind) { - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) { return substituteCallExpression(node); } @@ -49527,53 +50769,53 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 227 /* ClassDeclaration */ - || kind === 150 /* Constructor */ - || kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */; + return kind === 228 /* ClassDeclaration */ + || kind === 151 /* Constructor */ + || kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */; } /** * Hook for node emit. * + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { var savedCurrentSuperContainer = currentSuperContainer; currentSuperContainer = node; - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSuperContainer = savedCurrentSuperContainer; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } /** * Hooks node substitutions. * + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */) { return substituteExpression(node); } return node; } function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { if (flags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression]), "value", location); + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } else { - return ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression], location); + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), location); } } function getSuperContainerAsyncMethodFlags() { @@ -49636,7 +50878,7 @@ var ts; return node; } switch (node.kind) { - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -49661,25 +50903,21 @@ var ts; // Transforms `a[x] **= b` into `(_a = a)[_x = x] = Math.pow(_a[_x], b)` var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, /*location*/ left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, /*location*/ left.argumentExpression), - /*location*/ left); - value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, - /*location*/ left); + target = ts.setTextRange(ts.createElementAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(ts.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left); + value = ts.setTextRange(ts.createElementAccess(expressionTemp, argumentExpressionTemp), left); } else if (ts.isPropertyAccessExpression(left)) { // Transforms `a.x **= b` into `(_a = a).x = Math.pow(_a.x, b)` var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, /*location*/ left.expression), left.name, - /*location*/ left); - value = ts.createPropertyAccess(expressionTemp, left.name, - /*location*/ left); + target = ts.setTextRange(ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), left.name), left); + value = ts.setTextRange(ts.createPropertyAccess(expressionTemp, left.name), left); } else { // Transforms `a **= b` into `a = Math.pow(a, b)` target = left; value = left; } - return ts.createAssignment(target, ts.createMathPow(value, right, /*location*/ node), /*location*/ node); + return ts.setTextRange(ts.createAssignment(target, ts.createMathPow(value, right, /*location*/ node)), node); } function visitExponentiationExpression(node) { // Transforms `a ** b` into `Math.pow(a, b)` @@ -49869,7 +51107,7 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ - && node.kind === 217 /* ReturnStatement */ + && node.kind === 218 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { @@ -49902,91 +51140,91 @@ var ts; switch (node.kind) { case 114 /* StaticKeyword */: return undefined; // elide static keyword - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return visitClassDeclaration(node); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return visitClassExpression(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return visitParameter(node); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return visitArrowFunction(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return visitFunctionExpression(node); - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return visitVariableDeclaration(node); case 70 /* Identifier */: return visitIdentifier(node); - case 225 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: return visitSwitchStatement(node); - case 233 /* CaseBlock */: + case 234 /* CaseBlock */: return visitCaseBlock(node); - case 205 /* Block */: + case 206 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 216 /* BreakStatement */: - case 215 /* ContinueStatement */: + case 217 /* BreakStatement */: + case 216 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return visitLabeledStatement(node); - case 210 /* DoStatement */: - case 211 /* WhileStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return visitExpressionStatement(node); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return visitCatchClause(node); - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return visitCallExpression(node); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return visitNewExpression(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 12 /* NoSubstitutionTemplateLiteral */: case 13 /* TemplateHead */: case 14 /* TemplateMiddle */: case 15 /* TemplateTail */: return visitTemplateLiteral(node); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return visitTemplateExpression(node); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return visitYieldExpression(node); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return visitSpreadElement(node); case 96 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 98 /* ThisKeyword */: return visitThisKeyword(node); - case 202 /* MetaProperty */: + case 203 /* MetaProperty */: return visitMetaProperty(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return visitAccessorDeclaration(node); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return visitVariableStatement(node); - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -50001,7 +51239,7 @@ var ts; ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } function visitSwitchStatement(node) { if (convertedLoopState !== undefined) { @@ -50058,7 +51296,7 @@ var ts; if (ts.isGeneratedIdentifier(node)) { return node; } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + if (node.text !== "arguments" || !resolver.isArgumentsLocalBinding(node)) { return node; } return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); @@ -50069,13 +51307,13 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 216 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; - var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + var jump = node.kind === 217 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 216 /* BreakStatement */) { + if (node.kind === 217 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -50086,7 +51324,7 @@ var ts; } } else { - if (node.kind === 216 /* BreakStatement */) { + if (node.kind === 217 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -50134,8 +51372,9 @@ var ts; /*type*/ undefined, transformClassLikeDeclarationToExpression(node)); ts.setOriginalNode(variable, node); var statements = []; - var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([variable]), /*location*/ node); + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([variable])); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, node); ts.startOnNewLine(statement); statements.push(statement); // Add an `export default` statement for default exports (for `--target es5 --module es6`) @@ -50253,7 +51492,7 @@ var ts; ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); statements.push(statement); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); ts.setEmitFlags(block, 1536 /* NoComments */); return block; } @@ -50266,7 +51505,7 @@ var ts; */ function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node)), + statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node))), /*location*/ extendsClauseElement)); } } @@ -50288,8 +51527,8 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, ts.getDeclarationName(node), /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), - /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), - /*location*/ constructor || node); + /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); + ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); } @@ -50366,10 +51605,10 @@ var ts; if (constructor) { prependCaptureNewTargetIfNeeded(statements, constructor, /*copyOnWrite*/ false); } - var block = ts.createBlock(ts.createNodeArray(statements, + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ constructor ? constructor.body.statements : node.members), - /*location*/ constructor ? constructor.body : node, /*multiLine*/ true); + ts.setTextRange(block, constructor ? constructor.body : node); if (!constructor) { ts.setEmitFlags(block, 1536 /* NoComments */); } @@ -50382,17 +51621,17 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 217 /* ReturnStatement */) { + if (statement.kind === 218 /* ReturnStatement */) { return true; } - else if (statement.kind === 209 /* IfStatement */) { + else if (statement.kind === 210 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 205 /* Block */) { + else if (statement.kind === 206 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -50450,7 +51689,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -50460,8 +51699,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 192 /* BinaryExpression */ - || superCallExpression.left.kind !== 179 /* CallExpression */) { + if (superCallExpression.kind !== 193 /* BinaryExpression */ + || superCallExpression.left.kind !== 180 /* CallExpression */) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } // Shift comments from the original super call to the return statement. @@ -50496,25 +51735,25 @@ var ts; else if (ts.isBindingPattern(node.name)) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. - return ts.setOriginalNode(ts.createParameter( + return ts.setOriginalNode(ts.setTextRange(ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, ts.getGeneratedNameForNode(node), /*questionToken*/ undefined, /*type*/ undefined, - /*initializer*/ undefined, + /*initializer*/ undefined), /*location*/ node), /*original*/ node); } else if (node.initializer) { // Initializers are elided - return ts.setOriginalNode(ts.createParameter( + return ts.setOriginalNode(ts.setTextRange(ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, node.name, /*questionToken*/ undefined, /*type*/ undefined, - /*initializer*/ undefined, + /*initializer*/ undefined), /*location*/ node), /*original*/ node); } @@ -50544,17 +51783,17 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_36 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; // A rest parameter cannot have a binding pattern or an initializer, // so let's just ignore it. if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_36)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_36, initializer); + if (ts.isBindingPattern(name)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_36, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer); } } } @@ -50589,13 +51828,11 @@ var ts; */ function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer)), - /*location*/ parameter)) - ], /*location*/ parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */), - /*elseStatement*/ undefined, - /*location*/ parameter); + var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([ + ts.createStatement(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer))), parameter)) + ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */)); statement.startsOnNewLine = true; + ts.setTextRange(statement, parameter); ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 524288 /* CustomPrologue */); statements.push(statement); } @@ -50632,22 +51869,21 @@ var ts; var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); // var param = []; - statements.push(ts.setEmitFlags(ts.createVariableStatement( + statements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, /*type*/ undefined, ts.createArrayLiteral([])) - ]), + ])), /*location*/ parameter), 524288 /* CustomPrologue */)); // for (var _i = restIndex; _i < arguments.length; _i++) { // param[_i - restIndex] = arguments[_i]; // } - var forStatement = ts.createFor(ts.createVariableDeclarationList([ + var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) - ], /*location*/ parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), - /*location*/ parameter), ts.createPostfixIncrement(temp, /*location*/ parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 + ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ + ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp - : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), + : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), /*location*/ parameter)) ])); ts.setEmitFlags(forStatement, 524288 /* CustomPrologue */); @@ -50661,7 +51897,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 185 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 186 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -50671,8 +51907,9 @@ var ts; /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("_this", /*type*/ undefined, initializer) - ]), originalStatement); + ])); ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 524288 /* CustomPrologue */); + ts.setTextRange(captureThisStatement, originalStatement); ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } @@ -50680,22 +51917,22 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return statements; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 150 /* Constructor */: + case 151 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 92 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); @@ -50727,20 +51964,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 204 /* SemicolonClassElement */: + case 205 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 150 /* Constructor */: + case 151 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -50755,7 +51992,7 @@ var ts; * @param member The SemicolonClassElement node. */ function transformSemicolonClassElementToStatement(member) { - return ts.createEmptyStatement(/*location*/ member); + return ts.setTextRange(ts.createEmptyStatement(), member); } /** * Transforms a MethodDeclaration into a statement for a class body function. @@ -50771,7 +52008,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), + var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); @@ -50789,12 +52026,12 @@ var ts; * @param accessors The set of related get/set accessors. */ function transformAccessorsToStatement(receiver, accessors, container) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false), - /*location*/ ts.getSourceMapRange(accessors.firstAccessor)); + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } /** @@ -50831,12 +52068,12 @@ var ts; ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } - properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); + properties.push(ts.createPropertyAssignment("enumerable", ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue())); var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ target, propertyName, - ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true) + ts.createObjectLiteral(properties, /*multiLine*/ true) ]); if (startsOnNewLine) { call.startsOnNewLine = true; @@ -50861,7 +52098,8 @@ var ts; /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformFunctionBody(node), node); + /*type*/ undefined, transformFunctionBody(node)); + ts.setTextRange(func, node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8 /* CapturesThis */); exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); @@ -50931,15 +52169,15 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 227 /* FunctionDeclaration */ || node.kind === 185 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); convertedLoopState = savedConvertedLoopState; - return ts.setOriginalNode(ts.createFunctionExpression( + return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, /*typeParameters*/ undefined, parameters, - /*type*/ undefined, body, location), + /*type*/ undefined, body), location), /*original*/ node); } /** @@ -50977,7 +52215,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 185 /* ArrowFunction */); + ts.Debug.assert(node.kind === 186 /* ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -50993,7 +52231,8 @@ var ts; } } var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, /*location*/ body); + var returnStatement = ts.createReturn(expression); + ts.setTextRange(returnStatement, body); ts.setEmitFlags(returnStatement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1024 /* NoTrailingComments */); statements.push(returnStatement); // To align with the source map emit for the old emitter, we set a custom @@ -51007,7 +52246,8 @@ var ts; if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), multiLine); + ts.setTextRange(block, node.body); if (!multiLine && singleLine) { ts.setEmitFlags(block, 1 /* SingleLine */); } @@ -51019,7 +52259,7 @@ var ts; } function visitFunctionBodyDownLevel(node) { var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); - return ts.updateBlock(updated, ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, /*copyOnWrite*/ true), + return ts.updateBlock(updated, ts.setTextRange(ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, /*copyOnWrite*/ true)), /*location*/ updated.statements)); } function visitBlock(node, isFunctionBody) { @@ -51042,9 +52282,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -51060,9 +52300,9 @@ var ts; // If we are here it is most likely because our expression is a destructuring assignment. if (!needsDestructuringValue) { switch (node.expression.kind) { - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -51103,7 +52343,7 @@ var ts; } } if (assignments) { - updated = ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); }), node); + updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); })), node); } else { // none of declarations has initializer - the entire variable statement can be deleted @@ -51129,8 +52369,9 @@ var ts; var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ ? visitVariableDeclarationInLetDeclarationList : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); + var declarationList = ts.createVariableDeclarationList(declarations); ts.setOriginalNode(declarationList, node); + ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); if (node.transformFlags & 8388608 /* ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) @@ -51245,10 +52486,10 @@ var ts; return updated; } function recordLabel(node) { - convertedLoopState.labels[node.label.text] = node.label.text; + convertedLoopState.labels.set(node.label.text, node.label.text); } function resetLabel(node) { - convertedLoopState.labels[node.label.text] = undefined; + convertedLoopState.labels.set(node.label.text, undefined); } function visitLabeledStatement(node) { if (convertedLoopState && !convertedLoopState.labels) { @@ -51308,7 +52549,7 @@ var ts; // we don't want to emit a temporary variable for the RHS, just use it directly. var counter = ts.createLoopVariable(); var rhsReference = expression.kind === 70 /* Identifier */ - ? ts.createUniqueName(expression.text) + ? ts.createUniqueName(ts.unescapeIdentifier(expression.text)) : ts.createTempVariable(/*recordTempVariable*/ undefined); var elementAccess = ts.createElementAccess(rhsReference, counter); // Initialize LHS @@ -51322,8 +52563,9 @@ var ts; // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, elementAccess); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ initializer); + var declarationList = ts.createVariableDeclarationList(declarations); ts.setOriginalNode(declarationList, initializer); + ts.setTextRange(declarationList, initializer); // Adjust the source map range for the first declaration to align with the old // emitter. var firstDeclaration = declarations[0]; @@ -51335,12 +52577,11 @@ var ts; else { // The following call does not include the initializer, so we have // to emit it separately. - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.setOriginalNode(ts.createVariableDeclarationList([ + statements.push(ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), /*type*/ undefined, ts.createElementAccess(rhsReference, counter)) - ], /*location*/ ts.moveRangePos(initializer, -1)), initializer), - /*location*/ ts.moveRangeEnd(initializer, -1))); + ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); } } else { @@ -51355,7 +52596,7 @@ var ts; // Currently there is not way to check that assignment is binary expression of destructing assignment // so we have to cast never type to binaryExpression assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, /*location*/ ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createStatement(assignment), ts.moveRangeEnd(initializer, -1))); } } var bodyLocation; @@ -51364,7 +52605,7 @@ var ts; ts.addRange(statements, convertedLoopBodyStatements); } else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -51378,29 +52619,28 @@ var ts; ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression)); // The old emitter does not emit source maps for the block. // We add the location to preserve comments. - var body = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), - /*location*/ bodyLocation); + var body = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ statementsLocation)); + ts.setTextRange(body, bodyLocation); ts.setEmitFlags(body, 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); - var forStatement = ts.createFor(ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) - ], /*location*/ node.expression), 1048576 /* NoHoisting */), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), - /*location*/ node.expression), ts.createPostfixIncrement(counter, /*location*/ node.expression), body, - /*location*/ node); + var forStatement = ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)), + ts.setTextRange(ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression), node.expression) + ]), node.expression), 1048576 /* NoHoisting */), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), body); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); + ts.setTextRange(forStatement, node); return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 210 /* DoStatement */: - case 211 /* WhileStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -51423,7 +52663,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 142 /* ComputedPropertyName */) { + if (property.name.kind === 143 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -51437,8 +52677,7 @@ var ts; var temp = ts.createTempVariable(hoistVariableDeclaration); // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, node.multiLine), 32768 /* Indented */)); + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 32768 /* Indented */)); if (node.multiLine) { assignment.startsOnNewLine = true; } @@ -51496,11 +52735,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 225 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 226 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -51547,13 +52786,13 @@ var ts; copyOutParameters(loopOutParameters, 1 /* ToOutParameter */, statements_4); } ts.addRange(statements_4, lexicalEnvironment); - loopBody = ts.createBlock(statements_4, /*location*/ undefined, /*multiline*/ true); + loopBody = ts.createBlock(statements_4, /*multiline*/ true); } if (ts.isBlock(loopBody)) { loopBody.multiLine = true; } else { - loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); + loopBody = ts.createBlock([loopBody], /*multiline*/ true); } var isAsyncBlockContainingAwait = hierarchyFacts & 4 /* AsyncFunctionBody */ && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; @@ -51647,9 +52886,7 @@ var ts; // visit childnodes to transform initializer/condition/incrementor parts clone_4 = ts.visitEachChild(clone_4, visitor, context); // set loop statement - clone_4.statement = ts.createBlock(convertedLoopBodyStatements, - /*location*/ undefined, - /*multiline*/ true); + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, /*multiline*/ true); // reset and re-aggregate the transform flags clone_4.transformFlags = 0; ts.aggregateTransformFlags(clone_4); @@ -51718,26 +52955,25 @@ var ts; if (!state.labeledNonLocalBreaks) { state.labeledNonLocalBreaks = ts.createMap(); } - state.labeledNonLocalBreaks[labelText] = labelMarker; + state.labeledNonLocalBreaks.set(labelText, labelMarker); } else { if (!state.labeledNonLocalContinues) { state.labeledNonLocalContinues = ts.createMap(); } - state.labeledNonLocalContinues[labelText] = labelMarker; + state.labeledNonLocalContinues.set(labelText, labelMarker); } } function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { if (!table) { return; } - for (var labelText in table) { - var labelMarker = table[labelText]; + table.forEach(function (labelMarker, labelText) { var statements = []; // if there are no outer converted loop or outer label in question is located inside outer converted loop // then emit labeled break\continue // otherwise propagate pair 'label -> marker' to outer converted loop and emit 'return labelMarker' so outer loop can later decide what to do - if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) { var label = ts.createIdentifier(labelText); statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); } @@ -51746,7 +52982,7 @@ var ts; statements.push(ts.createReturn(loopResultName)); } caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); - } + }); } function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { var name = decl.name; @@ -51761,7 +52997,7 @@ var ts; else { loopParameters.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); if (resolver.getNodeCheckFlags(decl) & 2097152 /* NeedsLoopOutParameter */) { - var outParamName = ts.createUniqueName("out_" + name.text); + var outParamName = ts.createUniqueName("out_" + ts.unescapeIdentifier(name.text)); loopOutParameters.push({ originalName: name, outParamName: outParamName }); } } @@ -51781,20 +53017,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -51811,8 +53047,8 @@ var ts; * @param receiver The receiver for the assignment. */ function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), - /*location*/ property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -51826,8 +53062,8 @@ var ts; * @param receiver The receiver for the assignment. */ function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), - /*location*/ property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -51842,8 +53078,8 @@ var ts; */ function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined, container), - /*location*/ method); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined, container)); + ts.setTextRange(expression, method); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -51855,10 +53091,12 @@ var ts; var updated; if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var newVariableDeclaration = ts.createVariableDeclaration(temp); + ts.setTextRange(newVariableDeclaration, node.variableDeclaration); var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); - var list = ts.createVariableDeclarationList(vars, /*location*/ node.variableDeclaration, /*flags*/ node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); + var list = ts.createVariableDeclarationList(vars); + ts.setTextRange(list, node.variableDeclaration); + var destructure = ts.createVariableStatement(/*modifiers*/ undefined, list); updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); } else { @@ -51884,7 +53122,7 @@ var ts; ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); - return ts.createPropertyAssignment(node.name, functionExpression, + return ts.setTextRange(ts.createPropertyAssignment(node.name, functionExpression), /*location*/ node); } /** @@ -51908,7 +53146,7 @@ var ts; * @param node A ShorthandPropertyAssignment node. */ function visitShorthandPropertyAssignment(node) { - return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), + return ts.setTextRange(ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name)), /*location*/ node); } function visitComputedPropertyName(node) { @@ -52040,7 +53278,7 @@ var ts; })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 175 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 176 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -52056,8 +53294,7 @@ var ts; return ts.map(chunk, visitExpressionOfSpread); } function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { - return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, /*location*/ undefined, hasTrailingComma), visitor, ts.isExpression), - /*location*/ undefined, multiLine); + return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -52076,7 +53313,7 @@ var ts; * @param node A template literal. */ function visitTemplateLiteral(node) { - return ts.createLiteral(node.text, /*location*/ node); + return ts.setTextRange(ts.createLiteral(node.text), node); } /** * Visits a TaggedTemplateExpression node. @@ -52136,7 +53373,7 @@ var ts; // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's // and LineTerminatorSequences are normalized to for both TV and TRV. text = text.replace(/\r\n?/g, "\n"); - return ts.createLiteral(text, /*location*/ node); + return ts.setTextRange(ts.createLiteral(text), node); } /** * Visits a TemplateExpression node. @@ -52158,7 +53395,8 @@ var ts; // "abc" + (1 << 2) + "" var expression = ts.reduceLeft(expressions, ts.createAdd); if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); + expression.pos = node.pos; + expression.end = node.end; } return expression; } @@ -52241,19 +53479,21 @@ var ts; /** * Called by the printer just before a node is printed. * + * @param hint A hint as to the intended usage of the node. * @param node The node to be printed. + * @param emitCallback The callback used to emit the node. */ - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ : 65 /* FunctionIncludes */); - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); return; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } /** * Enables a more costly code path for substitutions when we determine a source file @@ -52273,24 +53513,24 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; context.enableSubstitution(98 /* ThisKeyword */); - context.enableEmitNotification(150 /* Constructor */); - context.enableEmitNotification(149 /* MethodDeclaration */); - context.enableEmitNotification(151 /* GetAccessor */); - context.enableEmitNotification(152 /* SetAccessor */); - context.enableEmitNotification(185 /* ArrowFunction */); - context.enableEmitNotification(184 /* FunctionExpression */); - context.enableEmitNotification(226 /* FunctionDeclaration */); + context.enableEmitNotification(151 /* Constructor */); + context.enableEmitNotification(150 /* MethodDeclaration */); + context.enableEmitNotification(152 /* GetAccessor */); + context.enableEmitNotification(153 /* SetAccessor */); + context.enableEmitNotification(186 /* ArrowFunction */); + context.enableEmitNotification(185 /* FunctionExpression */); + context.enableEmitNotification(227 /* FunctionDeclaration */); } } /** * Hooks node substitutions. * - * @param emitContext The context for the emitter. + * @param hint The context for the emitter. * @param node The node to substitute. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -52321,10 +53561,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 174 /* BindingElement */: - case 227 /* ClassDeclaration */: - case 230 /* EnumDeclaration */: - case 224 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 225 /* VariableDeclaration */: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -52366,7 +53606,7 @@ var ts; function substituteThisKeyword(node) { if (enabledSubstitutions & 1 /* CapturedThis */ && hierarchyFacts & 16 /* CapturesThis */) { - return ts.createIdentifier("_this", /*location*/ node); + return ts.setTextRange(ts.createIdentifier("_this"), node); } return node; } @@ -52382,11 +53622,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 208 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 209 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 179 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 180 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -52394,7 +53634,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 196 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 197 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -52419,6 +53659,118 @@ var ts; })(ts || (ts = {})); /// /// +/*@internal*/ +var ts; +(function (ts) { + /** + * Transforms ES5 syntax into ES3 syntax. + * + * @param context Context and state information for the transformation. + */ + function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + // enable emit notification only if using --jsx preserve or react-native + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(250 /* JsxOpeningElement */); + context.enableEmitNotification(251 /* JsxClosingElement */); + context.enableEmitNotification(249 /* JsxSelfClosingElement */); + noSubstitution = []; + } + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(178 /* PropertyAccessExpression */); + context.enableSubstitution(260 /* PropertyAssignment */); + return transformSourceFile; + /** + * Transforms an ES5 source file to ES3. + * + * @param node A SourceFile + */ + function transformSourceFile(node) { + return node; + } + /** + * Called by the printer just before a node is printed. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to emit. + * @param emitCallback A callback used to emit the node. + */ + function onEmitNode(hint, node, emitCallback) { + switch (node.kind) { + case 250 /* JsxOpeningElement */: + case 251 /* JsxClosingElement */: + case 249 /* JsxSelfClosingElement */: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(hint, node, emitCallback); + } + /** + * Hooks node substitutions. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to substitute. + */ + function onSubstituteNode(hint, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(hint, node); + } + node = previousOnSubstituteNode(hint, node); + if (ts.isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); + } + else if (ts.isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); + } + return node; + } + /** + * Substitutes a PropertyAccessExpression whose name is a reserved word. + * + * @param node A PropertyAccessExpression + */ + function substitutePropertyAccessExpression(node) { + var literalName = trySubstituteReservedName(node.name); + if (literalName) { + return ts.setTextRange(ts.createElementAccess(node.expression, literalName), node); + } + return node; + } + /** + * Substitutes a PropertyAssignment whose name is a reserved word. + * + * @param node A PropertyAssignment + */ + function substitutePropertyAssignment(node) { + var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return ts.updatePropertyAssignment(node, literalName, node.initializer); + } + return node; + } + /** + * If an identifier name is a reserved word, returns a string literal for the name. + * + * @param name An Identifier + */ + function trySubstituteReservedName(name) { + var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); + if (token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */) { + return ts.setTextRange(ts.createLiteral(name), name); + } + return undefined; + } + } + ts.transformES5 = transformES5; +})(ts || (ts = {})); +/// +/// // Transforms generator functions into a compatible ES5 representation with similar runtime // semantics. This is accomplished by first transforming the body of each generator // function into an intermediate representation that is the compiled into a JavaScript @@ -52589,13 +53941,15 @@ var ts; Instruction[Instruction["Catch"] = 6] = "Catch"; Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; })(Instruction || (Instruction = {})); - var instructionNames = ts.createMap((_a = {}, - _a[2 /* Return */] = "return", - _a[3 /* Break */] = "break", - _a[4 /* Yield */] = "yield", - _a[5 /* YieldStar */] = "yield*", - _a[7 /* Endfinally */] = "endfinally", - _a)); + function getInstructionName(instruction) { + switch (instruction) { + case 2 /* Return */: return "return"; + case 3 /* Break */: return "break"; + case 4 /* Yield */: return "yield"; + case 5 /* YieldStar */: return "yield*"; + case 7 /* Endfinally */: return "endfinally"; + } + } function transformGenerators(context) { var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); @@ -52687,13 +54041,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 210 /* DoStatement */: + case 211 /* DoStatement */: return visitDoStatement(node); - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: return visitWhileStatement(node); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: return visitSwitchStatement(node); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -52706,24 +54060,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return visitFunctionExpression(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return visitAccessorDeclaration(node); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return visitVariableStatement(node); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return visitForStatement(node); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return visitForInStatement(node); - case 216 /* BreakStatement */: + case 217 /* BreakStatement */: return visitBreakStatement(node); - case 215 /* ContinueStatement */: + case 216 /* ContinueStatement */: return visitContinueStatement(node); - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -52744,21 +54098,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitBinaryExpression(node); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return visitConditionalExpression(node); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return visitYieldExpression(node); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return visitCallExpression(node); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -52771,9 +54125,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -52792,11 +54146,11 @@ var ts; function visitFunctionDeclaration(node) { // Currently, we only support generators that were originally async functions. if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { - node = ts.setOriginalNode(ts.createFunctionDeclaration( + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration( /*decorators*/ undefined, node.modifiers, /*asteriskToken*/ undefined, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformGeneratorFunctionBody(node.body), + /*type*/ undefined, transformGeneratorFunctionBody(node.body)), /*location*/ node), node); } else { @@ -52830,11 +54184,11 @@ var ts; function visitFunctionExpression(node) { // Currently, we only support generators that were originally async functions. if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { - node = ts.setOriginalNode(ts.createFunctionExpression( + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformGeneratorFunctionBody(node.body), + /*type*/ undefined, transformGeneratorFunctionBody(node.body)), /*location*/ node), node); } else { @@ -52922,7 +54276,7 @@ var ts; operationArguments = savedOperationArguments; operationLocations = savedOperationLocations; state = savedState; - return ts.createBlock(statements, /*location*/ body, body.multiLine); + return ts.setTextRange(ts.createBlock(statements, body.multiLine), body); } /** * Visits a variable statement. @@ -53001,7 +54355,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -53013,7 +54367,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -53032,7 +54386,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 57 /* EqualsToken */, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.setTextRange(ts.createAssignment(target, ts.setTextRange(ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -53243,14 +54597,13 @@ var ts; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, /*location*/ undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, location, multiLine); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { emitAssignment(temp, hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, /*location*/ undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, - /*location*/ undefined, multiLine)); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); hasAssignedTemp = true; leadingElement = undefined; expressions = []; @@ -53281,8 +54634,7 @@ var ts; var multiLine = node.multiLine; var numInitialProperties = countInitialNodesWithoutYield(properties); var temp = declareLocal(); - emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, multiLine)); + emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine)); var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties); expressions.push(multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); return ts.inlineExpressions(expressions); @@ -53356,10 +54708,9 @@ var ts; // .mark resumeLabel // new (_b.apply(_a, _c.concat([%sent%, 2]))); var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, + return ts.setOriginalNode(ts.setTextRange(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, /*leadingElement*/ ts.createVoidZero())), - /*typeArguments*/ undefined, [], - /*location*/ node), node); + /*typeArguments*/ undefined, []), node), node); } return ts.visitEachChild(node, visitor, context); } @@ -53388,35 +54739,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 205 /* Block */: + case 206 /* Block */: return transformAndEmitBlock(node); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 209 /* IfStatement */: + case 210 /* IfStatement */: return transformAndEmitIfStatement(node); - case 210 /* DoStatement */: + case 211 /* DoStatement */: return transformAndEmitDoStatement(node); - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return transformAndEmitForStatement(node); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 215 /* ContinueStatement */: + case 216 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 216 /* BreakStatement */: + case 217 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 218 /* WithStatement */: + case 219 /* WithStatement */: return transformAndEmitWithStatement(node); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 221 /* ThrowStatement */: + case 222 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 222 /* TryStatement */: + case 223 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); @@ -53436,9 +54787,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - var name_37 = ts.getSynthesizedClone(variable.name); - ts.setCommentRange(name_37, variable.name); - hoistVariableDeclaration(name_37); + var name = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name, variable.name); + hoistVariableDeclaration(name); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -53604,8 +54955,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression), - /*location*/ initializer)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -53615,8 +54965,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression), - /*location*/ node.incrementor)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -53838,7 +55187,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 255 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 257 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -53851,7 +55200,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 254 /* CaseClause */) { + if (clause.kind === 256 /* CaseClause */) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -53993,9 +55342,9 @@ var ts; } return -1; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */) { return substituteExpression(node); } return node; @@ -54007,14 +55356,14 @@ var ts; return node; } function substituteExpressionIdentifier(node) { - if (renamedCatchVariables && ts.hasProperty(renamedCatchVariables, node.text)) { + if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { var original = ts.getOriginalNode(node); if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_38 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_38) { - var clone_7 = ts.getMutableClone(name_38); + var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; + if (name) { + var clone_7 = ts.getMutableClone(name); ts.setSourceMapRange(clone_7, node); ts.setCommentRange(clone_7, node); return clone_7; @@ -54158,10 +55507,10 @@ var ts; var name = declareLocal(text); if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = ts.createMap(); + renamedCatchVariableDeclarations = []; context.enableSubstitution(70 /* Identifier */); } - renamedCatchVariables[text] = true; + renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; var exception = peekBlock(); ts.Debug.assert(exception.state < 1 /* Catch */); @@ -54432,7 +55781,7 @@ var ts; */ function createInstruction(instruction) { var literal = ts.createLiteral(instruction); - literal.trailingComment = instructionNames[instruction]; + literal.trailingComment = getInstructionName(instruction); return literal; } /** @@ -54443,10 +55792,10 @@ var ts; */ function createInlineBreak(label, location) { ts.Debug.assert(label > 0, "Invalid label: " + label); - return ts.createReturn(ts.createArrayLiteral([ + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), location); + ])), location); } /** * Creates a statement that can be used indicate a Return operation. @@ -54455,15 +55804,16 @@ var ts; * @param location An optional source map location for the statement. */ function createInlineReturn(expression, location) { - return ts.createReturn(ts.createArrayLiteral(expression + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)]), location); + : [createInstruction(2 /* Return */)])), location); } /** * Creates an expression that can be used to resume from a Yield operation. */ function createGeneratorResume(location) { - return ts.createCall(ts.createPropertyAccess(state, "sent"), /*typeArguments*/ undefined, [], location); + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(state, "sent"), + /*typeArguments*/ undefined, []), location); } /** * Emits an empty instruction. @@ -54609,7 +55959,6 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, ts.createBlock(buildResult, - /*location*/ undefined, /*multiLine*/ buildResult.length > 0)), 262144 /* ReuseTempVariableScope */)); } /** @@ -54880,7 +56229,7 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeAssign(left, right, operationLocation) { - writeStatement(ts.createStatement(ts.createAssignment(left, right), operationLocation)); + writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); } /** * Writes a Throw operation to the current label's statement list. @@ -54891,7 +56240,7 @@ var ts; function writeThrow(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createThrow(expression, operationLocation)); + writeStatement(ts.setTextRange(ts.createThrow(expression), operationLocation)); } /** * Writes a Return operation to the current label's statement list. @@ -54902,9 +56251,9 @@ var ts; function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)]), operationLocation), 384 /* NoTokenSourceMaps */)); + : [createInstruction(2 /* Return */)])), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -54914,10 +56263,10 @@ var ts; */ function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -54927,10 +56276,10 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -54940,10 +56289,10 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -54953,9 +56302,9 @@ var ts; */ function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)]), operationLocation), 384 /* NoTokenSourceMaps */)); + : [createInstruction(4 /* Yield */)])), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -54965,10 +56314,10 @@ var ts; */ function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(5 /* YieldStar */), expression - ]), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -55051,186 +56400,903 @@ var ts; priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; - var _a; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - /** - * Transforms ES5 syntax into ES3 syntax. - * - * @param context Context and state information for the transformation. - */ - function transformES5(context) { - var compilerOptions = context.getCompilerOptions(); - // enable emit notification only if using --jsx preserve - var previousOnEmitNode; - var noSubstitution; - if (compilerOptions.jsx === 1 /* Preserve */) { - previousOnEmitNode = context.onEmitNode; - context.onEmitNode = onEmitNode; - context.enableEmitNotification(249 /* JsxOpeningElement */); - context.enableEmitNotification(250 /* JsxClosingElement */); - context.enableEmitNotification(248 /* JsxSelfClosingElement */); - noSubstitution = []; - } - var previousOnSubstituteNode = context.onSubstituteNode; - context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(177 /* PropertyAccessExpression */); - context.enableSubstitution(258 /* PropertyAssignment */); - return transformSourceFile; - /** - * Transforms an ES5 source file to ES3. - * - * @param node A SourceFile - */ - function transformSourceFile(node) { - return node; - } - /** - * Called by the printer just before a node is printed. - * - * @param node The node to be printed. - */ - function onEmitNode(emitContext, node, emitCallback) { - switch (node.kind) { - case 249 /* JsxOpeningElement */: - case 250 /* JsxClosingElement */: - case 248 /* JsxSelfClosingElement */: - var tagName = node.tagName; - noSubstitution[ts.getOriginalNodeId(tagName)] = true; - break; - } - previousOnEmitNode(emitContext, node, emitCallback); - } - /** - * Hooks node substitutions. - * - * @param emitContext The context for the emitter. - * @param node The node to substitute. - */ - function onSubstituteNode(emitContext, node) { - if (node.id && noSubstitution && noSubstitution[node.id]) { - return previousOnSubstituteNode(emitContext, node); - } - node = previousOnSubstituteNode(emitContext, node); - if (ts.isPropertyAccessExpression(node)) { - return substitutePropertyAccessExpression(node); - } - else if (ts.isPropertyAssignment(node)) { - return substitutePropertyAssignment(node); - } - return node; - } - /** - * Substitutes a PropertyAccessExpression whose name is a reserved word. - * - * @param node A PropertyAccessExpression - */ - function substitutePropertyAccessExpression(node) { - var literalName = trySubstituteReservedName(node.name); - if (literalName) { - return ts.createElementAccess(node.expression, literalName, /*location*/ node); - } - return node; - } - /** - * Substitutes a PropertyAssignment whose name is a reserved word. - * - * @param node A PropertyAssignment - */ - function substitutePropertyAssignment(node) { - var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); - if (literalName) { - return ts.updatePropertyAssignment(node, literalName, node.initializer); - } - return node; - } - /** - * If an identifier name is a reserved word, returns a string literal for the name. - * - * @param name An Identifier - */ - function trySubstituteReservedName(name) { - var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); - if (token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */) { - return ts.createLiteral(name, /*location*/ name); - } - return undefined; - } - } - ts.transformES5 = transformES5; })(ts || (ts = {})); /// /// /*@internal*/ var ts; (function (ts) { - function transformES2015Module(context) { + function transformModule(context) { + function getTransformModuleDelegate(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.AMD: return transformAMDModule; + case ts.ModuleKind.UMD: return transformUMDModule; + default: return transformCommonJSModule; + } + } + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var compilerOptions = context.getCompilerOptions(); - var previousOnEmitNode = context.onEmitNode; + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var moduleKind = ts.getEmitModuleKind(compilerOptions); var previousOnSubstituteNode = context.onSubstituteNode; - context.onEmitNode = onEmitNode; + var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(262 /* SourceFile */); - context.enableSubstitution(70 /* Identifier */); - var currentSourceFile; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(193 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(191 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(192 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(261 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(264 /* SourceFile */); // Restore state when substituting nodes in a file. + var moduleInfoMap = []; // The ExternalModuleInfo for each file. + var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. + var currentSourceFile; // The current file. + var currentModuleInfo; // The ExternalModuleInfo for the current file. + var noSubstitution; // Set of nodes for which substitution rules should be ignored. return transformSourceFile; + /** + * Transforms the module aspects of a SourceFile. + * + * @param node The SourceFile node. + */ function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { + if (ts.isDeclarationFile(node) + || !(ts.isExternalModule(node) + || compilerOptions.isolatedModules)) { return node; } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements); - ts.append(statements, ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + currentSourceFile = node; + currentModuleInfo = ts.collectExternalModuleInfo(node, resolver, compilerOptions); + moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo; + // Perform the transformation. + var transformModule = getTransformModuleDelegate(moduleKind); + var updated = transformModule(node); + currentSourceFile = undefined; + currentModuleInfo = undefined; + return ts.aggregateTransformFlags(updated); + } + /** + * Transforms a SourceFile into a CommonJS module. + * + * @param node The SourceFile node. + */ + function transformCommonJSModule(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + ts.addRange(statements, endLexicalEnvironment()); + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); + var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); + if (currentModuleInfo.hasExportStarsToExportValues) { + ts.addEmitHelper(updated, exportStarHelper); + } + return updated; + } + /** + * Transforms a SourceFile into an AMD module. + * + * @param node The SourceFile node. + */ + function transformAMDModule(node) { + var define = ts.createIdentifier("define"); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + // An AMD define function has the following shape: + // + // define(id?, dependencies?, factory); + // + // This has the shape of the following: + // + // define(name, ["module1", "module2"], function (module1Alias) { ... } + // + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // + // import "module" + // + // or + // + // /// + // + // we need to add modules without alias names to the end of the dependencies list + var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + // Create an updated SourceFile: + // + // define(moduleName?, ["module1", "module2"], function ... + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ + ts.createStatement(ts.createCall(define, + /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + // Add the dependency array argument: + // + // ["require", "exports", module1", "module2", ...] + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + // Add the module body function argument: + // + // function (require, exports, module1, module2) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ]))) + ]), + /*location*/ node.statements)); + } + /** + * Transforms a SourceFile into a UMD module. + * + * @param node The SourceFile node. + */ + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "factory")], + /*type*/ undefined, ts.setTextRange(ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement( + /*modifiers*/ undefined, [ + ts.createVariableDeclaration("v", + /*type*/ undefined, ts.createCall(ts.createIdentifier("factory"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), + /*typeArguments*/ undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], + /*multiLine*/ true), + /*location*/ undefined)); + // Create an updated SourceFile: + // + // (function (factory) { + // if (typeof module === "object" && typeof module.exports === "object") { + // var v = factory(require, exports); + // if (v !== undefined) module.exports = v; + // } + // else if (typeof define === 'function' && define.amd) { + // define(["require", "exports"], factory); + // } + // })(function ...) + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, + /*typeArguments*/ undefined, [ + // Add the module body function argument: + // + // function (require, exports) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ])) + ]), + /*location*/ node.statements)); + } + /** + * Collect the additional asynchronous dependencies for the module. + * + * @param node The source file. + * @param includeNonAmdDependencies A value indicating whether to include non-AMD dependencies. + */ + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + // names of modules with corresponding parameter in the factory function + var aliasedModuleNames = []; + // names of modules with no corresponding parameters in factory function + var unaliasedModuleNames = []; + // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding + // module names in aliasedModuleNames. + var importAliasNames = []; + // Fill in amd-dependency tags + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, amdDependency.name)); } else { - return ts.visitEachChild(node, visitor, context); + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); } } - return node; + for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { + var importNode = _c[_b]; + // Find the name of the external module + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + // Find the name of the module alias, if there is one + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + // Set emitFlags on the name of the classDeclaration + // This is so that when printer will not substitute the identifier + ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; } - function visitor(node) { + /** + * Transforms a SourceFile into an AMD or UMD module body. + * + * @param node The SourceFile node. + */ + function transformAsynchronousModuleBody(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } + // Visit each statement of the module body. + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + // End the lexical environment for the module body + // and merge any new lexical declarations. + ts.addRange(statements, endLexicalEnvironment()); + // Append the 'export =' statement if provided. + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); + var body = ts.createBlock(statements, /*multiLine*/ true); + if (currentModuleInfo.hasExportStarsToExportValues) { + // If we have any `export * from ...` declarations + // we need to inform the emitter to add the __export helper. + ts.addEmitHelper(body, exportStarHelper); + } + return body; + } + /** + * Adds the down-level representation of `export=` to the statement list if one exists + * in the source file. + * + * @param statements The Statement list to modify. + * @param emitAsReturn A value indicating whether to emit the `export=` statement as a + * return statement. + */ + function addExportEqualsIfNeeded(statements, emitAsReturn) { + if (currentModuleInfo.exportEquals) { + if (emitAsReturn) { + var statement = ts.createReturn(currentModuleInfo.exportEquals.expression); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + statements.push(statement); + } + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression)); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 1536 /* NoComments */); + statements.push(statement); + } + } + } + // + // Top-Level Source Element Visitors + // + /** + * Visits a node at the top level of the source file. + * + * @param node The node to visit. + */ + function sourceElementVisitor(node) { switch (node.kind) { - case 235 /* ImportEqualsDeclaration */: - // Elide `import=` as it is not legal with --module ES6 - return undefined; - case 241 /* ExportAssignment */: + case 237 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 236 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 243 /* ExportDeclaration */: + return visitExportDeclaration(node); + case 242 /* ExportAssignment */: return visitExportAssignment(node); + case 207 /* VariableStatement */: + return visitVariableStatement(node); + case 227 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 228 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 299 /* MergeDeclarationMarker */: + return visitMergeDeclarationMarker(node); + case 300 /* EndOfDeclarationMarker */: + return visitEndOfDeclarationMarker(node); + default: + // This visitor does not descend into the tree, as export/import statements + // are only transformed at the top level of a file. + return node; + } + } + /** + * Visits an ImportDeclaration node. + * + * @param node The node to visit. + */ + function visitImportDeclaration(node) { + var statements; + var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); + if (moduleKind !== ts.ModuleKind.AMD) { + if (!node.importClause) { + // import "mod"; + return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); + } + else { + var variables = []; + if (namespaceDeclaration && !ts.isDefaultImport(node)) { + // import * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, createRequireCall(node))); + } + else { + // import d from "mod"; + // import { x, y } from "mod"; + // import d, { x, y } from "mod"; + // import d, * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), + /*type*/ undefined, createRequireCall(node))); + if (namespaceDeclaration && ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node))); + } + } + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList(variables, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), + /*location*/ node)); + } + } + else if (namespaceDeclaration && ts.isDefaultImport(node)) { + // import d, * as n from "mod"; + statements = ts.append(statements, ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node)), + /*location*/ node) + ], languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Creates a `require()` call to import an external module. + * + * @param importNode The declararation to import. + */ + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (moduleName) { + args.push(moduleName); + } + return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); + } + /** + * Visits an ImportEqualsDeclaration node. + * + * @param node The node to visit. + */ + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; + if (moduleKind !== ts.ModuleKind.AMD) { + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(node.name, createRequireCall(node))), node)); + } + else { + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), + /*type*/ undefined, createRequireCall(node)) + ], + /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node)); + } + } + else { + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); + } + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportEqualsDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits an ExportDeclaration node. + * + * @param The node to visit. + */ + function visitExportDeclaration(node) { + if (!node.moduleSpecifier) { + // Elide export declarations with no module specifier as they are handled + // elsewhere. + return undefined; + } + var generatedName = ts.getGeneratedNameForNode(node); + if (node.exportClause) { + var statements = []; + // export { x, y } from "mod"; + if (moduleKind !== ts.ModuleKind.AMD) { + statements.push(ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(generatedName, + /*type*/ undefined, createRequireCall(node)) + ])), + /*location*/ node)); + } + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); + } + return ts.singleOrMany(statements); + } + else { + // export * from "mod"; + return ts.setTextRange(ts.createStatement(ts.createCall(ts.createIdentifier("__export"), + /*typeArguments*/ undefined, [ + moduleKind !== ts.ModuleKind.AMD + ? createRequireCall(node) + : generatedName + ])), node); + } + } + /** + * Visits an ExportAssignment node. + * + * @param node The node to visit. + */ + function visitExportAssignment(node) { + if (node.isExportEquals) { + return undefined; + } + var statements; + var original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); + } + else { + statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); + } + return ts.singleOrMany(statements); + } + /** + * Visits a FunctionDeclaration node. + * + * @param node The node to visit. + */ + function visitFunctionDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + /*typeParameters*/ undefined, node.parameters, + /*type*/ undefined, node.body), + /*location*/ node), + /*original*/ node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits a ClassDeclaration node. + * + * @param node The node to visit. + */ + function visitClassDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createClassDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + /*typeParameters*/ undefined, node.heritageClauses, node.members), node), node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits a VariableStatement node. + * + * @param node The node to visit. + */ + function visitVariableStatement(node) { + var statements; + var variables; + var expressions; + if (ts.hasModifier(node, 1 /* Export */)) { + var modifiers = void 0; + // If we're exporting these variables, then these just become assignments to 'exports.x'. + // We only want to emit assignments for variables with initializers. + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { + if (!modifiers) { + modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + } + variables = ts.append(variables, variable); + } + else if (variable.initializer) { + expressions = ts.append(expressions, transformInitializedVariable(variable)); + } + } + if (variables) { + statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); + } + if (expressions) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + } + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); + } + else { + statements = appendExportsOfVariableStatement(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Transforms an exported variable with an initializer into an expression. + * + * @param node The node to transform. + */ + function transformInitializedVariable(node) { + if (ts.isBindingPattern(node.name)) { + return ts.flattenDestructuringAssignment(node, + /*visitor*/ undefined, context, 0 /* All */, + /*needsValue*/ false, createExportExpression); + } + else { + return ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name), + /*location*/ node.name), node.initializer); + } + } + /** + * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged + * and transformed declaration. + * + * @param node The node to visit. + */ + function visitMergeDeclarationMarker(node) { + // For an EnumDeclaration or ModuleDeclaration that merges with a preceeding + // declaration we do not emit a leading variable declaration. To preserve the + // begin/end semantics of the declararation and to properly handle exports + // we wrapped the leading variable declaration in a `MergeDeclarationMarker`. + // + // To balance the declaration, add the exports of the elided variable + // statement. + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207 /* VariableStatement */) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } return node; } - function visitExportAssignment(node) { - // Elide `export=` as it is not legal with --module ES6 - return node.isExportEquals ? undefined : node; + /** + * Determines whether a node has an associated EndOfDeclarationMarker. + * + * @param node The node to test. + */ + function hasAssociatedEndOfDeclarationMarker(node) { + return (ts.getEmitFlags(node) & 2097152 /* HasEndOfDeclarationMarker */) !== 0; + } + /** + * Visits a DeclarationMarker used as a placeholder for the end of a transformed + * declaration. + * + * @param node The node to visit. + */ + function visitEndOfDeclarationMarker(node) { + // For some transformations we emit an `EndOfDeclarationMarker` to mark the actual + // end of the transformed declaration. We use this marker to emit any deferred exports + // of the declaration. + var id = ts.getOriginalNodeId(node); + var statements = deferredExports[id]; + if (statements) { + delete deferredExports[id]; + return ts.append(statements, node); + } + return node; + } + /** + * Appends the exports of an ImportDeclaration to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfImportDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + var importClause = decl.importClause; + if (!importClause) { + return statements; + } + if (importClause.name) { + statements = appendExportsOfDeclaration(statements, importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + switch (namedBindings.kind) { + case 239 /* NamespaceImport */: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 240 /* NamedImports */: + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var importBinding = _a[_i]; + statements = appendExportsOfDeclaration(statements, importBinding); + } + break; + } + } + return statements; + } + /** + * Appends the exports of an ImportEqualsDeclaration to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfImportEqualsDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + return appendExportsOfDeclaration(statements, decl); + } + /** + * Appends the exports of a VariableStatement to a statement list, returning the statement + * list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param node The VariableStatement whose exports are to be recorded. + */ + function appendExportsOfVariableStatement(statements, node) { + if (currentModuleInfo.exportEquals) { + return statements; + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + statements = appendExportsOfBindingElement(statements, decl); + } + return statements; + } + /** + * Appends the exports of a VariableDeclaration or BindingElement to a statement list, + * returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfBindingElement(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + statements = appendExportsOfBindingElement(statements, element); + } + } + } + else if (!ts.isGeneratedIdentifier(decl.name)) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + /** + * Appends the exports of a ClassDeclaration or FunctionDeclaration to a statement list, + * returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfHoistedDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.hasModifier(decl, 1 /* Export */)) { + var exportName = ts.hasModifier(decl, 512 /* Default */) ? ts.createIdentifier("default") : decl.name; + statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), /*location*/ decl); + } + if (decl.name) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + /** + * Appends the exports of a declaration to a statement list, returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration to export. + */ + function appendExportsOfDeclaration(statements, decl) { + var name = ts.getDeclarationName(decl); + var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(name.text); + if (exportSpecifiers) { + for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { + var exportSpecifier = exportSpecifiers_1[_i]; + statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name); + } + } + return statements; + } + /** + * Appends the down-level representation of an export to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param exportName The name of the export. + * @param expression The expression to export. + * @param location The location to use for source maps and comments for the export. + * @param allowComments Whether to allow comments on the export. + */ + function appendExportStatement(statements, exportName, expression, location, allowComments) { + statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); + return statements; + } + function createUnderscoreUnderscoreESModule() { + var statement; + if (languageVersion === 0 /* ES3 */) { + statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true))); + } + else { + statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ])); + } + ts.setEmitFlags(statement, 524288 /* CustomPrologue */); + return statement; + } + /** + * Creates a call to the current file's export function to export a value. + * + * @param name The bound name of the export. + * @param value The exported value. + * @param location The location to use for source maps and comments for the export. + * @param allowComments An optional value indicating whether to emit comments for the statement. + */ + function createExportStatement(name, value, location, allowComments) { + var statement = ts.setTextRange(ts.createStatement(createExportExpression(name, value)), location); + ts.startOnNewLine(statement); + if (!allowComments) { + ts.setEmitFlags(statement, 1536 /* NoComments */); + } + return statement; + } + /** + * Creates a call to the current file's export function to export a value. + * + * @param name The bound name of the export. + * @param value The exported value. + * @param location The location to use for source maps and comments for the export. + */ + function createExportExpression(name, value, location) { + return ts.setTextRange(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location); + } + // + // Modifier Visitors + // + /** + * Visit nodes to elide module-specific modifiers. + * + * @param node The node to visit. + */ + function modifierVisitor(node) { + // Elide module-specific modifiers. + switch (node.kind) { + case 83 /* ExportKeyword */: + case 78 /* DefaultKeyword */: + return undefined; + } + return node; } // // Emit Notification // /** - * Hook for node emit. + * Hook for node emit notifications. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(emitContext, node, emitCallback) { - if (ts.isSourceFile(node)) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264 /* SourceFile */) { currentSourceFile = node; - previousOnEmitNode(emitContext, node, emitCallback); + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; + noSubstitution = []; + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; + currentModuleInfo = undefined; + noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } // @@ -55239,27 +57305,188 @@ var ts; /** * Hooks node substitutions. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (ts.isIdentifier(node) && emitContext === 1 /* Expression */) { - return substituteExpressionIdentifier(node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (node.id && noSubstitution[node.id]) { + return node; + } + if (hint === 1 /* Expression */) { + return substituteExpression(node); + } + else if (ts.isShorthandPropertyAssignment(node)) { + return substituteShorthandPropertyAssignment(node); } return node; } + /** + * Substitution for a ShorthandPropertyAssignment whose declaration name is an imported + * or exported symbol. + * + * @param node The node to substitute. + */ + function substituteShorthandPropertyAssignment(node) { + var name = node.name; + var exportedOrImportedName = substituteExpressionIdentifier(name); + if (exportedOrImportedName !== name) { + // A shorthand property with an assignment initializer is probably part of a + // destructuring assignment + if (node.objectAssignmentInitializer) { + var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); + } + return ts.setTextRange(ts.createPropertyAssignment(name, exportedOrImportedName), node); + } + return node; + } + /** + * Substitution for an Expression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 193 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 192 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + return substituteUnaryExpression(node); + } + return node; + } + /** + * Substitution for an Identifier expression that may contain an imported or exported + * symbol. + * + * @param node The node to substitute. + */ function substituteExpressionIdentifier(node) { if (ts.getEmitFlags(node) & 4096 /* HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return ts.createPropertyAccess(externalHelpersModuleName, node); } + return node; + } + if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); + if (exportContainer && exportContainer.kind === 264 /* SourceFile */) { + return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), + /*location*/ node); + } + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts.isImportClause(importDeclaration)) { + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), + /*location*/ node); + } + else if (ts.isImportSpecifier(importDeclaration)) { + var name = importDeclaration.propertyName || importDeclaration.name; + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name)), + /*location*/ node); + } + } } return node; } + /** + * Substitution for a BinaryExpression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteBinaryExpression(node) { + // When we see an assignment expression whose left-hand side is an exported symbol, + // we should ensure all exports of that symbol are updated with the correct value. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + // - We do not substitute identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only substitute identifiers that are exported at the top level. + if (ts.isAssignmentOperator(node.operatorToken.kind) + && ts.isIdentifier(node.left) + && !ts.isGeneratedIdentifier(node.left) + && !ts.isLocalName(node.left) + && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + // For each additional export of the declaration, apply an export assignment. + var expression = node; + for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { + var exportName = exportedNames_1[_i]; + // Mark the node to prevent triggering this rule again. + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression, /*location*/ node); + } + return expression; + } + } + return node; + } + /** + * Substitution for a UnaryExpression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteUnaryExpression(node) { + // When we see a prefix or postfix increment expression whose operand is an exported + // symbol, we should ensure all exports of that symbol are updated with the correct + // value. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + // - We do not substitute identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only substitute identifiers that are exported at the top level. + if ((node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var expression = node.kind === 192 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1)), + /*location*/ node) + : node; + for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { + var exportName = exportedNames_2[_i]; + // Mark the node to prevent triggering this rule again. + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression); + } + return expression; + } + } + return node; + } + /** + * Gets the additional exports of a name. + * + * @param name The name. + */ + function getExports(name) { + if (!ts.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) { + return currentModuleInfo + && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; + } + } + } } - ts.transformES2015Module = transformES2015Module; + ts.transformModule = transformModule; + // emit output for the __export helper function + var exportStarHelper = { + name: "typescript:export-star", + scoped: true, + text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" + }; })(ts || (ts = {})); /// /// @@ -55276,14 +57503,14 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(262 /* SourceFile */); // Restore state when substituting nodes in a file. - var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. - var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. - var exportFunctionsMap = ts.createMap(); // The export function associated with a source file. - var noSubstitutionMap = ts.createMap(); // Set of nodes for which substitution rules should be ignored for each file. + context.enableSubstitution(193 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(191 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(192 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(264 /* SourceFile */); // Restore state when substituting nodes in a file. + var moduleInfoMap = []; // The ExternalModuleInfo for each file. + var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. + var exportFunctionsMap = []; // The export function associated with a source file. + var noSubstitutionMap = []; // Set of nodes for which substitution rules should be ignored for each file. var currentSourceFile; // The current file. var moduleInfo; // ExternalModuleInfo for the current file. var exportFunction; // The export function for the current file. @@ -55322,7 +57549,8 @@ var ts; moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); // Make sure that the name of the 'exports' function does not conflict with // existing identifiers. - exportFunction = exportFunctionsMap[id] = ts.createUniqueName("exports"); + exportFunction = ts.createUniqueName("exports"); + exportFunctionsMap[id] = exportFunction; contextObject = ts.createUniqueName("context"); // Add the body of the module. var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); @@ -55341,12 +57569,12 @@ var ts; // So the helper will be emit at the correct position instead of at the top of the source-file var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); - var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.createNodeArray([ + var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ], node.statements)), 1024 /* NoTrailingComments */); + ]), node.statements)), 1024 /* NoTrailingComments */); if (!(compilerOptions.outFile || compilerOptions.out)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -55374,13 +57602,13 @@ var ts; var externalImport = externalImports[i]; var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { // deduplicate/group entries in dependency list by the dependency name - var groupIndex = groupIndices[text]; dependencyGroups[groupIndex].externalImports.push(externalImport); } else { - groupIndices[text] = dependencyGroups.length; + groupIndices.set(text, dependencyGroups.length); dependencyGroups.push({ name: externalModuleName, externalImports: [externalImport] @@ -55464,7 +57692,7 @@ var ts; // - Temporary variables will appear at the top rather than at the bottom of the file ts.addRange(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + var moduleObject = ts.createObjectLiteral([ ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), ts.createPropertyAssignment("execute", ts.createFunctionExpression( /*modifiers*/ undefined, @@ -55472,12 +57700,11 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, ts.createBlock(executeStatements, - /*location*/ undefined, - /*multiLine*/ true))) - ]), - /*multiLine*/ true))); - return ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); + /*type*/ undefined, ts.createBlock(executeStatements, /*multiLine*/ true))) + ]); + moduleObject.multiLine = true; + statements.push(ts.createReturn(moduleObject)); + return ts.createBlock(statements, /*multiLine*/ true); } /** * Adds an exportStar function to a statement list if it is needed for the file. @@ -55493,13 +57720,13 @@ var ts; // to support this we store names of local/indirect exported entries in a set. // this set is used to filter names brought by star expors. // local names set should only be added if we have anything exported - if (!moduleInfo.exportedNames && ts.isEmpty(moduleInfo.exportSpecifiers)) { + if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) { // no exported declarations (export var ...) or export specifiers (export {x}) // check if we have any non star export declarations. var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 242 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 243 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -55519,12 +57746,12 @@ var ts; continue; } // write name of exported declaration, i.e 'export var x...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createTrue())); } } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 242 /* ExportDeclaration */) { + if (externalImport.kind !== 243 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -55535,14 +57762,14 @@ var ts; for (var _f = 0, _g = exportDecl.exportClause.elements; _f < _g.length; _f++) { var element = _g[_f]; // write name of indirectly exported entry, i.e. 'export {x} from ...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createTrue())); } } var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); statements.push(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(exportedNamesStorageRef, - /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true)) + /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*multiline*/ true)) ]))); var exportStarFunction = createExportStarFunction(exportedNamesStorageRef); statements.push(exportStarFunction); @@ -55583,9 +57810,7 @@ var ts; ])), ts.createStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [exports])) - ], - /*location*/ undefined, - /*multiline*/ true)); + ], /*multiline*/ true)); } /** * Creates an array setter callbacks for each dependency group. @@ -55605,19 +57830,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // fall-through - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -55634,7 +57859,7 @@ var ts; properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); } statements.push(ts.createStatement(ts.createCall(exportFunction, - /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)]))); + /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*multiline*/ true)]))); } else { // export * from 'foo' @@ -55653,9 +57878,9 @@ var ts; /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], - /*type*/ undefined, ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true))); + /*type*/ undefined, ts.createBlock(statements, /*multiLine*/ true))); } - return ts.createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); + return ts.createArrayLiteral(setters, /*multiLine*/ true); } // // Top-level Source Element Visitors @@ -55667,15 +57892,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return visitImportDeclaration(node); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -55776,11 +58001,9 @@ var ts; var name = ts.getLocalName(node); hoistVariableDeclaration(name); // Rewrite the class declaration into an assignment of a class expression. - statements = ts.append(statements, ts.createStatement(ts.createAssignment(name, ts.createClassExpression( + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement), - /*location*/ node)), - /*location*/ node)); + /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts.getOriginalNodeId(node); @@ -55815,7 +58038,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), /*location*/ node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -55853,7 +58076,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 1048576 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 262 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 264 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -55900,8 +58123,8 @@ var ts; function createVariableAssignment(name, value, location, isExportedDeclaration) { hoistVariableDeclaration(ts.getSynthesizedClone(name)); return isExportedDeclaration - ? createExportExpression(name, preventSubstitution(ts.createAssignment(name, value, location))) - : preventSubstitution(ts.createAssignment(name, value, location)); + ? createExportExpression(name, preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location))) + : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } /** * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged @@ -55917,7 +58140,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -55973,10 +58196,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 238 /* NamespaceImport */: + case 239 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 239 /* NamedImports */: + case 240 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -56094,10 +58317,10 @@ var ts; return statements; } var name = ts.getDeclarationName(decl); - var exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + var exportSpecifiers = moduleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { - for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { - var exportSpecifier = exportSpecifiers_1[_i]; + for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { + var exportSpecifier = exportSpecifiers_2[_i]; if (exportSpecifier.name.text !== excludeName) { statements = appendExportStatement(statements, exportSpecifier.name, name); } @@ -56155,43 +58378,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return visitClassDeclaration(node); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return visitForStatement(node); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return visitForInStatement(node); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return visitForOfStatement(node); - case 210 /* DoStatement */: + case 211 /* DoStatement */: return visitDoStatement(node); - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: return visitWhileStatement(node); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return visitLabeledStatement(node); - case 218 /* WithStatement */: + case 219 /* WithStatement */: return visitWithStatement(node); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: return visitSwitchStatement(node); - case 233 /* CaseBlock */: + case 234 /* CaseBlock */: return visitCaseBlock(node); - case 254 /* CaseClause */: + case 256 /* CaseClause */: return visitCaseClause(node); - case 255 /* DefaultClause */: + case 257 /* DefaultClause */: return visitDefaultClause(node); - case 222 /* TryStatement */: + case 223 /* TryStatement */: return visitTryStatement(node); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return visitCatchClause(node); - case 205 /* Block */: + case 206 /* Block */: return visitBlock(node); - case 296 /* MergeDeclarationMarker */: + case 299 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 297 /* EndOfDeclarationMarker */: + case 300 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -56371,7 +58594,7 @@ var ts; */ function destructuringVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 192 /* BinaryExpression */) { + && node.kind === 193 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (node.transformFlags & 2048 /* ContainsDestructuringAssignment */) { @@ -56419,7 +58642,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 262 /* SourceFile */; + return container !== undefined && container.kind === 264 /* SourceFile */; } else { return false; @@ -56447,12 +58670,12 @@ var ts; /** * Hook for node emit notifications. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. - * @param emit A callback used to emit the node in the printer. + * @param emitCallback A callback used to emit the node in the printer. */ - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 262 /* SourceFile */) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -56461,14 +58684,14 @@ var ts; if (noSubstitution) { delete noSubstitutionMap[id]; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } // @@ -56477,15 +58700,15 @@ var ts; /** * Hooks node substitutions. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); if (isSubstitutionPrevented(node)) { return node; } - if (emitContext === 1 /* Expression */) { + if (hint === 1 /* Expression */) { return substituteExpression(node); } return node; @@ -56499,10 +58722,10 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return substituteBinaryExpression(node); - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -56530,1119 +58753,11 @@ var ts; var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), /*location*/ node); } else if (ts.isImportSpecifier(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name), - /*location*/ node); - } - } - } - return node; - } - /** - * Substitution for a BinaryExpression that may contain an imported or exported symbol. - * - * @param node The node to substitute. - */ - function substituteBinaryExpression(node) { - // When we see an assignment expression whose left-hand side is an exported symbol, - // we should ensure all exports of that symbol are updated with the correct value. - // - // - We do not substitute generated identifiers for any reason. - // - We do not substitute identifiers tagged with the LocalName flag. - // - We do not substitute identifiers that were originally the name of an enum or - // namespace due to how they are transformed in TypeScript. - // - We only substitute identifiers that are exported at the top level. - if (ts.isAssignmentOperator(node.operatorToken.kind) - && ts.isIdentifier(node.left) - && !ts.isGeneratedIdentifier(node.left) - && !ts.isLocalName(node.left) - && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { - var exportedNames = getExports(node.left); - if (exportedNames) { - // For each additional export of the declaration, apply an export assignment. - var expression = node; - for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { - var exportName = exportedNames_1[_i]; - expression = createExportExpression(exportName, preventSubstitution(expression)); - } - return expression; - } - } - return node; - } - /** - * Substitution for a UnaryExpression that may contain an imported or exported symbol. - * - * @param node The node to substitute. - */ - function substituteUnaryExpression(node) { - // When we see a prefix or postfix increment expression whose operand is an exported - // symbol, we should ensure all exports of that symbol are updated with the correct - // value. - // - // - We do not substitute generated identifiers for any reason. - // - We do not substitute identifiers tagged with the LocalName flag. - // - We do not substitute identifiers that were originally the name of an enum or - // namespace due to how they are transformed in TypeScript. - // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) - && ts.isIdentifier(node.operand) - && !ts.isGeneratedIdentifier(node.operand) - && !ts.isLocalName(node.operand) - && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { - var exportedNames = getExports(node.operand); - if (exportedNames) { - var expression = node.kind === 191 /* PostfixUnaryExpression */ - ? ts.createPrefix(node.operator, node.operand, - /*location*/ node) - : node; - for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { - var exportName = exportedNames_2[_i]; - expression = createExportExpression(exportName, preventSubstitution(expression)); - } - if (node.kind === 191 /* PostfixUnaryExpression */) { - expression = node.operator === 42 /* PlusPlusToken */ - ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) - : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); - } - return expression; - } - } - return node; - } - /** - * Gets the exports of a name. - * - * @param name The name. - */ - function getExports(name) { - var exportedNames; - if (!ts.isGeneratedIdentifier(name)) { - var valueDeclaration = resolver.getReferencedImportDeclaration(name) - || resolver.getReferencedValueDeclaration(name); - if (valueDeclaration) { - var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 262 /* SourceFile */) { - exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); - } - exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); - } - } - return exportedNames; - } - /** - * Prevent substitution of a node for this transformer. - * - * @param node The node which should not be substituted. - */ - function preventSubstitution(node) { - if (noSubstitution === undefined) - noSubstitution = ts.createMap(); - noSubstitution[ts.getNodeId(node)] = true; - return node; - } - /** - * Determines whether a node should not be substituted. - * - * @param node The node to test. - */ - function isSubstitutionPrevented(node) { - return noSubstitution && node.id && noSubstitution[node.id]; - } - } - ts.transformSystemModule = transformSystemModule; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var moduleKind = ts.getEmitModuleKind(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(259 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(262 /* SourceFile */); // Restore state when substituting nodes in a file. - var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. - var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. - var currentSourceFile; // The current file. - var currentModuleInfo; // The ExternalModuleInfo for the current file. - var noSubstitution; // Set of nodes for which substitution rules should be ignored. - return transformSourceFile; - /** - * Transforms the module aspects of a SourceFile. - * - * @param node The SourceFile node. - */ - function transformSourceFile(node) { - if (ts.isDeclarationFile(node) - || !(ts.isExternalModule(node) - || compilerOptions.isolatedModules)) { - return node; - } - currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); - // Perform the transformation. - var transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule(node); - currentSourceFile = undefined; - currentModuleInfo = undefined; - return ts.aggregateTransformFlags(updated); - } - /** - * Transforms a SourceFile into a CommonJS module. - * - * @param node The SourceFile node. - */ - function transformCommonJSModule(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); - ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); - var updated = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); - if (currentModuleInfo.hasExportStarsToExportValues) { - ts.addEmitHelper(updated, exportStarHelper); - } - return updated; - } - /** - * Transforms a SourceFile into an AMD module. - * - * @param node The SourceFile node. - */ - function transformAMDModule(node) { - var define = ts.createIdentifier("define"); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - // An AMD define function has the following shape: - // - // define(id?, dependencies?, factory); - // - // This has the shape of the following: - // - // define(name, ["module1", "module2"], function (module1Alias) { ... } - // - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // - // import "module" - // - // or - // - // /// - // - // we need to add modules without alias names to the end of the dependencies list - var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - // Create an updated SourceFile: - // - // define(moduleName?, ["module1", "module2"], function ... - return ts.updateSourceFileNode(node, ts.createNodeArray([ - ts.createStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - // Add the dependency array argument: - // - // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - // Add the module body function argument: - // - // function (require, exports, module1, module2) ... - ts.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), - ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), - /*type*/ undefined, transformAsynchronousModuleBody(node)) - ]))) - ], - /*location*/ node.statements)); - } - /** - * Transforms a SourceFile into a UMD module. - * - * @param node The SourceFile node. - */ - function transformUMDModule(node) { - var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - var umdHeader = ts.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "factory")], - /*type*/ undefined, ts.createBlock([ - ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ - ts.createVariableStatement( - /*modifiers*/ undefined, [ - ts.createVariableDeclaration("v", - /*type*/ undefined, ts.createCall(ts.createIdentifier("factory"), - /*typeArguments*/ undefined, [ - ts.createIdentifier("require"), - ts.createIdentifier("exports") - ])) - ]), - ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) - ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("define"), - /*typeArguments*/ undefined, [ - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - ts.createIdentifier("factory") - ])) - ]))) - ], - /*location*/ undefined, - /*multiLine*/ true)); - // Create an updated SourceFile: - // - // (function (factory) { - // if (typeof module === "object" && typeof module.exports === "object") { - // var v = factory(require, exports); - // if (v !== undefined) module.exports = v; - // } - // else if (typeof define === 'function' && define.amd) { - // define(["require", "exports"], factory); - // } - // })(function ...) - return ts.updateSourceFileNode(node, ts.createNodeArray([ - ts.createStatement(ts.createCall(umdHeader, - /*typeArguments*/ undefined, [ - // Add the module body function argument: - // - // function (require, exports) ... - ts.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), - ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), - /*type*/ undefined, transformAsynchronousModuleBody(node)) - ])) - ], - /*location*/ node.statements)); - } - /** - * Collect the additional asynchronous dependencies for the module. - * - * @param node The source file. - * @param includeNonAmdDependencies A value indicating whether to include non-AMD dependencies. - */ - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - // names of modules with corresponding parameter in the factory function - var aliasedModuleNames = []; - // names of modules with no corresponding parameters in factory function - var unaliasedModuleNames = []; - // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding - // module names in aliasedModuleNames. - var importAliasNames = []; - // Fill in amd-dependency tags - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { - var importNode = _c[_b]; - // Find the name of the external module - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - // Find the name of the module alias, if there is one - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - // Set emitFlags on the name of the classDeclaration - // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - /** - * Transforms a SourceFile into an AMD or UMD module body. - * - * @param node The SourceFile node. - */ - function transformAsynchronousModuleBody(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - // Visit each statement of the module body. - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); - ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - // End the lexical environment for the module body - // and merge any new lexical declarations. - ts.addRange(statements, endLexicalEnvironment()); - // Append the 'export =' statement if provided. - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); - var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); - if (currentModuleInfo.hasExportStarsToExportValues) { - // If we have any `export * from ...` declarations - // we need to inform the emitter to add the __export helper. - ts.addEmitHelper(body, exportStarHelper); - } - return body; - } - /** - * Adds the down-level representation of `export=` to the statement list if one exists - * in the source file. - * - * @param statements The Statement list to modify. - * @param emitAsReturn A value indicating whether to emit the `export=` statement as a - * return statement. - */ - function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (currentModuleInfo.exportEquals) { - if (emitAsReturn) { - var statement = ts.createReturn(currentModuleInfo.exportEquals.expression, - /*location*/ currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression), - /*location*/ currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536 /* NoComments */); - statements.push(statement); - } - } - } - // - // Top-Level Source Element Visitors - // - /** - * Visits a node at the top level of the source file. - * - * @param node The node to visit. - */ - function sourceElementVisitor(node) { - switch (node.kind) { - case 236 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 235 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 242 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 241 /* ExportAssignment */: - return visitExportAssignment(node); - case 206 /* VariableStatement */: - return visitVariableStatement(node); - case 226 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 227 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 296 /* MergeDeclarationMarker */: - return visitMergeDeclarationMarker(node); - case 297 /* EndOfDeclarationMarker */: - return visitEndOfDeclarationMarker(node); - default: - // This visitor does not descend into the tree, as export/import statements - // are only transformed at the top level of a file. - return node; - } - } - /** - * Visits an ImportDeclaration node. - * - * @param node The node to visit. - */ - function visitImportDeclaration(node) { - var statements; - var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (moduleKind !== ts.ModuleKind.AMD) { - if (!node.importClause) { - // import "mod"; - return ts.createStatement(createRequireCall(node), /*location*/ node); - } - else { - var variables = []; - if (namespaceDeclaration && !ts.isDefaultImport(node)) { - // import * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, createRequireCall(node))); - } - else { - // import d from "mod"; - // import { x, y } from "mod"; - // import d, { x, y } from "mod"; - // import d, * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), - /*type*/ undefined, createRequireCall(node))); - if (namespaceDeclaration && ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node))); - } - } - statements = ts.append(statements, ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList(variables, - /*location*/ undefined, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), - /*location*/ node)); - } - } - else if (namespaceDeclaration && ts.isDefaultImport(node)) { - // import d, * as n from "mod"; - statements = ts.append(statements, ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node), - /*location*/ node) - ], - /*location*/ undefined, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfImportDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Creates a `require()` call to import an external module. - * - * @param importNode The declararation to import. - */ - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (moduleName) { - args.push(moduleName); - } - return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); - } - /** - * Visits an ImportEqualsDeclaration node. - * - * @param node The node to visit. - */ - function visitImportEqualsDeclaration(node) { - ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); - var statements; - if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(node.name, createRequireCall(node)), - /*location*/ node)); - } - else { - statements = ts.append(statements, ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), - /*type*/ undefined, createRequireCall(node)) - ], - /*location*/ undefined, - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), - /*location*/ node)); - } - } - else { - if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node)), - /*location*/ node)); - } - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfImportEqualsDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Visits an ExportDeclaration node. - * - * @param The node to visit. - */ - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - // Elide export declarations with no module specifier as they are handled - // elsewhere. - return undefined; - } - var generatedName = ts.getGeneratedNameForNode(node); - if (node.exportClause) { - var statements = []; - // export { x, y } from "mod"; - if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(generatedName, - /*type*/ undefined, createRequireCall(node)) - ]), - /*location*/ node)); - } - for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { - var specifier = _a[_i]; - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue), - /*location*/ specifier)); - } - return ts.singleOrMany(statements); - } - else { - // export * from "mod"; - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), - /*typeArguments*/ undefined, [ - moduleKind !== ts.ModuleKind.AMD - ? createRequireCall(node) - : generatedName - ]), - /*location*/ node); - } - } - /** - * Visits an ExportAssignment node. - * - * @param node The node to visit. - */ - function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; - } - var statements; - var original = node.original; - if (original && hasAssociatedEndOfDeclarationMarker(original)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); - } - else { - statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); - } - return ts.singleOrMany(statements); - } - /** - * Visits a FunctionDeclaration node. - * - * @param node The node to visit. - */ - function visitFunctionDeclaration(node) { - var statements; - if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createFunctionDeclaration( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), - /*typeParameters*/ undefined, node.parameters, - /*type*/ undefined, node.body, - /*location*/ node), - /*original*/ node)); - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfHoistedDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Visits a ClassDeclaration node. - * - * @param node The node to visit. - */ - function visitClassDeclaration(node) { - var statements; - if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createClassDeclaration( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), - /*typeParameters*/ undefined, node.heritageClauses, node.members, - /*location*/ node), - /*original*/ node)); - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfHoistedDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Visits a VariableStatement node. - * - * @param node The node to visit. - */ - function visitVariableStatement(node) { - var statements; - var variables; - var expressions; - if (ts.hasModifier(node, 1 /* Export */)) { - var modifiers = void 0; - // If we're exporting these variables, then these just become assignments to 'exports.x'. - // We only want to emit assignments for variables with initializers. - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { - if (!modifiers) { - modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); - } - variables = ts.append(variables, variable); - } - else if (variable.initializer) { - expressions = ts.append(expressions, transformInitializedVariable(variable)); - } - } - if (variables) { - statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); - } - if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), /*location*/ node)); - } - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); - } - else { - statements = appendExportsOfVariableStatement(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Transforms an exported variable with an initializer into an expression. - * - * @param node The node to transform. - */ - function transformInitializedVariable(node) { - if (ts.isBindingPattern(node.name)) { - return ts.flattenDestructuringAssignment(node, - /*visitor*/ undefined, context, 0 /* All */, - /*needsValue*/ false, createExportExpression); - } - else { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name, - /*location*/ node.name), node.initializer); - } - } - /** - * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged - * and transformed declaration. - * - * @param node The node to visit. - */ - function visitMergeDeclarationMarker(node) { - // For an EnumDeclaration or ModuleDeclaration that merges with a preceeding - // declaration we do not emit a leading variable declaration. To preserve the - // begin/end semantics of the declararation and to properly handle exports - // we wrapped the leading variable declaration in a `MergeDeclarationMarker`. - // - // To balance the declaration, add the exports of the elided variable - // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206 /* VariableStatement */) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); - } - return node; - } - /** - * Determines whether a node has an associated EndOfDeclarationMarker. - * - * @param node The node to test. - */ - function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 2097152 /* HasEndOfDeclarationMarker */) !== 0; - } - /** - * Visits a DeclarationMarker used as a placeholder for the end of a transformed - * declaration. - * - * @param node The node to visit. - */ - function visitEndOfDeclarationMarker(node) { - // For some transformations we emit an `EndOfDeclarationMarker` to mark the actual - // end of the transformed declaration. We use this marker to emit any deferred exports - // of the declaration. - var id = ts.getOriginalNodeId(node); - var statements = deferredExports[id]; - if (statements) { - delete deferredExports[id]; - return ts.append(statements, node); - } - return node; - } - /** - * Appends the exports of an ImportDeclaration to a statement list, returning the - * statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration whose exports are to be recorded. - */ - function appendExportsOfImportDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - var importClause = decl.importClause; - if (!importClause) { - return statements; - } - if (importClause.name) { - statements = appendExportsOfDeclaration(statements, importClause); - } - var namedBindings = importClause.namedBindings; - if (namedBindings) { - switch (namedBindings.kind) { - case 238 /* NamespaceImport */: - statements = appendExportsOfDeclaration(statements, namedBindings); - break; - case 239 /* NamedImports */: - for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { - var importBinding = _a[_i]; - statements = appendExportsOfDeclaration(statements, importBinding); - } - break; - } - } - return statements; - } - /** - * Appends the exports of an ImportEqualsDeclaration to a statement list, returning the - * statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration whose exports are to be recorded. - */ - function appendExportsOfImportEqualsDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - return appendExportsOfDeclaration(statements, decl); - } - /** - * Appends the exports of a VariableStatement to a statement list, returning the statement - * list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param node The VariableStatement whose exports are to be recorded. - */ - function appendExportsOfVariableStatement(statements, node) { - if (currentModuleInfo.exportEquals) { - return statements; - } - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - statements = appendExportsOfBindingElement(statements, decl); - } - return statements; - } - /** - * Appends the exports of a VariableDeclaration or BindingElement to a statement list, - * returning the statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration whose exports are to be recorded. - */ - function appendExportsOfBindingElement(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - if (ts.isBindingPattern(decl.name)) { - for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - statements = appendExportsOfBindingElement(statements, element); - } - } - } - else if (!ts.isGeneratedIdentifier(decl.name)) { - statements = appendExportsOfDeclaration(statements, decl); - } - return statements; - } - /** - * Appends the exports of a ClassDeclaration or FunctionDeclaration to a statement list, - * returning the statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration whose exports are to be recorded. - */ - function appendExportsOfHoistedDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - if (ts.hasModifier(decl, 1 /* Export */)) { - var exportName = ts.hasModifier(decl, 512 /* Default */) ? ts.createIdentifier("default") : decl.name; - statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), /*location*/ decl); - } - if (decl.name) { - statements = appendExportsOfDeclaration(statements, decl); - } - return statements; - } - /** - * Appends the exports of a declaration to a statement list, returning the statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration to export. - */ - function appendExportsOfDeclaration(statements, decl) { - var name = ts.getDeclarationName(decl); - var exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; - if (exportSpecifiers) { - for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { - var exportSpecifier = exportSpecifiers_2[_i]; - statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name); - } - } - return statements; - } - /** - * Appends the down-level representation of an export to a statement list, returning the - * statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param exportName The name of the export. - * @param expression The expression to export. - * @param location The location to use for source maps and comments for the export. - * @param allowComments Whether to allow comments on the export. - */ - function appendExportStatement(statements, exportName, expression, location, allowComments) { - if (exportName.text === "default") { - var sourceFile = ts.getOriginalNode(currentSourceFile, ts.isSourceFile); - if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 0 /* ES3 */) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements = ts.append(statements, ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), - /*typeArguments*/ undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } - statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); - return statements; - } - /** - * Creates a call to the current file's export function to export a value. - * - * @param name The bound name of the export. - * @param value The exported value. - * @param location The location to use for source maps and comments for the export. - * @param allowComments An optional value indicating whether to emit comments for the statement. - */ - function createExportStatement(name, value, location, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value), location); - ts.startOnNewLine(statement); - if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); - } - return statement; - } - /** - * Creates a call to the current file's export function to export a value. - * - * @param name The bound name of the export. - * @param value The exported value. - * @param location The location to use for source maps and comments for the export. - */ - function createExportExpression(name, value, location) { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value, location); - } - // - // Modifier Visitors - // - /** - * Visit nodes to elide module-specific modifiers. - * - * @param node The node to visit. - */ - function modifierVisitor(node) { - // Elide module-specific modifiers. - switch (node.kind) { - case 83 /* ExportKeyword */: - case 78 /* DefaultKeyword */: - return undefined; - } - return node; - } - // - // Emit Notification - // - /** - * Hook for node emit notifications. - * - * @param emitContext A context hint for the emitter. - * @param node The node to emit. - * @param emit A callback used to emit the node in the printer. - */ - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 262 /* SourceFile */) { - currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; - noSubstitution = ts.createMap(); - previousOnEmitNode(emitContext, node, emitCallback); - currentSourceFile = undefined; - currentModuleInfo = undefined; - noSubstitution = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - // - // Substitutions - // - /** - * Hooks node substitutions. - * - * @param emitContext A context hint for the emitter. - * @param node The node to substitute. - */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (node.id && noSubstitution[node.id]) { - return node; - } - if (emitContext === 1 /* Expression */) { - return substituteExpression(node); - } - else if (ts.isShorthandPropertyAssignment(node)) { - return substituteShorthandPropertyAssignment(node); - } - return node; - } - /** - * Substitution for a ShorthandPropertyAssignment whose declaration name is an imported - * or exported symbol. - * - * @param node The node to substitute. - */ - function substituteShorthandPropertyAssignment(node) { - var name = node.name; - var exportedOrImportedName = substituteExpressionIdentifier(name); - if (exportedOrImportedName !== name) { - // A shorthand property with an assignment initializer is probably part of a - // destructuring assignment - if (node.objectAssignmentInitializer) { - var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, /*location*/ node); - } - return ts.createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); - } - return node; - } - /** - * Substitution for an Expression that may contain an imported or exported symbol. - * - * @param node The node to substitute. - */ - function substituteExpression(node) { - switch (node.kind) { - case 70 /* Identifier */: - return substituteExpressionIdentifier(node); - case 192 /* BinaryExpression */: - return substituteBinaryExpression(node); - case 191 /* PostfixUnaryExpression */: - case 190 /* PrefixUnaryExpression */: - return substituteUnaryExpression(node); - } - return node; - } - /** - * Substitution for an Identifier expression that may contain an imported or exported - * symbol. - * - * @param node The node to substitute. - */ - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } - return node; - } - if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { - var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 262 /* SourceFile */) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), - /*location*/ node); - } - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), - /*location*/ node); - } - else if (ts.isImportSpecifier(importDeclaration)) { - var name_39 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_39), + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name)), /*location*/ node); } } @@ -57674,9 +58789,7 @@ var ts; var expression = node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { var exportName = exportedNames_3[_i]; - // Mark the node to prevent triggering this rule again. - noSubstitution[ts.getNodeId(expression)] = true; - expression = createExportExpression(exportName, expression, /*location*/ node); + expression = createExportExpression(exportName, preventSubstitution(expression)); } return expression; } @@ -57705,15 +58818,17 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 191 /* PostfixUnaryExpression */ - ? ts.createBinary(node.operand, ts.createToken(node.operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1), - /*location*/ node) + var expression = node.kind === 192 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { var exportName = exportedNames_4[_i]; - // Mark the node to prevent triggering this rule again. - noSubstitution[ts.getNodeId(expression)] = true; - expression = createExportExpression(exportName, expression); + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + if (node.kind === 192 /* PostfixUnaryExpression */) { + expression = node.operator === 42 /* PlusPlusToken */ + ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) + : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } return expression; } @@ -57721,29 +58836,144 @@ var ts; return node; } /** - * Gets the additional exports of a name. + * Gets the exports of a name. * * @param name The name. */ function getExports(name) { + var exportedNames; if (!ts.isGeneratedIdentifier(name)) { var valueDeclaration = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { - return currentModuleInfo - && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; + var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); + if (exportContainer && exportContainer.kind === 264 /* SourceFile */) { + exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); + } + exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); } } + return exportedNames; + } + /** + * Prevent substitution of a node for this transformer. + * + * @param node The node which should not be substituted. + */ + function preventSubstitution(node) { + if (noSubstitution === undefined) + noSubstitution = []; + noSubstitution[ts.getNodeId(node)] = true; + return node; + } + /** + * Determines whether a node should not be substituted. + * + * @param node The node to test. + */ + function isSubstitutionPrevented(node) { + return noSubstitution && node.id && noSubstitution[node.id]; } - var _a; } - ts.transformModule = transformModule; - // emit output for the __export helper function - var exportStarHelper = { - name: "typescript:export-star", - scoped: true, - text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" - }; + ts.transformSystemModule = transformSystemModule; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformES2015Module(context) { + var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.enableEmitNotification(264 /* SourceFile */); + context.enableSubstitution(70 /* Identifier */); + var currentSourceFile; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); + if (externalHelpersModuleName) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements); + ts.append(statements, ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); + } + else { + return ts.visitEachChild(node, visitor, context); + } + } + return node; + } + function visitor(node) { + switch (node.kind) { + case 236 /* ImportEqualsDeclaration */: + // Elide `import=` as it is not legal with --module ES6 + return undefined; + case 242 /* ExportAssignment */: + return visitExportAssignment(node); + } + return node; + } + function visitExportAssignment(node) { + // Elide `export=` as it is not legal with --module ES6 + return node.isExportEquals ? undefined : node; + } + // + // Emit Notification + // + /** + * Hook for node emit. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. + */ + function onEmitNode(hint, node, emitCallback) { + if (ts.isSourceFile(node)) { + currentSourceFile = node; + previousOnEmitNode(hint, node, emitCallback); + currentSourceFile = undefined; + } + else { + previousOnEmitNode(hint, node, emitCallback); + } + } + // + // Substitutions + // + /** + * Hooks node substitutions. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to substitute. + */ + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (ts.isIdentifier(node) && hint === 1 /* Expression */) { + return substituteExpressionIdentifier(node); + } + return node; + } + function substituteExpressionIdentifier(node) { + if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); + if (externalHelpersModuleName) { + return ts.createPropertyAccess(externalHelpersModuleName, node); + } + } + return node; + } + } + ts.transformES2015Module = transformES2015Module; })(ts || (ts = {})); /// /// @@ -57760,14 +58990,16 @@ var ts; /* @internal */ var ts; (function (ts) { - var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, - _a[ts.ModuleKind.System] = ts.transformSystemModule, - _a[ts.ModuleKind.AMD] = ts.transformModule, - _a[ts.ModuleKind.CommonJS] = ts.transformModule, - _a[ts.ModuleKind.UMD] = ts.transformModule, - _a[ts.ModuleKind.None] = ts.transformModule, - _a)); + function getModuleTransformer(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.ES2015: + return ts.transformES2015Module; + case ts.ModuleKind.System: + return ts.transformSystemModule; + default: + return ts.transformModule; + } + } var SyntaxKindFeatureFlags; (function (SyntaxKindFeatureFlags) { SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; @@ -57795,7 +59027,7 @@ var ts; transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); + transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. if (languageVersion < 1 /* ES5 */) { @@ -57813,7 +59045,7 @@ var ts; * @param transforms An array of Transformers. */ function transformFiles(resolver, host, sourceFiles, transformers) { - var enabledSyntaxKindFeatures = new Array(298 /* Count */); + var enabledSyntaxKindFeatures = new Array(301 /* Count */); var lexicalEnvironmentDisabled = false; var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; @@ -57836,19 +59068,22 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, - onSubstituteNode: function (_emitContext, node) { return node; }, + onSubstituteNode: function (_, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, + onEmitNode: function (hint, node, callback) { return callback(hint, node); }, enableEmitNotification: enableEmitNotification, isEmitNotificationEnabled: isEmitNotificationEnabled }; + ts.performance.mark("beforeTransform"); // Chain together and initialize each transformer. var transformation = ts.chain.apply(void 0, transformers)(context); // Transform each source file. var transformed = ts.map(sourceFiles, transformSourceFile); // Disable modification of the lexical environment. lexicalEnvironmentDisabled = true; + ts.performance.mark("afterTransform"); + ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { transformed: transformed, emitNodeWithSubstitution: emitNodeWithSubstitution, @@ -57881,20 +59116,16 @@ var ts; /** * Emits a node with possible substitution. * - * @param emitContext The current emit context. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emitCallback The callback used to emit the node or its substitute. */ - function emitNodeWithSubstitution(emitContext, node, emitCallback) { + function emitNodeWithSubstitution(hint, node, emitCallback) { if (node) { if (isSubstitutionEnabled(node)) { - var substitute = context.onSubstituteNode(emitContext, node); - if (substitute && substitute !== node) { - emitCallback(emitContext, substitute); - return; - } + node = context.onSubstituteNode(hint, node) || node; } - emitCallback(emitContext, node); + emitCallback(hint, node); } } /** @@ -57914,17 +59145,17 @@ var ts; /** * Emits a node with possible emit notification. * - * @param emitContext The current emit context. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emitCallback The callback used to emit the node. */ - function emitNodeWithNotification(emitContext, node, emitCallback) { + function emitNodeWithNotification(hint, node, emitCallback) { if (node) { if (isEmitNotificationEnabled(node)) { - context.onEmitNode(emitContext, node, emitCallback); + context.onEmitNode(hint, node, emitCallback); } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } } @@ -58028,7 +59259,6 @@ var ts; } } ts.transformFiles = transformFiles; - var _a; })(ts || (ts = {})); /// /* @internal */ @@ -58073,10 +59303,9 @@ var ts; * * @param filePath The path to the generated output file. * @param sourceMapFilePath The path to the output source map file. - * @param sourceFiles The input source files for the program. - * @param isBundledEmit A value indicating whether the generated output file is a bundle. + * @param sourceFileOrBundle The input source file or bundle for the program. */ - function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { + function initialize(filePath, sourceMapFilePath, sourceFileOrBundle) { if (disabled) { return; } @@ -58112,11 +59341,10 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (!isBundledEmit) { - ts.Debug.assert(sourceFiles.length === 1); + if (sourceFileOrBundle.kind === 264 /* SourceFile */) { // For modules or multiple emit files the mapRoot will have directory structure like the sources // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFiles[0], host, sourceMapDir)); + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { // The relative paths are relative to the common directory @@ -58239,31 +59467,32 @@ var ts; /** * Emits a node with possible leading and trailing source maps. * + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emitCallback The callback used to emit the node. */ - function emitNodeWithSourceMap(emitContext, node, emitCallback) { + function emitNodeWithSourceMap(hint, node, emitCallback) { if (disabled) { - return emitCallback(emitContext, node); + return emitCallback(hint, node); } if (node) { var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 294 /* NotEmittedStatement */ + if (node.kind !== 297 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); } if (emitFlags & 64 /* NoNestedSourceMaps */) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } - if (node.kind !== 294 /* NotEmittedStatement */ + if (node.kind !== 297 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -58398,11 +59627,10 @@ var ts; /* @internal */ var ts; (function (ts) { - function createCommentWriter(host, writer, sourceMap) { - var compilerOptions = host.getCompilerOptions(); - var extendedDiagnostics = compilerOptions.extendedDiagnostics; - var newLine = host.getNewLine(); - var emitPos = sourceMap.emitPos; + function createCommentWriter(printerOptions, emitPos) { + var extendedDiagnostics = printerOptions.extendedDiagnostics; + var newLine = ts.getNewLineCharacter(printerOptions); + var writer; var containerPos = -1; var containerEnd = -1; var declarationListContainerEnd = -1; @@ -58411,17 +59639,19 @@ var ts; var currentLineMap; var detachedCommentsInfo; var hasWrittenComment = false; - var disabled = compilerOptions.removeComments; + var disabled = printerOptions.removeComments; return { reset: reset, + setWriter: setWriter, setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, + emitLeadingCommentsOfPosition: emitLeadingCommentsOfPosition, }; - function emitNodeWithComments(emitContext, node, emitCallback) { + function emitNodeWithComments(hint, node, emitCallback) { if (disabled) { - emitCallback(emitContext, node); + emitCallback(hint, node); return; } if (node) { @@ -58431,18 +59661,18 @@ var ts; // Both pos and end are synthesized, so just emit the node without comments. if (emitFlags & 2048 /* NoNestedComments */) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } else { if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 294 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 297 /* NotEmittedStatement */; var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; // Emit leading comments if the position is not synthesized and the node @@ -58461,7 +59691,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 225 /* VariableDeclarationList */) { + if (node.kind === 226 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -58470,11 +59700,11 @@ var ts; } if (emitFlags & 2048 /* NoNestedComments */) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } if (extendedDiagnostics) { ts.performance.mark("beginEmitNodeWithComment"); @@ -58557,9 +59787,11 @@ var ts; hasWrittenComment = true; } // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -58567,6 +59799,12 @@ var ts; writer.write(" "); } } + function emitLeadingCommentsOfPosition(pos) { + if (disabled || pos === -1) { + return; + } + emitLeadingComments(pos, /*isEmittedNode*/ true); + } function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } @@ -58575,9 +59813,11 @@ var ts; if (!writer.isAtStartOfLine()) { writer.write(" "); } - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -58596,9 +59836,11 @@ var ts; } function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -58629,6 +59871,9 @@ var ts; currentLineMap = undefined; detachedCommentsInfo = undefined; } + function setWriter(output) { + writer = output; + } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; currentText = currentSourceFile.text; @@ -58661,9 +59906,11 @@ var ts; } } function writeComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); } /** * Determine if the given comment is a triple-slash @@ -58692,15 +59939,17 @@ var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, targetSourceFile) { var declarationDiagnostics = ts.createDiagnosticCollection(); - ts.forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); + ts.forEachEmittedFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); - function getDeclarationDiagnosticsFromFile(_a, sources, isBundledEmit) { + function getDeclarationDiagnosticsFromFile(_a, sourceFileOrBundle) { var declarationFilePath = _a.declarationFilePath; - emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit, /*emitOnlyDtsFiles*/ false); + emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sourceFileOrBundle, /*emitOnlyDtsFiles*/ false); } } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles) { + function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles) { + var sourceFiles = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var isBundledEmit = sourceFileOrBundle.kind === 265 /* Bundle */; var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -58774,7 +60023,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 236 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 237 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -58800,9 +60049,9 @@ var ts; } }); if (usedTypeDirectiveReferences) { - for (var directive in usedTypeDirectiveReferences) { + ts.forEachKey(usedTypeDirectiveReferences, function (directive) { referencesOutput += "/// " + newLine; - } + }); } return { reportedDeclarationError: reportedDeclarationError, @@ -58827,6 +60076,7 @@ var ts; var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; writer.reportInaccessibleThisError = reportInaccessibleThisError; + writer.reportIllegalExtends = reportIllegalExtends; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -58849,10 +60099,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 224 /* VariableDeclaration */) { + if (declaration.kind === 225 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 239 /* NamedImports */ || declaration.kind === 240 /* ImportSpecifier */ || declaration.kind === 237 /* ImportClause */) { + else if (declaration.kind === 240 /* NamedImports */ || declaration.kind === 241 /* ImportSpecifier */ || declaration.kind === 238 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -58870,7 +60120,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 236 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 237 /* 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; @@ -58880,12 +60130,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 231 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 232 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 231 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 232 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -58904,8 +60154,8 @@ var ts; } for (var _i = 0, typeReferenceDirectives_1 = typeReferenceDirectives; _i < typeReferenceDirectives_1.length; _i++) { var directive = typeReferenceDirectives_1[_i]; - if (!(directive in usedTypeDirectiveReferences)) { - usedTypeDirectiveReferences[directive] = directive; + if (!usedTypeDirectiveReferences.has(directive)) { + usedTypeDirectiveReferences.set(directive, directive); } } } @@ -58934,6 +60184,12 @@ var ts; handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); } + function reportIllegalExtends() { + if (errorNameNode) { + reportedDeclarationError = true; + emitterDiagnostics.add(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced, ts.declarationNameToString(errorNameNode))); + } + } function reportInaccessibleThisError() { if (errorNameNode) { reportedDeclarationError = true; @@ -58943,13 +60199,19 @@ var ts; function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); - if (type) { + // use the checker's type, not the declared type, + // for non-optional initialized parameters that aren't a parameter property + var shouldUseResolverType = declaration.kind === 145 /* Parameter */ && + resolver.isRequiredInitializedParameter(declaration); + if (type && !shouldUseResolverType) { // Write the type emitType(type); } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); + var format = 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */ | + (shouldUseResolverType ? 4096 /* AddUndefined */ : 0); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer); errorNameNode = undefined; } } @@ -59003,49 +60265,50 @@ var ts; function emitType(type) { switch (type.kind) { case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 133 /* ObjectKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 94 /* NullKeyword */: case 129 /* NeverKeyword */: - case 167 /* ThisType */: - case 171 /* LiteralType */: + case 168 /* ThisType */: + case 172 /* LiteralType */: return writeTextOfNode(currentText, type); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return emitTypeReference(type); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return emitTypeQuery(type); - case 162 /* ArrayType */: + case 163 /* ArrayType */: return emitArrayType(type); - case 163 /* TupleType */: + case 164 /* TupleType */: return emitTupleType(type); - case 164 /* UnionType */: + case 165 /* UnionType */: return emitUnionType(type); - case 165 /* IntersectionType */: + case 166 /* IntersectionType */: return emitIntersectionType(type); - case 166 /* ParenthesizedType */: + case 167 /* ParenthesizedType */: return emitParenType(type); - case 168 /* TypeOperator */: + case 169 /* TypeOperator */: return emitTypeOperator(type); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return emitIndexedAccessType(type); - case 170 /* MappedType */: + case 171 /* MappedType */: return emitMappedType(type); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 161 /* TypeLiteral */: + case 162 /* TypeLiteral */: return emitTypeLiteral(type); case 70 /* Identifier */: return emitEntityName(type); - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: return emitEntityName(type); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -59053,8 +60316,8 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 141 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 141 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 142 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 142 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); @@ -59063,14 +60326,14 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 235 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 236 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 177 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 178 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -59179,15 +60442,15 @@ var ts; // do not need to keep track of created temp names. function getExportDefaultTempVariableName() { var baseName = "_default"; - if (!(baseName in currentIdentifiers)) { + if (!currentIdentifiers.has(baseName)) { return baseName; } var count = 0; while (true) { count++; - var name_40 = baseName + "_" + count; - if (!(name_40 in currentIdentifiers)) { - return name_40; + var name = baseName + "_" + count; + if (!currentIdentifiers.has(name)) { + return name; } } } @@ -59234,10 +60497,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 235 /* ImportEqualsDeclaration */ || - (node.parent.kind === 262 /* SourceFile */ && isCurrentFileExternalModule)) { + else if (node.kind === 236 /* ImportEqualsDeclaration */ || + (node.parent.kind === 264 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 262 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 264 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -59247,7 +60510,7 @@ var ts; }); } else { - if (node.kind === 236 /* ImportDeclaration */) { + if (node.kind === 237 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -59265,23 +60528,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return writeVariableStatement(node); - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return writeClassDeclaration(node); - case 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -59289,7 +60552,7 @@ var ts; } function emitModuleElementDeclarationFlags(node) { // If the node is parented in the current source file we need to emit export declare or just export - if (node.parent.kind === 262 /* SourceFile */) { + if (node.parent.kind === 264 /* SourceFile */) { var modifiers = ts.getModifierFlags(node); // If the node is exported if (modifiers & 1 /* Export */) { @@ -59298,7 +60561,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 228 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 229 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -59350,7 +60613,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 238 /* NamespaceImport */) { + if (namedBindings.kind === 239 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -59374,7 +60637,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 238 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 239 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -59395,13 +60658,13 @@ var ts; // the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered // external modules since they are indistinguishable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' // so compiler will treat them as external modules. - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 231 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 232 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 235 /* ImportEqualsDeclaration */) { + if (parent.kind === 236 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 231 /* ModuleDeclaration */) { + else if (parent.kind === 232 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -59471,7 +60734,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 232 /* ModuleBlock */) { + while (node.body && node.body.kind !== 233 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -59541,7 +60804,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 149 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 150 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -59552,53 +60815,70 @@ 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 === 158 /* FunctionType */ || - node.parent.kind === 159 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 161 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 149 /* MethodDeclaration */ || - node.parent.kind === 148 /* MethodSignature */ || - node.parent.kind === 158 /* FunctionType */ || - node.parent.kind === 159 /* ConstructorType */ || - node.parent.kind === 153 /* CallSignature */ || - node.parent.kind === 154 /* ConstructSignature */); + if (node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 162 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 150 /* MethodDeclaration */ || + node.parent.kind === 149 /* MethodSignature */ || + node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + node.parent.kind === 154 /* CallSignature */ || + node.parent.kind === 155 /* ConstructSignature */); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } + if (node.default && !isPrivateMethodTypeParameter(node)) { + write(" = "); + if (node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 162 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 150 /* MethodDeclaration */ || + node.parent.kind === 149 /* MethodSignature */ || + node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + node.parent.kind === 154 /* CallSignature */ || + node.parent.kind === 155 /* ConstructSignature */); + emitType(node.default); + } + else { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.default, getTypeParameterConstraintVisibilityError); + } + } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 153 /* CallSignature */: + case 154 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* 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 === 227 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 228 /* 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 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -59617,7 +60897,7 @@ var ts; write(">"); } } - function emitHeritageClause(typeReferences, isImplementsList) { + function emitHeritageClause(className, typeReferences, isImplementsList) { if (typeReferences) { write(isImplementsList ? " implements " : " extends "); emitCommaList(typeReferences, emitTypeOfTypeReference); @@ -59631,20 +60911,22 @@ var ts; } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; + errorNameNode = className; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); + errorNameNode = undefined; } function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 227 /* ClassDeclaration */) { + if (node.parent.parent.kind === 228 /* 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 : - ts.Diagnostics.Extends_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; } else { // interface is inaccessible - diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; + diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; } return { diagnosticMessage: diagnosticMessage, @@ -59676,9 +60958,10 @@ var ts; emitTypeParameters(node.typeParameters); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); + node.name; + emitHeritageClause(node.name, [baseTypeNode], /*isImplementsList*/ false); } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); + emitHeritageClause(node.name, ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); write(" {"); writeLine(); increaseIndent(); @@ -59699,7 +60982,7 @@ var ts; emitTypeParameters(node.typeParameters); var interfaceExtendsTypes = ts.filter(ts.getInterfaceBaseTypeNodes(node), function (base) { return ts.isEntityNameExpression(base.expression); }); if (interfaceExtendsTypes && interfaceExtendsTypes.length) { - emitHeritageClause(interfaceExtendsTypes, /*isImplementsList*/ false); + emitHeritageClause(node.name, interfaceExtendsTypes, /*isImplementsList*/ false); } write(" {"); writeLine(); @@ -59723,7 +61006,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 !== 224 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 225 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -59734,11 +61017,11 @@ var ts; writeTextOfNode(currentText, node.name); // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor // we don't want to emit property declaration with "?" - if ((node.kind === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */ || - (node.kind === 144 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */ || + (node.kind === 145 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */) && node.parent.kind === 161 /* TypeLiteral */) { + if ((node.kind === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */) && node.parent.kind === 162 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -59751,14 +61034,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 224 /* VariableDeclaration */) { + if (node.kind === 225 /* VariableDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */) { + else if (node.kind === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -59767,7 +61050,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 === 227 /* ClassDeclaration */) { + else if (node.parent.kind === 228 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -59799,7 +61082,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 198 /* OmittedExpression */) { + if (element.kind !== 199 /* OmittedExpression */) { elements.push(element); } } @@ -59869,7 +61152,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 === 151 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 152 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -59882,7 +61165,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 151 /* GetAccessor */ + return accessor.kind === 152 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -59891,7 +61174,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 152 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 153 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? @@ -59941,17 +61224,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 226 /* FunctionDeclaration */) { + if (node.kind === 227 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 149 /* MethodDeclaration */ || node.kind === 150 /* Constructor */) { + else if (node.kind === 150 /* MethodDeclaration */ || node.kind === 151 /* Constructor */) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 226 /* FunctionDeclaration */) { + if (node.kind === 227 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 150 /* Constructor */) { + else if (node.kind === 151 /* Constructor */) { write("constructor"); } else { @@ -59971,17 +61254,17 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 155 /* IndexSignature */) { + if (node.kind === 156 /* IndexSignature */) { // Index signature can have readonly modifier emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { // Construct signature or constructor type write new Signature - if (node.kind === 154 /* ConstructSignature */ || node.kind === 159 /* ConstructorType */) { + if (node.kind === 155 /* ConstructSignature */ || node.kind === 160 /* ConstructorType */) { write("new "); } - else if (node.kind === 158 /* FunctionType */) { + else if (node.kind === 159 /* FunctionType */) { var currentOutput = writer.getText(); // Do not generate incorrect type when function type with type parameters is type argument // This could happen if user used space between two '<' making it error free @@ -59996,22 +61279,22 @@ var ts; } // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 155 /* IndexSignature */) { + if (node.kind === 156 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 158 /* FunctionType */ || node.kind === 159 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 161 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 159 /* FunctionType */ || node.kind === 160 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 162 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 150 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { + else if (node.kind !== 151 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -60025,26 +61308,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.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 153 /* CallSignature */: + case 154 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.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 155 /* IndexSignature */: + case 156 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.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 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -60052,7 +61335,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 === 227 /* ClassDeclaration */) { + else if (node.parent.kind === 228 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -60066,7 +61349,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -60101,9 +61384,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 158 /* FunctionType */ || - node.parent.kind === 159 /* ConstructorType */ || - node.parent.parent.kind === 161 /* TypeLiteral */) { + if (node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + node.parent.parent.kind === 162 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8 /* Private */)) { @@ -60119,29 +61402,29 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 150 /* Constructor */: + case 151 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.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 153 /* CallSignature */: + case 154 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.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 155 /* IndexSignature */: + case 156 /* IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -60149,7 +61432,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 === 227 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 228 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -60162,7 +61445,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 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -60174,12 +61457,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 === 172 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 173 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 173 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 174 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -60190,7 +61473,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 198 /* OmittedExpression */) { + if (bindingElement.kind === 199 /* 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) @@ -60199,7 +61482,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 174 /* BindingElement */) { + else if (bindingElement.kind === 175 /* 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" @@ -60238,40 +61521,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 226 /* FunctionDeclaration */: - case 231 /* ModuleDeclaration */: - case 235 /* ImportEqualsDeclaration */: - case 228 /* InterfaceDeclaration */: - case 227 /* ClassDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 230 /* EnumDeclaration */: + case 227 /* FunctionDeclaration */: + case 232 /* ModuleDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 229 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 231 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return emitExportDeclaration(node); - case 150 /* Constructor */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 151 /* Constructor */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: return writeFunctionDeclaration(node); - case 154 /* ConstructSignature */: - case 153 /* CallSignature */: - case 155 /* IndexSignature */: + case 155 /* ConstructSignature */: + case 154 /* CallSignature */: + case 156 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return emitAccessorDeclaration(node); - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return emitPropertyDeclaration(node); - case 261 /* EnumMember */: + case 263 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return emitExportAssignment(node); - case 262 /* SourceFile */: + case 264 /* SourceFile */: return emitSourceFile(node); } } @@ -60289,7 +61572,7 @@ var ts; } else { // Get the declaration file path - ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(declarationFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, @@ -60297,8 +61580,9 @@ var ts; referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, sourceFileOrBundle) { // Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path + var isBundledEmit = sourceFileOrBundle.kind === 265 /* Bundle */; if (isBundledEmit && !addBundledFileReference) { return; } @@ -60309,10 +61593,11 @@ var ts; } } /* @internal */ - function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { - var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles); + function writeDeclarationFile(declarationFilePath, sourceFileOrBundle, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { + var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { + var sourceFiles = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; var declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); ts.writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); @@ -60335,63 +61620,56 @@ var ts; } ts.writeDeclarationFile = writeDeclarationFile; })(ts || (ts = {})); -/// +/// /// -/// -/// +/// +/// /// -/* @internal */ var ts; (function (ts) { - // Flags enum to track count of temp variables and a few dedicated names - var TempFlags; - (function (TempFlags) { - TempFlags[TempFlags["Auto"] = 0] = "Auto"; - TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; - TempFlags[TempFlags["_i"] = 268435456] = "_i"; - })(TempFlags || (TempFlags = {})); - var id = function (s) { return s; }; - var nullTransformers = [function (_) { return id; }]; + var delimiters = createDelimiterMap(); + var brackets = createBracketsMap(); + /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { - var delimiters = createDelimiterMap(); - var brackets = createBracketsMap(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = emitOnlyDtsFiles ? nullTransformers : ts.getTransformers(compilerOptions); + var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); - var write = writer.write, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var sourceMap = ts.createSourceMapWriter(host, writer); - var emitNodeWithSourceMap = sourceMap.emitNodeWithSourceMap, emitTokenWithSourceMap = sourceMap.emitTokenWithSourceMap; - var comments = ts.createCommentWriter(host, writer, sourceMap); - var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition; - var nodeIdToGeneratedName; - var autoGeneratedIdToGeneratedName; - var generatedNameSet; - var tempFlags; var currentSourceFile; - var currentText; - var currentFileIdentifiers; var bundledHelpers; var isOwnFileEmit; var emitSkipped = false; var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); // Transform the source files - ts.performance.mark("beforeTransform"); - var _a = ts.transformFiles(resolver, host, sourceFiles, transformers), transformed = _a.transformed, emitNodeWithSubstitution = _a.emitNodeWithSubstitution, emitNodeWithNotification = _a.emitNodeWithNotification; - ts.performance.measure("transformTime", "beforeTransform"); + var transform = ts.transformFiles(resolver, host, sourceFiles, transformers); + // Create a printer to print the nodes + var printer = createPrinter(compilerOptions, { + // resolver hooks + hasGlobalName: resolver.hasGlobalName, + // transform hooks + onEmitNode: transform.emitNodeWithNotification, + onSubstituteNode: transform.emitNodeWithSubstitution, + // sourcemap hooks + onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, + onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, + onEmitSourceMapOfPosition: sourceMap.emitPos, + // emitter hooks + onEmitHelpers: emitHelpers, + onSetSourceFile: setSourceFile, + }); // Emit each output file ts.performance.mark("beforePrint"); - ts.forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); // Clean up emit nodes on parse tree - for (var _b = 0, sourceFiles_4 = sourceFiles; _b < sourceFiles_4.length; _b++) { - var sourceFile = sourceFiles_4[_b]; + for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { + var sourceFile = sourceFiles_2[_a]; ts.disposeEmitNodes(sourceFile); } return { @@ -60400,18 +61678,19 @@ var ts; emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList }; - function emitFile(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, isBundledEmit) { + function emitSourceFileOrBundle(_a, sourceFileOrBundle) { + var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath; // Make sure not to write js file and source map file if any of them cannot be written if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { if (!emitOnlyDtsFiles) { - printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle); } } else { emitSkipped = true; } if (declarationFilePath) { - emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; + emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFileOrBundle(sourceFileOrBundle), host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; } if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { @@ -60425,26 +61704,24 @@ var ts; } } } - function printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit) { - sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); - nodeIdToGeneratedName = []; - autoGeneratedIdToGeneratedName = []; - generatedNameSet = ts.createMap(); - bundledHelpers = isBundledEmit ? ts.createMap() : undefined; - isOwnFileEmit = !isBundledEmit; - // Emit helpers from all the files - if (isBundledEmit && moduleKind) { - for (var _a = 0, sourceFiles_5 = sourceFiles; _a < sourceFiles_5.length; _a++) { - var sourceFile = sourceFiles_5[_a]; - emitHelpers(sourceFile, /*isBundle*/ true); - } + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle) { + var bundle = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 264 /* SourceFile */ ? sourceFileOrBundle : undefined; + var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; + sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFileOrBundle); + if (bundle) { + bundledHelpers = ts.createMap(); + isOwnFileEmit = false; + printer.writeBundle(bundle, writer); } - // Print each transformed source file. - ts.forEach(sourceFiles, printSourceFile); - writeLine(); + else { + isOwnFileEmit = true; + printer.writeFile(sourceFile, writer); + } + writer.writeLine(); var sourceMappingURL = sourceMap.getSourceMappingURL(); if (sourceMappingURL) { - write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Sometimes tools can sometimes see this line as a source mapping url comment + writer.write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Sometimes tools can sometimes see this line as a source mapping url comment } // Write the source map if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) { @@ -60458,138 +61735,237 @@ var ts; ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles); // Reset state sourceMap.reset(); - comments.reset(); writer.reset(); - tempFlags = 0 /* Auto */; currentSourceFile = undefined; - currentText = undefined; + bundledHelpers = undefined; isOwnFileEmit = false; } - function printSourceFile(node) { + function setSourceFile(node) { currentSourceFile = node; - currentText = node.text; - currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); - comments.setSourceFile(node); - pipelineEmitWithNotification(0 /* SourceFile */, node); } - /** - * Emits a node. - */ - function emit(node) { - pipelineEmitWithNotification(3 /* Unspecified */, node); + function emitHelpers(node, writeLines) { + var helpersEmitted = false; + var bundle = node.kind === 265 /* Bundle */ ? node : undefined; + if (bundle && moduleKind === ts.ModuleKind.None) { + return; + } + var numNodes = bundle ? bundle.sourceFiles.length : 1; + for (var i = 0; i < numNodes; i++) { + var currentNode = bundle ? bundle.sourceFiles[i] : node; + var sourceFile = ts.isSourceFile(currentNode) ? currentNode : currentSourceFile; + var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = ts.isSourceFile(currentNode) && !isOwnFileEmit; + var helpers = ts.getEmitHelpers(currentNode); + if (helpers) { + for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { + var helper = _b[_a]; + if (!helper.scoped) { + // Skip the helper if it can be skipped and the noEmitHelpers compiler + // option is set, or if it can be imported and the importHelpers compiler + // option is set. + if (shouldSkip) + continue; + // Skip the helper if it can be bundled but hasn't already been emitted and we + // are emitting a bundled module. + if (shouldBundle) { + if (bundledHelpers.get(helper.name)) { + continue; + } + bundledHelpers.set(helper.name, true); + } + } + else if (bundle) { + // Skip the helper if it is scoped and we are emitting bundled helpers + continue; + } + writeLines(helper.text); + helpersEmitted = true; + } + } + } + return helpersEmitted; + } + } + ts.emitFiles = emitFiles; + function createPrinter(printerOptions, handlers) { + if (printerOptions === void 0) { printerOptions = {}; } + if (handlers === void 0) { handlers = {}; } + var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, onSubstituteNode = handlers.onSubstituteNode; + var newLine = ts.getNewLineCharacter(printerOptions); + var languageVersion = ts.getEmitScriptTarget(printerOptions); + var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); + var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; + var currentSourceFile; + var nodeIdToGeneratedName; // Map of generated names for specific nodes. + var autoGeneratedIdToGeneratedName; // Map of generated names for temp and loop variables. + var generatedNames; // Set of names generated by the NameGenerator. + var tempFlagsStack; // Stack of enclosing name generation scopes. + var tempFlags; // TempFlags for the current name generation scope. + var writer; + var ownWriter; + reset(); + return { + // public API + printNode: printNode, + printFile: printFile, + printBundle: printBundle, + // internal API + writeNode: writeNode, + writeFile: writeFile, + writeBundle: writeBundle + }; + function printNode(hint, node, sourceFile) { + switch (hint) { + case 0 /* SourceFile */: + ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); + break; + case 2 /* IdentifierName */: + ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); + break; + case 1 /* Expression */: + ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); + break; + } + switch (node.kind) { + case 264 /* SourceFile */: return printFile(node); + case 265 /* Bundle */: return printBundle(node); + } + writeNode(hint, node, sourceFile, beginPrint()); + return endPrint(); + } + function printBundle(bundle) { + writeBundle(bundle, beginPrint()); + return endPrint(); + } + function printFile(sourceFile) { + writeFile(sourceFile, beginPrint()); + return endPrint(); + } + function writeNode(hint, node, sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(hint, node, sourceFile); + reset(); + writer = previousWriter; + } + function writeBundle(bundle, output) { + var previousWriter = writer; + setWriter(output); + emitHelpersIndirect(bundle); + for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + print(0 /* SourceFile */, sourceFile, sourceFile); + } + reset(); + writer = previousWriter; + } + function writeFile(sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(0 /* SourceFile */, sourceFile, sourceFile); + reset(); + writer = previousWriter; + } + function beginPrint() { + return ownWriter || (ownWriter = ts.createTextWriter(newLine)); + } + function endPrint() { + var text = ownWriter.getText(); + ownWriter.reset(); + return text; + } + function print(hint, node, sourceFile) { + setSourceFile(sourceFile); + pipelineEmitWithNotification(hint, node); + } + function setSourceFile(sourceFile) { + currentSourceFile = sourceFile; + comments.setSourceFile(sourceFile); + if (onSetSourceFile) { + onSetSourceFile(sourceFile); + } + } + function setWriter(output) { + writer = output; + comments.setWriter(output); + } + function reset() { + nodeIdToGeneratedName = []; + autoGeneratedIdToGeneratedName = []; + generatedNames = ts.createMap(); + tempFlagsStack = []; + tempFlags = 0 /* Auto */; + comments.reset(); + setWriter(/*output*/ undefined); + } + function emit(node, hint) { + if (hint === void 0) { hint = 3 /* Unspecified */; } + pipelineEmitWithNotification(hint, node); } - /** - * Emits an IdentifierName. - */ function emitIdentifierName(node) { pipelineEmitWithNotification(2 /* IdentifierName */, node); } - /** - * Emits an expression node. - */ function emitExpression(node) { pipelineEmitWithNotification(1 /* Expression */, node); } - /** - * Emits a node with possible notification. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called from printSourceFile, emit, emitExpression, or - * emitIdentifierName. - */ - function pipelineEmitWithNotification(emitContext, node) { - emitNodeWithNotification(emitContext, node, pipelineEmitWithComments); + function pipelineEmitWithNotification(hint, node) { + if (onEmitNode) { + onEmitNode(hint, node, pipelineEmitWithComments); + } + else { + pipelineEmitWithComments(hint, node); + } } - /** - * Emits a node with comments. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithNotification. - */ - function pipelineEmitWithComments(emitContext, node) { - // Do not emit comments for SourceFile - if (emitContext === 0 /* SourceFile */) { - pipelineEmitWithSourceMap(emitContext, node); + function pipelineEmitWithComments(hint, node) { + if (emitNodeWithComments && hint !== 0 /* SourceFile */) { + emitNodeWithComments(hint, node, pipelineEmitWithSourceMap); + } + else { + pipelineEmitWithSourceMap(hint, node); + } + } + function pipelineEmitWithSourceMap(hint, node) { + if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */) { + onEmitSourceMapOfNode(hint, node, pipelineEmitWithSubstitution); + } + else { + pipelineEmitWithSubstitution(hint, node); + } + } + function pipelineEmitWithSubstitution(hint, node) { + if (onSubstituteNode) { + onSubstituteNode(hint, node, pipelineEmitWithHint); + } + else { + pipelineEmitWithHint(hint, node); + } + } + function pipelineEmitWithHint(hint, node) { + switch (hint) { + case 0 /* SourceFile */: return pipelineEmitSourceFile(node); + case 2 /* IdentifierName */: return pipelineEmitIdentifierName(node); + case 1 /* Expression */: return pipelineEmitExpression(node); + case 3 /* Unspecified */: return pipelineEmitUnspecified(node); + } + } + function pipelineEmitSourceFile(node) { + ts.Debug.assertNode(node, ts.isSourceFile); + emitSourceFile(node); + } + function pipelineEmitIdentifierName(node) { + ts.Debug.assertNode(node, ts.isIdentifier); + emitIdentifier(node); + } + function pipelineEmitUnspecified(node) { + var kind = node.kind; + // Reserved words + // Strict mode reserved words + // Contextual keywords + if (ts.isKeyword(kind)) { + writeTokenText(kind); return; } - emitNodeWithComments(emitContext, node, pipelineEmitWithSourceMap); - } - /** - * Emits a node with source maps. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithComments. - */ - function pipelineEmitWithSourceMap(emitContext, node) { - // Do not emit source mappings for SourceFile or IdentifierName - if (emitContext === 0 /* SourceFile */ - || emitContext === 2 /* IdentifierName */) { - pipelineEmitWithSubstitution(emitContext, node); - return; - } - emitNodeWithSourceMap(emitContext, node, pipelineEmitWithSubstitution); - } - /** - * Emits a node with possible substitution. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithSourceMap or - * pipelineEmitInUnspecifiedContext (when picking a more specific context). - */ - function pipelineEmitWithSubstitution(emitContext, node) { - emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext); - } - /** - * Emits a node. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithSubstitution. - */ - function pipelineEmitForContext(emitContext, node) { - switch (emitContext) { - case 0 /* SourceFile */: return pipelineEmitInSourceFileContext(node); - case 2 /* IdentifierName */: return pipelineEmitInIdentifierNameContext(node); - case 3 /* Unspecified */: return pipelineEmitInUnspecifiedContext(node); - case 1 /* Expression */: return pipelineEmitInExpressionContext(node); - } - } - /** - * Emits a node in the SourceFile EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInSourceFileContext(node) { - var kind = node.kind; - switch (kind) { - // Top-level nodes - case 262 /* SourceFile */: - return emitSourceFile(node); - } - } - /** - * Emits a node in the IdentifierName EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInIdentifierNameContext(node) { - var kind = node.kind; - switch (kind) { - // Identifiers - case 70 /* Identifier */: - return emitIdentifier(node); - } - } - /** - * Emits a node in the Unspecified EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInUnspecifiedContext(node) { - var kind = node.kind; switch (kind) { // Pseudo-literals case 13 /* TemplateHead */: @@ -60599,239 +61975,204 @@ var ts; // Identifiers case 70 /* Identifier */: return emitIdentifier(node); - // Reserved words - case 75 /* ConstKeyword */: - case 78 /* DefaultKeyword */: - case 83 /* ExportKeyword */: - case 104 /* VoidKeyword */: - // Strict mode reserved words - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 113 /* PublicKeyword */: - case 114 /* StaticKeyword */: - // Contextual keywords - case 116 /* AbstractKeyword */: - case 117 /* AsKeyword */: - case 118 /* AnyKeyword */: - case 119 /* AsyncKeyword */: - case 120 /* AwaitKeyword */: - case 121 /* BooleanKeyword */: - case 122 /* ConstructorKeyword */: - case 123 /* DeclareKeyword */: - case 124 /* GetKeyword */: - case 125 /* IsKeyword */: - case 127 /* ModuleKeyword */: - case 128 /* NamespaceKeyword */: - case 129 /* NeverKeyword */: - case 130 /* ReadonlyKeyword */: - case 131 /* RequireKeyword */: - case 132 /* NumberKeyword */: - case 133 /* SetKeyword */: - case 134 /* StringKeyword */: - case 135 /* SymbolKeyword */: - case 136 /* TypeKeyword */: - case 137 /* UndefinedKeyword */: - case 138 /* FromKeyword */: - case 139 /* GlobalKeyword */: - case 140 /* OfKeyword */: - writeTokenText(kind); - return; // Parse tree nodes // Names - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: return emitQualifiedName(node); - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return emitTypeParameter(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return emitParameter(node); - case 145 /* Decorator */: + case 146 /* Decorator */: return emitDecorator(node); // Type members - case 146 /* PropertySignature */: + case 147 /* PropertySignature */: return emitPropertySignature(node); - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 148 /* MethodSignature */: + case 149 /* MethodSignature */: return emitMethodSignature(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return emitConstructor(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return emitAccessorDeclaration(node); - case 153 /* CallSignature */: + case 154 /* CallSignature */: return emitCallSignature(node); - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: return emitConstructSignature(node); - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: return emitIndexSignature(node); // Types - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return emitTypePredicate(node); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return emitTypeReference(node); - case 158 /* FunctionType */: + case 159 /* FunctionType */: return emitFunctionType(node); - case 159 /* ConstructorType */: + case 160 /* ConstructorType */: return emitConstructorType(node); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return emitTypeQuery(node); - case 161 /* TypeLiteral */: + case 162 /* TypeLiteral */: return emitTypeLiteral(node); - case 162 /* ArrayType */: + case 163 /* ArrayType */: return emitArrayType(node); - case 163 /* TupleType */: + case 164 /* TupleType */: return emitTupleType(node); - case 164 /* UnionType */: + case 165 /* UnionType */: return emitUnionType(node); - case 165 /* IntersectionType */: + case 166 /* IntersectionType */: return emitIntersectionType(node); - case 166 /* ParenthesizedType */: + case 167 /* ParenthesizedType */: return emitParenthesizedType(node); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 167 /* ThisType */: + case 168 /* ThisType */: return emitThisType(); - case 168 /* TypeOperator */: + case 169 /* TypeOperator */: return emitTypeOperator(node); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 170 /* MappedType */: + case 171 /* MappedType */: return emitMappedType(node); - case 171 /* LiteralType */: + case 172 /* LiteralType */: return emitLiteralType(node); // Binding patterns - case 172 /* ObjectBindingPattern */: + case 173 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 173 /* ArrayBindingPattern */: + case 174 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 174 /* BindingElement */: + case 175 /* BindingElement */: return emitBindingElement(node); // Misc - case 203 /* TemplateSpan */: + case 204 /* TemplateSpan */: return emitTemplateSpan(node); - case 204 /* SemicolonClassElement */: + case 205 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 205 /* Block */: + case 206 /* Block */: return emitBlock(node); - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: return emitVariableStatement(node); - case 207 /* EmptyStatement */: + case 208 /* EmptyStatement */: return emitEmptyStatement(); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return emitExpressionStatement(node); - case 209 /* IfStatement */: + case 210 /* IfStatement */: return emitIfStatement(node); - case 210 /* DoStatement */: + case 211 /* DoStatement */: return emitDoStatement(node); - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: return emitWhileStatement(node); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return emitForStatement(node); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: return emitForInStatement(node); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: return emitForOfStatement(node); - case 215 /* ContinueStatement */: + case 216 /* ContinueStatement */: return emitContinueStatement(node); - case 216 /* BreakStatement */: + case 217 /* BreakStatement */: return emitBreakStatement(node); - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: return emitReturnStatement(node); - case 218 /* WithStatement */: + case 219 /* WithStatement */: return emitWithStatement(node); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: return emitSwitchStatement(node); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: return emitLabeledStatement(node); - case 221 /* ThrowStatement */: + case 222 /* ThrowStatement */: return emitThrowStatement(node); - case 222 /* TryStatement */: + case 223 /* TryStatement */: return emitTryStatement(node); - case 223 /* DebuggerStatement */: + case 224 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 225 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 226 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return emitClassDeclaration(node); - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 232 /* ModuleBlock */: + case 233 /* ModuleBlock */: return emitModuleBlock(node); - case 233 /* CaseBlock */: + case 234 /* CaseBlock */: return emitCaseBlock(node); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return emitImportDeclaration(node); - case 237 /* ImportClause */: + case 238 /* ImportClause */: return emitImportClause(node); - case 238 /* NamespaceImport */: + case 239 /* NamespaceImport */: return emitNamespaceImport(node); - case 239 /* NamedImports */: + case 240 /* NamedImports */: return emitNamedImports(node); - case 240 /* ImportSpecifier */: + case 241 /* ImportSpecifier */: return emitImportSpecifier(node); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: return emitExportAssignment(node); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return emitExportDeclaration(node); - case 243 /* NamedExports */: + case 244 /* NamedExports */: return emitNamedExports(node); - case 244 /* ExportSpecifier */: + case 245 /* ExportSpecifier */: return emitExportSpecifier(node); - case 245 /* MissingDeclaration */: + case 246 /* MissingDeclaration */: return; // Module references - case 246 /* ExternalModuleReference */: + case 247 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 249 /* JsxOpeningElement */: + case 250 /* JsxOpeningElement */: return emitJsxOpeningElement(node); - case 250 /* JsxClosingElement */: + case 251 /* JsxClosingElement */: return emitJsxClosingElement(node); - case 251 /* JsxAttribute */: + case 252 /* JsxAttribute */: return emitJsxAttribute(node); - case 252 /* JsxSpreadAttribute */: + case 253 /* JsxAttributes */: + return emitJsxAttributes(node); + case 254 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 253 /* JsxExpression */: + case 255 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 254 /* CaseClause */: + case 256 /* CaseClause */: return emitCaseClause(node); - case 255 /* DefaultClause */: + case 257 /* DefaultClause */: return emitDefaultClause(node); - case 256 /* HeritageClause */: + case 258 /* HeritageClause */: return emitHeritageClause(node); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 258 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 259 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 260 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 261 /* EnumMember */: + case 263 /* EnumMember */: return emitEnumMember(node); } // If the node is an expression, try to emit it as an expression with @@ -60840,13 +62181,7 @@ var ts; return pipelineEmitWithSubstitution(1 /* Expression */, node); } } - /** - * Emits a node in the Expression EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInExpressionContext(node) { + function pipelineEmitExpression(node) { var kind = node.kind; switch (kind) { // Literals @@ -60868,70 +62203,83 @@ var ts; writeTokenText(kind); return; // Expressions - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return emitCallExpression(node); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return emitNewExpression(node); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 182 /* TypeAssertionExpression */: + case 183 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return emitFunctionExpression(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return emitArrowFunction(node); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return emitDeleteExpression(node); - case 187 /* TypeOfExpression */: + case 188 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return emitVoidExpression(node); - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: return emitAwaitExpression(node); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return emitBinaryExpression(node); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return emitConditionalExpression(node); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return emitTemplateExpression(node); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return emitYieldExpression(node); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return emitSpreadExpression(node); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return emitClassExpression(node); - case 198 /* OmittedExpression */: + case 199 /* OmittedExpression */: return; - case 200 /* AsExpression */: + case 201 /* AsExpression */: return emitAsExpression(node); - case 201 /* NonNullExpression */: + case 202 /* NonNullExpression */: return emitNonNullExpression(node); - case 202 /* MetaProperty */: + case 203 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 247 /* JsxElement */: + case 248 /* JsxElement */: return emitJsxElement(node); - case 248 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes - case 295 /* PartiallyEmittedExpression */: + case 298 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); } } + function emitBodyIndirect(node, elements, emitCallback) { + if (emitBodyWithDetachedComments) { + emitBodyWithDetachedComments(node, elements, emitCallback); + } + else { + emitCallback(node); + } + } + function emitHelpersIndirect(node) { + if (onEmitHelpers) { + onEmitHelpers(node, writeLines); + } + } // // Literals/Pseudo-literals // @@ -60950,7 +62298,7 @@ var ts; // SyntaxKind.TemplateTail function emitLiteral(node) { var text = getLiteralTextOfNode(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) + if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } @@ -61049,7 +62397,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 151 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 152 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -61152,17 +62500,13 @@ var ts; write("{"); writeLine(); increaseIndent(); - if (node.readonlyToken) { - write("readonly "); - } + writeIfPresent(node.readonlyToken, "readonly "); write("["); emit(node.typeParameter.name); write(" in "); emit(node.typeParameter.constraint); write("]"); - if (node.questionToken) { - write("?"); - } + writeIfPresent(node.questionToken, "?"); write(": "); emit(node.type); write(";"); @@ -61240,7 +62584,7 @@ var ts; var indentAfterDot = false; if (!(ts.getEmitFlags(node) & 65536 /* NoIndentation */)) { var dotRangeStart = node.expression.end; - var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; + var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; var dotToken = { kind: 22 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); @@ -61257,9 +62601,11 @@ var ts; // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal function needsDotDotForPropertyAccess(expression) { if (expression.kind === 8 /* NumericLiteral */) { - // check if numeric literal was originally written with a dot + // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(22 /* DotToken */)) < 0; + return ts.getNumericLiteralFlags(text, /*hint*/ 15 /* All */) === 0 /* None */ + && !expression.isOctalLiteral + && text.indexOf(ts.tokenToString(22 /* DotToken */)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer @@ -61267,7 +62613,7 @@ var ts; // isFinite handles cases when constantValue is undefined return isFinite(constantValue) && Math.floor(constantValue) === constantValue - && compilerOptions.removeComments; + && printerOptions.removeComments; } } function emitElementAccessExpression(node) { @@ -61293,11 +62639,9 @@ var ts; emitExpression(node.template); } function emitTypeAssertionExpression(node) { - if (node.type) { - write("<"); - emit(node.type); - write(">"); - } + write("<"); + emit(node.type); + write(">"); emitExpression(node.expression); } function emitParenthesizedExpression(node) { @@ -61356,7 +62700,7 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 190 /* PrefixUnaryExpression */ + return operand.kind === 191 /* PrefixUnaryExpression */ && ((node.operator === 36 /* PlusToken */ && (operand.operator === 36 /* PlusToken */ || operand.operator === 42 /* PlusPlusToken */)) || (node.operator === 37 /* MinusToken */ && (operand.operator === 37 /* MinusToken */ || operand.operator === 43 /* MinusMinusToken */))); } @@ -61446,6 +62790,10 @@ var ts; else { writeToken(16 /* OpenBraceToken */, node.pos, /*contextNode*/ node); emitBlockStatements(node); + // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); writeToken(17 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } } @@ -61479,7 +62827,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 209 /* IfStatement */) { + if (node.elseStatement.kind === 210 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -61541,7 +62889,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 225 /* VariableDeclarationList */) { + if (node.kind === 226 /* VariableDeclarationList */) { emit(node); } else { @@ -61641,11 +62989,10 @@ var ts; emitBlockFunctionBody(body); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); emitSignatureHead(node); emitBlockFunctionBody(body); - tempFlags = savedTempFlags; + popNameGenerationScope(); } if (indentedFlag) { decreaseIndent(); @@ -61700,9 +63047,10 @@ var ts; function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) + var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine - : emitBlockFunctionBodyWorker); + : emitBlockFunctionBodyWorker; + emitBodyIndirect(body, body.statements, emitBlockFunctionBody); decreaseIndent(); writeToken(17 /* CloseBraceToken */, body.statements.end, body); } @@ -61712,8 +63060,9 @@ var ts; function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) { // Emit all the prologue directives (like "use strict"). var statementOffset = emitPrologueDirectives(body.statements, /*startWithNewLine*/ true); - var helpersEmitted = emitHelpers(body); - if (statementOffset === 0 && !helpersEmitted && emitBlockFunctionBodyOnSingleLine) { + var pos = writer.getTextPos(); + emitHelpersIndirect(body); + if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); emitList(body, body.statements, 384 /* SingleLineFunctionBodyStatements */); increaseIndent(); @@ -61736,15 +63085,14 @@ var ts; } emitTypeParameters(node, node.typeParameters); emitList(node, node.heritageClauses, 256 /* ClassHeritageClauses */); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 65 /* ClassMembers */); write("}"); + popNameGenerationScope(); if (indentedFlag) { decreaseIndent(); } - tempFlags = savedTempFlags; } function emitInterfaceDeclaration(node) { emitDecorators(node, node.decorators); @@ -61771,19 +63119,18 @@ var ts; emitModifiers(node, node.modifiers); write("enum "); emit(node.name); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 81 /* EnumMembers */); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 231 /* ModuleDeclaration */) { + while (body.kind === 232 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -61796,13 +63143,12 @@ var ts; write("{ }"); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write("{"); increaseIndent(); emitBlockStatements(node); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } } function emitCaseBlock(node) { @@ -61910,14 +63256,20 @@ var ts; write("<"); emitJsxTagName(node.tagName); write(" "); - emitList(node, node.attributes, 131328 /* JsxElementAttributes */); + // We are checking here so we won't re-enter the emiting pipeline and emit extra sourcemap + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write("/>"); } function emitJsxOpeningElement(node) { write("<"); emitJsxTagName(node.tagName); - writeIfAny(node.attributes, " "); - emitList(node, node.attributes, 131328 /* JsxElementAttributes */); + writeIfAny(node.attributes.properties, " "); + // We are checking here so we won't re-enter the emitting pipeline and emit extra sourcemap + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write(">"); } function emitJsxText(node) { @@ -61928,6 +63280,9 @@ var ts; emitJsxTagName(node.tagName); write(">"); } + function emitJsxAttributes(node) { + emitList(node, node.properties, 131328 /* JsxElementAttributes */); + } function emitJsxAttribute(node) { emit(node.name); emitWithPrefix("=", node.initializer); @@ -61990,7 +63345,6 @@ var ts; emitList(node, node.types, 272 /* HeritageClauseTypes */); } function emitCatchClause(node) { - writeLine(); var openParenPos = writeToken(73 /* CatchKeyword */, node.pos); write(" "); writeToken(18 /* OpenParenToken */, openParenPos); @@ -62013,7 +63367,7 @@ var ts; // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { + if (emitTrailingCommentsOfPosition && (ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -62045,16 +63399,15 @@ var ts; function emitSourceFile(node) { writeLine(); emitShebang(); - emitBodyWithDetachedComments(node, node.statements, emitSourceFileWorker); + emitBodyIndirect(node, node.statements, emitSourceFileWorker); } function emitSourceFileWorker(node) { var statements = node.statements; var statementOffset = emitPrologueDirectives(statements); - var savedTempFlags = tempFlags; - tempFlags = 0; - emitHelpers(node); + pushNameGenerationScope(); + emitHelpersIndirect(node); emitList(node, statements, 1 /* MultiLine */, statementOffset); - tempFlags = savedTempFlags; + popNameGenerationScope(); } // Transformation nodes function emitPartiallyEmittedExpression(node) { @@ -62079,76 +63432,11 @@ var ts; } return statements.length; } - function emitHelpers(node, isBundle) { - var sourceFile = ts.isSourceFile(node) ? node : currentSourceFile; - var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); - var shouldBundle = ts.isSourceFile(node) && !isOwnFileEmit; - var helpersEmitted = false; - var helpers = ts.getEmitHelpers(node); - if (helpers) { - for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { - var helper = _b[_a]; - if (!helper.scoped) { - // Skip the helper if it can be skipped and the noEmitHelpers compiler - // option is set, or if it can be imported and the importHelpers compiler - // option is set. - if (shouldSkip) - continue; - // Skip the helper if it can be bundled but hasn't already been emitted and we - // are emitting a bundled module. - if (shouldBundle) { - if (bundledHelpers[helper.name]) { - continue; - } - bundledHelpers[helper.name] = true; - } - } - else if (isBundle) { - // Skip the helper if it is scoped and we are emitting bundled helpers - continue; - } - writeLines(helper.text); - helpersEmitted = true; - } - } - if (helpersEmitted) { - writeLine(); - } - return helpersEmitted; - } - function writeLines(text) { - var lines = text.split(/\r\n?|\n/g); - var indentation = guessIndentation(lines); - for (var i = 0; i < lines.length; i++) { - var line = indentation ? lines[i].slice(indentation) : lines[i]; - if (line.length) { - if (i > 0) { - writeLine(); - } - write(line); - } - } - } - function guessIndentation(lines) { - var indentation; - for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { - var line = lines_1[_a]; - for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { - if (!ts.isWhiteSpace(line.charCodeAt(i))) { - if (indentation === undefined || i < indentation) { - indentation = i; - break; - } - } - } - } - return indentation; - } // // Helpers // function emitShebang() { - var shebang = ts.getShebang(currentText); + var shebang = ts.getShebang(currentSourceFile.text); if (shebang) { write(shebang); writeLine(); @@ -62268,6 +63556,15 @@ var ts; var child = children[start + i]; // Write the delimiter if this is not the first node. if (previousSibling) { + // i.e + // function commentedParameters( + // /* Parameter a */ + // a + // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline + // , + if (delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } write(delimiter); // Write either a line terminator or whitespace to separate the elements. if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { @@ -62284,14 +63581,16 @@ var ts; write(" "); } } + // Emit this child. if (shouldEmitInterveningComments) { - var commentRange = ts.getCommentRange(child); - emitTrailingCommentsOfPosition(commentRange.pos); + if (emitTrailingCommentsOfPosition) { + var commentRange = ts.getCommentRange(child); + emitTrailingCommentsOfPosition(commentRange.pos); + } } else { shouldEmitInterveningComments = mayEmitInterveningComments; } - // Emit this child. emit(child); if (shouldDecreaseIndentAfterEmit) { decreaseIndent(); @@ -62304,6 +63603,15 @@ var ts; if (format & 16 /* CommaDelimited */ && hasTrailingComma) { write(","); } + // Emit any trailing comment of the last element in the list + // i.e + // var array = [... + // 2 + // /* end of element 2 */ + // ]; + if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } // Decrease the indent, if requested. if (format & 64 /* Indented */) { decreaseIndent(); @@ -62320,6 +63628,38 @@ var ts; write(getClosingBracket(format)); } } + function write(s) { + writer.write(s); + } + function writeLine() { + writer.writeLine(); + } + function increaseIndent() { + writer.increaseIndent(); + } + function decreaseIndent() { + writer.decreaseIndent(); + } + function writeIfAny(nodes, text) { + if (ts.some(nodes)) { + write(text); + } + } + function writeIfPresent(node, text) { + if (node) { + write(text); + } + } + function writeToken(token, pos, contextNode) { + return onEmitSourceMapOfToken + ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) + : writeTokenText(token, pos); + } + function writeTokenText(token, pos) { + var tokenString = ts.tokenToString(token); + write(tokenString); + return pos < 0 ? pos : pos + tokenString.length; + } function writeLineOrSpace(node) { if (ts.getEmitFlags(node) & 1 /* SingleLine */) { write(" "); @@ -62328,23 +63668,32 @@ var ts; writeLine(); } } - function writeIfAny(nodes, text) { - if (nodes && nodes.length > 0) { - write(text); + function writeLines(text) { + var lines = text.split(/\r\n?|\n/g); + var indentation = guessIndentation(lines); + for (var i = 0; i < lines.length; i++) { + var line = indentation ? lines[i].slice(indentation) : lines[i]; + if (line.length) { + writeLine(); + write(line); + writeLine(); + } } } - function writeIfPresent(node, text) { - if (node !== undefined) { - write(text); + function guessIndentation(lines) { + var indentation; + for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { + var line = lines_1[_a]; + for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { + if (!ts.isWhiteSpace(line.charCodeAt(i))) { + if (indentation === undefined || i < indentation) { + indentation = i; + break; + } + } + } } - } - function writeToken(token, pos, contextNode) { - return emitTokenWithSourceMap(contextNode, token, pos, writeTokenText); - } - function writeTokenText(token, pos) { - var tokenString = ts.tokenToString(token); - write(tokenString); - return pos < 0 ? pos : pos + tokenString.length; + return indentation; } function increaseIndentIf(value, valueToWriteWhenNotIndenting) { if (value) { @@ -62455,15 +63804,23 @@ var ts; && !ts.nodeIsSynthesized(node2) && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } + function isSingleLineEmptyBlock(block) { + return !block.multiLine + && isEmptyBlock(block); + } + function isEmptyBlock(block) { + return block.statements.length === 0 + && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + } function skipSynthesizedParentheses(node) { - while (node.kind === 183 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 184 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; } function getTextOfNode(node, includeTrivia) { if (ts.isGeneratedIdentifier(node)) { - return getGeneratedIdentifier(node); + return generateName(node); } else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { return ts.unescapeIdentifier(node.text); @@ -62488,24 +63845,58 @@ var ts; } return ts.getLiteralText(node, currentSourceFile, languageVersion); } - function isSingleLineEmptyBlock(block) { - return !block.multiLine - && isEmptyBlock(block); + /** + * Push a new name generation scope. + */ + function pushNameGenerationScope() { + tempFlagsStack.push(tempFlags); + tempFlags = 0; } - function isEmptyBlock(block) { - return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + /** + * Pop the current name generation scope. + */ + function popNameGenerationScope() { + tempFlags = tempFlagsStack.pop(); } + /** + * Generate the text for a generated identifier. + */ + function generateName(name) { + if (name.autoGenerateKind === 4 /* Node */) { + // Node names generate unique names based on their original node + // and are cached based on that node's id. + var node = getNodeForGeneratedName(name); + return generateNameCached(node); + } + else { + // Auto, Loop, and Unique names are cached based on their unique + // autoGenerateId. + var autoGenerateId = name.autoGenerateId; + return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(makeName(name))); + } + } + function generateNameCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + } + /** + * Returns a value indicating whether a name is unique globally, within the current file, + * or within the NameGenerator. + */ function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentFileIdentifiers, name) && - !ts.hasProperty(generatedNameSet, name); + return !(hasGlobalName && hasGlobalName(name)) + && !currentSourceFile.identifiers.has(name) + && !generatedNames.has(name); } + /** + * Returns a value indicating whether a name is unique within a container. + */ function isUniqueLocalName(name, container) { for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { + if (node.locals) { + var local = node.locals.get(name); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { + if (local && local.flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { return false; } } @@ -62513,16 +63904,16 @@ var ts; return true; } /** - * Return the next available name in the pattern _a ... _z, _0, _1, ... - * TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name. - * Note that names generated by makeTempVariableName and makeUniqueName will never conflict. - */ + * Return the next available name in the pattern _a ... _z, _0, _1, ... + * TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name. + * Note that names generated by makeTempVariableName and makeUniqueName will never conflict. + */ function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_41 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_41)) { + var name = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name)) { tempFlags |= flags; - return name_41; + return name; } } while (true) { @@ -62530,19 +63921,21 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_42 = count < 26 + var name = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_42)) { - return name_42; + if (isUniqueName(name)) { + return name; } } } } - // Generate a name that is unique within the current file and doesn't conflict with any names - // in global scope. The name is formed by adding an '_n' suffix to the specified base name, - // where n is a positive integer. Note that names generated by makeTempVariableName and - // makeUniqueName are guaranteed to never conflict. + /** + * Generate a name that is unique within the current file and doesn't conflict with any names + * in global scope. The name is formed by adding an '_n' suffix to the specified base name, + * where n is a positive integer. Note that names generated by makeTempVariableName and + * makeUniqueName are guaranteed to never conflict. + */ function makeUniqueName(baseName) { // Find the first unique 'name_n', where n is a positive number if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { @@ -62552,58 +63945,69 @@ var ts; while (true) { var generatedName = baseName + i; if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; + generatedNames.set(generatedName, generatedName); + return generatedName; } i++; } } + /** + * Generates a unique name for a ModuleDeclaration or EnumDeclaration. + */ function generateNameForModuleOrEnum(node) { var name = getTextOfNode(node.name); // Use module/enum name itself if it is unique, otherwise make a unique variation return isUniqueLocalName(name, node) ? name : makeUniqueName(name); } + /** + * Generates a unique name for an ImportDeclaration or ExportDeclaration. + */ function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); var baseName = expr.kind === 9 /* StringLiteral */ ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; return makeUniqueName(baseName); } + /** + * Generates a unique name for a default export. + */ function generateNameForExportDefault() { return makeUniqueName("default"); } + /** + * Generates a unique name for a class expression. + */ function generateNameForClassExpression() { return makeUniqueName("class"); } function generateNameForMethodOrAccessor(node) { if (ts.isIdentifier(node.name)) { - return generateNameForNodeCached(node.name); + return generateNameCached(node.name); } return makeTempVariableName(0 /* Auto */); } /** * Generates a unique name from a node. - * - * @param node A node. */ function generateNameForNode(node) { switch (node.kind) { case 70 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 231 /* ModuleDeclaration */: - case 230 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: + case 231 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 236 /* ImportDeclaration */: - case 242 /* ExportDeclaration */: + case 237 /* ImportDeclaration */: + case 243 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 226 /* FunctionDeclaration */: - case 227 /* ClassDeclaration */: - case 241 /* ExportAssignment */: + case 227 /* FunctionDeclaration */: + case 228 /* ClassDeclaration */: + case 242 /* ExportAssignment */: return generateNameForExportDefault(); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return generateNameForClassExpression(); - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); @@ -62611,24 +64015,20 @@ var ts; } /** * Generates a unique identifier for a node. - * - * @param name A generated name. */ - function generateName(name) { + function makeName(name) { switch (name.autoGenerateKind) { case 1 /* Auto */: return makeTempVariableName(0 /* Auto */); case 2 /* Loop */: return makeTempVariableName(268435456 /* _i */); case 3 /* Unique */: - return makeUniqueName(name.text); + return makeUniqueName(ts.unescapeIdentifier(name.text)); } ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } /** * Gets the node from which a name should be generated. - * - * @param name A generated name wrapper. */ function getNodeForGeneratedName(name) { var autoGenerateId = name.autoGenerateId; @@ -62648,56 +64048,40 @@ var ts; // otherwise, return the original node for the source; return node; } - function generateNameForNodeCached(node) { - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); - } - /** - * Gets the generated identifier text from a generated identifier. - * - * @param name The generated identifier. - */ - function getGeneratedIdentifier(name) { - if (name.autoGenerateKind === 4 /* Node */) { - // Generated names generate unique names based on their original node - // and are cached based on that node's id - var node = getNodeForGeneratedName(name); - return generateNameForNodeCached(node); - } - else { - // Auto, Loop, and Unique names are cached based on their unique - // autoGenerateId. - var autoGenerateId = name.autoGenerateId; - return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(generateName(name))); - } - } - function createDelimiterMap() { - var delimiters = []; - delimiters[0 /* None */] = ""; - delimiters[16 /* CommaDelimited */] = ","; - delimiters[4 /* BarDelimited */] = " |"; - delimiters[8 /* AmpersandDelimited */] = " &"; - return delimiters; - } - function getDelimiter(format) { - return delimiters[format & 28 /* DelimitersMask */]; - } - function createBracketsMap() { - var brackets = []; - brackets[512 /* Braces */] = ["{", "}"]; - brackets[1024 /* Parenthesis */] = ["(", ")"]; - brackets[2048 /* AngleBrackets */] = ["<", ">"]; - brackets[4096 /* SquareBrackets */] = ["[", "]"]; - return brackets; - } - function getOpeningBracket(format) { - return brackets[format & 7680 /* BracketsMask */][0]; - } - function getClosingBracket(format) { - return brackets[format & 7680 /* BracketsMask */][1]; - } } - ts.emitFiles = emitFiles; + ts.createPrinter = createPrinter; + function createDelimiterMap() { + var delimiters = []; + delimiters[0 /* None */] = ""; + delimiters[16 /* CommaDelimited */] = ","; + delimiters[4 /* BarDelimited */] = " |"; + delimiters[8 /* AmpersandDelimited */] = " &"; + return delimiters; + } + function getDelimiter(format) { + return delimiters[format & 28 /* DelimitersMask */]; + } + function createBracketsMap() { + var brackets = []; + brackets[512 /* Braces */] = ["{", "}"]; + brackets[1024 /* Parenthesis */] = ["(", ")"]; + brackets[2048 /* AngleBrackets */] = ["<", ">"]; + brackets[4096 /* SquareBrackets */] = ["[", "]"]; + return brackets; + } + function getOpeningBracket(format) { + return brackets[format & 7680 /* BracketsMask */][0]; + } + function getClosingBracket(format) { + return brackets[format & 7680 /* BracketsMask */][1]; + } + // Flags enum to track count of temp variables and a few dedicated names + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); var ListFormat; (function (ListFormat) { ListFormat[ListFormat["None"] = 0] = "None"; @@ -62862,11 +64246,11 @@ var ts; return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; } function directoryExists(directoryPath) { - if (directoryPath in existingDirectories) { + if (existingDirectories.has(directoryPath)) { return true; } if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; + existingDirectories.set(directoryPath, true); return true; } return false; @@ -62885,10 +64269,11 @@ var ts; } var hash = ts.sys.createHash(data); var mtimeBefore = ts.sys.getModifiedTime(fileName); - if (mtimeBefore && fileName in outputFingerprints) { - var fingerprint = outputFingerprints[fileName]; + if (mtimeBefore) { + var fingerprint = outputFingerprints.get(fileName); // If output has not been changed, and the file has no external modification - if (fingerprint.byteOrderMark === writeByteOrderMark && + if (fingerprint && + fingerprint.byteOrderMark === writeByteOrderMark && fingerprint.hash === hash && fingerprint.mtime.getTime() === mtimeBefore.getTime()) { return; @@ -62896,11 +64281,11 @@ var ts; } ts.sys.writeFile(fileName, data, writeByteOrderMark); var mtimeAfter = ts.sys.getModifiedTime(fileName); - outputFingerprints[fileName] = { + outputFingerprints.set(fileName, { hash: hash, byteOrderMark: writeByteOrderMark, mtime: mtimeAfter - }; + }); } function writeFile(fileName, data, writeByteOrderMark, onError) { try { @@ -62999,10 +64384,14 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_43 = names_1[_i]; - var result = name_43 in cache - ? cache[name_43] - : cache[name_43] = loader(name_43, containingFile); + var name = names_1[_i]; + var result = void 0; + if (cache.has(name)) { + result = cache.get(name); + } + else { + cache.set(name, result = loader(name, containingFile)); + } resolutions.push(result); } return resolutions; @@ -63135,7 +64524,7 @@ var ts; return program; function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -63159,7 +64548,7 @@ var ts; classifiableNames = ts.createMap(); for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { var sourceFile = files_2[_i]; - ts.copyProperties(sourceFile.classifiableNames, classifiableNames); + ts.copyEntries(sourceFile.classifiableNames, classifiableNames); } } return classifiableNames; @@ -63395,7 +64784,7 @@ var ts; }; } function isSourceFileFromExternalLibrary(file) { - return sourceFilesFoundSearchingNodeModules[file.path]; + return sourceFilesFoundSearchingNodeModules.get(file.path); } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); @@ -63540,23 +64929,23 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 144 /* Parameter */: - case 147 /* PropertyDeclaration */: + case 145 /* Parameter */: + case 148 /* PropertyDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // Pass through - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 226 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 226 /* FunctionDeclaration */: - case 224 /* VariableDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 225 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -63564,35 +64953,35 @@ var ts; } } switch (node.kind) { - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 256 /* HeritageClause */: + case 258 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 107 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 182 /* TypeAssertionExpression */: + case 183 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; @@ -63607,29 +64996,29 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 227 /* ClassDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 226 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 226 /* FunctionDeclaration */: + case 228 /* ClassDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // pass through - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 206 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 207 /* VariableStatement */); } break; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { @@ -63641,16 +65030,16 @@ var ts; return; } break; - case 144 /* Parameter */: + case 145 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 199 /* ExpressionWithTypeArguments */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 200 /* ExpressionWithTypeArguments */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -63747,11 +65136,10 @@ var ts; && (options.isolatedModules || isExternalModuleFile) && !file.isDeclarationFile) { // synthesize 'import "tslib"' declaration - var externalHelpersModuleReference = ts.createSynthesizedNode(9 /* StringLiteral */); - externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(236 /* ImportDeclaration */); - importDecl.parent = file; + var externalHelpersModuleReference = ts.createLiteral(ts.externalHelpersModuleNameText); + var importDecl = ts.createImportDeclaration(undefined, undefined, undefined); externalHelpersModuleReference.parent = importDecl; + importDecl.parent = file; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -63767,9 +65155,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 236 /* ImportDeclaration */: - case 235 /* ImportEqualsDeclaration */: - case 242 /* ExportDeclaration */: + case 237 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 243 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -63784,7 +65172,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2 /* Ambient */) || ts.isDeclarationFile(file))) { var moduleName = node.name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -63884,18 +65272,18 @@ var ts; } // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { - sourceFilesFoundSearchingNodeModules[file_1.path] = false; + if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth == 0) { + sourceFilesFoundSearchingNodeModules.set(file_1.path, false); if (!options.noResolve) { processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } - else if (file_1 && modulesWithElidedImports[file_1.path]) { + else if (file_1 && modulesWithElidedImports.get(file_1.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } } @@ -63912,7 +65300,7 @@ var ts; }); filesByName.set(path, file); if (file) { - sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0); + sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; if (host.useCaseSensitiveFileNames()) { // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case @@ -63961,7 +65349,7 @@ var ts; } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { // If we already found this library as a primary reference - nothing to do - var previousResolution = resolvedTypeReferenceDirectives[typeReferenceDirective]; + var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { return; } @@ -63995,7 +65383,7 @@ var ts; fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { - resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective; + resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); } } function createDiagnostic(refFile, refPos, refEnd, message) { @@ -64044,7 +65432,7 @@ var ts; // This may still end up being an untyped module -- the file won't be included but imports will be allowed. var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { - modulesWithElidedImports[file.path] = true; + modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = ts.toPath(resolvedFileName, currentDirectory, getCanonicalFileName); @@ -64063,8 +65451,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var file = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var file = sourceFiles_3[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -64075,8 +65463,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -64235,7 +65623,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { + ts.forEachEmittedFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -64367,12 +65755,13 @@ var ts; }, { name: "jsx", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "preserve": 1 /* Preserve */, + "react-native": 3 /* ReactNative */, "react": 2 /* React */ }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, }, { name: "reactNamespace", @@ -64402,7 +65791,7 @@ var ts; { name: "module", shortName: "m", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "none": ts.ModuleKind.None, "commonjs": ts.ModuleKind.CommonJS, "amd": ts.ModuleKind.AMD, @@ -64416,7 +65805,7 @@ var ts; }, { name: "newLine", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "crlf": 0 /* CarriageReturnLineFeed */, "lf": 1 /* LineFeed */ }), @@ -64514,8 +65903,8 @@ var ts; shortName: "p", type: "string", isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY + description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY }, { name: "removeComments", @@ -64565,7 +65954,7 @@ var ts; { name: "target", shortName: "t", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "es3": 0 /* ES3 */, "es5": 1 /* ES5 */, "es6": 2 /* ES2015 */, @@ -64602,7 +65991,7 @@ var ts; }, { name: "moduleResolution", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "node": ts.ModuleResolutionKind.NodeJs, "classic": ts.ModuleResolutionKind.Classic, }), @@ -64711,7 +66100,7 @@ var ts; type: "list", element: { name: "lib", - type: ts.createMap({ + type: ts.createMapFromTemplate({ // JavaScript only "es5": "lib.es5.d.ts", "es6": "lib.es2015.d.ts", @@ -64760,6 +66149,16 @@ var ts; name: "alwaysStrict", type: "boolean", description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + }, + { + // A list of plugins to load in the language service + name: "plugins", + type: "list", + isTSConfigOnly: true, + element: { + name: "plugin", + type: "object" + } } ]; /* @internal */ @@ -64822,9 +66221,9 @@ var ts; var optionNameMap = ts.createMap(); var shortOptionNames = ts.createMap(); ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; + optionNameMap.set(option.name.toLowerCase(), option); if (option.shortName) { - shortOptionNames[option.shortName] = option.name; + shortOptionNames.set(option.shortName, option.name); } }); optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; @@ -64833,7 +66232,7 @@ var ts; ts.getOptionNameMap = getOptionNameMap; /* @internal */ function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -64885,11 +66284,12 @@ var ts; else if (s.charCodeAt(0) === 45 /* minus */) { s = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1).toLowerCase(); // Try to translate short option names to their full equivalents. - if (s in shortOptionNames) { - s = shortOptionNames[s]; + var short = shortOptionNames.get(s); + if (short !== undefined) { + s = short; } - if (s in optionNameMap) { - var opt = optionNameMap[s]; + var opt = optionNameMap.get(s); + if (opt) { if (opt.isTSConfigOnly) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } @@ -65037,21 +66437,20 @@ var ts; } function getNameOfCompilerOptionValue(value, customTypeMap) { // There is a typeMap associated with this command-line option so use it to map value back to its name - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { return key; } - } - return undefined; + }); } function serializeCompilerOptions(options) { - var result = ts.createMap(); + var result = {}; var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_44 in options) { - if (ts.hasProperty(options, name_44)) { + for (var name in options) { + if (ts.hasProperty(options, name)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - switch (name_44) { + switch (name) { case "init": case "watch": case "version": @@ -65059,14 +66458,14 @@ var ts; case "project": break; default: - var value = options[name_44]; - var optionDefinition = optionsNameMap[name_44.toLowerCase()]; + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { // There is no map associated with this compiler option then use the value as-is // This is the case if the value is expect to be string, number, boolean or list of string - result[name_44] = value; + result[name] = value; } else { if (optionDefinition.type === "list") { @@ -65075,11 +66474,11 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_44] = convertedValue; + result[name] = convertedValue; } else { // There is a typeMap associated with this command-line option so use it to map value back to its name - result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -65305,8 +66704,8 @@ var ts; } var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; + var opt = optionNameMap.get(id); + if (opt) { defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); } else { @@ -65340,8 +66739,9 @@ var ts; } function convertJsonOptionOfCustomType(opt, value, errors) { var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; + var val = opt.type.get(key); + if (val !== undefined) { + return val; } else { errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); @@ -65465,7 +66865,7 @@ var ts; for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { var fileName = fileNames_1[_i]; var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; + literalFileMap.set(keyMapper(file), file); } } if (include && include.length > 0) { @@ -65486,14 +66886,13 @@ var ts; // same directory, we should remove it. removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; + if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) { + wildcardFileMap.set(key, file); } } } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); + var literalFiles = ts.arrayFrom(literalFileMap.values()); + var wildcardFiles = ts.arrayFrom(wildcardFileMap.values()); return { fileNames: literalFiles.concat(wildcardFiles), wildcardDirectories: wildcardDirectories @@ -65501,8 +66900,8 @@ var ts; } function validateSpecs(specs, errors, allowTrailingRecursion) { var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + var spec = specs_1[_i]; if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); } @@ -65536,7 +66935,7 @@ var ts; // /a/b/a?z - Watch /a/b directly to catch any new file matching a?z var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); + var wildcardDirectories = {}; if (include !== undefined) { var recursiveKeys = []; for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { @@ -65558,14 +66957,16 @@ var ts; } } // Remove any subpaths under an existing recursively watched directory. - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; + for (var key in wildcardDirectories) + if (ts.hasProperty(wildcardDirectories, key)) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } } } - } + ; } return wildcardDirectories; } @@ -65592,11 +66993,11 @@ var ts; */ function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); + var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions); for (var i = 0 /* Highest */; i < adjustedExtensionPriority; i++) { var higherPriorityExtension = extensions[i]; var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { return true; } } @@ -65612,23 +67013,13 @@ var ts; */ function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions); for (var i = nextExtensionPriority; i < extensions.length; i++) { var lowerPriorityExtension = extensions[i]; var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; + wildcardFiles.delete(lowerPriorityPath); } } - /** - * Adds a file to an array of files. - * - * @param output The output array. - * @param file The file path. - */ - function addFileToOutput(output, file) { - output.push(file); - return output; - } /** * Gets a case sensitive key. * @@ -65811,6 +67202,10 @@ var ts; ScriptElementKind.letElement = "let"; ScriptElementKind.directory = "directory"; ScriptElementKind.externalModuleName = "external module name"; + /** + * + **/ + ScriptElementKind.jsxAttribute = "JSX attribute"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { @@ -65896,33 +67291,34 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 144 /* Parameter */: - case 224 /* VariableDeclaration */: - case 174 /* BindingElement */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 258 /* PropertyAssignment */: - case 259 /* ShorthandPropertyAssignment */: - case 261 /* EnumMember */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 257 /* CatchClause */: + case 145 /* Parameter */: + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 260 /* PropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: + case 263 /* EnumMember */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 259 /* CatchClause */: + case 252 /* JsxAttribute */: return 1 /* Value */; - case 143 /* TypeParameter */: - case 228 /* InterfaceDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 161 /* TypeLiteral */: + case 144 /* TypeParameter */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 162 /* TypeLiteral */: return 2 /* Type */; - case 227 /* ClassDeclaration */: - case 230 /* EnumDeclaration */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -65932,22 +67328,25 @@ var ts; else { return 4 /* Namespace */; } - case 239 /* NamedImports */: - case 240 /* ImportSpecifier */: - case 235 /* ImportEqualsDeclaration */: - case 236 /* ImportDeclaration */: - case 241 /* ExportAssignment */: - case 242 /* ExportDeclaration */: + case 240 /* NamedImports */: + case 241 /* ImportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportDeclaration */: + case 242 /* ExportAssignment */: + case 243 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 262 /* SourceFile */: + case 264 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 241 /* ExportAssignment */) { + if (node.kind === 264 /* SourceFile */) { + return 1 /* Value */; + } + else if (node.parent.kind === 242 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -65972,15 +67371,15 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 141 /* QualifiedName */ && + if (node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 235 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 236 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function isInRightSideOfImport(node) { - while (node.parent.kind === 141 /* QualifiedName */) { + while (node.parent.kind === 142 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -65991,27 +67390,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 141 /* QualifiedName */) { - while (root.parent && root.parent.kind === 141 /* QualifiedName */) { + if (root.parent.kind === 142 /* QualifiedName */) { + while (root.parent && root.parent.kind === 142 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 157 /* TypeReference */ && !isLastClause; + return root.parent.kind === 158 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 177 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 177 /* PropertyAccessExpression */) { + if (root.parent.kind === 178 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 178 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 199 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 256 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 200 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 258 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 227 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || - (decl.kind === 228 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); + return (decl.kind === 228 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || + (decl.kind === 229 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); } return false; } @@ -66019,17 +67418,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 157 /* TypeReference */ || - (node.parent.kind === 199 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 158 /* TypeReference */ || + (node.parent.kind === 200 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 98 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || - node.kind === 167 /* ThisType */; + node.kind === 168 /* ThisType */; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 179 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 180 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 180 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 181 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -66042,7 +67441,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 220 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 221 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -66052,13 +67451,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 /* Identifier */ && - (node.parent.kind === 216 /* BreakStatement */ || node.parent.kind === 215 /* ContinueStatement */) && + (node.parent.kind === 217 /* BreakStatement */ || node.parent.kind === 216 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 /* Identifier */ && - node.parent.kind === 220 /* LabeledStatement */ && + node.parent.kind === 221 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -66066,15 +67465,15 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 177 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 231 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 232 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -66085,19 +67484,19 @@ var ts; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 258 /* PropertyAssignment */: - case 261 /* EnumMember */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 231 /* ModuleDeclaration */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 260 /* PropertyAssignment */: + case 263 /* EnumMember */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 232 /* ModuleDeclaration */: return node.parent.name === node; - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: return true; } } @@ -66146,17 +67545,17 @@ var ts; return undefined; } switch (node.kind) { - case 262 /* SourceFile */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 230 /* EnumDeclaration */: - case 231 /* ModuleDeclaration */: + case 264 /* SourceFile */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: return node; } } @@ -66164,46 +67563,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 262 /* SourceFile */: + case 264 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: return ts.ScriptElementKind.classElement; - case 228 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; - case 229 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; - case 230 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; - case 224 /* VariableDeclaration */: + case 229 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 230 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 231 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 225 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 174 /* BindingElement */: + case 175 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 185 /* ArrowFunction */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: return ts.ScriptElementKind.functionElement; - case 151 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; - case 152 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 152 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; + case 153 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: return ts.ScriptElementKind.memberFunctionElement; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return ts.ScriptElementKind.memberVariableElement; - case 155 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; - case 154 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; - case 153 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; - case 150 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; - case 143 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; - case 261 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; - case 144 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 235 /* ImportEqualsDeclaration */: - case 240 /* ImportSpecifier */: - case 237 /* ImportClause */: - case 244 /* ExportSpecifier */: - case 238 /* NamespaceImport */: + case 156 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; + case 155 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; + case 154 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; + case 151 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; + case 144 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; + case 263 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 145 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 236 /* ImportEqualsDeclaration */: + case 241 /* ImportSpecifier */: + case 238 /* ImportClause */: + case 245 /* ExportSpecifier */: + case 239 /* NamespaceImport */: return ts.ScriptElementKind.alias; - case 286 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -66218,7 +67617,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 171 /* LiteralType */ ? node.parent : node; + var searchNode = node.parent.kind === 172 /* LiteralType */ ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32 /* StringLiteral */) { return type; @@ -66233,7 +67632,7 @@ var ts; return true; case 70 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 144 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 145 /* Parameter */; default: return false; } @@ -66278,42 +67677,42 @@ var ts; return false; } switch (n.kind) { - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 230 /* EnumDeclaration */: - case 176 /* ObjectLiteralExpression */: - case 172 /* ObjectBindingPattern */: - case 161 /* TypeLiteral */: - case 205 /* Block */: - case 232 /* ModuleBlock */: - case 233 /* CaseBlock */: - case 239 /* NamedImports */: - case 243 /* NamedExports */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 177 /* ObjectLiteralExpression */: + case 173 /* ObjectBindingPattern */: + case 162 /* TypeLiteral */: + case 206 /* Block */: + case 233 /* ModuleBlock */: + case 234 /* CaseBlock */: + case 240 /* NamedImports */: + case 244 /* NamedExports */: return nodeEndsWith(n, 17 /* CloseBraceToken */, sourceFile); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 180 /* NewExpression */: + case 181 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 179 /* CallExpression */: - case 183 /* ParenthesizedExpression */: - case 166 /* ParenthesizedType */: + case 180 /* CallExpression */: + case 184 /* ParenthesizedExpression */: + case 167 /* ParenthesizedType */: return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 154 /* ConstructSignature */: - case 153 /* CallSignature */: - case 185 /* ArrowFunction */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 155 /* ConstructSignature */: + case 154 /* CallSignature */: + case 186 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -66323,67 +67722,67 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 19 /* CloseParenToken */, sourceFile); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 209 /* IfStatement */: + case 210 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24 /* SemicolonToken */); - case 175 /* ArrayLiteralExpression */: - case 173 /* ArrayBindingPattern */: - case 178 /* ElementAccessExpression */: - case 142 /* ComputedPropertyName */: - case 163 /* TupleType */: + case 176 /* ArrayLiteralExpression */: + case 174 /* ArrayBindingPattern */: + case 179 /* ElementAccessExpression */: + case 143 /* ComputedPropertyName */: + case 164 /* TupleType */: return nodeEndsWith(n, 21 /* CloseBracketToken */, sourceFile); - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); - case 254 /* CaseClause */: - case 255 /* DefaultClause */: + case 256 /* CaseClause */: + case 257 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 211 /* WhileStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 212 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 210 /* DoStatement */: + case 211 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 105 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 187 /* TypeOfExpression */: - case 186 /* DeleteExpression */: - case 188 /* VoidExpression */: - case 195 /* YieldExpression */: - case 196 /* SpreadElement */: + case 188 /* TypeOfExpression */: + case 187 /* DeleteExpression */: + case 189 /* VoidExpression */: + case 196 /* YieldExpression */: + case 197 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 203 /* TemplateSpan */: + case 204 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 242 /* ExportDeclaration */: - case 236 /* ImportDeclaration */: + case 243 /* ExportDeclaration */: + case 237 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -66439,7 +67838,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 === 293 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 296 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -66611,7 +68010,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 262 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 264 /* 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. @@ -66670,17 +68069,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 253 /* JsxExpression */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 255 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 253 /* JsxExpression */) { + if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 255 /* JsxExpression */) { return true; } //
|
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 250 /* JsxClosingElement */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 251 /* JsxClosingElement */) { return true; } return false; @@ -66792,17 +68191,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 157 /* TypeReference */ || node.kind === 179 /* CallExpression */) { + if (node.kind === 158 /* TypeReference */ || node.kind === 180 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 227 /* ClassDeclaration */ || node.kind === 228 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 228 /* ClassDeclaration */ || node.kind === 229 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 140 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 141 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -66861,18 +68260,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 175 /* ArrayLiteralExpression */ || - node.kind === 176 /* ObjectLiteralExpression */) { + if (node.kind === 176 /* ArrayLiteralExpression */ || + node.kind === 177 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 192 /* BinaryExpression */ && + if (node.parent.kind === 193 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 57 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 214 /* ForOfStatement */ && + if (node.parent.kind === 215 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -66880,7 +68279,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 258 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 260 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -66908,12 +68307,32 @@ var ts; } } ts.isInNonReferenceComment = isInNonReferenceComment; + function createTextSpanFromNode(node, sourceFile) { + return ts.createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); + } + ts.createTextSpanFromNode = createTextSpanFromNode; + function isTypeKeyword(kind) { + switch (kind) { + case 118 /* AnyKeyword */: + case 121 /* BooleanKeyword */: + case 129 /* NeverKeyword */: + case 132 /* NumberKeyword */: + case 133 /* ObjectKeyword */: + case 135 /* StringKeyword */: + case 136 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + return true; + default: + return false; + } + } + ts.isTypeKeyword = isTypeKeyword; })(ts || (ts = {})); // Display-part writer helpers /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 144 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 145 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -66937,7 +68356,8 @@ var ts; decreaseIndent: function () { indent--; }, clear: resetWriter, trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop }; function writeIndent() { if (lineStart) { @@ -67094,7 +68514,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location) && - location.parent.kind === 142 /* ComputedPropertyName */) { + location.parent.kind === 143 /* ComputedPropertyName */) { return location.text; } // Try to get the local symbol if we're dealing with an 'export default' @@ -67106,7 +68526,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 240 /* ImportSpecifier */ || location.parent.kind === 244 /* ExportSpecifier */) && + (location.parent.kind === 241 /* ImportSpecifier */ || location.parent.kind === 245 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -67226,7 +68646,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 124 /* GetKeyword */ || - keyword2 === 133 /* SetKeyword */ || + keyword2 === 134 /* SetKeyword */ || keyword2 === 122 /* ConstructorKeyword */ || keyword2 === 114 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". @@ -67385,10 +68805,10 @@ var ts; angleBracketStack--; } else if (token === 118 /* AnyKeyword */ || - token === 134 /* StringKeyword */ || + token === 135 /* StringKeyword */ || token === 132 /* NumberKeyword */ || token === 121 /* BooleanKeyword */ || - token === 135 /* SymbolKeyword */) { + token === 136 /* 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, @@ -67560,7 +68980,7 @@ var ts; } } function isKeyword(token) { - return token >= 71 /* FirstKeyword */ && token <= 140 /* LastKeyword */; + return token >= 71 /* FirstKeyword */ && token <= 141 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -67617,10 +69037,10 @@ var ts; // 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 231 /* ModuleDeclaration */: - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 226 /* FunctionDeclaration */: + case 232 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 227 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -67671,7 +69091,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 231 /* ModuleDeclaration */ && + return declaration.kind === 232 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -67686,7 +69106,7 @@ var ts; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run // in a third of the time it would normally take. - if (classifiableNames[identifier.text]) { + if (classifiableNames.get(identifier.text)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var type = classifySymbol(symbol, ts.getMeaningFromLocation(node)); @@ -67835,16 +69255,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 282 /* JSDocParameterTag */: + case 285 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 285 /* JSDocTemplateTag */: + case 288 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 284 /* JSDocTypeTag */: + case 287 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 283 /* JSDocReturnTag */: + case 286 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -67931,22 +69351,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 249 /* JsxOpeningElement */: + case 250 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 250 /* JsxClosingElement */: + case 251 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 248 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 251 /* JsxAttribute */: + case 252 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -67974,17 +69394,17 @@ var ts; if (token) { if (tokenKind === 57 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 224 /* VariableDeclaration */ || - token.parent.kind === 147 /* PropertyDeclaration */ || - token.parent.kind === 144 /* Parameter */ || - token.parent.kind === 251 /* JsxAttribute */) { + if (token.parent.kind === 225 /* VariableDeclaration */ || + token.parent.kind === 148 /* PropertyDeclaration */ || + token.parent.kind === 145 /* Parameter */ || + token.parent.kind === 252 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 192 /* BinaryExpression */ || - token.parent.kind === 190 /* PrefixUnaryExpression */ || - token.parent.kind === 191 /* PostfixUnaryExpression */ || - token.parent.kind === 193 /* ConditionalExpression */) { + if (token.parent.kind === 193 /* BinaryExpression */ || + token.parent.kind === 191 /* PrefixUnaryExpression */ || + token.parent.kind === 192 /* PostfixUnaryExpression */ || + token.parent.kind === 194 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -67994,7 +69414,7 @@ var ts; return 4 /* numericLiteral */; } else if (tokenKind === 9 /* StringLiteral */) { - return token.parent.kind === 251 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 252 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 11 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -68010,32 +69430,32 @@ var ts; else if (tokenKind === 70 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 144 /* Parameter */: + case 145 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -68064,7 +69484,6 @@ var ts; } ts.getEncodedSyntacticClassifications = getEncodedSyntacticClassifications; })(ts || (ts = {})); -/// /* @internal */ var ts; (function (ts) { @@ -68072,10 +69491,10 @@ var ts; (function (Completions) { function getCompletionsAtPosition(host, typeChecker, log, compilerOptions, sourceFile, position) { if (ts.isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position); + return getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); } if (ts.isInString(sourceFile, position)) { - return getStringLiteralCompletionEntries(sourceFile, position); + return getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log); } var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (!completionData) { @@ -68088,13 +69507,13 @@ var ts; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true); - ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target)); } else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 /* JSX */ && - location.parent && location.parent.kind === 250 /* JsxClosingElement */) { + location.parent && location.parent.kind === 251 /* JsxClosingElement */) { // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. // For example: @@ -68111,632 +69530,642 @@ var ts; return undefined; } } - getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true); + getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); } // Add keywords if this is not a member completion list if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { - var entries = []; - var nameTable = ts.getNameTable(sourceFile); - for (var name_45 in nameTable) { - // Skip identifiers produced only from the current location - if (nameTable[name_45] === position) { - continue; + } + Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames, target) { + var entries = []; + var nameTable = ts.getNameTable(sourceFile); + nameTable.forEach(function (pos, name) { + // Skip identifiers produced only from the current location + if (pos === position) { + return; + } + if (!uniqueNames.get(name)) { + uniqueNames.set(name, name); + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name), target, /*performCharacterChecks*/ true); + if (displayName) { + var entry = { + name: displayName, + kind: ts.ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } - if (!uniqueNames[name_45]) { - uniqueNames[name_45] = name_45; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_45), compilerOptions.target, /*performCharacterChecks*/ true); - if (displayName) { - var entry = { - name: displayName, - kind: ts.ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; + } + }); + return entries; + } + function createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target) { + // 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(typeChecker, symbol, target, performCharacterChecks, location); + if (!displayName) { + return undefined; + } + // TODO(drosen): Right now we just permit *all* semantic meanings when calling + // 'getSymbolKind' which is permissible given that it is backwards compatible; but + // really we should consider passing the meaning for the node so that we don't report + // that a suggestion for a value is an interface. We COULD also just do what + // 'getSymbolModifiers' does, which is to use the first declaration. + // Use a 'sortText' of 0' so that all symbol completion entries come before any other + // entries (like JavaScript identifier entries). + return { + name: displayName, + kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), + kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), + sortText: "0", + }; + } + function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks, typeChecker, target, log) { + var start = ts.timestamp(); + var uniqueNames = ts.createMap(); + if (symbols) { + for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { + var symbol = symbols_4[_i]; + var entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + if (entry) { + var id = ts.escapeIdentifier(entry.name); + if (!uniqueNames.get(id)) { entries.push(entry); + uniqueNames.set(id, id); } } } - return entries; } - function createCompletionEntry(symbol, location, performCharacterChecks) { - // 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(typeChecker, symbol, compilerOptions.target, performCharacterChecks, location); - if (!displayName) { - return undefined; + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); + return uniqueNames; + } + function getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log) { + var node = ts.findPrecedingToken(position, sourceFile); + if (!node || node.kind !== 9 /* StringLiteral */) { + return undefined; + } + if (node.parent.kind === 260 /* PropertyAssignment */ && + node.parent.parent.kind === 177 /* ObjectLiteralExpression */ && + node.parent.name === node) { + // Get quoted name of properties of the object literal expression + // i.e. interface ConfigFiles { + // 'jspm:dev': string + // } + // let files: ConfigFiles = { + // '/*completion position*/' + // } + // + // function foo(c: ConfigFiles) {} + // foo({ + // '/*completion position*/' + // }); + return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent, typeChecker, compilerOptions.target, log); + } + else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { + // Get all names of properties on the expression + // i.e. interface A { + // 'prop1': string + // } + // let a: A; + // a['/*completion position*/'] + return getStringLiteralCompletionEntriesFromElementAccess(node.parent, typeChecker, compilerOptions.target, log); + } + else if (node.parent.kind === 237 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + // Get all known external module names or complete a path to a module + // i.e. import * as ns from "/*completion position*/"; + // import x = require("/*completion position*/"); + // var y = require("/*completion position*/"); + return getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); + } + else if (isEqualityExpression(node.parent)) { + // Get completions from the type of the other operand + // i.e. switch (a) { + // case '/*completion position*/' + // } + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.left === node ? node.parent.right : node.parent.left), typeChecker); + } + else if (ts.isCaseOrDefaultClause(node.parent)) { + // Get completions from the type of the switch expression + // i.e. x === '/*completion position' + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.parent.parent.expression), typeChecker); + } + else { + var argumentInfo = ts.SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); + if (argumentInfo) { + // Get string literal completions from specialized signatures of the target + // i.e. declare function f(a: 'A'); + // f("/*completion position*/") + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker); } - // TODO(drosen): Right now we just permit *all* semantic meanings when calling - // 'getSymbolKind' which is permissible given that it is backwards compatible; but - // really we should consider passing the meaning for the node so that we don't report - // that a suggestion for a value is an interface. We COULD also just do what - // 'getSymbolModifiers' does, which is to use the first declaration. - // Use a 'sortText' of 0' so that all symbol completion entries come before any other - // entries (like JavaScript identifier entries). - return { - name: displayName, - kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0", - }; + // Get completion for string literal from string literal type + // i.e. var x: "hi" | "hello" = "/*completion position*/" + return getStringLiteralCompletionEntriesFromType(typeChecker.getContextualType(node), typeChecker); } - function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { - var start = ts.timestamp(); - var uniqueNames = ts.createMap(); - if (symbols) { - for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { - var symbol = symbols_4[_i]; - var entry = createCompletionEntry(symbol, location, performCharacterChecks); - if (entry) { - var id = ts.escapeIdentifier(entry.name); - if (!uniqueNames[id]) { - entries.push(entry); - uniqueNames[id] = id; + } + function getStringLiteralCompletionEntriesFromPropertyAssignment(element, typeChecker, target, log) { + var type = typeChecker.getContextualType(element.parent); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + } + } + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker) { + var candidates = []; + var entries = []; + typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); + for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { + var candidate = candidates_3[_i]; + addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries, typeChecker); + } + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; + } + return undefined; + } + function getStringLiteralCompletionEntriesFromElementAccess(node, typeChecker, target, log) { + var type = typeChecker.getTypeAtLocation(node.expression); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + } + return undefined; + } + function getStringLiteralCompletionEntriesFromType(type, typeChecker) { + if (type) { + var entries = []; + addStringLiteralCompletionsFromType(type, entries, typeChecker); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; + } + } + return undefined; + } + function addStringLiteralCompletionsFromType(type, result, typeChecker) { + if (type && type.flags & 16384 /* TypeParameter */) { + type = typeChecker.getApparentType(type); + } + if (!type) { + return; + } + if (type.flags & 65536 /* Union */) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + addStringLiteralCompletionsFromType(t, result, typeChecker); + } + } + else if (type.flags & 32 /* StringLiteral */) { + result.push({ + name: type.text, + kindModifiers: ts.ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.variableElement, + sortText: "0" + }); + } + } + function getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker) { + var literalValue = ts.normalizeSlashes(node.text); + var scriptPath = node.getSourceFile().path; + var scriptDirectory = ts.getDirectoryPath(scriptPath); + var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); + var entries; + if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { + var extensions = ts.getSupportedExtensions(compilerOptions); + if (compilerOptions.rootDirs) { + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, span, compilerOptions, host, scriptPath); + } + else { + entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, span, host, scriptPath); + } + } + else { + // Check for node modules + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); + } + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: entries + }; + } + /** + * Takes a script path and returns paths for all potential folders that could be merged with its + * containing folder via the "rootDirs" compiler option + */ + function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { + // Make all paths absolute/normalized if they are not already + rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); + // Determine the path to the directory containing the script relative to the root directory it is contained within + var relativeDirectory; + for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { + var rootDirectory = rootDirs_1[_i]; + if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + break; + } + } + // Now find a path for each potential directory that is to be merged with the one containing the script + return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); + } + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, compilerOptions, host, exclude) { + var basePath = compilerOptions.project || host.getCurrentDirectory(); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + var result = []; + for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { + var baseDirectory = baseDirectories_1[_i]; + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); + } + return result; + } + /** + * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. + */ + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, host, exclude, result) { + if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); + /** + * Remove the basename from the path. Note that we don't use the basename to filter completions; + * the client is responsible for refining completions. + */ + fragment = ts.getDirectoryPath(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; + } + fragment = ts.ensureTrailingDirectorySeparator(fragment); + var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); + var baseDirectory = ts.getDirectoryPath(absolutePath); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + if (tryDirectoryExists(host, baseDirectory)) { + // Enumerate the available files if possible + var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + if (files) { + /** + * Multiple file entries might map to the same truncated name once we remove extensions + * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: + * + * both foo.ts and foo.tsx become foo + */ + var foundFiles = ts.createMap(); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var filePath = files_3[_i]; + filePath = ts.normalizePath(filePath); + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + continue; + } + var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + if (!foundFiles.get(foundFileName)) { + foundFiles.set(foundFileName, true); + } + } + ts.forEachKey(foundFiles, function (foundFile) { + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); + }); + } + // If possible, get folder completion as well + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { + var directory = directories_2[_a]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); + } + } + } + return result; + } + /** + * Check all of the declared modules and those in node modules. Possible sources of modules: + * Modules that are found by the type checker + * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) + * Modules from node_modules (i.e. those listed in package.json) + * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions + */ + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span, compilerOptions, host, typeChecker) { + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var result; + if (baseUrl) { + var fileExtensions = ts.getSupportedExtensions(compilerOptions); + var projectDir = compilerOptions.project || host.getCurrentDirectory(); + var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); + result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, /*includeExtensions*/ false, span, host); + if (paths) { + for (var path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { + var pattern = _a[_i]; + for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { + var match = _c[_b]; + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + else if (ts.startsWith(path, fragment)) { + var entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); + } } } } } - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); - return uniqueNames; } - function getStringLiteralCompletionEntries(sourceFile, position) { - var node = ts.findPrecedingToken(position, sourceFile); - if (!node || node.kind !== 9 /* StringLiteral */) { - return undefined; + else { + result = []; + } + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); + for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { + var moduleName = _e[_d]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + return result; + } + function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { + if (host.readDirectory) { + var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; + if (parsed) { + // The prefix has two effective parts: the directory path and the base component after the filepath that is not a + // full directory component. For example: directory/path/of/prefix/base* + var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); + var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); + var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; + // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call + var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; + var normalizedSuffix = ts.normalizePath(parsed.suffix); + var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); + var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + // If we have a suffix, then we need to read the directory all the way down. We could create a glob + // that encodes the suffix, but we would have to escape the character "?" which readDirectory + // doesn't support. For now, this is safer but slower + var includeGlob = normalizedSuffix ? "**/*" : "./*"; + var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); + if (matches) { + var result = []; + // Trim away prefix and suffix + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; + var normalizedMatch = ts.normalizePath(match); + if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { + continue; + } + var start = completePrefix.length; + var length_5 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); + } + return result; + } } - if (node.parent.kind === 258 /* PropertyAssignment */ && - node.parent.parent.kind === 176 /* ObjectLiteralExpression */ && - node.parent.name === node) { - // Get quoted name of properties of the object literal expression - // i.e. interface ConfigFiles { - // 'jspm:dev': string - // } - // let files: ConfigFiles = { - // '/*completion position*/' - // } - // - // function foo(c: ConfigFiles) {} - // foo({ - // '/*completion position*/' - // }); - return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); + } + return undefined; + } + function enumeratePotentialNonRelativeModules(fragment, scriptPath, options, typeChecker, host) { + // Check If this is a nested module + var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; + var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; + // Get modules that the type checker picked up + var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); + var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); + // Nested modules of the form "module-name/sub" need to be adjusted to only return the string + // after the last '/' that appears in the fragment because that's where the replacement span + // starts + if (isNestedModule) { + var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { + if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { + return moduleName.substr(moduleNameWithSeperator_1.length); + } + return moduleName; + }); + } + if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { + for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { + var visibleModule = _a[_i]; + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.moduleName); + } + else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { + var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, /*exclude*/ undefined, /*include*/ ["./*"]); + if (nestedFiles) { + for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { + var f = nestedFiles_1[_b]; + f = ts.normalizePath(f); + var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + } + } + } } - else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { - // Get all names of properties on the expression - // i.e. interface A { - // 'prop1': string - // } - // let a: A; - // a['/*completion position*/'] - return getStringLiteralCompletionEntriesFromElementAccess(node.parent); - } - else if (node.parent.kind === 236 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { - // Get all known external module names or complete a path to a module - // i.e. import * as ns from "/*completion position*/"; - // import x = require("/*completion position*/"); - // var y = require("/*completion position*/"); - return getStringLiteralCompletionEntriesFromModuleNames(node); + } + return ts.deduplicate(nonRelativeModules); + } + function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { + var token = ts.getTokenAtPosition(sourceFile, position); + if (!token) { + return undefined; + } + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + if (!commentRanges || !commentRanges.length) { + return undefined; + } + var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); + if (!range) { + return undefined; + } + var completionInfo = { + /** + * We don't want the editor to offer any other completions, such as snippets, inside a comment. + */ + isGlobalCompletion: false, + isMemberCompletion: false, + /** + * The user may type in a path that doesn't yet exist, creating a "new identifier" + * with respect to the collection of identifiers the server is aware of. + */ + isNewIdentifierLocation: true, + entries: [] + }; + var text = sourceFile.text.substr(range.pos, position - range.pos); + var match = tripleSlashDirectiveFragmentRegex.exec(text); + if (match) { + var prefix = match[1]; + var kind = match[2]; + var toComplete = match[3]; + var scriptPath = ts.getDirectoryPath(sourceFile.path); + if (kind === "path") { + // Give completions for a relative path + var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, span_10, host, sourceFile.path); } else { - var argumentInfo = ts.SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); - if (argumentInfo) { - // Get string literal completions from specialized signatures of the target - // i.e. declare function f(a: 'A'); - // f("/*completion position*/") - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); - } - // Get completion for string literal from string literal type - // i.e. var x: "hi" | "hello" = "/*completion position*/" - return getStringLiteralCompletionEntriesFromContextualType(node); + // Give completions based on the typings available + var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); } } - function getStringLiteralCompletionEntriesFromPropertyAssignment(element) { - var type = typeChecker.getContextualType(element.parent); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + return completionInfo; + } + function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { + if (result === void 0) { result = []; } + // Check for typings specified in compiler options + if (options.types) { + for (var _i = 0, _a = options.types; _i < _a.length; _i++) { + var moduleName = _a[_i]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + } + else if (host.getDirectories) { + var typeRoots = void 0; + try { + // Wrap in try catch because getEffectiveTypeRoots touches the filesystem + typeRoots = ts.getEffectiveTypeRoots(options, host); + } + catch (e) { } + if (typeRoots) { + for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { + var root = typeRoots_2[_b]; + getCompletionEntriesFromDirectories(host, root, span, result); } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo) { - var candidates = []; - var entries = []; - typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); - for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { - var candidate = candidates_3[_i]; - if (candidate.parameters.length > argumentInfo.argumentIndex) { - var parameter = candidate.parameters[argumentInfo.argumentIndex]; - addStringLiteralCompletionsFromType(typeChecker.getTypeAtLocation(parameter.valueDeclaration), entries); + if (host.getDirectories) { + // Also get all @types typings installed in visible node_modules directories + for (var _c = 0, _d = findPackageJsons(scriptPath, host); _c < _d.length; _c++) { + var packageJson = _d[_c]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, typesDir, span, result); + } + } + return result; + } + function getCompletionEntriesFromDirectories(host, directory, span, result) { + if (host.getDirectories && tryDirectoryExists(host, directory)) { + var directories = tryGetDirectories(host, directory); + if (directories) { + for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { + var typeDirectory = directories_3[_i]; + typeDirectory = ts.normalizePath(typeDirectory); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); } } - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; - } - return undefined; } - function getStringLiteralCompletionEntriesFromElementAccess(node) { - var type = typeChecker.getTypeAtLocation(node.expression); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + function findPackageJsons(currentDir, host) { + var paths = []; + var currentConfigPath; + while (true) { + currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + currentDir = ts.getDirectoryPath(currentConfigPath); + var parent = ts.getDirectoryPath(currentDir); + if (currentDir === parent) { + break; } - } - return undefined; - } - function getStringLiteralCompletionEntriesFromContextualType(node) { - var type = typeChecker.getContextualType(node); - if (type) { - var entries_2 = []; - addStringLiteralCompletionsFromType(type, entries_2); - if (entries_2.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; - } - } - return undefined; - } - function addStringLiteralCompletionsFromType(type, result) { - if (type && type.flags & 16384 /* TypeParameter */) { - type = typeChecker.getApparentType(type); - } - if (!type) { - return; - } - if (type.flags & 65536 /* Union */) { - ts.forEach(type.types, function (t) { return addStringLiteralCompletionsFromType(t, result); }); + currentDir = parent; } else { - if (type.flags & 32 /* StringLiteral */) { + break; + } + } + return paths; + } + function enumerateNodeModulesVisibleToScript(host, scriptPath) { + var result = []; + if (host.readFile && host.fileExists) { + for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + var packageJson = _a[_i]; + var contents = tryReadingPackageJson(packageJson); + if (!contents) { + return; + } + var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); + var foundModuleNames = []; + // Provide completions for all non @types dependencies + for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { + var key = nodeModulesDependencyKeys_1[_b]; + addPotentialPackageNames(contents[key], foundModuleNames); + } + for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { + var moduleName = foundModuleNames_1[_c]; + var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); result.push({ - name: type.text, - kindModifiers: ts.ScriptElementKindModifier.none, - kind: ts.ScriptElementKind.variableElement, - sortText: "0" + moduleName: moduleName, + moduleDir: moduleDir }); } } } - function getStringLiteralCompletionEntriesFromModuleNames(node) { - var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; - var scriptDirectory = ts.getDirectoryPath(scriptPath); - var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); - var entries; - if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { - if (compilerOptions.rootDirs) { - entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ false, span, scriptPath); - } - else { - entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ false, span, scriptPath); - } + return result; + function tryReadingPackageJson(filePath) { + try { + var fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; } - else { - // Check for node modules - entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); - } - return { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: entries - }; - } - /** - * Takes a script path and returns paths for all potential folders that could be merged with its - * containing folder via the "rootDirs" compiler option - */ - function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { - // Make all paths absolute/normalized if they are not already - rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); - // Determine the path to the directory containing the script relative to the root directory it is contained within - var relativeDirectory; - for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { - var rootDirectory = rootDirs_1[_i]; - if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { - relativeDirectory = scriptPath.substr(rootDirectory.length); - break; - } - } - // Now find a path for each potential directory that is to be merged with the one containing the script - return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); - } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, exclude) { - var basePath = compilerOptions.project || host.getCurrentDirectory(); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); - var result = []; - for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { - var baseDirectory = baseDirectories_1[_i]; - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, exclude, result); - } - return result; - } - /** - * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. - */ - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, exclude, result) { - if (result === void 0) { result = []; } - if (fragment === undefined) { - fragment = ""; - } - fragment = ts.normalizeSlashes(fragment); - /** - * Remove the basename from the path. Note that we don't use the basename to filter completions; - * the client is responsible for refining completions. - */ - fragment = ts.getDirectoryPath(fragment); - if (fragment === "") { - fragment = "." + ts.directorySeparator; - } - fragment = ts.ensureTrailingDirectorySeparator(fragment); - var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); - var baseDirectory = ts.getDirectoryPath(absolutePath); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (tryDirectoryExists(host, baseDirectory)) { - // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); - if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - var foundFiles = ts.createMap(); - for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { - var filePath = files_3[_i]; - filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { - continue; - } - var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); - if (!foundFiles[foundFileName]) { - foundFiles[foundFileName] = true; - } - } - for (var foundFile in foundFiles) { - result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); - } - } - // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); - if (directories) { - for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { - var directory = directories_2[_a]; - var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); - } - } - } - return result; - } - /** - * Check all of the declared modules and those in node modules. Possible sources of modules: - * Modules that are found by the type checker - * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) - * Modules from node_modules (i.e. those listed in package.json) - * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions - */ - function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span) { - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var result; - if (baseUrl) { - var fileExtensions = ts.getSupportedExtensions(compilerOptions); - var projectDir = compilerOptions.project || host.getCurrentDirectory(); - var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, /*includeExtensions*/ false, span); - if (paths) { - for (var path in paths) { - if (paths.hasOwnProperty(path)) { - if (path === "*") { - if (paths[path]) { - for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { - var pattern = _a[_i]; - for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions); _b < _c.length; _b++) { - var match = _c[_b]; - result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - else if (ts.startsWith(path, fragment)) { - var entry = paths[path] && paths[path].length === 1 && paths[path][0]; - if (entry) { - result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - } - } - else { - result = []; - } - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions); _d < _e.length; _d++) { - var moduleName = _e[_d]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - return result; - } - function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions) { - if (host.readDirectory) { - var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; - if (parsed) { - // The prefix has two effective parts: the directory path and the base component after the filepath that is not a - // full directory component. For example: directory/path/of/prefix/base* - var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); - var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); - var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); - var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; - // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call - var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; - var normalizedSuffix = ts.normalizePath(parsed.suffix); - var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); - var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - // If we have a suffix, then we need to read the directory all the way down. We could create a glob - // that encodes the suffix, but we would have to escape the character "?" which readDirectory - // doesn't support. For now, this is safer but slower - var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); - if (matches) { - var result = []; - // Trim away prefix and suffix - for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { - var match = matches_1[_i]; - var normalizedMatch = ts.normalizePath(match); - if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { - continue; - } - var start = completePrefix.length; - var length_5 = normalizedMatch.length - start - normalizedSuffix.length; - result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); - } - return result; - } - } - } - return undefined; - } - function enumeratePotentialNonRelativeModules(fragment, scriptPath, options) { - // Check If this is a nested module - var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; - var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; - // Get modules that the type checker picked up - var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); - var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); - // Nested modules of the form "module-name/sub" need to be adjusted to only return the string - // after the last '/' that appears in the fragment because that's where the replacement span - // starts - if (isNestedModule) { - var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); - nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { - if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { - return moduleName.substr(moduleNameWithSeperator_1.length); - } - return moduleName; - }); - } - if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { - for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { - var visibleModule = _a[_i]; - if (!isNestedModule) { - nonRelativeModules.push(visibleModule.moduleName); - } - else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { - var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, /*exclude*/ undefined, /*include*/ ["./*"]); - if (nestedFiles) { - for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { - var f = nestedFiles_1[_b]; - f = ts.normalizePath(f); - var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); - nonRelativeModules.push(nestedModule); - } - } - } - } - } - return ts.deduplicate(nonRelativeModules); - } - function getTripleSlashReferenceCompletion(sourceFile, position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (!token) { + catch (e) { return undefined; } - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - if (!commentRanges || !commentRanges.length) { - return undefined; - } - var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); - if (!range) { - return undefined; - } - var completionInfo = { - /** - * We don't want the editor to offer any other completions, such as snippets, inside a comment. - */ - isGlobalCompletion: false, - isMemberCompletion: false, - /** - * The user may type in a path that doesn't yet exist, creating a "new identifier" - * with respect to the collection of identifiers the server is aware of. - */ - isNewIdentifierLocation: true, - entries: [] - }; - var text = sourceFile.text.substr(range.pos, position - range.pos); - var match = tripleSlashDirectiveFragmentRegex.exec(text); - if (match) { - var prefix = match[1]; - var kind = match[2]; - var toComplete = match[3]; - var scriptPath = ts.getDirectoryPath(sourceFile.path); - if (kind === "path") { - // Give completions for a relative path - var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, span_10, sourceFile.path); - } - else { - // Give completions based on the typings available - var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); - } - } - return completionInfo; } - function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { - if (result === void 0) { result = []; } - // Check for typings specified in compiler options - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - // Wrap in try catch because getEffectiveTypeRoots touches the filesystem - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch (e) { } - if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, root, span, result); + function addPotentialPackageNames(dependencies, result) { + if (dependencies) { + for (var dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { + result.push(dep); } } } - if (host.getDirectories) { - // Also get all @types typings installed in visible node_modules directories - for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { - var packageJson = _d[_c]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, typesDir, span, result); - } - } - return result; - } - function getCompletionEntriesFromDirectories(host, directory, span, result) { - if (host.getDirectories && tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { - var typeDirectory = directories_3[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - function findPackageJsons(currentDir) { - var paths = []; - var currentConfigPath; - while (true) { - currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_14 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_14) { - break; - } - currentDir = parent_14; - } - else { - break; - } - } - return paths; - } - function enumerateNodeModulesVisibleToScript(host, scriptPath) { - var result = []; - if (host.readFile && host.fileExists) { - for (var _i = 0, _a = findPackageJsons(scriptPath); _i < _a.length; _i++) { - var packageJson = _a[_i]; - var contents = tryReadingPackageJson(packageJson); - if (!contents) { - return; - } - var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); - var foundModuleNames = []; - // Provide completions for all non @types dependencies - for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { - var key = nodeModulesDependencyKeys_1[_b]; - addPotentialPackageNames(contents[key], foundModuleNames); - } - for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { - var moduleName = foundModuleNames_1[_c]; - var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName: moduleName, - moduleDir: moduleDir - }); - } - } - } - return result; - function tryReadingPackageJson(filePath) { - try { - var fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; - } - catch (e) { - return undefined; - } - } - function addPotentialPackageNames(dependencies, result) { - if (dependencies) { - for (var dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { - result.push(dep); - } - } - } - } - } - function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; - } - // Replace everything after the last directory seperator that appears - function getDirectoryFragmentTextSpan(text, textStart) { - var index = text.lastIndexOf(ts.directorySeparator); - var offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset }; - } - // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) - function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; - var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; - } - return false; - } - function normalizeAndPreserveTrailingSlash(path) { - return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); } } - Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function createCompletionEntryForModule(name, kind, replacementSpan) { + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; + } + // Replace everything after the last directory seperator that appears + function getDirectoryFragmentTextSpan(text, textStart) { + var index = text.lastIndexOf(ts.directorySeparator); + var offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset }; + } + // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) + function isPathRelativeToScript(path) { + if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; + var slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; + } + return false; + } + function normalizeAndPreserveTrailingSlash(path) { + return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); + } function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { // Compute all the completion symbols again. var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_3 = completionData.location; + var symbols = completionData.symbols, location_1 = completionData.location; // Find the symbol with the matching entry name. // 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(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_3) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_1) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_3, location_3, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), @@ -68764,12 +70193,12 @@ var ts; // Compute all the completion symbols again. var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_4 = completionData.location; + var symbols = completionData.symbols, location_2 = completionData.location; // Find the symbol with the matching entry name. // 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. - return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_4) === entryName ? s : undefined; }); + return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_2) === entryName ? s : undefined; }); } return undefined; } @@ -68800,9 +70229,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 284 /* JSDocTypeTag */: - case 282 /* JSDocParameterTag */: - case 283 /* JSDocReturnTag */: + case 287 /* JSDocTypeTag */: + case 285 /* JSDocParameterTag */: + case 286 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -68847,13 +70276,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_15 = contextToken.parent, kind = contextToken.kind; + var parent = contextToken.parent, kind = contextToken.kind; if (kind === 22 /* DotToken */) { - if (parent_15.kind === 177 /* PropertyAccessExpression */) { + if (parent.kind === 178 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_15.kind === 141 /* QualifiedName */) { + else if (parent.kind === 142 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -68864,13 +70293,27 @@ var ts; } } else if (sourceFile.languageVariant === 1 /* JSX */) { - if (kind === 26 /* LessThanToken */) { - isRightOfOpenTag = true; - location = contextToken; - } - else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 250 /* JsxClosingElement */) { - isStartingCloseTag = true; - location = contextToken; + switch (contextToken.parent.kind) { + case 251 /* JsxClosingElement */: + if (kind === 40 /* SlashToken */) { + isStartingCloseTag = true; + location = contextToken; + } + break; + case 193 /* BinaryExpression */: + if (!(contextToken.parent.left.flags & 32768 /* ThisNodeHasError */)) { + // It has a left-hand side, so we're not in an opening JSX tag. + break; + } + // fall through + case 249 /* JsxSelfClosingElement */: + case 248 /* JsxElement */: + case 250 /* JsxOpeningElement */: + if (kind === 26 /* LessThanToken */) { + isRightOfOpenTag = true; + location = contextToken; + } + break; } } } @@ -68917,7 +70360,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */ || node.kind === 177 /* PropertyAccessExpression */) { + if (node.kind === 70 /* Identifier */ || node.kind === 142 /* QualifiedName */ || node.kind === 178 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -68973,11 +70416,11 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 248 /* JsxSelfClosingElement */) || (jsxContainer.kind === 249 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 249 /* JsxSelfClosingElement */) || (jsxContainer.kind === 250 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element - attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + attrsType = typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); if (attrsType) { - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); + symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes.properties); isMemberCompletion = true; isNewIdentifierLocation = false; return true; @@ -69021,9 +70464,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 262 /* SourceFile */ || - scopeNode.kind === 194 /* TemplateExpression */ || - scopeNode.kind === 253 /* JsxExpression */ || + scopeNode.kind === 264 /* SourceFile */ || + scopeNode.kind === 195 /* TemplateExpression */ || + scopeNode.kind === 255 /* JsxExpression */ || ts.isStatement(scopeNode); } /// TODO filter meaning based on the current context @@ -69056,11 +70499,11 @@ var ts; return true; } if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 249 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 250 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 250 /* JsxClosingElement */ || contextToken.parent.kind === 248 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 247 /* JsxElement */; + if (contextToken.parent.kind === 251 /* JsxClosingElement */ || contextToken.parent.kind === 249 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 248 /* JsxElement */; } } return false; @@ -69070,40 +70513,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 25 /* CommaToken */: - return containingNodeKind === 179 /* CallExpression */ // func( a, | - || containingNodeKind === 150 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 180 /* NewExpression */ // new C(a, | - || containingNodeKind === 175 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 192 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 158 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 180 /* CallExpression */ // func( a, | + || containingNodeKind === 151 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 181 /* NewExpression */ // new C(a, | + || containingNodeKind === 176 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 193 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 159 /* FunctionType */; // var x: (s: string, list| case 18 /* OpenParenToken */: - return containingNodeKind === 179 /* CallExpression */ // func( | - || containingNodeKind === 150 /* Constructor */ // constructor( | - || containingNodeKind === 180 /* NewExpression */ // new C(a| - || containingNodeKind === 183 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 166 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 180 /* CallExpression */ // func( | + || containingNodeKind === 151 /* Constructor */ // constructor( | + || containingNodeKind === 181 /* NewExpression */ // new C(a| + || containingNodeKind === 184 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 167 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 20 /* OpenBracketToken */: - return containingNodeKind === 175 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 155 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 142 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + return containingNodeKind === 176 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 156 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 143 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 127 /* ModuleKeyword */: // module | case 128 /* NamespaceKeyword */: return true; case 22 /* DotToken */: - return containingNodeKind === 231 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 232 /* ModuleDeclaration */; // module A.| case 16 /* OpenBraceToken */: - return containingNodeKind === 227 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 228 /* ClassDeclaration */; // class A{ | case 57 /* EqualsToken */: - return containingNodeKind === 224 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 192 /* BinaryExpression */; // x = a| + return containingNodeKind === 225 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 193 /* BinaryExpression */; // x = a| case 13 /* TemplateHead */: - return containingNodeKind === 194 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 195 /* TemplateExpression */; // `aa ${| case 14 /* TemplateMiddle */: - return containingNodeKind === 203 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 204 /* TemplateSpan */; // `aa ${10} dd ${| case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: - return containingNodeKind === 147 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 148 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -69146,7 +70589,7 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 176 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 177 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; @@ -69156,7 +70599,7 @@ var ts; typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 172 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 173 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -69167,11 +70610,11 @@ var ts; // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 144 /* Parameter */) { + if (!canGetType && rootDeclaration.kind === 145 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 149 /* MethodDeclaration */ || rootDeclaration.parent.kind === 152 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 150 /* MethodDeclaration */ || rootDeclaration.parent.kind === 153 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -69213,9 +70656,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 239 /* NamedImports */ ? - 236 /* ImportDeclaration */ : - 242 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 240 /* NamedImports */ ? + 237 /* ImportDeclaration */ : + 243 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -69223,12 +70666,13 @@ var ts; } isMemberCompletion = true; isNewIdentifierLocation = false; - var exports; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); + if (!moduleSpecifierSymbol) { + symbols = ts.emptyArray; + return true; } - symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : ts.emptyArray; + var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); + symbols = filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements); return true; } /** @@ -69240,9 +70684,9 @@ var ts; switch (contextToken.kind) { case 16 /* OpenBraceToken */: // const x = { | case 25 /* CommaToken */: - var parent_16 = contextToken.parent; - if (parent_16 && (parent_16.kind === 176 /* ObjectLiteralExpression */ || parent_16.kind === 172 /* ObjectBindingPattern */)) { - return parent_16; + var parent = contextToken.parent; + if (parent && (parent.kind === 177 /* ObjectLiteralExpression */ || parent.kind === 173 /* ObjectBindingPattern */)) { + return parent; } break; } @@ -69259,8 +70703,8 @@ var ts; case 16 /* OpenBraceToken */: // import { | case 25 /* CommaToken */: switch (contextToken.parent.kind) { - case 239 /* NamedImports */: - case 243 /* NamedExports */: + case 240 /* NamedImports */: + case 244 /* NamedExports */: return contextToken.parent; } } @@ -69269,37 +70713,54 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_17 = contextToken.parent; + var parent = contextToken.parent; switch (contextToken.kind) { case 27 /* LessThanSlashToken */: case 40 /* SlashToken */: case 70 /* Identifier */: - case 251 /* JsxAttribute */: - case 252 /* JsxSpreadAttribute */: - if (parent_17 && (parent_17.kind === 248 /* JsxSelfClosingElement */ || parent_17.kind === 249 /* JsxOpeningElement */)) { - return parent_17; + case 253 /* JsxAttributes */: + case 252 /* JsxAttribute */: + case 254 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 249 /* JsxSelfClosingElement */ || parent.kind === 250 /* JsxOpeningElement */)) { + return parent; } - else if (parent_17.kind === 251 /* JsxAttribute */) { - return parent_17.parent; + else if (parent.kind === 252 /* JsxAttribute */) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + return parent.parent.parent; } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_17 && ((parent_17.kind === 251 /* JsxAttribute */) || (parent_17.kind === 252 /* JsxSpreadAttribute */))) { - return parent_17.parent; + if (parent && ((parent.kind === 252 /* JsxAttribute */) || (parent.kind === 254 /* JsxSpreadAttribute */))) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + return parent.parent.parent; } break; case 17 /* CloseBraceToken */: - if (parent_17 && - parent_17.kind === 253 /* JsxExpression */ && - parent_17.parent && - (parent_17.parent.kind === 251 /* JsxAttribute */)) { - return parent_17.parent.parent; + if (parent && + parent.kind === 255 /* JsxExpression */ && + parent.parent && parent.parent.kind === 252 /* JsxAttribute */) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + // each JsxAttribute can have initializer as JsxExpression + return parent.parent.parent.parent; } - if (parent_17 && parent_17.kind === 252 /* JsxSpreadAttribute */) { - return parent_17.parent; + if (parent && parent.kind === 254 /* JsxSpreadAttribute */) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + return parent.parent.parent; } break; } @@ -69308,16 +70769,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 226 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: return true; } return false; @@ -69329,66 +70790,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25 /* CommaToken */: - return containingNodeKind === 224 /* VariableDeclaration */ || - containingNodeKind === 225 /* VariableDeclarationList */ || - containingNodeKind === 206 /* VariableStatement */ || - containingNodeKind === 230 /* EnumDeclaration */ || + return containingNodeKind === 225 /* VariableDeclaration */ || + containingNodeKind === 226 /* VariableDeclarationList */ || + containingNodeKind === 207 /* VariableStatement */ || + containingNodeKind === 231 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 227 /* ClassDeclaration */ || - containingNodeKind === 197 /* ClassExpression */ || - containingNodeKind === 228 /* InterfaceDeclaration */ || - containingNodeKind === 173 /* ArrayBindingPattern */ || - containingNodeKind === 229 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 228 /* ClassDeclaration */ || + containingNodeKind === 198 /* ClassExpression */ || + containingNodeKind === 229 /* InterfaceDeclaration */ || + containingNodeKind === 174 /* ArrayBindingPattern */ || + containingNodeKind === 230 /* TypeAliasDeclaration */; // type Map, K, | case 22 /* DotToken */: - return containingNodeKind === 173 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 174 /* ArrayBindingPattern */; // var [.| case 55 /* ColonToken */: - return containingNodeKind === 174 /* BindingElement */; // var {x :html| + return containingNodeKind === 175 /* BindingElement */; // var {x :html| case 20 /* OpenBracketToken */: - return containingNodeKind === 173 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 174 /* ArrayBindingPattern */; // var [x| case 18 /* OpenParenToken */: - return containingNodeKind === 257 /* CatchClause */ || + return containingNodeKind === 259 /* CatchClause */ || isFunction(containingNodeKind); case 16 /* OpenBraceToken */: - return containingNodeKind === 230 /* EnumDeclaration */ || - containingNodeKind === 228 /* InterfaceDeclaration */ || - containingNodeKind === 161 /* TypeLiteral */; // const x : { | + return containingNodeKind === 231 /* EnumDeclaration */ || + containingNodeKind === 229 /* InterfaceDeclaration */ || + containingNodeKind === 162 /* TypeLiteral */; // const x : { | case 24 /* SemicolonToken */: - return containingNodeKind === 146 /* PropertySignature */ && + return containingNodeKind === 147 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 228 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 161 /* TypeLiteral */); // const x : { a; | + (contextToken.parent.parent.kind === 229 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 162 /* TypeLiteral */); // const x : { a; | case 26 /* LessThanToken */: - return containingNodeKind === 227 /* ClassDeclaration */ || - containingNodeKind === 197 /* ClassExpression */ || - containingNodeKind === 228 /* InterfaceDeclaration */ || - containingNodeKind === 229 /* TypeAliasDeclaration */ || + return containingNodeKind === 228 /* ClassDeclaration */ || + containingNodeKind === 198 /* ClassExpression */ || + containingNodeKind === 229 /* InterfaceDeclaration */ || + containingNodeKind === 230 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); case 114 /* StaticKeyword */: - return containingNodeKind === 147 /* PropertyDeclaration */; + return containingNodeKind === 148 /* PropertyDeclaration */; case 23 /* DotDotDotToken */: - return containingNodeKind === 144 /* Parameter */ || + return containingNodeKind === 145 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 173 /* ArrayBindingPattern */); // var [...z| + contextToken.parent.parent.kind === 174 /* ArrayBindingPattern */); // var [...z| case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: - return containingNodeKind === 144 /* Parameter */; + return containingNodeKind === 145 /* Parameter */; case 117 /* AsKeyword */: - return containingNodeKind === 240 /* ImportSpecifier */ || - containingNodeKind === 244 /* ExportSpecifier */ || - containingNodeKind === 238 /* NamespaceImport */; + return containingNodeKind === 241 /* ImportSpecifier */ || + containingNodeKind === 245 /* ExportSpecifier */ || + containingNodeKind === 239 /* NamespaceImport */; case 74 /* ClassKeyword */: case 82 /* EnumKeyword */: case 108 /* InterfaceKeyword */: case 88 /* FunctionKeyword */: case 103 /* VarKeyword */: case 124 /* GetKeyword */: - case 133 /* SetKeyword */: + case 134 /* SetKeyword */: case 90 /* ImportKeyword */: case 109 /* LetKeyword */: case 75 /* ConstKeyword */: case 115 /* YieldKeyword */: - case 136 /* TypeKeyword */: + case 137 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -69436,13 +70897,13 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_46 = element.propertyName || element.name; - existingImportsOrExports[name_46.text] = true; + var name = element.propertyName || element.name; + existingImportsOrExports.set(name.text, true); } - if (!ts.someProperties(existingImportsOrExports)) { + if (existingImportsOrExports.size === 0) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); } - return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports[e.name]; }); + return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports.get(e.name); }); } /** * Filters out completion suggestions for named imports or exports. @@ -69458,12 +70919,12 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 258 /* PropertyAssignment */ && - m.kind !== 259 /* ShorthandPropertyAssignment */ && - m.kind !== 174 /* BindingElement */ && - m.kind !== 149 /* MethodDeclaration */ && - m.kind !== 151 /* GetAccessor */ && - m.kind !== 152 /* SetAccessor */) { + if (m.kind !== 260 /* PropertyAssignment */ && + m.kind !== 261 /* ShorthandPropertyAssignment */ && + m.kind !== 175 /* BindingElement */ && + m.kind !== 150 /* MethodDeclaration */ && + m.kind !== 152 /* GetAccessor */ && + m.kind !== 153 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -69471,7 +70932,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 174 /* BindingElement */ && m.propertyName) { + if (m.kind === 175 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 70 /* Identifier */) { existingName = m.propertyName.text; @@ -69483,9 +70944,9 @@ var ts; // things like '__proto__' are not filtered out. existingName = m.name.text; } - existingMemberNames[existingName] = true; + existingMemberNames.set(existingName, true); } - return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames[m.name]; }); + return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames.get(m.name); }); } /** * Filters out completion suggestions from 'symbols' according to existing JSX attributes. @@ -69501,11 +70962,11 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 251 /* JsxAttribute */) { - seenNames[attr.name.text] = true; + if (attr.kind === 252 /* JsxAttribute */) { + seenNames.set(attr.name.text, true); } } - return ts.filter(symbols, function (a) { return !seenNames[a.name]; }); + return ts.filter(symbols, function (a) { return !seenNames.get(a.name); }); } } /** @@ -69551,7 +71012,7 @@ var ts; } // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 71 /* FirstKeyword */; i <= 140 /* LastKeyword */; i++) { + for (var i = 71 /* FirstKeyword */; i <= 141 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -69603,6 +71064,15 @@ var ts; catch (e) { } return undefined; } + function isEqualityExpression(node) { + return ts.isBinaryExpression(node) && isEqualityOperatorKind(node.operatorToken.kind); + } + function isEqualityOperatorKind(kind) { + return kind == 31 /* EqualsEqualsToken */ || + kind === 32 /* ExclamationEqualsToken */ || + kind === 33 /* EqualsEqualsEqualsToken */ || + kind === 34 /* ExclamationEqualsEqualsToken */; + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -69612,534 +71082,519 @@ var ts; (function (DocumentHighlights) { function getDocumentHighlights(typeChecker, cancellationToken, sourceFile, position, sourceFilesToSearch) { var node = ts.getTouchingWord(sourceFile, position); + return node && (getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) || getSyntacticDocumentHighlights(node, sourceFile)); + } + DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + function getHighlightSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var end = node.getEnd(); + return { + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(start, end), + kind: ts.HighlightSpanKind.none + }; + } + function getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) { + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch); + return referencedSymbols && convertReferencedSymbols(referencedSymbols); + } + function convertReferencedSymbols(referencedSymbols) { + var fileNameToDocumentHighlights = ts.createMap(); + var result = []; + for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { + var referencedSymbol = referencedSymbols_1[_i]; + for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { + var referenceEntry = _b[_a]; + var fileName = referenceEntry.fileName; + var documentHighlights = fileNameToDocumentHighlights.get(fileName); + if (!documentHighlights) { + documentHighlights = { fileName: fileName, highlightSpans: [] }; + fileNameToDocumentHighlights.set(fileName, documentHighlights); + result.push(documentHighlights); + } + documentHighlights.highlightSpans.push({ + textSpan: referenceEntry.textSpan, + kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference + }); + } + } + return result; + } + function getSyntacticDocumentHighlights(node, sourceFile) { + var highlightSpans = getHighlightSpans(node, sourceFile); + if (!highlightSpans || highlightSpans.length === 0) { + return undefined; + } + return [{ fileName: sourceFile.fileName, highlightSpans: highlightSpans }]; + } + // returns true if 'node' is defined and has a matching 'kind'. + function hasKind(node, kind) { + return node !== undefined && node.kind === kind; + } + // Null-propagating 'parent' function. + function parent(node) { + return node && node.parent; + } + function getHighlightSpans(node, sourceFile) { if (!node) { return undefined; } - return getSemanticDocumentHighlights(node) || getSyntacticDocumentHighlights(node); - function getHighlightSpanForNode(node) { - var start = node.getStart(); - var end = node.getEnd(); - return { - fileName: sourceFile.fileName, - textSpan: ts.createTextSpanFromBounds(start, end), - kind: ts.HighlightSpanKind.none - }; + switch (node.kind) { + case 89 /* IfKeyword */: + case 81 /* ElseKeyword */: + if (hasKind(node.parent, 210 /* IfStatement */)) { + return getIfElseOccurrences(node.parent, sourceFile); + } + break; + case 95 /* ReturnKeyword */: + if (hasKind(node.parent, 218 /* ReturnStatement */)) { + return highlightSpans(getReturnOccurrences(node.parent)); + } + break; + case 99 /* ThrowKeyword */: + if (hasKind(node.parent, 222 /* ThrowStatement */)) { + return highlightSpans(getThrowOccurrences(node.parent)); + } + break; + case 101 /* TryKeyword */: + case 73 /* CatchKeyword */: + case 86 /* FinallyKeyword */: + var tryStatement = node.kind === 73 /* CatchKeyword */ ? parent(parent(node)) : parent(node); + if (hasKind(tryStatement, 223 /* TryStatement */)) { + return highlightSpans(getTryCatchFinallyOccurrences(tryStatement, sourceFile)); + } + break; + case 97 /* SwitchKeyword */: + if (hasKind(node.parent, 220 /* SwitchStatement */)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent)); + } + break; + case 72 /* CaseKeyword */: + case 78 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 220 /* SwitchStatement */)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent.parent.parent)); + } + break; + case 71 /* BreakKeyword */: + case 76 /* ContinueKeyword */: + if (hasKind(node.parent, 217 /* BreakStatement */) || hasKind(node.parent, 216 /* ContinueStatement */)) { + return highlightSpans(getBreakOrContinueStatementOccurrences(node.parent)); + } + break; + case 87 /* ForKeyword */: + if (hasKind(node.parent, 213 /* ForStatement */) || + hasKind(node.parent, 214 /* ForInStatement */) || + hasKind(node.parent, 215 /* ForOfStatement */)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case 105 /* WhileKeyword */: + case 80 /* DoKeyword */: + if (hasKind(node.parent, 212 /* WhileStatement */) || hasKind(node.parent, 211 /* DoStatement */)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case 122 /* ConstructorKeyword */: + if (hasKind(node.parent, 151 /* Constructor */)) { + return highlightSpans(getConstructorOccurrences(node.parent)); + } + break; + case 124 /* GetKeyword */: + case 134 /* SetKeyword */: + if (hasKind(node.parent, 152 /* GetAccessor */) || hasKind(node.parent, 153 /* SetAccessor */)) { + return highlightSpans(getGetAndSetOccurrences(node.parent)); + } + break; + default: + if (ts.isModifierKind(node.kind) && node.parent && + (ts.isDeclaration(node.parent) || node.parent.kind === 207 /* VariableStatement */)) { + return highlightSpans(getModifierOccurrences(node.kind, node.parent)); + } } - function getSemanticDocumentHighlights(node) { - if (node.kind === 70 /* Identifier */ || - node.kind === 98 /* ThisKeyword */ || - node.kind === 167 /* ThisType */ || - node.kind === 96 /* SuperKeyword */ || - node.kind === 9 /* StringLiteral */ || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/ false); - return convertReferencedSymbols(referencedSymbols); - } - return undefined; - function convertReferencedSymbols(referencedSymbols) { - if (!referencedSymbols) { - return undefined; - } - var fileNameToDocumentHighlights = ts.createMap(); - var result = []; - for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { - var referencedSymbol = referencedSymbols_1[_i]; - for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { - var referenceEntry = _b[_a]; - var fileName = referenceEntry.fileName; - var documentHighlights = fileNameToDocumentHighlights[fileName]; - if (!documentHighlights) { - documentHighlights = { fileName: fileName, highlightSpans: [] }; - fileNameToDocumentHighlights[fileName] = documentHighlights; - result.push(documentHighlights); - } - documentHighlights.highlightSpans.push({ - textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference - }); - } - } - return result; - } + function highlightSpans(nodes) { + return nodes && nodes.map(function (node) { return getHighlightSpanForNode(node, sourceFile); }); } - function getSyntacticDocumentHighlights(node) { - var fileName = sourceFile.fileName; - var highlightSpans = getHighlightSpans(node); - if (!highlightSpans || highlightSpans.length === 0) { - return undefined; + } + /** + * Aggregates all throw-statements within this node *without* crossing + * into function boundaries and try-blocks with catch-clauses. + */ + function aggregateOwnedThrowStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 222 /* ThrowStatement */) { + statementAccumulator.push(node); } - return [{ fileName: fileName, highlightSpans: highlightSpans }]; - // returns true if 'node' is defined and has a matching 'kind'. - function hasKind(node, kind) { - return node !== undefined && node.kind === kind; - } - // Null-propagating 'parent' function. - function parent(node) { - return node && node.parent; - } - function getHighlightSpans(node) { - if (node) { - switch (node.kind) { - case 89 /* IfKeyword */: - case 81 /* ElseKeyword */: - if (hasKind(node.parent, 209 /* IfStatement */)) { - return getIfElseOccurrences(node.parent); - } - break; - case 95 /* ReturnKeyword */: - if (hasKind(node.parent, 217 /* ReturnStatement */)) { - return getReturnOccurrences(node.parent); - } - break; - case 99 /* ThrowKeyword */: - if (hasKind(node.parent, 221 /* ThrowStatement */)) { - return getThrowOccurrences(node.parent); - } - break; - case 73 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 222 /* TryStatement */)) { - return getTryCatchFinallyOccurrences(node.parent.parent); - } - break; - case 101 /* TryKeyword */: - case 86 /* FinallyKeyword */: - if (hasKind(parent(node), 222 /* TryStatement */)) { - return getTryCatchFinallyOccurrences(node.parent); - } - break; - case 97 /* SwitchKeyword */: - if (hasKind(node.parent, 219 /* SwitchStatement */)) { - return getSwitchCaseDefaultOccurrences(node.parent); - } - break; - case 72 /* CaseKeyword */: - case 78 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 219 /* SwitchStatement */)) { - return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); - } - break; - case 71 /* BreakKeyword */: - case 76 /* ContinueKeyword */: - if (hasKind(node.parent, 216 /* BreakStatement */) || hasKind(node.parent, 215 /* ContinueStatement */)) { - return getBreakOrContinueStatementOccurrences(node.parent); - } - break; - case 87 /* ForKeyword */: - if (hasKind(node.parent, 212 /* ForStatement */) || - hasKind(node.parent, 213 /* ForInStatement */) || - hasKind(node.parent, 214 /* ForOfStatement */)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 105 /* WhileKeyword */: - case 80 /* DoKeyword */: - if (hasKind(node.parent, 211 /* WhileStatement */) || hasKind(node.parent, 210 /* DoStatement */)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 122 /* ConstructorKeyword */: - if (hasKind(node.parent, 150 /* Constructor */)) { - return getConstructorOccurrences(node.parent); - } - break; - case 124 /* GetKeyword */: - case 133 /* SetKeyword */: - if (hasKind(node.parent, 151 /* GetAccessor */) || hasKind(node.parent, 152 /* SetAccessor */)) { - return getGetAndSetOccurrences(node.parent); - } - break; - default: - if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 206 /* VariableStatement */)) { - return getModifierOccurrences(node.kind, node.parent); - } - } - } - return undefined; - } - /** - * Aggregates all throw-statements within this node *without* crossing - * into function boundaries and try-blocks with catch-clauses. - */ - function aggregateOwnedThrowStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 221 /* ThrowStatement */) { - statementAccumulator.push(node); - } - else if (node.kind === 222 /* TryStatement */) { - var tryStatement = node; - if (tryStatement.catchClause) { - aggregate(tryStatement.catchClause); - } - else { - // Exceptions thrown within a try block lacking a catch clause - // are "owned" in the current context. - aggregate(tryStatement.tryBlock); - } - if (tryStatement.finallyBlock) { - aggregate(tryStatement.finallyBlock); - } - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, aggregate); - } - } - } - /** - * For lack of a better name, this function takes a throw statement and returns the - * nearest ancestor that is a try-block (whose try statement has a catch clause), - * function-block, or source file. - */ - function getThrowStatementOwner(throwStatement) { - var child = throwStatement; - while (child.parent) { - var parent_18 = child.parent; - if (ts.isFunctionBlock(parent_18) || parent_18.kind === 262 /* SourceFile */) { - return parent_18; - } - // 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_18.kind === 222 /* TryStatement */) { - var tryStatement = parent_18; - if (tryStatement.tryBlock === child && tryStatement.catchClause) { - return child; - } - } - child = parent_18; - } - return undefined; - } - function aggregateAllBreakAndContinueStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 216 /* BreakStatement */ || node.kind === 215 /* ContinueStatement */) { - statementAccumulator.push(node); - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, aggregate); - } - } - } - function ownsBreakOrContinueStatement(owner, statement) { - var actualOwner = getBreakOrContinueOwner(statement); - return actualOwner && actualOwner === owner; - } - function getBreakOrContinueOwner(statement) { - for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { - switch (node_2.kind) { - case 219 /* SwitchStatement */: - if (statement.kind === 215 /* ContinueStatement */) { - continue; - } - // Fall through. - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 211 /* WhileStatement */: - case 210 /* DoStatement */: - if (!statement.label || isLabeledBy(node_2, statement.label.text)) { - return node_2; - } - break; - default: - // Don't cross function boundaries. - if (ts.isFunctionLike(node_2)) { - return undefined; - } - break; - } - } - return undefined; - } - function getModifierOccurrences(modifier, declaration) { - 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 === 227 /* ClassDeclaration */ || - container.kind === 197 /* ClassExpression */ || - (declaration.kind === 144 /* Parameter */ && hasKind(container, 150 /* Constructor */)))) { - return undefined; - } - } - else if (modifier === 114 /* StaticKeyword */) { - if (!(container.kind === 227 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */)) { - return undefined; - } - } - else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { - if (!(container.kind === 232 /* ModuleBlock */ || container.kind === 262 /* SourceFile */)) { - return undefined; - } - } - else if (modifier === 116 /* AbstractKeyword */) { - if (!(container.kind === 227 /* ClassDeclaration */ || declaration.kind === 227 /* ClassDeclaration */)) { - return undefined; - } + else if (node.kind === 223 /* TryStatement */) { + var tryStatement = node; + if (tryStatement.catchClause) { + aggregate(tryStatement.catchClause); } else { - // unsupported modifier - return undefined; - } - var keywords = []; - var modifierFlag = getFlagFromModifier(modifier); - var nodes; - switch (container.kind) { - case 232 /* ModuleBlock */: - case 262 /* SourceFile */: - // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 128 /* Abstract */) { - nodes = declaration.members.concat(declaration); - } - else { - nodes = container.statements; - } - break; - case 150 /* Constructor */: - nodes = container.parameters.concat(container.parent.members); - break; - case 227 /* ClassDeclaration */: - case 197 /* 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 & 28 /* AccessibilityModifier */) { - var constructor = ts.forEach(container.members, function (member) { - return member.kind === 150 /* Constructor */ && member; - }); - if (constructor) { - nodes = nodes.concat(constructor.parameters); - } - } - else if (modifierFlag & 128 /* Abstract */) { - nodes = nodes.concat(container); - } - break; - default: - ts.Debug.fail("Invalid container kind."); - } - ts.forEach(nodes, function (node) { - if (ts.getModifierFlags(node) & modifierFlag) { - ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - function getFlagFromModifier(modifier) { - switch (modifier) { - case 113 /* PublicKeyword */: - return 4 /* Public */; - case 111 /* PrivateKeyword */: - return 8 /* Private */; - case 112 /* ProtectedKeyword */: - return 16 /* Protected */; - case 114 /* StaticKeyword */: - return 32 /* Static */; - case 83 /* ExportKeyword */: - return 1 /* Export */; - case 123 /* DeclareKeyword */: - return 2 /* Ambient */; - case 116 /* AbstractKeyword */: - return 128 /* Abstract */; - default: - ts.Debug.fail(); - } - } - } - function pushKeywordIf(keywordList, token) { - var expected = []; - for (var _i = 2; _i < arguments.length; _i++) { - expected[_i - 2] = arguments[_i]; - } - if (token && ts.contains(expected, token.kind)) { - keywordList.push(token); - return true; - } - return false; - } - function getGetAndSetOccurrences(accessorDeclaration) { - var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 151 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 152 /* 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, 124 /* GetKeyword */, 133 /* SetKeyword */); }); - } - } - } - function getConstructorOccurrences(constructorDeclaration) { - var declarations = constructorDeclaration.symbol.getDeclarations(); - var keywords = []; - ts.forEach(declarations, function (declaration) { - ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 122 /* ConstructorKeyword */); - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getLoopBreakContinueOccurrences(loopNode) { - var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87 /* ForKeyword */, 105 /* WhileKeyword */, 80 /* DoKeyword */)) { - // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 210 /* DoStatement */) { - var loopTokens = loopNode.getChildren(); - for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { - break; - } - } - } - } - var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */, 76 /* ContinueKeyword */); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { - var owner = getBreakOrContinueOwner(breakOrContinueStatement); - if (owner) { - switch (owner.kind) { - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 210 /* DoStatement */: - case 211 /* WhileStatement */: - return getLoopBreakContinueOccurrences(owner); - case 219 /* SwitchStatement */: - return getSwitchCaseDefaultOccurrences(owner); - } - } - return undefined; - } - function getSwitchCaseDefaultOccurrences(switchStatement) { - var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 97 /* 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(), 72 /* CaseKeyword */, 78 /* DefaultKeyword */); - var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */); - } - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getTryCatchFinallyOccurrences(tryStatement) { - var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 101 /* TryKeyword */); - if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73 /* CatchKeyword */); + // Exceptions thrown within a try block lacking a catch clause + // are "owned" in the current context. + aggregate(tryStatement.tryBlock); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 86 /* FinallyKeyword */); + aggregate(tryStatement.finallyBlock); } - return ts.map(keywords, getHighlightSpanForNode); } - function getThrowOccurrences(throwStatement) { - var owner = getThrowStatementOwner(throwStatement); - if (!owner) { - return undefined; - } - var keywords = []; - ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* 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(), 95 /* ReturnKeyword */); - }); - } - return ts.map(keywords, getHighlightSpanForNode); - } - 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, 205 /* Block */))) { - return undefined; - } - var keywords = []; - ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); - }); - // Include 'throw' statements that do not occur within a try block. - ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* 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, 209 /* 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], 89 /* 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], 81 /* ElseKeyword */)) { - break; - } - } - if (!hasKind(ifStatement.elseStatement, 209 /* IfStatement */)) { - break; - } - ifStatement = ifStatement.elseStatement; - } - var result = []; - // 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 === 81 /* ElseKeyword */ && i < keywords.length - 1) { - var elseKeyword = keywords[i]; - var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. - var shouldCombindElseAndIf = true; - // Avoid recalculating getStart() by iterating backwards. - for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { - if (!ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { - shouldCombindElseAndIf = false; - break; - } - } - if (shouldCombindElseAndIf) { - result.push({ - fileName: fileName, - textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: ts.HighlightSpanKind.reference - }); - i++; // skip the next keyword - continue; - } - } - // Ordinary case: just highlight the keyword. - result.push(getHighlightSpanForNode(keywords[i])); - } - return result; + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); } } } - DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + /** + * For lack of a better name, this function takes a throw statement and returns the + * nearest ancestor that is a try-block (whose try statement has a catch clause), + * function-block, or source file. + */ + function getThrowStatementOwner(throwStatement) { + var child = throwStatement; + while (child.parent) { + var parent_2 = child.parent; + if (ts.isFunctionBlock(parent_2) || parent_2.kind === 264 /* SourceFile */) { + return parent_2; + } + // 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_2.kind === 223 /* TryStatement */) { + var tryStatement = parent_2; + if (tryStatement.tryBlock === child && tryStatement.catchClause) { + return child; + } + } + child = parent_2; + } + return undefined; + } + function aggregateAllBreakAndContinueStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 217 /* BreakStatement */ || node.kind === 216 /* ContinueStatement */) { + statementAccumulator.push(node); + } + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); + } + } + } + function ownsBreakOrContinueStatement(owner, statement) { + var actualOwner = getBreakOrContinueOwner(statement); + return actualOwner && actualOwner === owner; + } + function getBreakOrContinueOwner(statement) { + for (var node = statement.parent; node; node = node.parent) { + switch (node.kind) { + case 220 /* SwitchStatement */: + if (statement.kind === 216 /* ContinueStatement */) { + continue; + } + // Fall through. + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 212 /* WhileStatement */: + case 211 /* DoStatement */: + if (!statement.label || isLabeledBy(node, statement.label.text)) { + return node; + } + break; + default: + // Don't cross function boundaries. + if (ts.isFunctionLike(node)) { + return undefined; + } + break; + } + } + return undefined; + } + function getModifierOccurrences(modifier, declaration) { + 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 === 228 /* ClassDeclaration */ || + container.kind === 198 /* ClassExpression */ || + (declaration.kind === 145 /* Parameter */ && hasKind(container, 151 /* Constructor */)))) { + return undefined; + } + } + else if (modifier === 114 /* StaticKeyword */) { + if (!(container.kind === 228 /* ClassDeclaration */ || container.kind === 198 /* ClassExpression */)) { + return undefined; + } + } + else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { + if (!(container.kind === 233 /* ModuleBlock */ || container.kind === 264 /* SourceFile */)) { + return undefined; + } + } + else if (modifier === 116 /* AbstractKeyword */) { + if (!(container.kind === 228 /* ClassDeclaration */ || declaration.kind === 228 /* ClassDeclaration */)) { + return undefined; + } + } + else { + // unsupported modifier + return undefined; + } + var keywords = []; + var modifierFlag = getFlagFromModifier(modifier); + var nodes; + switch (container.kind) { + case 233 /* ModuleBlock */: + case 264 /* SourceFile */: + // Container is either a class declaration or the declaration is a classDeclaration + if (modifierFlag & 128 /* Abstract */) { + nodes = declaration.members.concat(declaration); + } + else { + nodes = container.statements; + } + break; + case 151 /* Constructor */: + nodes = container.parameters.concat(container.parent.members); + break; + case 228 /* ClassDeclaration */: + case 198 /* 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 & 28 /* AccessibilityModifier */) { + var constructor = ts.forEach(container.members, function (member) { + return member.kind === 151 /* Constructor */ && member; + }); + if (constructor) { + nodes = nodes.concat(constructor.parameters); + } + } + else if (modifierFlag & 128 /* Abstract */) { + nodes = nodes.concat(container); + } + break; + default: + ts.Debug.fail("Invalid container kind."); + } + ts.forEach(nodes, function (node) { + if (ts.getModifierFlags(node) & modifierFlag) { + ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); + } + }); + return keywords; + function getFlagFromModifier(modifier) { + switch (modifier) { + case 113 /* PublicKeyword */: + return 4 /* Public */; + case 111 /* PrivateKeyword */: + return 8 /* Private */; + case 112 /* ProtectedKeyword */: + return 16 /* Protected */; + case 114 /* StaticKeyword */: + return 32 /* Static */; + case 83 /* ExportKeyword */: + return 1 /* Export */; + case 123 /* DeclareKeyword */: + return 2 /* Ambient */; + case 116 /* AbstractKeyword */: + return 128 /* Abstract */; + default: + ts.Debug.fail(); + } + } + } + function pushKeywordIf(keywordList, token) { + var expected = []; + for (var _i = 2; _i < arguments.length; _i++) { + expected[_i - 2] = arguments[_i]; + } + if (token && ts.contains(expected, token.kind)) { + keywordList.push(token); + return true; + } + return false; + } + function getGetAndSetOccurrences(accessorDeclaration) { + var keywords = []; + tryPushAccessorKeyword(accessorDeclaration.symbol, 152 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 153 /* SetAccessor */); + return keywords; + function tryPushAccessorKeyword(accessorSymbol, accessorKind) { + var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); + if (accessor) { + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124 /* GetKeyword */, 134 /* SetKeyword */); }); + } + } + } + function getConstructorOccurrences(constructorDeclaration) { + var declarations = constructorDeclaration.symbol.getDeclarations(); + var keywords = []; + ts.forEach(declarations, function (declaration) { + ts.forEach(declaration.getChildren(), function (token) { + return pushKeywordIf(keywords, token, 122 /* ConstructorKeyword */); + }); + }); + return keywords; + } + function getLoopBreakContinueOccurrences(loopNode) { + var keywords = []; + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87 /* ForKeyword */, 105 /* WhileKeyword */, 80 /* DoKeyword */)) { + // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. + if (loopNode.kind === 211 /* DoStatement */) { + var loopTokens = loopNode.getChildren(); + for (var i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { + break; + } + } + } + } + var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(loopNode, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */, 76 /* ContinueKeyword */); + } + }); + return keywords; + } + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { + var owner = getBreakOrContinueOwner(breakOrContinueStatement); + if (owner) { + switch (owner.kind) { + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + return getLoopBreakContinueOccurrences(owner); + case 220 /* SwitchStatement */: + return getSwitchCaseDefaultOccurrences(owner); + } + } + return undefined; + } + function getSwitchCaseDefaultOccurrences(switchStatement) { + var keywords = []; + pushKeywordIf(keywords, switchStatement.getFirstToken(), 97 /* 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(), 72 /* CaseKeyword */, 78 /* DefaultKeyword */); + var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(switchStatement, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */); + } + }); + }); + return keywords; + } + function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { + var keywords = []; + pushKeywordIf(keywords, tryStatement.getFirstToken(), 101 /* TryKeyword */); + if (tryStatement.catchClause) { + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73 /* CatchKeyword */); + } + if (tryStatement.finallyBlock) { + var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 86 /* FinallyKeyword */); + } + return keywords; + } + function getThrowOccurrences(throwStatement) { + var owner = getThrowStatementOwner(throwStatement); + if (!owner) { + return undefined; + } + var keywords = []; + ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* 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(), 95 /* ReturnKeyword */); + }); + } + return keywords; + } + 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, 206 /* Block */))) { + return undefined; + } + var keywords = []; + ts.forEachReturnStatement(func.body, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); + }); + // Include 'throw' statements that do not occur within a try block. + ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* ThrowKeyword */); + }); + return keywords; + } + function getIfElseOccurrences(ifStatement, sourceFile) { + var keywords = []; + // Traverse upwards through all parent if-statements linked by their else-branches. + while (hasKind(ifStatement.parent, 210 /* 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], 89 /* 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], 81 /* ElseKeyword */)) { + break; + } + } + if (!hasKind(ifStatement.elseStatement, 210 /* IfStatement */)) { + break; + } + ifStatement = ifStatement.elseStatement; + } + var result = []; + // 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 === 81 /* ElseKeyword */ && i < keywords.length - 1) { + var elseKeyword = keywords[i]; + var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. + var shouldCombindElseAndIf = true; + // Avoid recalculating getStart() by iterating backwards. + for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { + if (!ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { + shouldCombindElseAndIf = false; + break; + } + } + if (shouldCombindElseAndIf) { + result.push({ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), + kind: ts.HighlightSpanKind.reference + }); + i++; // skip the next keyword + continue; + } + } + // Ordinary case: just highlight the keyword. + result.push(getHighlightSpanForNode(keywords[i], sourceFile)); + } + return result; + } /** * Whether or not a 'node' is preceded by a label of the given string. * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 220 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 221 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -70160,15 +71615,15 @@ var ts; return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + "|" + settings.allowJs + "|" + settings.baseUrl + "|" + JSON.stringify(settings.typeRoots) + "|" + JSON.stringify(settings.rootDirs) + "|" + JSON.stringify(settings.paths); } function getBucketForCompilationSettings(key, createIfMissing) { - var bucket = buckets[key]; + var bucket = buckets.get(key); if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(); + buckets.set(key, bucket = ts.createFileMap()); } return bucket; } function reportStats() { - var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { - var entries = buckets[name]; + var bucketInfoArray = ts.arrayFrom(buckets.keys()).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { + var entries = buckets.get(name); var sourceFiles = []; entries.forEachValue(function (key, entry) { sourceFiles.push({ @@ -70266,57 +71721,30 @@ var ts; (function (ts) { var FindAllReferences; (function (FindAllReferences) { - function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments) { + function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments, isForRename) { var node = ts.getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); - if (node === sourceFile) { - return undefined; - } - switch (node.kind) { - case 8 /* NumericLiteral */: - if (!ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - break; - } - // Fallthrough - case 70 /* Identifier */: - case 98 /* ThisKeyword */: - // case SyntaxKind.SuperKeyword: TODO:GH#9268 - case 122 /* ConstructorKeyword */: - case 9 /* StringLiteral */: - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, /*implementations*/ false); - } - return undefined; + return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename); } FindAllReferences.findReferencedSymbols = findReferencedSymbols; - function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, implementations) { + function convertReferences(referenceSymbols) { + return referenceSymbols && ts.flatMap(referenceSymbols, function (r) { return r.references; }); + } + FindAllReferences.convertReferences = convertReferences; + function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename, implementations) { if (!implementations) { - // Labels - if (ts.isLabelName(node)) { - if (ts.isJumpStatementTarget(node)) { - var labelDefinition = ts.getTargetLabel(node.parent, node.text); - // if we have a label definition, look within its statement for references, if not, then - // the label is undefined and we have no results.. - return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; - } - else { - // it is a label definition and not a target, search within the parent labeledStatement - return getLabelReferencesInNode(node.parent, node); - } - } - if (ts.isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles); - } - if (node.kind === 96 /* SuperKeyword */) { - return getReferencesForSuperKeyword(node); + var special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken); + if (special) { + return special; } } // `getSymbolAtLocation` normally returns the symbol of the class when given the constructor keyword, // so we have to specify that we want the constructor symbol. var symbol = typeChecker.getSymbolAtLocation(node); - if (!implementations && !symbol && node.kind === 9 /* StringLiteral */) { - return getReferencesForStringLiteral(node, sourceFiles); - } // Could not find a symbol e.g. unknown identifier if (!symbol) { + if (!implementations && node.kind === 9 /* StringLiteral */) { + return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); + } // Can't have references to something that we have no symbol for. return undefined; } @@ -70325,1040 +71753,1120 @@ var ts; if (!declarations || !declarations.length) { return undefined; } - var result; + var _a = followAliases(symbol, node, typeChecker, isForRename), aliasedSymbol = _a.symbol, shorthandModuleSymbol = _a.shorthandModuleSymbol; + symbol = aliasedSymbol; + // Build the set of symbols to search for, initially it has only the current symbol + var searchSymbols = populateSearchSymbolSet(symbol, node, typeChecker, implementations); + if (shorthandModuleSymbol) { + searchSymbols.push(shorthandModuleSymbol); + } // Compute the meaning from the location and the symbol it references var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), declarations); + var result = []; + // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. + var symbolToIndex = []; + var inheritsFromCache = ts.createMap(); // 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); - // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. - var symbolToIndex = []; if (scope) { - result = []; - getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + getRefs(scope, declaredName); } else { - var internedName = getInternedName(symbol, node); - for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { - var sourceFile = sourceFiles_8[_i]; + var isDefault = ts.isExportDefaultSymbol(symbol); + var internedName = isDefault ? symbol.valueDeclaration.localSymbol.name : getInternedName(symbol, node); + for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { + var sourceFile = sourceFiles_5[_i]; cancellationToken.throwIfCancellationRequested(); - var nameTable = ts.getNameTable(sourceFile); - if (nameTable[internedName] !== undefined) { - result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + var searchName = (isDefault ? getDefaultImportName(symbol, sourceFile, typeChecker) : undefined) || + (sourceFileHasName(sourceFile, internedName) ? declaredName : undefined); + if (searchName !== undefined) { + getRefs(sourceFile, searchName); } } } return result; - function getDefinition(symbol) { - var info = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node); - var name = ts.map(info.displayParts, function (p) { return p.text; }).join(""); - var declarations = symbol.declarations; - if (!declarations || declarations.length === 0) { - return undefined; - } - return { - containerKind: "", - containerName: "", - name: name, - kind: info.symbolKind, - fileName: declarations[0].getSourceFile().fileName, - textSpan: ts.createTextSpan(declarations[0].getStart(), 0), - displayParts: info.displayParts - }; + function getRefs(scope, searchName) { + getReferencesInNode(scope, symbol, searchName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache); } - function getAliasSymbolForPropertyNameSymbol(symbol, location) { - if (symbol.flags & 8388608 /* Alias */) { - // Default import get alias - var defaultImport = ts.getDeclarationOfKind(symbol, 237 /* ImportClause */); - if (defaultImport) { - return typeChecker.getAliasedSymbol(symbol); - } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 240 /* ImportSpecifier */ || - declaration.kind === 244 /* ExportSpecifier */) ? declaration : undefined; }); - if (importOrExportSpecifier && - // export { a } - (!importOrExportSpecifier.propertyName || - // export {a as class } where a is location - importOrExportSpecifier.propertyName === location)) { - // If Import specifier -> get alias - // else Export specifier -> get local target - return importOrExportSpecifier.kind === 240 /* ImportSpecifier */ ? - typeChecker.getAliasedSymbol(symbol) : - typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); - } + } + FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; + /** getReferencedSymbols for special node kinds. */ + function getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken) { + if (ts.isTypeKeyword(node.kind)) { + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + } + // Labels + if (ts.isLabelName(node)) { + if (ts.isJumpStatementTarget(node)) { + var labelDefinition = ts.getTargetLabel(node.parent, node.text); + // if we have a label definition, look within its statement for references, if not, then + // the label is undefined and we have no results.. + return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, cancellationToken); } + else { + // it is a label definition and not a target, search within the parent labeledStatement + return getLabelReferencesInNode(node.parent, node, cancellationToken); + } + } + if (ts.isThis(node)) { + return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); + } + if (node.kind === 96 /* SuperKeyword */) { + return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); + } + return undefined; + } + /** + * Follows aliases to get to the original declaration of a symbol. + * For a shorthand ambient module, we don't follow the alias to it, but we will need to add it to the set of search symbols. + */ + function followAliases(symbol, node, typeChecker, isForRename) { + while (true) { + // When renaming a default import, only rename in the current file + if (isForRename && isImportDefaultSymbol(symbol)) { + return { symbol: symbol }; + } + var aliasedSymbol = getAliasSymbolForPropertyNameSymbol(symbol, node, typeChecker); + // Don't follow alias if it goes to unknown symbol. This can happen if it points to an untyped module. + if (!aliasedSymbol || !aliasedSymbol.declarations) { + return { symbol: symbol }; + } + if (ts.isShorthandAmbientModuleSymbol(aliasedSymbol)) { + return { symbol: symbol, shorthandModuleSymbol: aliasedSymbol }; + } + symbol = aliasedSymbol; + } + } + function sourceFileHasName(sourceFile, name) { + return ts.getNameTable(sourceFile).get(name) !== undefined; + } + /** + * Given a symbol, see if any of the imports in a source file reference it. + * Only call this if `symbol` is a default export. + */ + function getDefaultImportName(symbol, sourceFile, checker) { + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var importSpecifier = _a[_i]; + var importDecl = importSpecifier.parent; + ts.Debug.assert(importDecl.moduleSpecifier === importSpecifier); + var defaultName = importDecl.importClause.name; + var defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName)); + if (symbol === defaultReferencedSymbol) { + return defaultName.text; + } + } + return undefined; + } + function getDefinition(symbol, node, typeChecker) { + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node), displayParts = _a.displayParts, symbolKind = _a.symbolKind; + var name = displayParts.map(function (p) { return p.text; }).join(""); + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { return undefined; } - function followAliasIfNecessary(symbol, location) { - return getAliasSymbolForPropertyNameSymbol(symbol, location) || symbol; - } - function getPropertySymbolOfDestructuringAssignment(location) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - typeChecker.getPropertySymbolOfDestructuringAssignment(location); - } - function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 174 /* BindingElement */); - return bindingElement && - bindingElement.parent.kind === 172 /* ObjectBindingPattern */ && - !bindingElement.propertyName; - } - function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 174 /* BindingElement */); - var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); - } + return { + containerKind: "", + containerName: "", + name: name, + kind: symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: ts.createTextSpan(declarations[0].getStart(), 0), + displayParts: displayParts + }; + } + function getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) { + if (!(symbol.flags & 8388608 /* Alias */)) { return undefined; } - function getInternedName(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 under the cursor. - if (ts.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); - symbol = localExportDefaultSymbol || symbol; - return ts.stripQuotes(symbol.name); + // Default import get alias + var defaultImport = ts.getDeclarationOfKind(symbol, 238 /* ImportClause */); + if (defaultImport) { + return typeChecker.getAliasedSymbol(symbol); } - /** - * 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 === 184 /* FunctionExpression */ || valueDeclaration.kind === 197 /* 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 (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); - if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 227 /* ClassDeclaration */); - } - } - // If the symbol is an import we would like to find it if we are looking for what it imports. - // So consider it visible outside its declaration scope. - if (symbol.flags & 8388608 /* Alias */) { - return undefined; - } - // If symbol is of object binding pattern element without property name we would want to - // look for property too and that could be anywhere - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - return undefined; - } - // 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 /* SyntheticProperty */)) { - return undefined; - } - var scope; - var declarations = symbol.getDeclarations(); - if (declarations) { - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; - var container = ts.getContainerNode(declaration); - if (!container) { - return undefined; - } - if (scope && scope !== container) { - // Different declarations have different containers, bail out - return undefined; - } - if (container.kind === 262 /* 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; - } - // The search scope is the container node - scope = container; - } - } - return scope; + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 241 /* ImportSpecifier */ || + declaration.kind === 245 /* ExportSpecifier */) ? declaration : undefined; }); + if (importOrExportSpecifier && + // export { a } + (!importOrExportSpecifier.propertyName || + // export {a as class } where a is location + importOrExportSpecifier.propertyName === location)) { + // If Import specifier -> get alias + // else Export specifier -> get local target + return importOrExportSpecifier.kind === 241 /* ImportSpecifier */ ? + typeChecker.getAliasedSymbol(symbol) : + typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } - function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { - var positions = []; - /// TODO: Cache symbol existence for files to save text search - // Also, need to make this work for unicode escapes. - // Be resilient in the face of a symbol with no name or zero length name - if (!symbolName || !symbolName.length) { - return positions; + } + function followAliasIfNecessary(symbol, location, typeChecker) { + return getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) || symbol; + } + function getPropertySymbolOfDestructuringAssignment(location, typeChecker) { + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && + typeChecker.getPropertySymbolOfDestructuringAssignment(location); + } + function isObjectBindingPatternElementWithoutPropertyName(symbol) { + var bindingElement = ts.getDeclarationOfKind(symbol, 175 /* BindingElement */); + return bindingElement && + bindingElement.parent.kind === 173 /* ObjectBindingPattern */ && + !bindingElement.propertyName; + } + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker) { + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + var bindingElement = ts.getDeclarationOfKind(symbol, 175 /* BindingElement */); + var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); + return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + } + return undefined; + } + function getInternedName(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 under the cursor. + if (ts.isImportOrExportSpecifierName(location)) { + return location.text; + } + 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 === 185 /* FunctionExpression */ || valueDeclaration.kind === 198 /* 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 (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); + if (privateDeclaration) { + return ts.getAncestor(privateDeclaration, 228 /* ClassDeclaration */); } - var text = sourceFile.text; - var sourceLength = text.length; - var symbolNameLength = symbolName.length; - var position = text.indexOf(symbolName, start); - while (position >= 0) { - cancellationToken.throwIfCancellationRequested(); - // If we are past the end, stop looking - if (position > end) - break; - // We found a match. Make sure it's not part of a larger word (i.e. the char - // before and after it have to be a non-identifier char). - var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5 /* Latest */))) { - // Found a real match. Keep searching. - positions.push(position); + } + // If the symbol is an import we would like to find it if we are looking for what it imports. + // So consider it visible outside its declaration scope. + if (symbol.flags & 8388608 /* Alias */) { + return undefined; + } + // If symbol is of object binding pattern element without property name we would want to + // look for property too and that could be anywhere + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + return undefined; + } + // 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 & 134217728 /* Transient */ && symbol.checkFlags & 2 /* SyntheticProperty */)) { + return undefined; + } + var scope; + var declarations = symbol.getDeclarations(); + if (declarations) { + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; + var container = ts.getContainerNode(declaration); + if (!container) { + return undefined; } - position = text.indexOf(symbolName, position + symbolNameLength + 1); + if (scope && scope !== container) { + // Different declarations have different containers, bail out + return undefined; + } + if (container.kind === 264 /* 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; + } + // The search scope is the container node + scope = container; } + } + return scope; + } + function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end, cancellationToken) { + var positions = []; + /// TODO: Cache symbol existence for files to save text search + // Also, need to make this work for unicode escapes. + // Be resilient in the face of a symbol with no name or zero length name + if (!symbolName || !symbolName.length) { return positions; } - function getLabelReferencesInNode(container, targetLabel) { - var references = []; - var sourceFile = container.getSourceFile(); - var labelName = targetLabel.text; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.getWidth() !== labelName.length) { - return; - } - // Only pick labels that are either the target label, or have a target that is the target label - if (node === targetLabel || - (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ts.ScriptElementKind.label, - name: labelName, - textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()), - displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] - }; - return [{ definition: definition, references: references }]; + var text = sourceFile.text; + var sourceLength = text.length; + var symbolNameLength = symbolName.length; + var position = text.indexOf(symbolName, start); + while (position >= 0) { + cancellationToken.throwIfCancellationRequested(); + // If we are past the end, stop looking + if (position > end) + break; + // We found a match. Make sure it's not part of a larger word (i.e. the char + // before and after it have to be a non-identifier char). + var endPosition = position + symbolNameLength; + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5 /* Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5 /* Latest */))) { + // Found a real match. Keep searching. + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); } - function isValidReferencePosition(node, searchSymbolName) { - if (node) { - // Compare the length so we filter out strict superstrings of the symbol we are looking for - switch (node.kind) { - case 70 /* Identifier */: - return node.getWidth() === searchSymbolName.length; - case 9 /* StringLiteral */: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - // For string literals we have two additional chars for the quotes - return node.getWidth() === searchSymbolName.length + 2; + return positions; + } + function getLabelReferencesInNode(container, targetLabel, cancellationToken) { + var references = []; + var sourceFile = container.getSourceFile(); + var labelName = targetLabel.text; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { + return; + } + // Only pick labels that are either the target label, or have a target that is the target label + if (node === targetLabel || + (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { + references.push(getReferenceEntryFromNode(node)); + } + }); + var definition = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ts.ScriptElementKind.label, + name: labelName, + textSpan: ts.createTextSpanFromNode(targetLabel, sourceFile), + displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] + }; + return [{ definition: definition, references: references }]; + } + function isValidReferencePosition(node, searchSymbolName) { + // Compare the length so we filter out strict superstrings of the symbol we are looking for + switch (node && node.kind) { + case 70 /* Identifier */: + return node.getWidth() === searchSymbolName.length; + case 9 /* StringLiteral */: + return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + // For string literals we have two additional chars for the quotes + node.getWidth() === searchSymbolName.length + 2; + case 8 /* NumericLiteral */: + return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; + default: + return false; + } + } + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + var name = ts.tokenToString(keywordKind); + var references = []; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var sourceFile = sourceFiles_6[_i]; + cancellationToken.throwIfCancellationRequested(); + addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); + } + if (!references.length) + return undefined; + var definition = { + containerKind: "", + containerName: "", + fileName: references[0].fileName, + kind: ts.ScriptElementKind.keyword, + name: name, + textSpan: references[0].textSpan, + displayParts: [{ text: name, kind: ts.ScriptElementKind.keyword }] + }; + return [{ definition: definition, references: references }]; + } + function addReferencesForKeywordInFile(sourceFile, kind, searchText, cancellationToken, references) { + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { + var position = possiblePositions_1[_i]; + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (referenceLocation.kind === kind) { + references.push({ + textSpan: ts.createTextSpanFromNode(referenceLocation), + fileName: sourceFile.fileName, + isWriteAccess: false, + isDefinition: false, + }); + } + } + } + /** Search within node "container" for references for a search value, where the search value is defined as a + * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). + * searchLocation: a node where the search value + */ + function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache) { + var sourceFile = container.getSourceFile(); + var start = findInComments ? container.getFullStart() : container.getStart(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); + var parents = getParentSymbolsOfPropertyAccess(); + for (var _i = 0, possiblePositions_2 = possiblePositions; _i < possiblePositions_2.length; _i++) { + var position = possiblePositions_2[_i]; + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (!isValidReferencePosition(referenceLocation, searchText)) { + // This wasn't the start of a token. Check to see if it might be a + // match in a comment or string if that's what the caller is asking + // for. + if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { + // In the case where we're looking inside comments/strings, we don't have + // an actual definition. So just use 'undefined' here. Features like + // 'Rename' won't care (as they ignore the definitions), and features like + // 'FindReferences' will just filter out these results. + result.push({ + definition: undefined, + references: [{ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpan(position, searchText.length), + isWriteAccess: false, + isDefinition: false + }] + }); + } + continue; + } + if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { + continue; + } + var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); + if (referenceSymbol) { + var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); + var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, + /*searchLocationIsConstructor*/ searchLocation.kind === 122 /* ConstructorKeyword */, parents, inheritsFromCache, typeChecker); + if (relatedSymbol) { + addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); + } + else if (!(referenceSymbol.flags & 134217728 /* Transient */) && ts.contains(searchSymbols, shorthandValueSymbol)) { + addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); + } + else if (searchLocation.kind === 122 /* ConstructorKeyword */) { + findAdditionalConstructorReferences(referenceSymbol, referenceLocation); + } + } + } + return; + /* If we are just looking for implementations and this is a property access expression, we need to get the + * symbol of the local type of the symbol the property is being accessed on. This is because our search + * symbol may have a different parent symbol if the local type's symbol does not declare the property + * being accessed (i.e. it is declared in some parent class or interface) + */ + function getParentSymbolsOfPropertyAccess() { + if (implementations) { + var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); + if (propertyAccessExpression) { + var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); + if (localParentType) { + if (localParentType.symbol && localParentType.symbol.flags & (32 /* Class */ | 64 /* Interface */) && localParentType.symbol !== searchSymbol.parent) { + return [localParentType.symbol]; } - break; - case 8 /* NumericLiteral */: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return node.getWidth() === searchSymbolName.length; + else if (localParentType.flags & 196608 /* UnionOrIntersection */) { + return getSymbolsForClassAndInterfaceComponents(localParentType); } - break; + } + } + } + } + /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ + function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { + ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); + var referenceClass = referenceLocation.parent; + if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { + ts.Debug.assert(referenceClass.name === referenceLocation); + // This is the class declaration containing the constructor. + addReferences(findOwnConstructorCalls(searchSymbol, sourceFile)); + } + else { + // If this class appears in `extends C`, then the extending class' "super" calls are references. + var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); + if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation, typeChecker) === searchSymbol) { + addReferences(superConstructorAccesses(classExtending)); + } + } + } + function addReferences(references) { + if (references.length) { + var referencedSymbol = getReferencedSymbol(searchSymbol); + ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); + } + } + function getReferencedSymbol(symbol) { + var symbolId = ts.getSymbolId(symbol); + var index = symbolToIndex[symbolId]; + if (index === undefined) { + index = result.length; + symbolToIndex[symbolId] = index; + result.push({ + definition: getDefinition(symbol, searchLocation, typeChecker), + references: [] + }); + } + return result[index]; + } + function addReferenceToRelatedSymbol(node, relatedSymbol) { + var references = getReferencedSymbol(relatedSymbol).references; + if (implementations) { + getImplementationReferenceEntryForNode(node, references, typeChecker); + } + else { + references.push(getReferenceEntryFromNode(node)); + } + } + } + function getPropertyAccessExpressionFromRightHandSide(node) { + return ts.isRightSideOfPropertyAccess(node) && node.parent; + } + /** `classSymbol` is the class where the constructor was defined. + * Reference the constructor and all calls to `new this()`. + */ + function findOwnConstructorCalls(classSymbol, sourceFile) { + var result = []; + for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var ctrKeyword = ts.findChildOfKind(decl, 122 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 151 /* Constructor */ && !!ctrKeyword); + result.push(ctrKeyword); + } + classSymbol.exports.forEach(function (member) { + var decl = member.valueDeclaration; + if (decl && decl.kind === 150 /* MethodDeclaration */) { + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 98 /* ThisKeyword */, function (thisKeyword) { + if (ts.isNewExpressionTarget(thisKeyword)) { + result.push(thisKeyword); + } + }); + } + } + }); + return result; + } + /** Find references to `super` in the constructor of an extending class. */ + function superConstructorAccesses(cls) { + var symbol = cls.symbol; + var ctr = symbol.members.get("__constructor"); + if (!ctr) { + return []; + } + var result = []; + for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.Debug.assert(decl.kind === 151 /* Constructor */); + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 96 /* SuperKeyword */, function (node) { + if (ts.isCallExpressionTarget(node)) { + result.push(node); + } + }); + } + } + ; + return result; + } + function getImplementationReferenceEntryForNode(refNode, result, typeChecker) { + // Check if we found a function/propertyAssignment/method with an implementation or initializer + if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { + result.push(getReferenceEntryFromNode(refNode.parent)); + } + else if (refNode.kind === 70 /* Identifier */) { + if (refNode.parent.kind === 261 /* ShorthandPropertyAssignment */) { + // Go ahead and dereference the shorthand assignment by going to its definition + getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + } + // Check if the node is within an extends or implements clause + var containingClass = getContainingClassIfInHeritageClause(refNode); + if (containingClass) { + result.push(getReferenceEntryFromNode(containingClass)); + return; + } + // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface + var containingTypeReference = getContainingTypeReference(refNode); + if (containingTypeReference) { + var parent = containingTypeReference.parent; + if (ts.isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent.initializer)); + } + else if (ts.isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { + if (parent.body.kind === 206 /* Block */) { + ts.forEachReturnStatement(parent.body, function (returnStatement) { + if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { + maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); + } + }); + } + else if (isImplementationExpression(parent.body)) { + maybeAdd(getReferenceEntryFromNode(parent.body)); + } + } + else if (ts.isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { + maybeAdd(getReferenceEntryFromNode(parent.expression)); + } + } + } + // Type nodes can contain multiple references to the same type. For example: + // let x: Foo & (Foo & Bar) = ... + // Because we are returning the implementation locations and not the identifier locations, + // duplicate entries would be returned here as each of the type references is part of + // the same implementation. For that reason, check before we add a new entry + function maybeAdd(a) { + if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { + result.push(a); + } + } + } + function getSymbolsForClassAndInterfaceComponents(type, result) { + if (result === void 0) { result = []; } + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var componentType = _a[_i]; + if (componentType.symbol && componentType.symbol.getFlags() & (32 /* Class */ | 64 /* Interface */)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & 196608 /* UnionOrIntersection */) { + getSymbolsForClassAndInterfaceComponents(componentType, result); + } + } + return result; + } + function getContainingTypeReference(node) { + var topLevelTypeReference = undefined; + while (node) { + if (ts.isTypeNode(node)) { + topLevelTypeReference = node; + } + node = node.parent; + } + return topLevelTypeReference; + } + function getContainingClassIfInHeritageClause(node) { + if (node && node.parent) { + if (node.kind === 200 /* ExpressionWithTypeArguments */ + && node.parent.kind === 258 /* HeritageClause */ + && ts.isClassLike(node.parent.parent)) { + return node.parent.parent; + } + else if (node.kind === 70 /* Identifier */ || node.kind === 178 /* PropertyAccessExpression */) { + return getContainingClassIfInHeritageClause(node.parent); + } + } + return undefined; + } + /** + * Returns true if this is an expression that can be considered an implementation + */ + function isImplementationExpression(node) { + switch (node.kind) { + case 184 /* ParenthesizedExpression */: + return isImplementationExpression(node.expression); + case 186 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 177 /* ObjectLiteralExpression */: + case 198 /* ClassExpression */: + case 176 /* ArrayLiteralExpression */: + return true; + default: + return false; + } + } + /** + * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol + * is an interface, determines if some ancestor of the child symbol extends or inherits from it. + * Also takes in a cache of previous results which makes this slightly more efficient and is + * necessary to avoid potential loops like so: + * class A extends B { } + * class B extends A { } + * + * We traverse the AST rather than using the type checker because users are typically only interested + * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling + * implementations of types that share a common ancestor with the type whose implementation we are + * searching for need to be filtered out of the results. The type checker doesn't let us make the + * distinction between structurally compatible implementations and explicit implementations, so we + * must use the AST. + * + * @param child A class or interface Symbol + * @param parent Another class or interface Symbol + * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results + */ + function explicitlyInheritsFrom(child, parent, cachedResults, typeChecker) { + var parentIsInterface = parent.getFlags() & 64 /* Interface */; + return searchHierarchy(child); + function searchHierarchy(symbol) { + if (symbol === parent) { + return true; + } + var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); + var cached = cachedResults.get(key); + if (cached !== undefined) { + return cached; + } + // Set the key so that we don't infinitely recurse + cachedResults.set(key, false); + var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + if (parentIsInterface) { + var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { + var typeReference = interfaceReferences_1[_i]; + if (searchTypeReference(typeReference)) { + return true; + } + } + } + } + return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + } + else if (declaration.kind === 229 /* InterfaceDeclaration */) { + if (parentIsInterface) { + return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); + } + } + return false; + }); + cachedResults.set(key, inherits); + return inherits; + } + function searchTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); } } return false; } - /** Search within node "container" for references for a search value, where the search value is defined as a - * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). - * searchLocation: a node where the search value - */ - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { - var sourceFile = container.getSourceFile(); - var start = findInComments ? container.getFullStart() : container.getStart(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd()); - var parents = getParentSymbolsOfPropertyAccess(); - var inheritsFromCache = ts.createMap(); - if (possiblePositions.length) { - // Build the set of symbols to search for, initially it has only the current symbol - var searchSymbols_1 = populateSearchSymbolSet(searchSymbol, searchLocation); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { - // This wasn't the start of a token. Check to see if it might be a - // match in a comment or string if that's what the caller is asking - // for. - if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || - (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { - // In the case where we're looking inside comments/strings, we don't have - // an actual definition. So just use 'undefined' here. Features like - // 'Rename' won't care (as they ignore the definitions), and features like - // 'FindReferences' will just filter out these results. - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: ts.createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); - } - return; - } - if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { - return; - } - var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, - /*searchLocationIsConstructor*/ searchLocation.kind === 122 /* ConstructorKeyword */, parents, inheritsFromCache); - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); - } - else if (!(referenceSymbol.flags & 67108864 /* Transient */) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); - } - else if (searchLocation.kind === 122 /* ConstructorKeyword */) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); - } - } - }); - } - return; - /* If we are just looking for implementations and this is a property access expression, we need to get the - * symbol of the local type of the symbol the property is being accessed on. This is because our search - * symbol may have a different parent symbol if the local type's symbol does not declare the property - * being accessed (i.e. it is declared in some parent class or interface) - */ - function getParentSymbolsOfPropertyAccess() { - if (implementations) { - var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); - if (propertyAccessExpression) { - var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); - if (localParentType) { - if (localParentType.symbol && localParentType.symbol.flags & (32 /* Class */ | 64 /* Interface */) && localParentType.symbol !== searchSymbol.parent) { - return [localParentType.symbol]; - } - else if (localParentType.flags & 196608 /* UnionOrIntersection */) { - return getSymbolsForClassAndInterfaceComponents(localParentType); - } - } - } - } - } - function getPropertyAccessExpressionFromRightHandSide(node) { - return ts.isRightSideOfPropertyAccess(node) && node.parent; - } - /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ - function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { - ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); - var referenceClass = referenceLocation.parent; - if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { - ts.Debug.assert(referenceClass.name === referenceLocation); - // This is the class declaration containing the constructor. - addReferences(findOwnConstructorCalls(searchSymbol)); - } - else { - // If this class appears in `extends C`, then the extending class' "super" calls are references. - var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); - if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) { - addReferences(superConstructorAccesses(classExtending)); - } - } - } - function addReferences(references) { - if (references.length) { - var referencedSymbol = getReferencedSymbol(searchSymbol); - ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); - } - } - /** `classSymbol` is the class where the constructor was defined. - * Reference the constructor and all calls to `new this()`. - */ - function findOwnConstructorCalls(classSymbol) { - var result = []; - for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 150 /* Constructor */); - var ctrKeyword = decl.getChildAt(0); - ts.Debug.assert(ctrKeyword.kind === 122 /* ConstructorKeyword */); - result.push(ctrKeyword); - } - ts.forEachProperty(classSymbol.exports, function (member) { - var decl = member.valueDeclaration; - if (decl && decl.kind === 149 /* MethodDeclaration */) { - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 98 /* ThisKeyword */, function (thisKeyword) { - if (ts.isNewExpressionTarget(thisKeyword)) { - result.push(thisKeyword); - } - }); - } - } - }); - return result; - } - /** Find references to `super` in the constructor of an extending class. */ - function superConstructorAccesses(cls) { - var symbol = cls.symbol; - var ctr = symbol.members["__constructor"]; - if (!ctr) { - return []; - } - var result = []; - for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 150 /* Constructor */); - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 96 /* SuperKeyword */, function (node) { - if (ts.isCallExpressionTarget(node)) { - result.push(node); - } - }); - } - } - ; - return result; - } - function getReferencedSymbol(symbol) { - var symbolId = ts.getSymbolId(symbol); - var index = symbolToIndex[symbolId]; - if (index === undefined) { - index = result.length; - symbolToIndex[symbolId] = index; - result.push({ - definition: getDefinition(symbol), - references: [] - }); - } - return result[index]; - } - function addReferenceToRelatedSymbol(node, relatedSymbol) { - var references = getReferencedSymbol(relatedSymbol).references; - if (implementations) { - getImplementationReferenceEntryForNode(node, references); - } - else { - references.push(getReferenceEntryFromNode(node)); - } - } - } - function getImplementationReferenceEntryForNode(refNode, result) { - // Check if we found a function/propertyAssignment/method with an implementation or initializer - if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); - } - else if (refNode.kind === 70 /* Identifier */) { - if (refNode.parent.kind === 259 /* ShorthandPropertyAssignment */) { - // Go ahead and dereference the shorthand assignment by going to its definition - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); - } - // Check if the node is within an extends or implements clause - var containingClass = getContainingClassIfInHeritageClause(refNode); - if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); - return; - } - // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface - var containingTypeReference = getContainingTypeReference(refNode); - if (containingTypeReference) { - var parent_19 = containingTypeReference.parent; - if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_19.initializer)); - } - else if (ts.isFunctionLike(parent_19) && parent_19.type === containingTypeReference && parent_19.body) { - if (parent_19.body.kind === 205 /* Block */) { - ts.forEachReturnStatement(parent_19.body, function (returnStatement) { - if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); - } - }); - } - else if (isImplementationExpression(parent_19.body)) { - maybeAdd(getReferenceEntryFromNode(parent_19.body)); - } - } - else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_19.expression)); - } - } - } - // Type nodes can contain multiple references to the same type. For example: - // let x: Foo & (Foo & Bar) = ... - // Because we are returning the implementation locations and not the identifier locations, - // duplicate entries would be returned here as each of the type references is part of - // the same implementation. For that reason, check before we add a new entry - function maybeAdd(a) { - if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { - result.push(a); - } - } - } - function getSymbolsForClassAndInterfaceComponents(type, result) { - if (result === void 0) { result = []; } - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var componentType = _a[_i]; - if (componentType.symbol && componentType.symbol.getFlags() & (32 /* Class */ | 64 /* Interface */)) { - result.push(componentType.symbol); - } - if (componentType.getFlags() & 196608 /* UnionOrIntersection */) { - getSymbolsForClassAndInterfaceComponents(componentType, result); - } - } - return result; - } - function getContainingTypeReference(node) { - var topLevelTypeReference = undefined; - while (node) { - if (ts.isTypeNode(node)) { - topLevelTypeReference = node; - } - node = node.parent; - } - return topLevelTypeReference; - } - function getContainingClassIfInHeritageClause(node) { - if (node && node.parent) { - if (node.kind === 199 /* ExpressionWithTypeArguments */ - && node.parent.kind === 256 /* HeritageClause */ - && ts.isClassLike(node.parent.parent)) { - return node.parent.parent; - } - else if (node.kind === 70 /* Identifier */ || node.kind === 177 /* PropertyAccessExpression */) { - return getContainingClassIfInHeritageClause(node.parent); - } - } + } + function getReferencesForSuperKeyword(superKeyword, typeChecker, cancellationToken) { + var searchSpaceNode = ts.getSuperContainer(superKeyword, /*stopOnFunctions*/ false); + if (!searchSpaceNode) { return undefined; } - /** - * Returns true if this is an expression that can be considered an implementation - */ - function isImplementationExpression(node) { - // Unwrap parentheses - if (node.kind === 183 /* ParenthesizedExpression */) { - return isImplementationExpression(node.expression); - } - return node.kind === 185 /* ArrowFunction */ || - node.kind === 184 /* FunctionExpression */ || - node.kind === 176 /* ObjectLiteralExpression */ || - node.kind === 197 /* ClassExpression */ || - node.kind === 175 /* ArrayLiteralExpression */; - } - /** - * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol - * is an interface, determines if some ancestor of the child symbol extends or inherits from it. - * Also takes in a cache of previous results which makes this slightly more efficient and is - * necessary to avoid potential loops like so: - * class A extends B { } - * class B extends A { } - * - * We traverse the AST rather than using the type checker because users are typically only interested - * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling - * implementations of types that share a common ancestor with the type whose implementation we are - * searching for need to be filtered out of the results. The type checker doesn't let us make the - * distinction between structurally compatible implementations and explicit implementations, so we - * must use the AST. - * - * @param child A class or interface Symbol - * @param parent Another class or interface Symbol - * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results - */ - function explicitlyInheritsFrom(child, parent, cachedResults) { - var parentIsInterface = parent.getFlags() & 64 /* Interface */; - return searchHierarchy(child); - function searchHierarchy(symbol) { - if (symbol === parent) { - return true; - } - var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); - if (key in cachedResults) { - return cachedResults[key]; - } - // Set the key so that we don't infinitely recurse - cachedResults[key] = false; - var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - if (parentIsInterface) { - var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); - if (interfaceReferences) { - for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { - var typeReference = interfaceReferences_1[_i]; - if (searchTypeReference(typeReference)) { - return true; - } - } - } - } - return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - } - else if (declaration.kind === 228 /* InterfaceDeclaration */) { - if (parentIsInterface) { - return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); - } - } - return false; - }); - cachedResults[key] = inherits; - return inherits; - } - function searchTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type && type.symbol) { - return searchHierarchy(type.symbol); - } - } - return false; - } - } - function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, /*stopOnFunctions*/ false); - if (!searchSpaceNode) { + // Whether 'super' occurs in a static context within a class. + var staticFlag = 32 /* Static */; + switch (searchSpaceNode.kind) { + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + default: return undefined; + } + var references = []; + var sourceFile = searchSpaceNode.getSourceFile(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + for (var _i = 0, possiblePositions_3 = possiblePositions; _i < possiblePositions_3.length; _i++) { + var position = possiblePositions_3[_i]; + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 96 /* SuperKeyword */) { + continue; } - // Whether 'super' occurs in a static context within a class. - var staticFlag = 32 /* Static */; - switch (searchSpaceNode.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); + // If we have a 'super' container, we must have an enclosing class. + // Now make sure the owning class is the same as the search-space + // and has the same static qualifier as the original 'super's owner. + if (container && (32 /* Static */ & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(getReferenceEntryFromNode(node)); + } + } + var definition = getDefinition(searchSpaceNode.symbol, superKeyword, typeChecker); + return [{ definition: definition, references: references }]; + } + function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, typeChecker, cancellationToken) { + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); + // Whether 'this' occurs in a static context within a class. + var staticFlag = 32 /* Static */; + switch (searchSpaceNode.kind) { + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; - default: + } + // fall through + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + case 264 /* SourceFile */: + if (ts.isExternalModule(searchSpaceNode)) { return undefined; - } - var references = []; + } + // Fall through + case 227 /* FunctionDeclaration */: + case 185 /* 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. + default: + return undefined; + } + var references = []; + var possiblePositions; + if (searchSpaceNode.kind === 264 /* SourceFile */) { + ts.forEach(sourceFiles, function (sourceFile) { + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { var sourceFile = searchSpaceNode.getSourceFile(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); + var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: thisOrSuperKeyword.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: "this", + textSpan: ts.createTextSpanFromNode(thisOrSuperKeyword), + displayParts: displayParts + }, + references: references + }]; + function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 96 /* SuperKeyword */) { + if (!node || !ts.isThis(node)) { return; } - var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); - // If we have a 'super' container, we must have an enclosing class. - // Now make sure the owning class is the same as the search-space - // and has the same static qualifier as the original 'super's owner. - if (container && (32 /* Static */ & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); + var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); + switch (searchSpaceNode.kind) { + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + if (searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 198 /* ClassExpression */: + case 228 /* 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 && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 264 /* SourceFile */: + if (container.kind === 264 /* SourceFile */ && !ts.isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); + } + break; } }); - var definition = getDefinition(searchSpaceNode.symbol); - return [{ definition: definition, references: references }]; } - function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); - // Whether 'this' occurs in a static context within a class. - var staticFlag = 32 /* Static */; - switch (searchSpaceNode.kind) { - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - if (ts.isObjectLiteralMethod(searchSpaceNode)) { - break; + } + function getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (!type) { + // nothing to do here. moving on + return undefined; + } + var references = []; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); + } + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: type.text, + textSpan: ts.createTextSpanFromNode(node), + displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] + }, + references: references + }]; + function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { + for (var _i = 0, possiblePositions_4 = possiblePositions; _i < possiblePositions_4.length; _i++) { + var position = possiblePositions_4[_i]; + cancellationToken.throwIfCancellationRequested(); + var node_2 = ts.getTouchingWord(sourceFile, position); + if (!node_2 || node_2.kind !== 9 /* StringLiteral */) { + return; + } + var type_2 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + if (type_2 === searchType) { + references.push(getReferenceEntryFromNode(node_2)); + } + } + } + } + function populateSearchSymbolSet(symbol, location, typeChecker, implementations) { + // The search set contains at least the current symbol + var result = [symbol]; + // If the location is name of property symbol from object literal destructuring pattern + // Search the property symbol + // for ( { property: p2 } of elems) { } + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 261 /* ShorthandPropertyAssignment */) { + var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, typeChecker); + if (propertySymbol) { + result.push(propertySymbol); + } + } + // If the location is in a context sensitive location (i.e. in an object literal) try + // to get a contextual type for it, and add the property symbol from the contextual + // type to the search set + if (containingObjectLiteralElement) { + ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (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 + * property name and variable declaration of the identifier. + * Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service + * should show both 'name' in 'obj' and 'name' in variable declaration + * const name = "Foo"; + * const obj = { name }; + * In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment + * so that when matching with potential reference symbol, both symbols from property declaration and variable declaration + * will be included correctly. + */ + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } + } + // If the symbol.valueDeclaration is a property parameter declaration, + // we should include both parameter declaration symbol and property declaration symbol + // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. + // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 145 /* Parameter */ && + ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + ts.addRange(result, typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); + } + // If this is symbol of binding element without propertyName declaration in Object binding pattern + // Include the property in the search + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker); + if (bindingElementPropertySymbol) { + result.push(bindingElementPropertySymbol); + } + // If this is a union property, add all the symbols from all its source symbols in all unioned types. + // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list + for (var _i = 0, _a = typeChecker.getRootSymbols(symbol); _i < _a.length; _i++) { + var rootSymbol = _a[_i]; + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap(), typeChecker); + } + } + return result; + } + /** + * Find symbol of the given property-name and add the symbol to the given result array + * @param symbol a symbol to start searching for the given propertyName + * @param propertyName a name of property to search for + * @param result an array of symbol of found property symbols + * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. + * The value of previousIterationSymbol is undefined when the function is first called. + */ + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, typeChecker) { + if (!symbol) { + return; + } + // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited + // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. + // For example: + // interface C extends C { + // /*findRef*/propName: string; + // } + // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, + // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, + // the function will add any found symbol of the property-name, then its sub-routine will call + // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already + // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. + if (previousIterationSymbolsCache.has(symbol.name)) { + return; + } + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === 229 /* InterfaceDeclaration */) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); + } + }); + } + return; + function getPropertySymbolFromTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type) { + var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); + if (propertySymbol) { + result.push.apply(result, typeChecker.getRootSymbols(propertySymbol)); } - // fall through - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class - break; - case 262 /* SourceFile */: - if (ts.isExternalModule(searchSpaceNode)) { + // Visit the typeReference as well to see if it directly or indirectly use that property + previousIterationSymbolsCache.set(symbol.name, symbol); + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, typeChecker); + } + } + } + } + function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker) { + if (ts.contains(searchSymbols, referenceSymbol)) { + // If we are searching for constructor uses, they must be 'new' expressions. + return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) ? referenceSymbol : undefined; + } + // If the reference symbol is an alias, check if what it is aliasing is one of the search + // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. + var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation, typeChecker); + if (aliasSymbol) { + return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker); + } + // If the reference location is in an object literal, try to get the contextual type for the + // object literal, lookup the property symbol in the contextual type, and use this symbol to + // compare to our searchSymbol + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { + return ts.find(typeChecker.getRootSymbols(contextualSymbol), function (symbol) { return ts.contains(searchSymbols, symbol); }); + }); + if (contextualSymbol) { + return contextualSymbol; + } + // If the reference location is the name of property from object literal destructuring pattern + // Get the property symbol from the object literal's type and look if thats the search symbol + // In below eg. get 'property' from type of elems iterating type + // for ( { property: p2 } of elems) { } + var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, typeChecker); + if (propertySymbol && ts.contains(searchSymbols, propertySymbol)) { + return propertySymbol; + } + } + // If the reference location is the binding element and doesn't have property name + // then include the binding element in the related symbols + // let { a } : { a }; + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, typeChecker); + if (bindingElementPropertySymbol && ts.contains(searchSymbols, bindingElementPropertySymbol)) { + return bindingElementPropertySymbol; + } + // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) + // Or a union property, use its underlying unioned symbols + return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { + // if it is in the list, then we are done + if (ts.contains(searchSymbols, rootSymbol)) { + return rootSymbol; + } + // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the + // parent symbol + if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + // Parents will only be defined if implementations is true + if (parents) { + if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache, typeChecker); })) { return undefined; } - // Fall through - case 226 /* FunctionDeclaration */: - case 184 /* 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. - default: - return undefined; - } - var references = []; - var possiblePositions; - if (searchSpaceNode.kind === 262 /* SourceFile */) { - ts.forEach(sourceFiles, function (sourceFile) { - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); - }); - } - else { - var sourceFile = searchSpaceNode.getSourceFile(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); - } - var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: "this", - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: displayParts - }, - references: references - }]; - function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || !ts.isThis(node)) { - return; - } - var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); - switch (searchSpaceNode.kind) { - case 184 /* FunctionExpression */: - case 226 /* FunctionDeclaration */: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 197 /* ClassExpression */: - case 227 /* 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 && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 262 /* SourceFile */: - if (container.kind === 262 /* SourceFile */ && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); - } - } - function getReferencesForStringLiteral(node, sourceFiles) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (!type) { - // nothing to do here. moving on - return undefined; - } - var references = []; - for (var _i = 0, sourceFiles_9 = sourceFiles; _i < sourceFiles_9.length; _i++) { - var sourceFile = sourceFiles_9[_i]; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd()); - getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); - } - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: type.text, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] - }, - references: references - }]; - function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { - for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { - var position = possiblePositions_1[_i]; - cancellationToken.throwIfCancellationRequested(); - var node_3 = ts.getTouchingWord(sourceFile, position); - if (!node_3 || node_3.kind !== 9 /* StringLiteral */) { - return; - } - var type_1 = ts.getStringLiteralTypeForNode(node_3, typeChecker); - if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_3)); - } } + var result = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap(), typeChecker); + return ts.find(result, function (symbol) { return ts.contains(searchSymbols, symbol); }); } - } - function populateSearchSymbolSet(symbol, location) { - // The search set contains at least the current symbol - var result = [symbol]; - // If the location is name of property symbol from object literal destructuring pattern - // Search the property symbol - // for ( { property: p2 } of elems) { } - var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 259 /* ShorthandPropertyAssignment */) { - var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); - if (propertySymbol) { - result.push(propertySymbol); - } - } - // If the symbol is an alias, add what it aliases to the list - // import {a} from "mod"; - // export {a} - // If the symbol is an alias to default declaration, add what it aliases to the list - // declare "mod" { export default class B { } } - // import B from "mod"; - //// For export specifiers, the exported name can be referring to a local symbol, e.g.: - //// import {a} from "mod"; - //// export {a as somethingElse} - //// We want the *local* declaration of 'a' as declared in the import, - //// *not* as declared within "mod" (or farther) - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(symbol, location); - if (aliasSymbol) { - result = result.concat(populateSearchSymbolSet(aliasSymbol, location)); - } - // If the location is in a context sensitive location (i.e. in an object literal) try - // to get a contextual type for it, and add the property symbol from the contextual - // type to the search set - if (containingObjectLiteralElement) { - ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (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 - * property name and variable declaration of the identifier. - * Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service - * should show both 'name' in 'obj' and 'name' in variable declaration - * const name = "Foo"; - * const obj = { name }; - * In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment - * so that when matching with potential reference symbol, both symbols from property declaration and variable declaration - * will be included correctly. - */ - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); - } - } - // If the symbol.valueDeclaration is a property parameter declaration, - // we should include both parameter declaration symbol and property declaration symbol - // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. - // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 144 /* Parameter */ && - ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { - result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); - } - // If this is symbol of binding element without propertyName declaration in Object binding pattern - // Include the property in the search - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol); - if (bindingElementPropertySymbol) { - result.push(bindingElementPropertySymbol); - } - // If this is a union property, add all the symbols from all its source symbols in all unioned types. - // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list - ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap()); - } - }); - return result; - } - /** - * Find symbol of the given property-name and add the symbol to the given result array - * @param symbol a symbol to start searching for the given propertyName - * @param propertyName a name of property to search for - * @param result an array of symbol of found property symbols - * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. - * The value of previousIterationSymbol is undefined when the function is first called. - */ - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache) { - if (!symbol) { - return; - } - // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited - // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. - // For example: - // interface C extends C { - // /*findRef*/propName: string; - // } - // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, - // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, - // the function will add any found symbol of the property-name, then its sub-routine will call - // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already - // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. - if (symbol.name in previousIterationSymbolsCache) { - return; - } - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === 228 /* InterfaceDeclaration */) { - ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); - } - }); - } - return; - function getPropertySymbolFromTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type) { - var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); - if (propertySymbol) { - result.push.apply(result, typeChecker.getRootSymbols(propertySymbol)); - } - // Visit the typeReference as well to see if it directly or indirectly use that property - previousIterationSymbolsCache[symbol.name] = symbol; - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); - } - } - } - } - function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache) { - if (ts.contains(searchSymbols, referenceSymbol)) { - // If we are searching for constructor uses, they must be 'new' expressions. - return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) && referenceSymbol; - } - // If the reference symbol is an alias, check if what it is aliasing is one of the search - // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); - if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache); - } - // If the reference location is in an object literal, try to get the contextual type for the - // object literal, lookup the property symbol in the contextual type, and use this symbol to - // compare to our searchSymbol - var containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); - if (containingObjectLiteralElement) { - var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (contextualSymbol) { - return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - }); - if (contextualSymbol) { - return contextualSymbol; - } - // If the reference location is the name of property from object literal destructuring pattern - // Get the property symbol from the object literal's type and look if thats the search symbol - // In below eg. get 'property' from type of elems iterating type - // for ( { property: p2 } of elems) { } - var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation); - if (propertySymbol && searchSymbols.indexOf(propertySymbol) >= 0) { - return propertySymbol; - } - } - // If the reference location is the binding element and doesn't have property name - // then include the binding element in the related symbols - // let { a } : { a }; - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol); - if (bindingElementPropertySymbol && searchSymbols.indexOf(bindingElementPropertySymbol) >= 0) { - return bindingElementPropertySymbol; - } - // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) - // Or a union property, use its underlying unioned symbols - return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { - // if it is in the list, then we are done - if (searchSymbols.indexOf(rootSymbol) >= 0) { - return rootSymbol; - } - // Finally, try all properties with the same name in any type the containing type extended or implemented, and - // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the - // parent symbol - if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - // Parents will only be defined if implementations is true - if (parents) { - if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache); })) { - return undefined; - } - } - var result_4 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_4, /*previousIterationSymbolsCache*/ ts.createMap()); - return ts.forEach(result_4, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - } - return undefined; - }); - } - function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 142 /* ComputedPropertyName */) { - var nameExpression = node.name.expression; - // treat computed property names where expression is string/numeric literal as just string/numeric literal - if (ts.isStringOrNumericLiteral(nameExpression)) { - return nameExpression.text; - } - return undefined; - } - return node.name.text; - } - function getPropertySymbolsFromContextualType(node) { - var objectLiteral = node.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - var name = getNameFromObjectLiteralElement(node); - if (name && contextualType) { - var result_5 = []; - var symbol_2 = contextualType.getProperty(name); - if (symbol_2) { - result_5.push(symbol_2); - } - if (contextualType.flags & 65536 /* Union */) { - ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name); - if (symbol) { - result_5.push(symbol); - } - }); - } - return result_5; + return undefined; + }); + } + function getNameFromObjectLiteralElement(node) { + if (node.name.kind === 143 /* ComputedPropertyName */) { + var nameExpression = node.name.expression; + // treat computed property names where expression is string/numeric literal as just string/numeric literal + if (ts.isStringOrNumericLiteral(nameExpression)) { + return nameExpression.text; } return undefined; } - /** Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations - * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class - * then we need to widen the search to include type positions as well. - * On the contrary, if we are searching for "Bar" in type position and we trace bar to an interface, and an uninstantiated - * module, we want to keep the search limited to only types, as the two declarations (interface and uninstantiated module) - * do not intersect in any of the three spaces. - */ - function getIntersectingMeaningFromDeclarations(meaning, declarations) { - if (declarations) { - var lastIterationMeaning = void 0; - do { - // The result is order-sensitive, for instance if initialMeaning === Namespace, and declarations = [class, instantiated module] - // we need to consider both as they initialMeaning intersects with the module in the namespace space, and the module - // intersects with the class in the value space. - // To achieve that we will keep iterating until the result stabilizes. - // Remember the last meaning - lastIterationMeaning = meaning; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; - var declarationMeaning = ts.getMeaningFromDeclaration(declaration); - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; - } - } - } while (meaning !== lastIterationMeaning); + return node.name.text; + } + /** Gets all symbols for one property. Does not get symbols for every property. */ + function getPropertySymbolsFromContextualType(node, typeChecker) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + var result_4 = []; + var symbol = contextualType.getProperty(name); + if (symbol) { + result_4.push(symbol); } - return meaning; + if (contextualType.flags & 65536 /* Union */) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_4.push(symbol); + } + }); + } + return result_4; } + return undefined; } - FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; - function convertReferences(referenceSymbols) { - if (!referenceSymbols) { - return undefined; + /** + * Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations + * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class + * then we need to widen the search to include type positions as well. + * On the contrary, if we are searching for "Bar" in type position and we trace bar to an interface, and an uninstantiated + * module, we want to keep the search limited to only types, as the two declarations (interface and uninstantiated module) + * do not intersect in any of the three spaces. + */ + function getIntersectingMeaningFromDeclarations(meaning, declarations) { + if (declarations) { + var lastIterationMeaning = void 0; + do { + // The result is order-sensitive, for instance if initialMeaning === Namespace, and declarations = [class, instantiated module] + // we need to consider both as they initialMeaning intersects with the module in the namespace space, and the module + // intersects with the class in the value space. + // To achieve that we will keep iterating until the result stabilizes. + // Remember the last meaning + lastIterationMeaning = meaning; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + var declarationMeaning = ts.getMeaningFromDeclaration(declaration); + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } while (meaning !== lastIterationMeaning); } - var referenceEntries = []; - for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) { - var referenceSymbol = referenceSymbols_1[_i]; - ts.addRange(referenceEntries, referenceSymbol.references); - } - return referenceEntries; + return meaning; } - FindAllReferences.convertReferences = convertReferences; function isImplementation(node) { if (!node) { return false; @@ -71367,7 +72875,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 224 /* VariableDeclaration */) { + else if (node.kind === 225 /* VariableDeclaration */) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } @@ -71377,18 +72885,18 @@ var ts; } else { switch (node.kind) { - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 230 /* EnumDeclaration */: - case 231 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 231 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 206 /* VariableStatement */) { - ts.Debug.assert(node.parent.kind === 225 /* VariableDeclarationList */); + if (node.parent && node.parent.parent && node.parent.parent.kind === 207 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 226 /* VariableDeclarationList */); return node.parent.parent; } } @@ -71427,10 +72935,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 191 /* PostfixUnaryExpression */ || parent.kind === 190 /* PrefixUnaryExpression */) { + if (parent.kind === 192 /* PostfixUnaryExpression */ || parent.kind === 191 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 192 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 193 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 57 /* FirstAssignment */ <= operator && operator <= 69 /* LastAssignment */; } @@ -71445,33 +72953,6 @@ var ts; forEachDescendantOfKind(child, kind, action); }); } - /** - * Returns the containing object literal property declaration given a possible name node, e.g. "a" in x = { "a": 1 } - */ - function getContainingObjectLiteralElement(node) { - switch (node.kind) { - case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - if (node.parent.kind === 142 /* ComputedPropertyName */) { - return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; - } - // intential fall through - case 70 /* Identifier */: - return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; - } - return undefined; - } - function isObjectLiteralPropertyDeclaration(node) { - switch (node.kind) { - case 258 /* PropertyAssignment */: - case 259 /* ShorthandPropertyAssignment */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - return true; - } - return false; - } /** Get `C` given `N` if `N` is in the position `class C extends N` or `class C extends foo.N` where `N` is an identifier. */ function tryGetClassByExtendingIdentifier(node) { return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); @@ -71482,6 +72963,9 @@ var ts; } return false; } + function isImportDefaultSymbol(symbol) { + return symbol.declarations[0].kind === 238 /* ImportClause */; + } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); /* @internal */ @@ -71502,11 +72986,9 @@ var ts; // Type reference directives var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { - var referenceFile = program.getResolvedTypeReferenceDirectives()[typeReferenceDirective.fileName]; - if (referenceFile && referenceFile.resolvedFileName) { - return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; - } - return undefined; + var referenceFile = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); + return referenceFile && referenceFile.resolvedFileName && + [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; } var node = ts.getTouchingPropertyName(sourceFile, position); if (node === sourceFile) { @@ -71516,7 +72998,7 @@ var ts; if (ts.isJumpStatementTarget(node)) { var labelName = node.text; var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ts.ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, ts.ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } var typeChecker = program.getTypeChecker(); var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); @@ -71542,7 +73024,7 @@ var ts; // if (node.kind === 70 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 240 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 239 /* NamedImports */))) { + (declaration.kind === 241 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 240 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -71551,7 +73033,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 === 259 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 261 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -71562,6 +73044,37 @@ var ts; var shorthandContainerName_1 = typeChecker.symbolToString(symbol.parent, node); return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind_1, shorthandSymbolName_1, shorthandContainerName_1); }); } + if (ts.isJsxOpeningLikeElement(node.parent)) { + // If there are errors when trying to figure out stateless component function, just return the first declaration + // For example: + // declare function /*firstSource*/MainButton(buttonProps: ButtonProps): JSX.Element; + // declare function /*secondSource*/MainButton(linkProps: LinkProps): JSX.Element; + // declare function /*thirdSource*/MainButton(props: ButtonProps | LinkProps): JSX.Element; + // let opt =
; // Error - We get undefined for resolved signature indicating an error, then just return the first declaration + var _a = getSymbolInfo(typeChecker, symbol, node), symbolName = _a.symbolName, symbolKind = _a.symbolKind, containerName = _a.containerName; + return [createDefinitionInfo(symbol.valueDeclaration, symbolKind, symbolName, containerName)]; + } + // If the current location we want to find its definition is in an object literal, try to get the contextual type for the + // object literal, lookup the property symbol in the contextual type, and use this for goto-definition. + // For example + // interface Props{ + // /*first*/prop1: number + // prop2: boolean + // } + // function Foo(arg: Props) {} + // Foo( { pr/*1*/op1: 10, prop2: true }) + var element = ts.getContainingObjectLiteralElement(node); + if (element) { + if (typeChecker.getContextualType(element.parent)) { + var result = []; + var propertySymbols = ts.getPropertySymbolsFromContextualType(typeChecker, element); + for (var _i = 0, propertySymbols_1 = propertySymbols; _i < propertySymbols_1.length; _i++) { + var propertySymbol = propertySymbols_1[_i]; + result.push.apply(result, getDefinitionFromSymbol(typeChecker, propertySymbol, node)); + } + return result; + } + } return getDefinitionFromSymbol(typeChecker, symbol, node); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; @@ -71580,13 +73093,13 @@ var ts; return undefined; } if (type.flags & 65536 /* Union */ && !(type.flags & 16 /* Enum */)) { - var result_6 = []; + var result_5 = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(/*to*/ result_6, /*from*/ getDefinitionFromSymbol(typeChecker, t.symbol, node)); + ts.addRange(/*to*/ result_5, /*from*/ getDefinitionFromSymbol(typeChecker, t.symbol, node)); } }); - return result_6; + return result_5; } if (!type.symbol) { return undefined; @@ -71633,29 +73146,42 @@ var ts; function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { var declarations = []; var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 150 /* Constructor */) || - (!selectConstructors && (d.kind === 226 /* FunctionDeclaration */ || d.kind === 149 /* MethodDeclaration */ || d.kind === 148 /* MethodSignature */))) { + for (var _i = 0, signatureDeclarations_1 = signatureDeclarations; _i < signatureDeclarations_1.length; _i++) { + var d = signatureDeclarations_1[_i]; + if (selectConstructors ? d.kind === 151 /* Constructor */ : isSignatureDeclaration(d)) { declarations.push(d); if (d.body) definition = d; } - }); - if (definition) { - result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); - return true; } - else if (declarations.length) { - result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); + if (declarations.length) { + result.push(createDefinitionInfo(definition || ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); return true; } return false; } } + function isSignatureDeclaration(node) { + switch (node.kind) { + case 151 /* Constructor */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + return true; + default: + return false; + } + } + /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */ function createDefinitionInfo(node, symbolKind, symbolName, containerName) { + return createDefinitionInfoFromName(node.name || node, symbolKind, symbolName, containerName); + } + /** Creates a DefinitionInfo directly from the name of a declaration. */ + function createDefinitionInfoFromName(name, symbolKind, symbolName, containerName) { + var sourceFile = name.getSourceFile(); return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromNode(name, sourceFile), kind: symbolKind, name: symbolName, containerKind: undefined, @@ -71703,7 +73229,15 @@ var ts; } function tryGetSignatureDeclaration(typeChecker, node) { var callLike = getAncestorCallLikeExpression(node); - return callLike && typeChecker.getResolvedSignature(callLike).declaration; + var signature = callLike && typeChecker.getResolvedSignature(callLike); + if (signature) { + var decl = signature.declaration; + if (decl && isSignatureDeclaration(decl)) { + return decl; + } + } + // Don't go to a function type, go to the value having that type. + return undefined; } })(GoToDefinition = ts.GoToDefinition || (ts.GoToDefinition = {})); })(ts || (ts = {})); @@ -71715,7 +73249,7 @@ var ts; function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 259 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 261 /* ShorthandPropertyAssignment */) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -71728,7 +73262,7 @@ var ts; } else { // Perform "Find all References" and retrieve only those that are implementations - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/ true); + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ false, /*implementations*/ true); var result = ts.flatMap(referencedSymbols, function (symbol) { return ts.map(symbol.references, function (_a) { var textSpan = _a.textSpan, fileName = _a.fileName; @@ -71882,19 +73416,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 226 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 150 /* Constructor */: - case 227 /* ClassDeclaration */: - case 206 /* VariableStatement */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 151 /* Constructor */: + case 228 /* ClassDeclaration */: + case 207 /* VariableStatement */: break findOwner; - case 262 /* SourceFile */: + case 264 /* SourceFile */: return undefined; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - if (commentOwner.parent.kind === 231 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 232 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -71941,7 +73475,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 206 /* VariableStatement */) { + if (commentOwner.kind === 207 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -71959,17 +73493,17 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 183 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 184 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return rightHandSide.parameters; - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150 /* Constructor */) { + if (member.kind === 151 /* Constructor */) { return member.parameters; } } @@ -72027,7 +73561,7 @@ var ts; }); if (!safeList) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = result.config ? ts.createMap(result.config) : EmptySafeList; + safeList = result.config ? ts.createMapFromTemplate(result.config) : EmptySafeList; } var filesToWatch = []; // Directories to search for package.json, bower.json and other typing information @@ -72054,33 +73588,33 @@ var ts; if (unresolvedImports) { for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { var moduleId = unresolvedImports_1[_a]; - var typingName = moduleId in nodeCoreModules ? "node" : moduleId; - if (!(typingName in inferredTypings)) { - inferredTypings[typingName] = undefined; + var typingName = nodeCoreModules.has(moduleId) ? "node" : moduleId; + if (!inferredTypings.has(typingName)) { + inferredTypings.set(typingName, undefined); } } } // Add the cached typing locations for inferred typings that are already installed - for (var name_47 in packageNameToTypingLocation) { - if (name_47 in inferredTypings && !inferredTypings[name_47]) { - inferredTypings[name_47] = packageNameToTypingLocation[name_47]; + packageNameToTypingLocation.forEach(function (typingLocation, name) { + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined) { + inferredTypings.set(name, typingLocation); } - } + }); // Remove typings that the user has added to the exclude list for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { var excludeTypingName = exclude_1[_b]; - delete inferredTypings[excludeTypingName]; + inferredTypings.delete(excludeTypingName); } var newTypingNames = []; var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); + inferredTypings.forEach(function (inferred, typing) { + if (inferred !== undefined) { + cachedTypingPaths.push(inferred); } else { newTypingNames.push(typing); } - } + }); return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; /** * Merge a given list of typingNames to the inferredTypings map @@ -72091,8 +73625,8 @@ var ts; } for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { var typing = typingNames_1[_i]; - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; + if (!inferredTypings.has(typing)) { + inferredTypings.set(typing, undefined); } } } @@ -72131,7 +73665,7 @@ var ts; var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); if (safeList !== EmptySafeList) { - mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return safeList.has(f); })); } var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2 /* JSX */; }); if (hasJsxFile) { @@ -72174,7 +73708,7 @@ var ts; } if (packageJson.typings) { var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; + inferredTypings.set(packageJson.name, absolutePath); } else { typingNames.push(packageJson.name); @@ -72194,47 +73728,49 @@ var ts; function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; - // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - ts.forEach(sourceFiles, function (sourceFile) { + var _loop_4 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { - return; + return "continue"; } - var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_48 in nameToDeclarations) { - var declarations = nameToDeclarations[name_48]; + ts.forEachEntry(sourceFile.getNamedDeclarations(), function (declarations, name) { 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_48); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); if (!matches) { - continue; + return; // continue to next named declarations } - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { + var declaration = declarations_12[_i]; // It was a match! If the pattern has dots in it, then also see if the // declaration container matches as well. if (patternMatcher.patternContainsDots) { var containers = getContainers(declaration); if (!containers) { - return undefined; + return true; // Break out of named declarations and go to the next source file. } - matches = patternMatcher.getMatches(containers, name_48); + matches = patternMatcher.getMatches(containers, name); if (!matches) { - continue; + return; // continue to next named declarations } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_48, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } - } - }); + }); + }; + // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] + for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { + var sourceFile = sourceFiles_8[_i]; + _loop_4(sourceFile); + } // Remove imports when the imported declaration is already in the list and has the same name. rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 237 /* ImportClause */ || decl.kind === 240 /* ImportSpecifier */ || decl.kind === 235 /* ImportEqualsDeclaration */) { + if (decl.kind === 238 /* ImportClause */ || decl.kind === 241 /* ImportSpecifier */ || decl.kind === 236 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -72276,7 +73812,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 142 /* ComputedPropertyName */) { + else if (declaration.name.kind === 143 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ true); } else { @@ -72297,7 +73833,7 @@ var ts; } return true; } - if (expression.kind === 177 /* PropertyAccessExpression */) { + if (expression.kind === 178 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -72310,7 +73846,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 === 142 /* ComputedPropertyName */) { + if (declaration.name.kind === 143 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } @@ -72356,7 +73892,7 @@ var ts; matchKind: ts.PatternMatchKind[rawItem.matchKind], isCaseSensitive: rawItem.isCaseSensitive, fileName: rawItem.fileName, - textSpan: ts.createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), + textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: container && container.name ? container.name.text : "", containerKind: container && container.name ? ts.getNodeKind(container) : "" @@ -72463,7 +73999,7 @@ var ts; return; } switch (node.kind) { - case 150 /* Constructor */: + case 151 /* Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -72475,21 +74011,21 @@ var ts; } } break; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 149 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 237 /* ImportClause */: + case 238 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -72501,7 +74037,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 238 /* NamespaceImport */) { + if (namedBindings.kind === 239 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -72512,12 +74048,12 @@ var ts; } } break; - case 174 /* BindingElement */: - case 224 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 225 /* VariableDeclaration */: var decl = node; - var name_49 = decl.name; - if (ts.isBindingPattern(name_49)) { - addChildrenRecursively(name_49); + var name = decl.name; + if (ts.isBindingPattern(name)) { + addChildrenRecursively(name); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { // For `const x = function() {}`, just use the function node, not the const. @@ -72527,12 +74063,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 185 /* ArrowFunction */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -72542,9 +74078,9 @@ var ts; } endNode(); break; - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 228 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -72552,21 +74088,21 @@ var ts; } endNode(); break; - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 244 /* ExportSpecifier */: - case 235 /* ImportEqualsDeclaration */: - case 155 /* IndexSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 229 /* TypeAliasDeclaration */: + case 245 /* ExportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 156 /* IndexSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 230 /* TypeAliasDeclaration */: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 286 /* JSDocTypedefTag */) { + if (tag.kind === 289 /* JSDocTypedefTag */) { addLeafNode(tag); } }); @@ -72584,9 +74120,9 @@ var ts; // Anonymous items are never merged. return true; } - var itemsWithSameName = nameToItems[name]; + var itemsWithSameName = nameToItems.get(name); if (!itemsWithSameName) { - nameToItems[name] = child; + nameToItems.set(name, child); return true; } if (itemsWithSameName instanceof Array) { @@ -72604,7 +74140,7 @@ var ts; if (tryMerge(itemWithSameName, child)) { return false; } - nameToItems[name] = [itemWithSameName, child]; + nameToItems.set(name, [itemWithSameName, child]); return true; } function tryMerge(a, b) { @@ -72617,14 +74153,14 @@ var ts; }); /** a and b have the same name, but they may not be mergeable. */ function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 231 /* ModuleDeclaration */ || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 232 /* ModuleDeclaration */ || areSameModule(a, b)); // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 231 /* ModuleDeclaration */) { + if (a.body.kind !== 232 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -72652,39 +74188,20 @@ var ts; function compareChildren(child1, child2) { var name1 = tryGetName(child1.node), name2 = tryGetName(child2.node); if (name1 && name2) { - var cmp = localeCompareFix(name1, name2); + var cmp = ts.compareStringsCaseInsensitive(name1, name2); return cmp !== 0 ? cmp : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } else { return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } } - // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". - var localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; - var localeCompareFix = localeCompareIsCorrect ? ts.collator.compare : function (a, b) { - // This isn't perfect, but it passes all of our tests. - for (var i = 0; i < Math.min(a.length, b.length); i++) { - var chA = a.charAt(i), chB = b.charAt(i); - if (chA === "\"" && chB === "'") { - return 1; - } - if (chA === "'" && chB === "\"") { - return -1; - } - var cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); - if (cmp !== 0) { - return cmp; - } - } - return a.length - b.length; - }; /** * This differs from getItemName because this is just used for sorting. * We only sort nodes by name that have a more-or-less "direct" name, as opposed to `new()` and the like. * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 231 /* ModuleDeclaration */) { + if (node.kind === 232 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -72692,18 +74209,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 197 /* ClassExpression */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 198 /* ClassExpression */: return getFunctionOrClassName(node); - case 286 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 231 /* ModuleDeclaration */) { + if (node.kind === 232 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -72714,16 +74231,16 @@ var ts; } } switch (node.kind) { - case 262 /* SourceFile */: + case 264 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 185 /* ArrowFunction */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -72731,15 +74248,15 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return "constructor"; - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: return "new()"; - case 153 /* CallSignature */: + case 154 /* CallSignature */: return "()"; - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: return "[]"; - case 286 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return ""; @@ -72751,7 +74268,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 206 /* VariableStatement */) { + if (parentNode && parentNode.kind === 207 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -72780,24 +74297,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 230 /* EnumDeclaration */: - case 228 /* InterfaceDeclaration */: - case 231 /* ModuleDeclaration */: - case 262 /* SourceFile */: - case 229 /* TypeAliasDeclaration */: - case 286 /* JSDocTypedefTag */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 231 /* EnumDeclaration */: + case 229 /* InterfaceDeclaration */: + case 232 /* ModuleDeclaration */: + case 264 /* SourceFile */: + case 230 /* TypeAliasDeclaration */: + case 289 /* JSDocTypedefTag */: return true; - case 150 /* Constructor */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 224 /* VariableDeclaration */: + case 151 /* Constructor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 225 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 185 /* ArrowFunction */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -72807,10 +74324,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 232 /* ModuleBlock */: - case 262 /* SourceFile */: - case 149 /* MethodDeclaration */: - case 150 /* Constructor */: + case 233 /* ModuleBlock */: + case 264 /* SourceFile */: + case 150 /* MethodDeclaration */: + case 151 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -72819,7 +74336,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 224 /* VariableDeclaration */ && childKind !== 174 /* BindingElement */; + return childKind !== 225 /* VariableDeclaration */ && childKind !== 175 /* BindingElement */; }); } } @@ -72830,7 +74347,7 @@ var ts; return { text: getItemName(n.node), kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: ts.map(n.children, convertToTree) }; @@ -72839,7 +74356,7 @@ var ts; return { text: getItemName(n.node), kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, indent: n.indent, @@ -72877,7 +74394,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 === 231 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 232 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -72888,28 +74405,34 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 231 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 232 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 142 /* ComputedPropertyName */; + return !member.name || member.name.kind === 143 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 262 /* SourceFile */ + return node.kind === 264 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) - : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); + : ts.createTextSpanFromNode(node, curSourceFile); + } + function getModifiers(node) { + if (node.parent && node.parent.kind === 225 /* VariableDeclaration */) { + node = node.parent; + } + return ts.getNodeModifiers(node); } function getFunctionOrClassName(node) { if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 224 /* VariableDeclaration */) { + else if (node.parent.kind === 225 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 192 /* BinaryExpression */ && + else if (node.parent.kind === 193 /* BinaryExpression */ && node.parent.operatorToken.kind === 57 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 258 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 260 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512 /* Default */) { @@ -72920,7 +74443,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 184 /* FunctionExpression */ || node.kind === 185 /* ArrowFunction */ || node.kind === 197 /* ClassExpression */; + return node.kind === 185 /* FunctionExpression */ || node.kind === 186 /* ArrowFunction */ || node.kind === 198 /* ClassExpression */; } /** * Matches all whitespace characters in a string. Eg: @@ -72950,7 +74473,7 @@ var ts; if (hintSpanNode && startElement && endElement) { var span_12 = { textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), - hintSpan: ts.createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), + hintSpan: ts.createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse }; @@ -73010,7 +74533,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 185 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 186 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -73022,30 +74545,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 205 /* Block */: + case 206 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_20 = n.parent; + var parent = n.parent; var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent_20.kind === 210 /* DoStatement */ || - parent_20.kind === 213 /* ForInStatement */ || - parent_20.kind === 214 /* ForOfStatement */ || - parent_20.kind === 212 /* ForStatement */ || - parent_20.kind === 209 /* IfStatement */ || - parent_20.kind === 211 /* WhileStatement */ || - parent_20.kind === 218 /* WithStatement */ || - parent_20.kind === 257 /* CatchClause */) { - addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); + if (parent.kind === 211 /* DoStatement */ || + parent.kind === 214 /* ForInStatement */ || + parent.kind === 215 /* ForOfStatement */ || + parent.kind === 213 /* ForStatement */ || + parent.kind === 210 /* IfStatement */ || + parent.kind === 212 /* WhileStatement */ || + parent.kind === 219 /* WithStatement */ || + parent.kind === 259 /* CatchClause */) { + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_20.kind === 222 /* TryStatement */) { + if (parent.kind === 223 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_20; + var tryStatement = parent; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -73055,10 +74578,11 @@ var ts; break; } } + // fall through. } // Block was a standalone block. In this case we want to only collapse // the span of the block, independent of any parent span. - var span_14 = ts.createTextSpanFromBounds(n.getStart(), n.end); + var span_14 = ts.createTextSpanFromNode(n); elements.push({ textSpan: span_14, hintSpan: span_14, @@ -73068,23 +74592,23 @@ var ts; break; } // Fallthrough. - case 232 /* ModuleBlock */: { + case 233 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: - case 230 /* EnumDeclaration */: - case 176 /* ObjectLiteralExpression */: - case 233 /* CaseBlock */: { + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 177 /* ObjectLiteralExpression */: + case 234 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 20 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -73180,10 +74704,11 @@ var ts; return totalMatch; } function getWordSpans(word) { - if (!(word in stringToWordSpans)) { - stringToWordSpans[word] = breakIntoWordSpans(word); + var spans = stringToWordSpans.get(word); + if (!spans) { + stringToWordSpans.set(word, spans = breakIntoWordSpans(word)); } - return stringToWordSpans[word]; + return spans; } function matchTextChunk(candidate, chunk, punctuationStripped) { var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); @@ -73758,7 +75283,7 @@ var ts; else { if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -73789,7 +75314,7 @@ var ts; } if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -73805,7 +75330,7 @@ var ts; token = nextToken(); if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -73835,7 +75360,7 @@ var ts; } if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -73847,7 +75372,7 @@ var ts; } else if (token === 38 /* AsteriskToken */) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -73999,93 +75524,85 @@ var ts; var Rename; (function (Rename) { function getRenameInfo(typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile, position) { - var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); + var getCanonicalDefaultLibName = ts.memoize(function () { return getCanonicalFileName(ts.normalizePath(defaultLibFileName)); }); var node = ts.getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); - if (node) { - if (node.kind === 70 /* Identifier */ || - node.kind === 9 /* StringLiteral */ || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - ts.isThis(node)) { - var symbol = typeChecker.getSymbolAtLocation(node); - // Only allow a symbol to be renamed if it actually has at least one declaration. - if (symbol) { - var declarations = symbol.getDeclarations(); - if (declarations && declarations.length > 0) { - // Disallow rename for elements that are defined in the standard TypeScript library. - if (ts.forEach(declarations, isDefinedInLibraryFile)) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); - var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - if (kind) { - return { - canRename: true, - kind: kind, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: typeChecker.getFullyQualifiedName(symbol), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - else if (node.kind === 9 /* StringLiteral */) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (type) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - else { - var displayName = ts.stripQuotes(type.text); - return { - canRename: true, - kind: ts.ScriptElementKind.variableElement, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: displayName, - kindModifiers: ts.ScriptElementKindModifier.none, - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - } - } - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element)); - function getRenameInfoError(localizedErrorMessage) { - return { - canRename: false, - localizedErrorMessage: localizedErrorMessage, - displayName: undefined, - fullDisplayName: undefined, - kind: undefined, - kindModifiers: undefined, - triggerSpan: undefined - }; - } + var renameInfo = node && nodeIsEligibleForRename(node) + ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) + : undefined; + return renameInfo || getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); function isDefinedInLibraryFile(declaration) { - if (defaultLibFileName) { - var sourceFile_1 = declaration.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_1.fileName)); - if (canonicalName === canonicalDefaultLibName) { - return true; - } + if (!defaultLibFileName) { + return false; } - return false; - } - function createTriggerSpanForNode(node, sourceFile) { - var start = node.getStart(sourceFile); - var width = node.getWidth(sourceFile); - if (node.kind === 9 /* StringLiteral */) { - // Exclude the quotes - start += 1; - width -= 2; - } - return ts.createTextSpan(start, width); + var sourceFile = declaration.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); + return canonicalName === getCanonicalDefaultLibName(); } } Rename.getRenameInfo = getRenameInfo; + function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { + var symbol = typeChecker.getSymbolAtLocation(node); + // Only allow a symbol to be renamed if it actually has at least one declaration. + if (symbol) { + var declarations = symbol.getDeclarations(); + if (declarations && declarations.length > 0) { + // Disallow rename for elements that are defined in the standard TypeScript library. + if (ts.some(declarations, isDefinedInLibraryFile)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); + } + var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); + var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); + return kind ? getRenameInfoSuccess(displayName, typeChecker.getFullyQualifiedName(symbol), kind, ts.SymbolDisplay.getSymbolModifiers(symbol), node, sourceFile) : undefined; + } + } + else if (node.kind === 9 /* StringLiteral */) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (type) { + if (isDefinedInLibraryFile(node)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); + } + var displayName = ts.stripQuotes(type.text); + return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); + } + } + } + function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { + return { + canRename: true, + kind: kind, + displayName: displayName, + localizedErrorMessage: undefined, + fullDisplayName: fullDisplayName, + kindModifiers: kindModifiers, + triggerSpan: createTriggerSpanForNode(node, sourceFile) + }; + } + function getRenameInfoError(diagnostic) { + return { + canRename: false, + localizedErrorMessage: ts.getLocaleSpecificMessage(diagnostic), + displayName: undefined, + fullDisplayName: undefined, + kind: undefined, + kindModifiers: undefined, + triggerSpan: undefined + }; + } + function createTriggerSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var width = node.getWidth(sourceFile); + if (node.kind === 9 /* StringLiteral */) { + // Exclude the quotes + start += 1; + width -= 2; + } + return ts.createTextSpan(start, width); + } + function nodeIsEligibleForRename(node) { + return node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || + ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + ts.isThis(node); + } })(Rename = ts.Rename || (ts.Rename = {})); })(ts || (ts = {})); /// @@ -74232,6 +75749,7 @@ var ts; ArgumentListKind[ArgumentListKind["TypeArguments"] = 0] = "TypeArguments"; ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; + ArgumentListKind[ArgumentListKind["JSXAttributesArguments"] = 3] = "JSXAttributesArguments"; })(ArgumentListKind = SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); @@ -74263,7 +75781,7 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 179 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 180 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -74271,7 +75789,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 70 /* Identifier */ ? expression - : expression.kind === 177 /* PropertyAccessExpression */ + : expression.kind === 178 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -74281,10 +75799,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameToDeclarations = sourceFile.getNamedDeclarations(); - var declarations = nameToDeclarations[name.text]; + var declarations = nameToDeclarations.get(name.text); if (declarations) { - for (var _b = 0, declarations_10 = declarations; _b < declarations_10.length; _b++) { - var declaration = declarations_10[_b]; + for (var _b = 0, declarations_13 = declarations; _b < declarations_13.length; _b++) { + var declaration = declarations_13[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -74304,21 +75822,21 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 179 /* CallExpression */ || node.parent.kind === 180 /* NewExpression */) { + if (node.parent.kind === 180 /* CallExpression */ || node.parent.kind === 181 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: - // 1. The token introduces a list, and should begin a sig help session + // 1. The token introduces a list, and should begin a signature help session // 2. The token is either not associated with a list, or ends a list, so the session should end - // 3. The token is buried inside a list, and should give sig help + // 3. The token is buried inside a list, and should give signature help // // The following are examples of each: // // Case 1: - // foo<#T, U>(#a, b) -> The token introduces a list, and should begin a sig help session + // foo<#T, U>(#a, b) -> The token introduces a list, and should begin a signature help session // Case 2: // fo#o#(a, b)# -> The token is either not associated with a list, or ends a list, so the session should end // Case 3: - // foo(a#, #b#) -> The token is buried inside a list, and should give sig help + // foo(a#, #b#) -> The token is buried inside a list, and should give signature help // Find out if 'node' is an argument, a type argument, or neither if (node.kind === 26 /* LessThanToken */ || node.kind === 18 /* OpenParenToken */) { @@ -74337,7 +75855,7 @@ var ts; } // findListItemInfo can return undefined if we are not in parent's argument list // or type argument list. This includes cases where the cursor is: - // - To the right of the closing paren, non-substitution template, or template tail. + // - To the right of the closing parenthesis, non-substitution template, or template tail. // - Between the type arguments and the arguments (greater than token) // - On the target of the call (parent.func) // - On the 'new' keyword in a 'new' expression @@ -74358,25 +75876,25 @@ var ts; } return undefined; } - else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 181 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 182 /* 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, /*argumentIndex*/ 0, sourceFile); } } - else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 181 /* TaggedTemplateExpression */) { + else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 182 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 194 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 195 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 203 /* TemplateSpan */ && node.parent.parent.parent.kind === 181 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 204 /* TemplateSpan */ && node.parent.parent.parent.kind === 182 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 194 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 195 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 15 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -74385,8 +75903,25 @@ var ts; var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position); return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } + else if (node.parent && ts.isJsxOpeningLikeElement(node.parent)) { + // Provide a signature help for JSX opening element or JSX self-closing element. + // This is not guarantee that JSX tag-name is resolved into stateless function component. (that is done in "getSignatureHelpItems") + // i.e + // export function MainButton(props: ButtonProps, context: any): JSX.Element { ... } + // ' '' - // That will give us 2 non-commas. We then add one for the last comma, givin us an + // That will give us 2 non-commas. We then add one for the last comma, giving us an // arg count of 3. var listChildren = argumentsList.getChildren(); var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 25 /* CommaToken */; }); @@ -74494,7 +76029,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 === 194 /* TemplateExpression */) { + if (template.kind === 195 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -74503,7 +76038,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 262 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 264 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -74516,6 +76051,7 @@ var ts; if (argumentInfo) { return argumentInfo; } + // TODO: Handle generic call with incomplete syntax } return undefined; } @@ -74648,7 +76184,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 197 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 198 /* ClassExpression */) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ts.ScriptElementKind.enumElement; @@ -74705,7 +76241,7 @@ var ts; if (flags & 16384 /* Constructor */) return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4 /* Property */) { - if (flags & 268435456 /* SyntheticProperty */) { + if (flags & 134217728 /* Transient */ && symbol.checkFlags & 2 /* 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(); @@ -74725,6 +76261,9 @@ var ts; } return unionPropertyKind; } + if (location.parent && ts.isJsxAttribute(location.parent)) { + return ts.ScriptElementKind.jsxAttribute; + } return ts.ScriptElementKind.memberVariableElement; } return ts.ScriptElementKind.unknown; @@ -74754,7 +76293,7 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 177 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 178 /* 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)) { @@ -74762,21 +76301,24 @@ var ts; } } // try get the call/construct signature from the type if it matches - var callExpression = void 0; - if (location.kind === 179 /* CallExpression */ || location.kind === 180 /* NewExpression */) { - callExpression = location; + var callExpressionLike = void 0; + if (location.kind === 180 /* CallExpression */ || location.kind === 181 /* NewExpression */) { + callExpressionLike = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { - callExpression = location.parent; + callExpressionLike = location.parent; } - if (callExpression) { + else if (location.parent && ts.isJsxOpeningLikeElement(location.parent) && ts.isFunctionLike(symbol.valueDeclaration)) { + callExpressionLike = location.parent; + } + if (callExpressionLike) { var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); if (!signature && candidateSignatures.length) { // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 180 /* NewExpression */ || callExpression.expression.kind === 96 /* SuperKeyword */; + var useConstructSignatures = callExpressionLike.kind === 181 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 96 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -74803,6 +76345,7 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { + case ts.ScriptElementKind.jsxAttribute: case ts.ScriptElementKind.memberVariableElement: case ts.ScriptElementKind.variableElement: case ts.ScriptElementKind.constElement: @@ -74829,24 +76372,24 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 150 /* Constructor */)) { + (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 151 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 150 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 151 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 150 /* Constructor */) { + if (functionDeclaration.kind === 151 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 153 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 154 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -74855,7 +76398,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 197 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 198 /* 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 @@ -74878,7 +76421,7 @@ var ts; } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(136 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(137 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -74899,7 +76442,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 231 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 232 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 70 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 128 /* NamespaceKeyword */ : 127 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -74920,28 +76463,28 @@ var ts; } else { // Method/function type parameter - var declaration = ts.getDeclarationOfKind(symbol, 143 /* TypeParameter */); + var declaration = ts.getDeclarationOfKind(symbol, 144 /* TypeParameter */); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 154 /* ConstructSignature */) { + if (declaration.kind === 155 /* ConstructSignature */) { displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 153 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 154 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 229 /* TypeAliasDeclaration */) { + else if (declaration.kind === 230 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(136 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(137 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -74952,7 +76495,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 261 /* EnumMember */) { + if (declaration.kind === 263 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -74964,7 +76507,7 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 234 /* NamespaceExportDeclaration */) { + if (symbol.declarations[0].kind === 235 /* NamespaceExportDeclaration */) { displayParts.push(ts.keywordPart(83 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(128 /* NamespaceKeyword */)); @@ -74975,7 +76518,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 235 /* ImportEqualsDeclaration */) { + if (declaration.kind === 236 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -75011,6 +76554,7 @@ var ts; } // For properties, variables and local vars: show the type if (symbolKind === ts.ScriptElementKind.memberVariableElement || + symbolKind === ts.ScriptElementKind.jsxAttribute || symbolFlags & 3 /* Variable */ || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { @@ -75048,10 +76592,10 @@ var ts; // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 262 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 264 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 192 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 193 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -75132,16 +76676,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 184 /* FunctionExpression */) { + if (declaration.kind === 185 /* FunctionExpression */) { return true; } - if (declaration.kind !== 224 /* VariableDeclaration */ && declaration.kind !== 226 /* FunctionDeclaration */) { + if (declaration.kind !== 225 /* VariableDeclaration */ && declaration.kind !== 227 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { + for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent_21.kind === 262 /* SourceFile */ || parent_21.kind === 232 /* ModuleBlock */) { + if (parent.kind === 264 /* SourceFile */ || parent.kind === 233 /* ModuleBlock */) { return false; } } @@ -75194,7 +76738,7 @@ var ts; sourceFile.moduleName = transpileOptions.moduleName; } if (transpileOptions.renamedDependencies) { - sourceFile.renamedDependencies = ts.createMap(transpileOptions.renamedDependencies); + sourceFile.renamedDependencies = ts.createMapFromTemplate(transpileOptions.renamedDependencies); } var newLine = ts.getNewLineCharacter(options); // Output @@ -75249,10 +76793,10 @@ var ts; function fixupCompilerOptions(options, diagnostics) { // Lazily create this value to fix module loading errors. commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { - return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); + return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_3 = function (opt) { + var _loop_5 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -75263,7 +76807,7 @@ var ts; options[opt.name] = ts.parseCustomTypeOption(opt, value, diagnostics); } else { - if (!ts.forEachProperty(opt.type, function (v) { return v === value; })) { + if (!ts.forEachEntry(opt.type, function (v) { return v === value; })) { // Supplied value isn't a valid enum value. diagnostics.push(ts.createCompilerDiagnosticForInvalidCustomType(opt)); } @@ -75271,7 +76815,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_3(opt); + _loop_5(opt); } return options; } @@ -75379,10 +76923,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 251 /* JsxAttribute */: - case 249 /* JsxOpeningElement */: - case 250 /* JsxClosingElement */: - case 248 /* JsxSelfClosingElement */: + case 252 /* JsxAttribute */: + case 250 /* JsxOpeningElement */: + case 251 /* JsxClosingElement */: + case 249 /* JsxSelfClosingElement */: return node.kind === 70 /* Identifier */; } } @@ -75794,7 +77338,7 @@ var ts; this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Space after }. - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromRange(0 /* FirstToken */, 140 /* LastToken */, [19 /* CloseParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromRange(0 /* FirstToken */, 141 /* LastToken */, [19 /* CloseParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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(17 /* CloseBraceToken */, 81 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 105 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); @@ -75859,7 +77403,7 @@ var ts; this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101 /* TryKeyword */, 86 /* FinallyKeyword */]), 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124 /* GetKeyword */, 133 /* SetKeyword */]), 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124 /* GetKeyword */, 134 /* SetKeyword */]), 70 /* 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); @@ -75870,8 +77414,8 @@ var ts; // 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([127 /* ModuleKeyword */, 131 /* RequireKeyword */]), 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 130 /* ReadonlyKeyword */, 133 /* SetKeyword */, 114 /* StaticKeyword */, 136 /* TypeKeyword */, 138 /* FromKeyword */, 126 /* KeyOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 138 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 130 /* ReadonlyKeyword */, 134 /* SetKeyword */, 114 /* StaticKeyword */, 137 /* TypeKeyword */, 139 /* FromKeyword */, 126 /* KeyOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 139 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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(9 /* StringLiteral */, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions @@ -75891,7 +77435,7 @@ var ts; // decorators this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 133 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 134 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115 /* YieldKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); @@ -76021,9 +77565,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_50 in o) { - if (o[name_50] === rule) { - return name_50; + for (var name in o) { + if (o[name] === rule) { + return name; } } throw new Error("Unknown rule"); @@ -76032,44 +77576,44 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 212 /* ForStatement */; + return context.contextNode.kind === 213 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 192 /* BinaryExpression */: - case 193 /* ConditionalExpression */: - case 200 /* AsExpression */: - case 244 /* ExportSpecifier */: - case 240 /* ImportSpecifier */: - case 156 /* TypePredicate */: - case 164 /* UnionType */: - case 165 /* IntersectionType */: + case 193 /* BinaryExpression */: + case 194 /* ConditionalExpression */: + case 201 /* AsExpression */: + case 245 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: + case 157 /* TypePredicate */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 174 /* BindingElement */: + case 175 /* BindingElement */: // equals in type X = ... - case 229 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: // equal in p = 0; - case 144 /* Parameter */: - case 261 /* EnumMember */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 145 /* Parameter */: + case 263 /* EnumMember */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return context.currentTokenSpan.kind === 57 /* EqualsToken */ || context.nextTokenSpan.kind === 57 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return context.currentTokenSpan.kind === 91 /* InKeyword */ || context.nextTokenSpan.kind === 91 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 214 /* ForOfStatement */: - return context.currentTokenSpan.kind === 140 /* OfKeyword */ || context.nextTokenSpan.kind === 140 /* OfKeyword */; + case 215 /* ForOfStatement */: + return context.currentTokenSpan.kind === 141 /* OfKeyword */ || context.nextTokenSpan.kind === 141 /* OfKeyword */; } return false; }; @@ -76077,7 +77621,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 193 /* ConditionalExpression */; + return context.contextNode.kind === 194 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -76099,7 +77643,7 @@ var ts; return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; Rules.IsBraceWrappedContext = function (context) { - return context.contextNode.kind === 172 /* ObjectBindingPattern */ || Rules.IsSingleLineBlockContext(context); + return context.contextNode.kind === 173 /* ObjectBindingPattern */ || Rules.IsSingleLineBlockContext(context); }; // This check is done before an open brace in a control construct, a function, or a typescript block declaration Rules.IsBeforeMultilineBlockContext = function (context) { @@ -76124,70 +77668,70 @@ var ts; return true; } switch (node.kind) { - case 205 /* Block */: - case 233 /* CaseBlock */: - case 176 /* ObjectLiteralExpression */: - case 232 /* ModuleBlock */: + case 206 /* Block */: + case 234 /* CaseBlock */: + case 177 /* ObjectLiteralExpression */: + case 233 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 226 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 153 /* CallSignature */: - case 184 /* FunctionExpression */: - case 150 /* Constructor */: - case 185 /* ArrowFunction */: + case 154 /* CallSignature */: + case 185 /* FunctionExpression */: + case 151 /* Constructor */: + case 186 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 228 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 226 /* FunctionDeclaration */ || context.contextNode.kind === 184 /* FunctionExpression */; + return context.contextNode.kind === 227 /* FunctionDeclaration */ || context.contextNode.kind === 185 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 228 /* InterfaceDeclaration */: - case 230 /* EnumDeclaration */: - case 161 /* TypeLiteral */: - case 231 /* ModuleDeclaration */: - case 242 /* ExportDeclaration */: - case 243 /* NamedExports */: - case 236 /* ImportDeclaration */: - case 239 /* NamedImports */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 162 /* TypeLiteral */: + case 232 /* ModuleDeclaration */: + case 243 /* ExportDeclaration */: + case 244 /* NamedExports */: + case 237 /* ImportDeclaration */: + case 240 /* NamedImports */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 227 /* ClassDeclaration */: - case 231 /* ModuleDeclaration */: - case 230 /* EnumDeclaration */: - case 257 /* CatchClause */: - case 232 /* ModuleBlock */: - case 219 /* SwitchStatement */: + case 228 /* ClassDeclaration */: + case 232 /* ModuleDeclaration */: + case 231 /* EnumDeclaration */: + case 259 /* CatchClause */: + case 233 /* ModuleBlock */: + case 220 /* SwitchStatement */: return true; - case 205 /* Block */: { + case 206 /* Block */: { var blockParent = context.currentTokenParent.parent; - if (blockParent.kind !== 185 /* ArrowFunction */ && - blockParent.kind !== 184 /* FunctionExpression */) { + if (blockParent.kind !== 186 /* ArrowFunction */ && + blockParent.kind !== 185 /* FunctionExpression */) { return true; } } @@ -76196,31 +77740,31 @@ var ts; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 209 /* IfStatement */: - case 219 /* SwitchStatement */: - case 212 /* ForStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 211 /* WhileStatement */: - case 222 /* TryStatement */: - case 210 /* DoStatement */: - case 218 /* WithStatement */: + case 210 /* IfStatement */: + case 220 /* SwitchStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 212 /* WhileStatement */: + case 223 /* TryStatement */: + case 211 /* DoStatement */: + case 219 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 257 /* CatchClause */: + case 259 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 176 /* ObjectLiteralExpression */; + return context.contextNode.kind === 177 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 179 /* CallExpression */; + return context.contextNode.kind === 180 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 180 /* NewExpression */; + return context.contextNode.kind === 181 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -76232,25 +77776,25 @@ var ts; return context.nextTokenSpan.kind !== 21 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 185 /* ArrowFunction */; + return context.contextNode.kind === 186 /* ArrowFunction */; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 247 /* JsxElement */; + return context.contextNode.kind !== 248 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 253 /* JsxExpression */; + return context.contextNode.kind === 255 /* JsxExpression */; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 251 /* JsxAttribute */; + return context.nextTokenParent.kind === 252 /* JsxAttribute */; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 251 /* JsxAttribute */; + return context.contextNode.kind === 252 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 248 /* JsxSelfClosingElement */; + return context.contextNode.kind === 249 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -76265,42 +77809,42 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 145 /* Decorator */; + return node.kind === 146 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 225 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 226 /* 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 === 231 /* ModuleDeclaration */; + return context.contextNode.kind === 232 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 161 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 162 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 26 /* LessThanToken */ && token.kind !== 28 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 157 /* TypeReference */: - case 182 /* TypeAssertionExpression */: - case 229 /* TypeAliasDeclaration */: - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 228 /* InterfaceDeclaration */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 199 /* ExpressionWithTypeArguments */: + case 158 /* TypeReference */: + case 183 /* TypeAssertionExpression */: + case 230 /* TypeAliasDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 200 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -76311,16 +77855,16 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 182 /* TypeAssertionExpression */; + return context.contextNode.kind === 183 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 188 /* VoidExpression */; + return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 189 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 195 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 196 /* YieldExpression */ && context.contextNode.expression !== undefined; }; Rules.IsNonNullAssertionContext = function (context) { - return context.contextNode.kind === 201 /* NonNullExpression */; + return context.contextNode.kind === 202 /* NonNullExpression */; }; return Rules; }()); @@ -76344,7 +77888,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 140 /* LastToken */ + 1; + this.mapRowLength = 141 /* 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); @@ -76358,7 +77902,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - ts.Debug.assert(row <= 140 /* LastKeyword */ && column <= 140 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 141 /* LastKeyword */ && column <= 141 /* LastKeyword */, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -76539,7 +78083,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 140 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 141 /* LastToken */; token++) { result.push(token); } return result; @@ -76583,9 +78127,9 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 140 /* LastKeyword */); + TokenRange.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 141 /* LastKeyword */); TokenRange.BinaryOperators = TokenRange.FromRange(26 /* FirstBinaryOperator */, 69 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 140 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 141 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42 /* PlusPlusToken */, 43 /* MinusMinusToken */, 51 /* TildeToken */, 50 /* ExclamationToken */]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 70 /* Identifier */, 18 /* OpenParenToken */, 20 /* OpenBracketToken */, 16 /* OpenBraceToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); @@ -76593,7 +78137,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 132 /* NumberKeyword */, 134 /* StringKeyword */, 121 /* BooleanKeyword */, 135 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 132 /* NumberKeyword */, 135 /* StringKeyword */, 121 /* BooleanKeyword */, 136 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -76864,17 +78408,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 227 /* ClassDeclaration */: - case 228 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 232 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 262 /* SourceFile */: - case 205 /* Block */: - case 232 /* ModuleBlock */: + return body && body.kind === 233 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 264 /* SourceFile */: + case 206 /* Block */: + case 233 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -77079,20 +78623,20 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 227 /* ClassDeclaration */: return 74 /* ClassKeyword */; - case 228 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; - case 226 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; - case 230 /* EnumDeclaration */: return 230 /* EnumDeclaration */; - case 151 /* GetAccessor */: return 124 /* GetKeyword */; - case 152 /* SetAccessor */: return 133 /* SetKeyword */; - case 149 /* MethodDeclaration */: + case 228 /* ClassDeclaration */: return 74 /* ClassKeyword */; + case 229 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; + case 227 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; + case 231 /* EnumDeclaration */: return 231 /* EnumDeclaration */; + case 152 /* GetAccessor */: return 124 /* GetKeyword */; + case 153 /* SetAccessor */: return 134 /* SetKeyword */; + case 150 /* MethodDeclaration */: if (node.asteriskToken) { return 38 /* AsteriskToken */; } /* fall-through */ - case 147 /* PropertyDeclaration */: - case 144 /* Parameter */: + case 148 /* PropertyDeclaration */: + case 145 /* Parameter */: return node.name.kind; } } @@ -77130,16 +78674,16 @@ var ts; return indentation; case 40 /* SlashToken */: case 28 /* GreaterThanToken */: { - if (container.kind === 249 /* JsxOpeningElement */ || - container.kind === 250 /* JsxClosingElement */ || - container.kind === 248 /* JsxSelfClosingElement */) { + if (container.kind === 250 /* JsxOpeningElement */ || + container.kind === 251 /* JsxClosingElement */ || + container.kind === 249 /* JsxSelfClosingElement */) { return indentation; } break; } case 20 /* OpenBracketToken */: case 21 /* CloseBracketToken */: { - if (container.kind !== 170 /* MappedType */) { + if (container.kind !== 171 /* MappedType */) { return indentation; } break; @@ -77249,11 +78793,11 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 145 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 146 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 175 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 176 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -77610,12 +79154,12 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 150 /* Constructor */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 185 /* ArrowFunction */: + case 151 /* Constructor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 186 /* ArrowFunction */: if (node.typeParameters === list) { return 26 /* LessThanToken */; } @@ -77623,8 +79167,8 @@ var ts; return 18 /* OpenParenToken */; } break; - case 179 /* CallExpression */: - case 180 /* NewExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: if (node.typeArguments === list) { return 26 /* LessThanToken */; } @@ -77632,7 +79176,7 @@ var ts; return 18 /* OpenParenToken */; } break; - case 157 /* TypeReference */: + case 158 /* TypeReference */: if (node.typeArguments === list) { return 26 /* LessThanToken */; } @@ -77748,7 +79292,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 192 /* BinaryExpression */) { + if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 193 /* 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 */) { @@ -77871,7 +79415,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.isStatementButNotDeclaration(current)) && - (parent.kind === 262 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 264 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -77904,7 +79448,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 209 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 210 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -77916,23 +79460,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 157 /* TypeReference */: + case 158 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return node.parent.properties; - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return node.parent.elements; - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: { + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -77943,8 +79487,8 @@ var ts; } break; } - case 180 /* NewExpression */: - case 179 /* CallExpression */: { + case 181 /* NewExpression */: + case 180 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -77974,8 +79518,8 @@ var ts; if (node.kind === 19 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 179 /* CallExpression */ || - node.parent.kind === 180 /* NewExpression */) && + if (node.parent && (node.parent.kind === 180 /* CallExpression */ || + node.parent.kind === 181 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -77993,10 +79537,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 177 /* PropertyAccessExpression */: - case 178 /* ElementAccessExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 178 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: node = node.expression; break; default: @@ -78060,49 +79604,49 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 208 /* ExpressionStatement */: - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 228 /* InterfaceDeclaration */: - case 230 /* EnumDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 175 /* ArrayLiteralExpression */: - case 205 /* Block */: - case 232 /* ModuleBlock */: - case 176 /* ObjectLiteralExpression */: - case 161 /* TypeLiteral */: - case 170 /* MappedType */: - case 163 /* TupleType */: - case 233 /* CaseBlock */: - case 255 /* DefaultClause */: - case 254 /* CaseClause */: - case 183 /* ParenthesizedExpression */: - case 177 /* PropertyAccessExpression */: - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 206 /* VariableStatement */: - case 224 /* VariableDeclaration */: - case 241 /* ExportAssignment */: - case 217 /* ReturnStatement */: - case 193 /* ConditionalExpression */: - case 173 /* ArrayBindingPattern */: - case 172 /* ObjectBindingPattern */: - case 249 /* JsxOpeningElement */: - case 248 /* JsxSelfClosingElement */: - case 253 /* JsxExpression */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 144 /* Parameter */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 166 /* ParenthesizedType */: - case 181 /* TaggedTemplateExpression */: - case 189 /* AwaitExpression */: - case 243 /* NamedExports */: - case 239 /* NamedImports */: - case 244 /* ExportSpecifier */: - case 240 /* ImportSpecifier */: + case 209 /* ExpressionStatement */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 176 /* ArrayLiteralExpression */: + case 206 /* Block */: + case 233 /* ModuleBlock */: + case 177 /* ObjectLiteralExpression */: + case 162 /* TypeLiteral */: + case 171 /* MappedType */: + case 164 /* TupleType */: + case 234 /* CaseBlock */: + case 257 /* DefaultClause */: + case 256 /* CaseClause */: + case 184 /* ParenthesizedExpression */: + case 178 /* PropertyAccessExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 207 /* VariableStatement */: + case 225 /* VariableDeclaration */: + case 242 /* ExportAssignment */: + case 218 /* ReturnStatement */: + case 194 /* ConditionalExpression */: + case 174 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 250 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + case 255 /* JsxExpression */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 145 /* Parameter */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 167 /* ParenthesizedType */: + case 182 /* TaggedTemplateExpression */: + case 190 /* AwaitExpression */: + case 244 /* NamedExports */: + case 240 /* NamedImports */: + case 245 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: return true; } return false; @@ -78111,27 +79655,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 210 /* DoStatement */: - case 211 /* WhileStatement */: - case 213 /* ForInStatement */: - case 214 /* ForOfStatement */: - case 212 /* ForStatement */: - case 209 /* IfStatement */: - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 185 /* ArrowFunction */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - return childKind !== 205 /* Block */; - case 242 /* ExportDeclaration */: - return childKind !== 243 /* NamedExports */; - case 236 /* ImportDeclaration */: - return childKind !== 237 /* ImportClause */ || - (child.namedBindings && child.namedBindings.kind !== 239 /* NamedImports */); - case 247 /* JsxElement */: - return childKind !== 250 /* JsxClosingElement */; + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 213 /* ForStatement */: + case 210 /* IfStatement */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 186 /* ArrowFunction */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + return childKind !== 206 /* Block */; + case 243 /* ExportDeclaration */: + return childKind !== 244 /* NamedExports */; + case 237 /* ImportDeclaration */: + return childKind !== 238 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 240 /* NamedImports */); + case 248 /* JsxElement */: + return childKind !== 251 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -78152,7 +79696,7 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var codeFixes = ts.createMap(); + var codeFixes = []; function registerCodeFix(action) { ts.forEach(action.errorCodes, function (error) { var fixes = codeFixes[error]; @@ -78228,9 +79772,9 @@ var ts; if (IndexInfoOfKind) { var writer = ts.getSingleLineStringWriter(); checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); - var result_7 = writer.string(); + var result_6 = writer.string(); ts.releaseStringWriter(writer); - return result_7; + return result_6; } } return ""; @@ -78324,7 +79868,7 @@ var ts; } // figure out if the this access is actuall inside the supercall // i.e. super(this.a), since in that case we won't suggest a fix - if (superCall.expression && superCall.expression.kind == 179 /* CallExpression */) { + if (superCall.expression && superCall.expression.kind == 180 /* CallExpression */) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -78348,7 +79892,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -78431,6 +79975,25 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + var start = token.getStart(sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_this_to_unresolved_variable), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start: start, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -78450,43 +80013,43 @@ var ts; switch (token.kind) { case 70 /* Identifier */: switch (token.parent.kind) { - case 224 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: switch (token.parent.parent.parent.kind) { - case 212 /* ForStatement */: + case 213 /* ForStatement */: var forStatement = token.parent.parent.parent; var forInitializer = forStatement.initializer; if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); + return createCodeFixToRemoveNode(forInitializer); } else { return removeSingleItem(forInitializer.declarations, token); } - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 225 /* VariableDeclarationList */) { + if (forOfStatement.initializer.kind === 226 /* VariableDeclarationList */) { var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); + return createCodeFix("{}", forOfInitializer.declarations[0].getStart(), forOfInitializer.declarations[0].getWidth()); } break; - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: // There is no valid fix in the case of: // for .. in return undefined; - case 257 /* CatchClause */: + case 259 /* CatchClause */: var catchClause = token.parent.parent; var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); + return createCodeFixToRemoveNode(parameter); default: var variableStatement = token.parent.parent.parent; if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); + return createCodeFixToRemoveNode(variableStatement); } else { var declarations = variableStatement.declarationList.declarations; return removeSingleItem(declarations, token); } } - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: var typeParameters = token.parent.parent.typeParameters; if (typeParameters.length === 1) { return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); @@ -78494,75 +80057,101 @@ var ts; else { return removeSingleItem(typeParameters, token); } - case 144 /* Parameter */: + case 145 /* Parameter */: var functionDeclaration = token.parent.parent; if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + return createCodeFixToRemoveNode(token.parent); } else { return removeSingleItem(functionDeclaration.parameters, token); } // handle case where 'import a = A;' - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: var importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case 240 /* ImportSpecifier */: + return createCodeFixToRemoveNode(importEquals); + case 241 /* ImportSpecifier */: var namedImports = token.parent.parent; if (namedImports.elements.length === 1) { // Only 1 import and it is unused. So the entire declaration should be removed. var importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); + return createCodeFixToRemoveNode(importSpec); } else { return removeSingleItem(namedImports.elements, token); } - // handle case where "import d, * as ns from './file'" + // handle case where "import d, * as ns from './file'" // or "'import {a, b as ns} from './file'" - case 237 /* ImportClause */: + case 238 /* ImportClause */: var importClause = token.parent; if (!importClause.namedBindings) { var importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + return createCodeFixToRemoveNode(importDecl); } else { - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); + // import |d,| * as ns from './file' + var start_4 = importClause.name.getStart(); + var end = findFirstNonSpaceCharPosStarting(importClause.name.end); + if (sourceFile.text.charCodeAt(end) === 44 /* comma */) { + end = findFirstNonSpaceCharPosStarting(end + 1); + } + return createCodeFix("", start_4, end - start_4); } - case 238 /* NamespaceImport */: + case 239 /* NamespaceImport */: var namespaceImport = token.parent; if (namespaceImport.name == token && !namespaceImport.parent.name) { var importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + return createCodeFixToRemoveNode(importDecl); } else { - var start_4 = namespaceImport.parent.name.end; - return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); + var start_5 = namespaceImport.parent.name.end; + return createCodeFix("", start_5, namespaceImport.parent.namedBindings.end - start_5); } } break; - case 147 /* PropertyDeclaration */: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case 238 /* NamespaceImport */: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + case 148 /* PropertyDeclaration */: + case 239 /* NamespaceImport */: + return createCodeFixToRemoveNode(token.parent); } if (ts.isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + return createCodeFixToRemoveNode(token.parent); } else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); + return createCodeFixToRemoveNode(token.parent.parent); } else { return undefined; } function findImportDeclaration(token) { var importDecl = token; - while (importDecl.kind != 236 /* ImportDeclaration */ && importDecl.parent) { + while (importDecl.kind != 237 /* ImportDeclaration */ && importDecl.parent) { importDecl = importDecl.parent; } return importDecl; } + function createCodeFixToRemoveNode(node) { + var end = node.getEnd(); + var endCharCode = sourceFile.text.charCodeAt(end); + var afterEndCharCode = sourceFile.text.charCodeAt(end + 1); + if (ts.isLineBreak(endCharCode)) { + end += 1; + } + // in the case of CR LF, you could have two consecutive new line characters for one new line. + // this needs to be differenciated from two LF LF chars that actually mean two new lines. + if (ts.isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) { + end += 1; + } + var start = node.getStart(); + return createCodeFix("", start, end - start); + } + function findFirstNonSpaceCharPosStarting(start) { + while (ts.isWhiteSpace(sourceFile.text.charCodeAt(start))) { + start += 1; + } + return start; + } function createCodeFix(newText, start, length) { return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: newText, span: { start: start, length: length } }] @@ -78594,18 +80183,19 @@ var ts; })(ModuleSpecifierComparison || (ModuleSpecifierComparison = {})); var ImportCodeActionMap = (function () { function ImportCodeActionMap() { - this.symbolIdToActionMap = ts.createMap(); + this.symbolIdToActionMap = []; } ImportCodeActionMap.prototype.addAction = function (symbolId, newAction) { if (!newAction) { return; } - if (!this.symbolIdToActionMap[symbolId]) { + var actions = this.symbolIdToActionMap[symbolId]; + if (!actions) { this.symbolIdToActionMap[symbolId] = [newAction]; return; } if (newAction.kind === "CodeChange") { - this.symbolIdToActionMap[symbolId].push(newAction); + actions.push(newAction); return; } var updatedNewImports = []; @@ -78649,8 +80239,8 @@ var ts; }; ImportCodeActionMap.prototype.getAllActions = function () { var result = []; - for (var symbolId in this.symbolIdToActionMap) { - result = ts.concatenate(result, this.symbolIdToActionMap[symbolId]); + for (var key in this.symbolIdToActionMap) { + result = ts.concatenate(result, this.symbolIdToActionMap[key]); } return result; }; @@ -78684,6 +80274,7 @@ var ts; codefix.registerCodeFix({ errorCodes: [ ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics.Cannot_find_namespace_0.code, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code ], getCodeActions: function (context) { @@ -78695,7 +80286,7 @@ var ts; var name = token.getText(); var symbolIdActionMap = new ImportCodeActionMap(); // this is a module id -> module import declaration map - var cachedImportDeclarations = ts.createMap(); + var cachedImportDeclarations = []; var cachedNewImportInsertPosition; var currentTokenMeaning = ts.getMeaningFromLocation(token); if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { @@ -78732,8 +80323,9 @@ var ts; return symbolIdActionMap.getAllActions(); function getImportDeclarations(moduleSymbol) { var moduleSymbolId = getUniqueSymbolId(moduleSymbol); - if (cachedImportDeclarations[moduleSymbolId]) { - return cachedImportDeclarations[moduleSymbolId]; + var cached = cachedImportDeclarations[moduleSymbolId]; + if (cached) { + return cached; } var existingDeclarations = []; for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { @@ -78748,10 +80340,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 236 /* ImportDeclaration */) { + if (node.kind === 237 /* ImportDeclaration */) { return node; } - if (node.kind === 235 /* ImportEqualsDeclaration */) { + if (node.kind === 236 /* ImportEqualsDeclaration */) { return node; } node = node.parent; @@ -78795,11 +80387,11 @@ var ts; var namespaceImportDeclaration; var namedImportDeclaration; var existingModuleSpecifier; - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; - if (declaration.kind === 236 /* ImportDeclaration */) { + for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { + var declaration = declarations_14[_i]; + if (declaration.kind === 237 /* ImportDeclaration */) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 238 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 239 /* NamespaceImport */) { // case: // import * as ns from "foo" namespaceImportDeclaration = declaration; @@ -78839,7 +80431,7 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 246 /* ExternalModuleReference */) { + if (declaration.moduleReference && declaration.moduleReference.kind === 247 /* ExternalModuleReference */) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); @@ -78887,7 +80479,7 @@ var ts; } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 236 /* ImportDeclaration */) { + if (declaration.kind === 237 /* ImportDeclaration */) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -78935,18 +80527,18 @@ var ts; : "" + context.newLineCharacter + importStatementText + ";"; return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], newText, { start: cachedNewImportInsertPosition, length: 0 }, sourceFile.fileName, "NewImport", moduleSpecifierWithoutQuotes); function getModuleSpecifierForNewImport() { - var fileName = sourceFile.path; - var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().path; + var fileName = sourceFile.fileName; + var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; var sourceDirectory = ts.getDirectoryPath(fileName); var options = context.program.getCompilerOptions(); return tryGetModuleNameFromAmbientModule() || - tryGetModuleNameFromBaseUrl() || - tryGetModuleNameFromRootDirs() || tryGetModuleNameFromTypeRoots() || tryGetModuleNameAsNodeModule() || + tryGetModuleNameFromBaseUrl() || + tryGetModuleNameFromRootDirs() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 262 /* SourceFile */) { + if (moduleSymbol.valueDeclaration.kind !== 264 /* SourceFile */) { return moduleSymbol.name; } } @@ -78954,8 +80546,7 @@ var ts; if (!options.baseUrl) { return undefined; } - var normalizedBaseUrl = ts.toPath(options.baseUrl, ts.getDirectoryPath(options.baseUrl), getCanonicalFileName); - var relativeName = tryRemoveParentDirectoryName(moduleFileName, normalizedBaseUrl); + var relativeName = getRelativePathIfInDirectory(moduleFileName, options.baseUrl); if (!relativeName) { return undefined; } @@ -78989,9 +80580,8 @@ var ts; } function tryGetModuleNameFromRootDirs() { if (options.rootDirs) { - var normalizedRootDirs = ts.map(options.rootDirs, function (rootDir) { return ts.toPath(rootDir, /*basePath*/ undefined, getCanonicalFileName); }); - var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, normalizedRootDirs); - var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, normalizedRootDirs); + var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, options.rootDirs); + var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, options.rootDirs); if (normalizedTargetPath !== undefined) { var relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath; return ts.removeFileExtension(relativePath); @@ -79055,7 +80645,7 @@ var ts; function getPathRelativeToRootDirs(path, rootDirs) { for (var _i = 0, rootDirs_2 = rootDirs; _i < rootDirs_2.length; _i++) { var rootDir = rootDirs_2[_i]; - var relativeName = tryRemoveParentDirectoryName(path, rootDir); + var relativeName = getRelativePathIfInDirectory(path, rootDir); if (relativeName !== undefined) { return relativeName; } @@ -79069,19 +80659,14 @@ var ts; } return fileName; } + function getRelativePathIfInDirectory(path, directoryPath) { + var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); + return ts.isRootedDiskPath(relativePath) || ts.startsWith(relativePath, "..") ? undefined : relativePath; + } function getRelativePath(path, directoryPath) { var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); return ts.moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath; } - function tryRemoveParentDirectoryName(path, parentDirectory) { - var index = path.indexOf(parentDirectory); - if (index === 0) { - return ts.endsWith(parentDirectory, ts.directorySeparator) - ? path.substring(parentDirectory.length) - : path.substring(parentDirectory.length + 1); - } - return undefined; - } } } function createCodeAction(description, diagnosticArgs, newText, span, fileName, kind, moduleSpecifier) { @@ -79109,7 +80694,7 @@ var ts; */ function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { var classMembers = classDeclaration.symbol.members; - var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !(symbol.getName() in classMembers); }); + var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !classMembers.has(symbol.getName()); }); var insertion = ""; for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { var symbol = missingMembers_1[_i]; @@ -79132,14 +80717,14 @@ var ts; var name = declaration.name ? declaration.name.getText() : undefined; var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); switch (declaration.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 146 /* PropertySignature */: - case 147 /* PropertyDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 147 /* PropertySignature */: + case 148 /* PropertyDeclaration */: var typeString = checker.typeToString(type, enclosingDeclaration, 0 /* None */); return "" + visibility + name + ": " + typeString + ";" + newlineChar; - case 148 /* MethodSignature */: - case 149 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 150 /* MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -79179,7 +80764,7 @@ var ts; } } function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { - var newSignatureDeclaration = ts.createNode(153 /* CallSignature */); + var newSignatureDeclaration = ts.createNode(154 /* CallSignature */); newSignatureDeclaration.parent = enclosingDeclaration; newSignatureDeclaration.name = signatures[0].getDeclaration().name; var maxNonRestArgs = -1; @@ -79210,7 +80795,7 @@ var ts; } return checker.getSignatureFromDeclaration(newSignatureDeclaration); function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { - var newParameter = ts.createNode(144 /* Parameter */); + var newParameter = ts.createNode(145 /* Parameter */); newParameter.symbol = new SymbolConstructor(1 /* FunctionScopedVariable */, maxArgsParameterSymbolNames[index] || "rest"); newParameter.symbol.valueDeclaration = newParameter; newParameter.symbol.declarations = [newParameter]; @@ -79241,6 +80826,7 @@ var ts; /// /// /// +/// /// /// /// @@ -79276,7 +80862,7 @@ var ts; /** The version of the language service API */ ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 141 /* FirstNode */ ? new NodeObject(kind, pos, end) : + var node = kind >= 142 /* FirstNode */ ? new NodeObject(kind, pos, end) : kind === 70 /* Identifier */ ? new IdentifierObject(70 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; @@ -79334,7 +80920,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(293 /* SyntaxList */, nodes.pos, nodes.end, this); + var list = createNode(296 /* SyntaxList */, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -79353,11 +80939,11 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 141 /* FirstNode */) { + if (this.kind >= 142 /* FirstNode */) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 279 /* FirstJSDocTagNode */ && this.kind <= 292 /* LastJSDocTagNode */; + var useJSDocScanner_1 = this.kind >= 282 /* FirstJSDocTagNode */ && this.kind <= 295 /* LastJSDocTagNode */; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -79414,8 +81000,10 @@ var ts; if (!children.length) { return undefined; } - var child = children[0]; - return child.kind < 141 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + var child = ts.find(children, function (kid) { return kid.kind < 266 /* FirstJSDocNode */ || kid.kind > 295 /* LastJSDocNode */; }); + return child.kind < 142 /* FirstNode */ ? + child : + child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -79423,7 +81011,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 141 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 142 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -79622,27 +81210,31 @@ var ts; return this.namedDeclarations; }; SourceFileObject.prototype.computeNamedDeclarations = function () { - var result = ts.createMap(); + var result = ts.createMultiMap(); ts.forEachChild(this, visit); return result; function addDeclaration(declaration) { var name = getDeclarationName(declaration); if (name) { - ts.multiMapAdd(result, name, declaration); + result.add(name, declaration); } } function getDeclarations(name) { - return result[name] || (result[name] = []); + var declarations = result.get(name); + if (!declarations) { + result.set(name, declarations = []); + } + return declarations; } function getDeclarationName(declaration) { if (declaration.name) { - var result_8 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_8 !== undefined) { - return result_8; + var result_7 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_7 !== undefined) { + return result_7; } - if (declaration.name.kind === 142 /* ComputedPropertyName */) { + if (declaration.name.kind === 143 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 177 /* PropertyAccessExpression */) { + if (expr.kind === 178 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -79662,10 +81254,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 226 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -79685,32 +81277,32 @@ var ts; } ts.forEachChild(node, visit); break; - case 227 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 228 /* InterfaceDeclaration */: - case 229 /* TypeAliasDeclaration */: - case 230 /* EnumDeclaration */: - case 231 /* ModuleDeclaration */: - case 235 /* ImportEqualsDeclaration */: - case 244 /* ExportSpecifier */: - case 240 /* ImportSpecifier */: - case 235 /* ImportEqualsDeclaration */: - case 237 /* ImportClause */: - case 238 /* NamespaceImport */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 161 /* TypeLiteral */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 231 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 245 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 238 /* ImportClause */: + case 239 /* NamespaceImport */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 162 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 144 /* Parameter */: + case 145 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // fall through - case 224 /* VariableDeclaration */: - case 174 /* BindingElement */: { + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -79719,19 +81311,19 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 261 /* EnumMember */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 263 /* EnumMember */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: addDeclaration(node); break; - case 242 /* ExportDeclaration */: + case 243 /* 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 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -79743,7 +81335,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 238 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 239 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -80173,6 +81765,7 @@ var ts; ts.Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + path); return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } + // We didn't already have the file. Fall through and acquire it from the registry. } // Could not find this file in the old program, create a new SourceFile for it. return documentRegistry.acquireDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); @@ -80273,10 +81866,10 @@ var ts; // Try getting just type at this position and show switch (node.kind) { case 70 /* Identifier */: - case 177 /* PropertyAccessExpression */: - case 141 /* QualifiedName */: + case 178 /* PropertyAccessExpression */: + case 142 /* QualifiedName */: case 98 /* ThisKeyword */: - case 167 /* ThisType */: + case 168 /* ThisType */: case 96 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); @@ -80318,10 +81911,10 @@ var ts; function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); if (results) { - var sourceFile_2 = getCanonicalFileName(ts.normalizeSlashes(fileName)); + var sourceFile_1 = getCanonicalFileName(ts.normalizeSlashes(fileName)); // Get occurrences only supports reporting occurrences for the file queried. So // filter down to that list. - results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_2; }); + results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_1; }); } return results; } @@ -80356,21 +81949,21 @@ var ts; } } function findRenameLocations(fileName, position, findInStrings, findInComments) { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments, /*isForRename*/ true); return ts.FindAllReferences.convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ false); return ts.FindAllReferences.convertReferences(referencedSymbols); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ false); // Only include referenced symbols that have a valid definition. return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); } - function findReferencedSymbols(fileName, position, findInStrings, findInComments) { + function findReferencedSymbols(fileName, position, findInStrings, findInComments, isForRename) { synchronizeHostData(); - return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments); + return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments, isForRename); } /// NavigateTo function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { @@ -80419,15 +82012,15 @@ var ts; return; } switch (node.kind) { - case 177 /* PropertyAccessExpression */: - case 141 /* QualifiedName */: + case 178 /* PropertyAccessExpression */: + case 142 /* QualifiedName */: case 9 /* StringLiteral */: case 85 /* FalseKeyword */: case 100 /* TrueKeyword */: case 94 /* NullKeyword */: case 96 /* SuperKeyword */: case 98 /* ThisKeyword */: - case 167 /* ThisType */: + case 168 /* ThisType */: case 70 /* Identifier */: break; // Cant create the text span @@ -80444,7 +82037,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 === 231 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 232 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -80587,7 +82180,7 @@ var ts; var span = { start: start, length: end - start }; var newLineChar = ts.getNewLineOrDefaultFromHost(host); var allFixes = []; - ts.forEach(errorCodes, function (error) { + ts.forEach(ts.deduplicate(errorCodes), function (error) { cancellationToken.throwIfCancellationRequested(); var context = { errorCode: error, @@ -80821,7 +82414,7 @@ var ts; function walk(node) { switch (node.kind) { case 70 /* Identifier */: - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + setNameTable(node.text, node); break; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: @@ -80830,10 +82423,10 @@ 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 === 246 /* ExternalModuleReference */ || + node.parent.kind === 247 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + setNameTable(node.text, node); } break; default: @@ -80846,11 +82439,72 @@ var ts; } } } + function setNameTable(text, node) { + nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); + } } + function isObjectLiteralElement(node) { + switch (node.kind) { + case 252 /* JsxAttribute */: + case 254 /* JsxSpreadAttribute */: + case 260 /* PropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + return true; + } + return false; + } + /** + * Returns the containing object literal property declaration given a possible name node, e.g. "a" in x = { "a": 1 } + */ + /* @internal */ + function getContainingObjectLiteralElement(node) { + switch (node.kind) { + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + if (node.parent.kind === 143 /* ComputedPropertyName */) { + return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; + } + // intentionally fall through + case 70 /* Identifier */: + return isObjectLiteralElement(node.parent) && + (node.parent.parent.kind === 177 /* ObjectLiteralExpression */ || node.parent.parent.kind === 253 /* JsxAttributes */) && + node.parent.name === node ? node.parent : undefined; + } + return undefined; + } + ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; + /* @internal */ + function getPropertySymbolsFromContextualType(typeChecker, node) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = ts.getTextOfPropertyName(node.name); + if (name && contextualType) { + var result_8 = []; + var symbol = contextualType.getProperty(name); + if (contextualType.flags & 65536 /* Union */) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_8.push(symbol); + } + }); + return result_8; + } + if (symbol) { + result_8.push(symbol); + return result_8; + } + } + return undefined; + } + ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 178 /* ElementAccessExpression */ && + node.parent.kind === 179 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -80866,10 +82520,7 @@ var ts; throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); } ts.getDefaultLibFilePath = getDefaultLibFilePath; - function initializeServices() { - ts.objectAllocator = getServicesObjectAllocator(); - } - initializeServices(); + ts.objectAllocator = getServicesObjectAllocator(); })(ts || (ts = {})); // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. @@ -80934,113 +82585,113 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 206 /* VariableStatement */: + case 207 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 224 /* VariableDeclaration */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 225 /* VariableDeclaration */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return spanInVariableDeclaration(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return spanInParameterDeclaration(node); - case 226 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 150 /* Constructor */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 151 /* Constructor */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 205 /* Block */: + case 206 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 232 /* ModuleBlock */: + case 233 /* ModuleBlock */: return spanInBlock(node); - case 257 /* CatchClause */: + case 259 /* CatchClause */: return spanInBlock(node.block); - case 208 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 217 /* ReturnStatement */: + case 218 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 211 /* WhileStatement */: + case 212 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 210 /* DoStatement */: + case 211 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 223 /* DebuggerStatement */: + case 224 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 209 /* IfStatement */: + case 210 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 220 /* LabeledStatement */: + case 221 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 216 /* BreakStatement */: - case 215 /* ContinueStatement */: + case 217 /* BreakStatement */: + case 216 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 212 /* ForStatement */: + case 213 /* ForStatement */: return spanInForStatement(node); - case 213 /* ForInStatement */: + case 214 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 214 /* ForOfStatement */: + case 215 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 219 /* SwitchStatement */: + case 220 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 254 /* CaseClause */: - case 255 /* DefaultClause */: + case 256 /* CaseClause */: + case 257 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 222 /* TryStatement */: + case 223 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 221 /* ThrowStatement */: + case 222 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 241 /* ExportAssignment */: + case 242 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 236 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 242 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 227 /* ClassDeclaration */: - case 230 /* EnumDeclaration */: - case 261 /* EnumMember */: - case 174 /* BindingElement */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 263 /* EnumMember */: + case 175 /* BindingElement */: // span on complete node return textSpan(node); - case 218 /* WithStatement */: + case 219 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 145 /* Decorator */: + case 146 /* Decorator */: return spanInNodeArray(node.parent.decorators); - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 228 /* InterfaceDeclaration */: - case 229 /* TypeAliasDeclaration */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: return undefined; // Tokens: case 24 /* SemicolonToken */: @@ -81070,7 +82721,7 @@ var ts; case 73 /* CatchKeyword */: case 86 /* FinallyKeyword */: return spanInNextNode(node); - case 140 /* OfKeyword */: + case 141 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -81083,13 +82734,13 @@ var ts; // a or ...c or d: x from // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern if ((node.kind === 70 /* Identifier */ || - node.kind == 196 /* SpreadElement */ || - node.kind === 258 /* PropertyAssignment */ || - node.kind === 259 /* ShorthandPropertyAssignment */) && + node.kind == 197 /* SpreadElement */ || + node.kind === 260 /* PropertyAssignment */ || + node.kind === 261 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 192 /* BinaryExpression */) { + if (node.kind === 193 /* BinaryExpression */) { var binaryExpression = node; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -81112,22 +82763,22 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 210 /* DoStatement */: + case 211 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 145 /* Decorator */: + case 146 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 212 /* ForStatement */: - case 214 /* ForOfStatement */: + case 213 /* ForStatement */: + case 215 /* ForOfStatement */: return textSpan(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: if (node.parent.operatorToken.kind === 25 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -81136,13 +82787,13 @@ var ts; } } // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 258 /* PropertyAssignment */ && + if (node.parent.kind === 260 /* PropertyAssignment */ && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 182 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 183 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNextNode(node.parent.type); } // return type of function go to previous token @@ -81150,8 +82801,8 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 224 /* VariableDeclaration */ || - node.parent.kind === 144 /* Parameter */)) { + if ((node.parent.kind === 225 /* VariableDeclaration */ || + node.parent.kind === 145 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -81159,7 +82810,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 192 /* BinaryExpression */) { + if (node.parent.kind === 193 /* BinaryExpression */) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -81185,7 +82836,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 213 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 214 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -81196,7 +82847,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 214 /* ForOfStatement */) { + variableDeclaration.parent.parent.kind === 215 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -81236,7 +82887,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 227 /* ClassDeclaration */ && functionDeclaration.kind !== 150 /* Constructor */); + (functionDeclaration.parent.kind === 228 /* ClassDeclaration */ && functionDeclaration.kind !== 151 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -81259,25 +82910,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 231 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 211 /* WhileStatement */: - case 209 /* IfStatement */: - case 213 /* ForInStatement */: + case 212 /* WhileStatement */: + case 210 /* IfStatement */: + case 214 /* ForInStatement */: 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 212 /* ForStatement */: - case 214 /* ForOfStatement */: + case 213 /* ForStatement */: + case 215 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 225 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 226 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -81302,23 +82953,23 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 198 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 199 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 174 /* BindingElement */) { + if (bindingPattern.parent.kind === 175 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 173 /* ArrayBindingPattern */ && node.kind !== 172 /* ObjectBindingPattern */); - var elements = node.kind === 175 /* ArrayLiteralExpression */ ? + ts.Debug.assert(node.kind !== 174 /* ArrayBindingPattern */ && node.kind !== 173 /* ObjectBindingPattern */); + var elements = node.kind === 176 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 198 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 199 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -81326,18 +82977,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 192 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 193 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 230 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 227 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 233 /* CaseBlock */: + case 234 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -81345,24 +82996,24 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 232 /* ModuleBlock */: + case 233 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 230 /* EnumDeclaration */: - case 227 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 228 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 205 /* Block */: + case 206 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through - case 257 /* CatchClause */: + case 259 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 233 /* CaseBlock */: + case 234 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -81370,7 +83021,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 172 /* ObjectBindingPattern */: + case 173 /* ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -81386,7 +83037,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 173 /* ArrayBindingPattern */: + case 174 /* ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -81401,12 +83052,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 210 /* DoStatement */ || - node.parent.kind === 179 /* CallExpression */ || - node.parent.kind === 180 /* NewExpression */) { + if (node.parent.kind === 211 /* DoStatement */ || + node.parent.kind === 180 /* CallExpression */ || + node.parent.kind === 181 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 183 /* ParenthesizedExpression */) { + if (node.parent.kind === 184 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -81415,21 +83066,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 184 /* FunctionExpression */: - case 226 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 150 /* Constructor */: - case 211 /* WhileStatement */: - case 210 /* DoStatement */: - case 212 /* ForStatement */: - case 214 /* ForOfStatement */: - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 183 /* ParenthesizedExpression */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 151 /* Constructor */: + case 212 /* WhileStatement */: + case 211 /* DoStatement */: + case 213 /* ForStatement */: + case 215 /* ForOfStatement */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 184 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -81439,20 +83090,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 258 /* PropertyAssignment */ || - node.parent.kind === 144 /* Parameter */) { + node.parent.kind === 260 /* PropertyAssignment */ || + node.parent.kind === 145 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 182 /* TypeAssertionExpression */) { + if (node.parent.kind === 183 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 210 /* DoStatement */) { + if (node.parent.kind === 211 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -81460,7 +83111,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 214 /* ForOfStatement */) { + if (node.parent.kind === 215 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -81591,7 +83242,10 @@ var ts; if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } - return JSON.parse(settingsJson); + var compilerOptions = JSON.parse(settingsJson); + // permit language service to handle all files (filtering should be performed on the host side) + compilerOptions.allowNonTsExtensions = true; + return compilerOptions; }; LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { var encoded = this.shimHost.getScriptFileNames(); @@ -82099,12 +83753,6 @@ var ts; var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (resolvedFileName && !compilerOptions.allowJs && ts.fileExtensionIs(resolvedFileName, ".js")) { - return { - resolvedFileName: undefined, - failedLookupLocations: [] - }; - } return { resolvedFileName: resolvedFileName, failedLookupLocations: result.failedLookupLocations @@ -82278,4 +83926,4 @@ var TypeScript; // 'toolsVersion' gets consumed by the managed side, so it's not unused. // TODO: it should be moved into a namespace though. /* @internal */ -var toolsVersion = "2.2"; +var toolsVersion = "2.3"; diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 47b04ae9e58..a009c63ec7d 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -98,32 +98,32 @@ var ts; var measures; function mark(markName) { if (enabled) { - marks[markName] = ts.timestamp(); - counts[markName] = (counts[markName] || 0) + 1; + marks.set(markName, ts.timestamp()); + counts.set(markName, (counts.get(markName) || 0) + 1); profilerEvent(markName); } } performance.mark = mark; function measure(measureName, startMarkName, endMarkName) { if (enabled) { - var end = endMarkName && marks[endMarkName] || ts.timestamp(); - var start = startMarkName && marks[startMarkName] || profilerStart; - measures[measureName] = (measures[measureName] || 0) + (end - start); + var end = endMarkName && marks.get(endMarkName) || ts.timestamp(); + var start = startMarkName && marks.get(startMarkName) || profilerStart; + measures.set(measureName, (measures.get(measureName) || 0) + (end - start)); } } performance.measure = measure; function getCount(markName) { - return counts && counts[markName] || 0; + return counts && counts.get(markName) || 0; } performance.getCount = getCount; function getDuration(measureName) { - return measures && measures[measureName] || 0; + return measures && measures.get(measureName) || 0; } performance.getDuration = getDuration; function forEachMeasure(cb) { - for (var key in measures) { - cb(key, measures[key]); - } + measures.forEach(function (measure, key) { + cb(key, measure); + }); } performance.forEachMeasure = forEachMeasure; function enable() { @@ -142,22 +142,96 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.2.0"; + ts.version = "2.3.0"; })(ts || (ts = {})); (function (ts) { - var createObject = Object.create; - ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - function createMap(template) { - var map = createObject(null); + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(undefined, { usage: "sort", sensitivity: "accent" }) : undefined; + ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + function createDictionaryObject() { + var map = Object.create(null); map["__"] = undefined; delete map["__"]; + return map; + } + function createMap() { + return new MapCtr(); + } + ts.createMap = createMap; + function createMapFromTemplate(template) { + var map = new MapCtr(); for (var key in template) if (hasOwnProperty.call(template, key)) { - map[key] = template[key]; + map.set(key, template[key]); } return map; } - ts.createMap = createMap; + ts.createMapFromTemplate = createMapFromTemplate; + var MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); + function shimMap() { + var MapIterator = (function () { + function MapIterator(data, selector) { + this.index = 0; + this.data = data; + this.selector = selector; + this.keys = Object.keys(data); + } + MapIterator.prototype.next = function () { + var index = this.index; + if (index < this.keys.length) { + this.index++; + return { value: this.selector(this.data, this.keys[index]), done: false }; + } + return { value: undefined, done: true }; + }; + return MapIterator; + }()); + return (function () { + function class_1() { + this.data = createDictionaryObject(); + this.size = 0; + } + class_1.prototype.get = function (key) { + return this.data[key]; + }; + class_1.prototype.set = function (key, value) { + if (!this.has(key)) { + this.size++; + } + this.data[key] = value; + return this; + }; + class_1.prototype.has = function (key) { + return key in this.data; + }; + class_1.prototype.delete = function (key) { + if (this.has(key)) { + this.size--; + delete this.data[key]; + return true; + } + return false; + }; + class_1.prototype.clear = function () { + this.data = createDictionaryObject(); + this.size = 0; + }; + class_1.prototype.keys = function () { + return new MapIterator(this.data, function (_data, key) { return key; }); + }; + class_1.prototype.values = function () { + return new MapIterator(this.data, function (data, key) { return data[key]; }); + }; + class_1.prototype.entries = function () { + return new MapIterator(this.data, function (data, key) { return [key, data[key]]; }); + }; + class_1.prototype.forEach = function (action) { + for (var key in this.data) { + action(this.data[key], key); + } + }; + return class_1; + }()); + } function createFileMap(keyMapper) { var files = createMap(); return { @@ -170,32 +244,27 @@ var ts; clear: clear, }; function forEachValueInMap(f) { - for (var key in files) { - f(key, files[key]); - } + files.forEach(function (file, key) { + f(key, file); + }); } function getKeys() { - var keys = []; - for (var key in files) { - keys.push(key); - } - return keys; + return arrayFrom(files.keys()); } function get(path) { - return files[toKey(path)]; + return files.get(toKey(path)); } function set(path, value) { - files[toKey(path)] = value; + files.set(toKey(path), value); } function contains(path) { - return toKey(path) in files; + return files.has(toKey(path)); } function remove(path) { - var key = toKey(path); - delete files[key]; + files.delete(toKey(path)); } function clear() { - files = createMap(); + files.clear(); } function toKey(path) { return keyMapper ? keyMapper(path) : path; @@ -209,6 +278,10 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + function length(array) { + return array ? array.length : 0; + } + ts.length = length; function forEach(array, callback) { if (array) { for (var i = 0; i < array.length; i++) { @@ -249,6 +322,15 @@ var ts; return undefined; } ts.find = find; + function findIndex(array, predicate) { + for (var i = 0; i < array.length; i++) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; + } + ts.findIndex = findIndex; function findMap(array, callback) { for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); @@ -470,21 +552,18 @@ var ts; return result; } ts.spanMap = spanMap; - function mapObject(object, f) { - var result; - if (object) { - result = {}; - for (var _i = 0, _a = getOwnKeys(object); _i < _a.length; _i++) { - var v = _a[_i]; - var _b = f(v, object[v]) || [undefined, undefined], key = _b[0], value = _b[1]; - if (key !== undefined) { - result[key] = value; - } - } + function mapEntries(map, f) { + if (!map) { + return undefined; } + var result = createMap(); + map.forEach(function (value, key) { + var _a = f(key, value), newKey = _a[0], newValue = _a[1]; + result.set(newKey, newValue); + }); return result; } - ts.mapObject = mapObject; + ts.mapEntries = mapEntries; function some(array, predicate) { if (array) { if (predicate) { @@ -768,38 +847,55 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - function forEachProperty(map, callback) { - var result; - for (var key in map) { - if (result = callback(map[key], key)) - break; + function arrayFrom(iterator) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(value); } return result; + var _b; } - ts.forEachProperty = forEachProperty; - function someProperties(map, predicate) { - for (var key in map) { - if (!predicate || predicate(map[key], key)) - return true; + ts.arrayFrom = arrayFrom; + function convertToArray(iterator, f) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(f(value)); } - return false; + return result; + var _b; } - ts.someProperties = someProperties; - function copyProperties(source, target) { - for (var key in source) { - target[key] = source[key]; + ts.convertToArray = convertToArray; + function forEachEntry(map, callback) { + var iterator = map.entries(); + for (var _a = iterator.next(), pair = _a.value, done = _a.done; !done; _b = iterator.next(), pair = _b.value, done = _b.done, _b) { + var key = pair[0], value = pair[1]; + var result = callback(value, key); + if (result) { + return result; + } } + return undefined; + var _b; } - ts.copyProperties = copyProperties; - function appendProperty(map, key, value) { - if (key === undefined || value === undefined) - return map; - if (map === undefined) - map = createMap(); - map[key] = value; - return map; + ts.forEachEntry = forEachEntry; + function forEachKey(map, callback) { + var iterator = map.keys(); + for (var _a = iterator.next(), key = _a.value, done = _a.done; !done; _b = iterator.next(), key = _b.value, done = _b.done, _b) { + var result = callback(key); + if (result) { + return result; + } + } + return undefined; + var _b; } - ts.appendProperty = appendProperty; + ts.forEachKey = forEachKey; + function copyEntries(source, target) { + source.forEach(function (value, key) { + target.set(key, value); + }); + } + ts.copyEntries = copyEntries; function assign(t) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -815,14 +911,6 @@ var ts; return t; } ts.assign = assign; - function reduceProperties(map, callback, initial) { - var result = initial; - for (var key in map) { - result = callback(result, map[key], String(key)); - } - return result; - } - ts.reduceProperties = reduceProperties; function equalOwnProperties(left, right, equalityComparer) { if (left === right) return true; @@ -847,23 +935,14 @@ var ts; var result = createMap(); for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { var value = array_8[_i]; - result[makeKey(value)] = makeValue ? makeValue(value) : value; + result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; } ts.arrayToMap = arrayToMap; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; function cloneMap(map) { var clone = createMap(); - copyProperties(map, clone); + copyEntries(map, clone); return clone; } ts.cloneMap = cloneMap; @@ -890,27 +969,32 @@ var ts; return result; } ts.extend = extend; - function multiMapAdd(map, key, value) { - var values = map[key]; + function createMultiMap() { + var map = createMap(); + map.add = multiMapAdd; + map.remove = multiMapRemove; + return map; + } + ts.createMultiMap = createMultiMap; + function multiMapAdd(key, value) { + var values = this.get(key); if (values) { values.push(value); - return values; } else { - return map[key] = [value]; + this.set(key, values = [value]); } + return values; } - ts.multiMapAdd = multiMapAdd; - function multiMapRemove(map, key, value) { - var values = map[key]; + function multiMapRemove(key, value) { + var values = this.get(key); if (values) { unorderedRemoveItem(values, value); if (!values.length) { - delete map[key]; + this.delete(key); } } } - ts.multiMapRemove = multiMapRemove; function isArray(value) { return Array.isArray ? Array.isArray(value) : value instanceof Array; } @@ -1088,8 +1172,10 @@ var ts; if (b === undefined) return 1; if (ignoreCase) { - if (ts.collator && String.prototype.localeCompare) { - var result = a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); + if (ts.collator) { + var result = ts.localeCompareIsCorrect ? + ts.collator.compare(a, b) : + a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 : result > 0 ? 1 : 0; } a = a.toUpperCase(); @@ -1471,36 +1557,26 @@ var ts; var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; var singleAsteriskRegexFragmentOther = "[^/]*"; function getRegularExpressionForWildcard(specs, basePath, usage) { + var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); + if (!patterns || !patterns.length) { + return undefined; + } + var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; + } + ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + function getRegularExpressionsForWildcards(specs, basePath, usage) { if (specs === undefined || specs.length === 0) { return undefined; } var replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther; var singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther; var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; - var pattern = ""; - var hasWrittenSubpattern = false; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!spec) { - continue; - } - var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); - if (subPattern === undefined) { - continue; - } - if (hasWrittenSubpattern) { - pattern += "|"; - } - pattern += "(" + subPattern + ")"; - hasWrittenSubpattern = true; - } - if (!pattern) { - return undefined; - } - var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return flatMap(specs, function (spec) { + return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + }); } - ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function isImplicitGlob(lastPathComponent) { return !/[.*?]/.test(lastPathComponent); } @@ -1570,6 +1646,7 @@ var ts; currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); return { + includeFilePatterns: map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -1582,34 +1659,48 @@ var ts; currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); - var result = []; + var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; + var comparer = useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive; for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; visitDirectory(basePath, combinePaths(currentDirectory, basePath)); } - return result; + return flatten(results); function visitDirectory(path, absolutePath) { var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; + files = files.slice().sort(comparer); + directories = directories.slice().sort(comparer); + var _loop_1 = function (current) { + var name = combinePaths(path, current); + var absoluteName = combinePaths(absolutePath, current); + if (extensions && !fileExtensionIsAny(name, extensions)) + return "continue"; + if (excludeRegex && excludeRegex.test(absoluteName)) + return "continue"; + if (!includeFileRegexes) { + results[0].push(name); + } + else { + var includeIndex = findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); }); + if (includeIndex !== -1) { + results[includeIndex].push(name); + } + } + }; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var current = files_1[_i]; - var name_1 = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); - if ((!extensions || fileExtensionIsAny(name_1, extensions)) && - (!includeFileRegex || includeFileRegex.test(absoluteName)) && - (!excludeRegex || !excludeRegex.test(absoluteName))) { - result.push(name_1); - } + _loop_1(current); } for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var current = directories_1[_b]; - var name_2 = combinePaths(path, current); + var name = combinePaths(path, current); var absoluteName = combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { - visitDirectory(name_2, absoluteName); + visitDirectory(name, absoluteName); } } } @@ -1625,14 +1716,14 @@ var ts; includeBasePaths.push(getIncludeBasePath(absolute)); } includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); - var _loop_1 = function (includeBasePath) { + var _loop_2 = function (includeBasePath) { if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } }; for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { var includeBasePath = includeBasePaths_1[_a]; - _loop_1(includeBasePath); + _loop_2(includeBasePath); } } return basePaths; @@ -1672,13 +1763,13 @@ var ts; var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions); function getSupportedExtensions(options, extraFileExtensions) { var needAllExtensions = options && options.allowJs; - if (!extraFileExtensions || extraFileExtensions.length === 0) { + if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = (needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions).slice(0); + var extensions = allSupportedExtensions.slice(0); for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { var extInfo = extraFileExtensions_1[_i]; - if (needAllExtensions || extInfo.scriptKind === 3) { + if (extensions.indexOf(extInfo.extension) === -1) { extensions.push(extInfo.extension); } } @@ -1709,30 +1800,30 @@ var ts; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { - return adjustExtensionPriority(i); + return adjustExtensionPriority(i, supportedExtensions); } } return 0; } ts.getExtensionPriority = getExtensionPriority; - function adjustExtensionPriority(extensionPriority) { + function adjustExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2) { return 0; } - else if (extensionPriority < 5) { + else if (extensionPriority < supportedExtensions.length) { return 2; } else { - return 5; + return supportedExtensions.length; } } ts.adjustExtensionPriority = adjustExtensionPriority; - function getNextLowestExtensionPriority(extensionPriority) { + function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2) { return 2; } else { - return 5; + return supportedExtensions.length; } } ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority; @@ -2079,32 +2170,32 @@ var ts; var useNonPollingWatchers = process.env["TSC_NONPOLLING_WATCHER"]; function createWatchedFileSet() { var dirWatchers = ts.createMap(); - var fileWatcherCallbacks = ts.createMap(); + var fileWatcherCallbacks = ts.createMultiMap(); return { addFile: addFile, removeFile: removeFile }; function reduceDirWatcherRefCountForFile(fileName) { var dirName = ts.getDirectoryPath(fileName); - var watcher = dirWatchers[dirName]; + var watcher = dirWatchers.get(dirName); if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); - delete dirWatchers[dirName]; + dirWatchers.delete(dirName); } } } function addDirWatcher(dirPath) { - var watcher = dirWatchers[dirPath]; + var watcher = dirWatchers.get(dirPath); if (watcher) { watcher.referenceCount += 1; return; } watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; - dirWatchers[dirPath] = watcher; + dirWatchers.set(dirPath, watcher); return; } function addFileWatcherCallback(filePath, callback) { - ts.multiMapAdd(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.add(filePath, callback); } function addFile(fileName, callback) { addFileWatcherCallback(fileName, callback); @@ -2116,16 +2207,19 @@ var ts; reduceDirWatcherRefCountForFile(watchedFile.fileName); } function removeFileWatcherCallback(filePath, callback) { - ts.multiMapRemove(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.remove(filePath, callback); } function fileEventHandler(eventName, relativeFileName, baseDirPath) { var fileName = typeof relativeFileName !== "string" ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); - if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { - for (var _i = 0, _a = fileWatcherCallbacks[fileName]; _i < _a.length; _i++) { - var fileCallback = _a[_i]; - fileCallback(fileName); + if ((eventName === "change" || eventName === "rename")) { + var callbacks = fileWatcherCallbacks.get(fileName); + if (callbacks) { + for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) { + var fileCallback = callbacks_1[_i]; + fileCallback(fileName); + } } } } @@ -2190,10 +2284,10 @@ var ts; if (entry === "." || entry === "..") { continue; } - var name_3 = ts.combinePaths(path, entry); + var name = ts.combinePaths(path, entry); var stat = void 0; try { - stat = _fs.statSync(name_3); + stat = _fs.statSync(name); } catch (e) { continue; @@ -2267,7 +2361,7 @@ var ts; }, watchDirectory: function (directoryName, callback, recursive) { var options; - if (!directoryExists(directoryName)) { + if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { @@ -2282,6 +2376,9 @@ var ts; } ; }); + function isUNCPath(s) { + return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47; + } }, resolvePath: function (path) { return _path.resolve(path); @@ -2592,6 +2689,7 @@ var ts; Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", message: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", message: "Invalid use of '{0}'. Modules are automatically in strict mode." }, + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", message: "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export_assignment_is_not_supported_when_module_flag_is_system_1218", message: "Export assignment is not supported when '--module' flag is 'system'." }, Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", message: "Generators are only available when targeting ECMAScript 2015 or higher." }, @@ -2870,6 +2968,8 @@ var ts; Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, + A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, + Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union 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_2601", message: "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_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2880,6 +2980,7 @@ var ts; 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_2607", message: "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_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, + Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -2928,11 +3029,15 @@ var ts; The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: { code: 2699, category: ts.DiagnosticCategory.Error, key: "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", message: "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'." }, Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, + Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, + Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "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_4002", message: "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_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2943,8 +3048,8 @@ var ts; Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4014", message: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_function_has_or_is_using_private_name_1_4016", message: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019", message: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "'extends' clause of exported class '{0}' has or is using private name '{1}'." }, + extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "'extends' clause of exported interface '{0}' has or is using private name '{1}'." }, Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023", message: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024", message: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_private_name_1_4025", message: "Exported variable '{0}' has or is using private name '{1}'." }, @@ -3007,6 +3112,7 @@ var ts; Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced: { code: 4093, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced_4093", message: "'extends' clause of exported class '{0}' refers to a type whose name cannot be referenced." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -3052,7 +3158,7 @@ var ts; Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, - Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_in_the_given_directory_6020", message: "Compile the project in the given directory." }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, @@ -3067,6 +3173,7 @@ var ts; LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, STRATEGY: { code: 6039, category: ts.DiagnosticCategory.Message, key: "STRATEGY_6039", message: "STRATEGY" }, + FILE_OR_DIRECTORY: { code: 6040, category: ts.DiagnosticCategory.Message, key: "FILE_OR_DIRECTORY_6040", message: "FILE OR DIRECTORY" }, Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation_complete_Watching_for_file_changes_6042", message: "Compilation complete. Watching for file changes." }, Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_map_file_6043", message: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_expects_an_argument_6044", message: "Compiler option '{0}' expects an argument." }, @@ -3100,7 +3207,7 @@ var ts; Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, @@ -3120,7 +3227,7 @@ var ts; File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, + package_json_does_not_have_a_0_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_0_field_6100", message: "'package.json' does not have a '{0}' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -3157,7 +3264,6 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, @@ -3210,7 +3316,7 @@ var ts; parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: ts.DiagnosticCategory.Error, key: "parameter_modifiers_can_only_be_used_in_a_ts_file_8012", message: "'parameter modifiers' 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_8015", message: "'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_8016", message: "'type assertion expressions' 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_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause." }, class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "class_expressions_are_not_currently_supported_9003", message: "'class' expressions are not currently supported." }, Language_service_is_disabled: { code: 9004, category: ts.DiagnosticCategory.Error, key: "Language_service_is_disabled_9004", message: "Language service is disabled." }, 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_17000", message: "JSX attributes must only be assigned a non-empty 'expression'." }, @@ -3234,9 +3340,10 @@ var ts; Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, + Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, @@ -3252,7 +3359,7 @@ var ts; return token >= 70; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = ts.createMap({ + var textToToken = ts.createMapFromTemplate({ "abstract": 116, "any": 118, "as": 117, @@ -3276,7 +3383,7 @@ var ts; "false": 85, "finally": 86, "for": 87, - "from": 138, + "from": 139, "function": 88, "get": 124, "if": 89, @@ -3294,27 +3401,28 @@ var ts; "new": 93, "null": 94, "number": 132, + "object": 133, "package": 110, "private": 111, "protected": 112, "public": 113, "readonly": 130, "require": 131, - "global": 139, + "global": 140, "return": 95, - "set": 133, + "set": 134, "static": 114, - "string": 134, + "string": 135, "super": 96, "switch": 97, - "symbol": 135, + "symbol": 136, "this": 98, "throw": 99, "true": 100, "try": 101, - "type": 136, + "type": 137, "typeof": 102, - "undefined": 137, + "undefined": 138, "var": 103, "void": 104, "while": 105, @@ -3322,7 +3430,7 @@ var ts; "yield": 115, "async": 119, "await": 120, - "of": 140, + "of": 141, "{": 16, "}": 17, "(": 18, @@ -3417,9 +3525,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_4 in source) { - result[source[name_4]] = name_4; - } + source.forEach(function (value, name) { + result[value] = name; + }); return result; } var tokenStrings = makeReverseMap(textToToken); @@ -3428,7 +3536,7 @@ var ts; } ts.tokenToString = tokenToString; function stringToToken(s) { - return textToToken[s]; + return textToToken.get(s); } ts.stringToToken = stringToToken; function computeLineStarts(text) { @@ -3488,7 +3596,6 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - var hasOwnProperty = Object.prototype.hasOwnProperty; function isWhiteSpace(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } @@ -4147,8 +4254,11 @@ var ts; var len = tokenValue.length; if (len >= 2 && len <= 11) { var ch = tokenValue.charCodeAt(0); - if (ch >= 97 && ch <= 122 && hasOwnProperty.call(textToToken, tokenValue)) { - return token = textToToken[tokenValue]; + if (ch >= 97 && ch <= 122) { + token = textToToken.get(tokenValue); + if (token !== undefined) { + return token; + } } } return token = 70; @@ -4858,12 +4968,13 @@ var ts; }, { name: "jsx", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "preserve": 1, + "react-native": 3, "react": 2 }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, }, { name: "reactNamespace", @@ -4893,7 +5004,7 @@ var ts; { name: "module", shortName: "m", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "none": ts.ModuleKind.None, "commonjs": ts.ModuleKind.CommonJS, "amd": ts.ModuleKind.AMD, @@ -4907,7 +5018,7 @@ var ts; }, { name: "newLine", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "crlf": 0, "lf": 1 }), @@ -5004,8 +5115,8 @@ var ts; shortName: "p", type: "string", isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY + description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY }, { name: "removeComments", @@ -5055,7 +5166,7 @@ var ts; { name: "target", shortName: "t", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "es3": 0, "es5": 1, "es6": 2, @@ -5092,7 +5203,7 @@ var ts; }, { name: "moduleResolution", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "node": ts.ModuleResolutionKind.NodeJs, "classic": ts.ModuleResolutionKind.Classic, }), @@ -5197,7 +5308,7 @@ var ts; type: "list", element: { name: "lib", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "es5": "lib.es5.d.ts", "es6": "lib.es2015.d.ts", "es2015": "lib.es2015.d.ts", @@ -5243,6 +5354,15 @@ var ts; name: "alwaysStrict", type: "boolean", description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + }, + { + name: "plugins", + type: "list", + isTSConfigOnly: true, + element: { + name: "plugin", + type: "object" + } } ]; ts.typeAcquisitionDeclarations = [ @@ -5297,9 +5417,9 @@ var ts; var optionNameMap = ts.createMap(); var shortOptionNames = ts.createMap(); ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; + optionNameMap.set(option.name.toLowerCase(), option); if (option.shortName) { - shortOptionNames[option.shortName] = option.name; + shortOptionNames.set(option.shortName, option.name); } }); optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; @@ -5307,7 +5427,7 @@ var ts; } ts.getOptionNameMap = getOptionNameMap; function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -5356,11 +5476,12 @@ var ts; } else if (s.charCodeAt(0) === 45) { s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); - if (s in shortOptionNames) { - s = shortOptionNames[s]; + var short = shortOptionNames.get(s); + if (short !== undefined) { + s = short; } - if (s in optionNameMap) { - var opt = optionNameMap[s]; + var opt = optionNameMap.get(s); + if (opt) { if (opt.isTSConfigOnly) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } @@ -5486,19 +5607,18 @@ var ts; } } function getNameOfCompilerOptionValue(value, customTypeMap) { - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { return key; } - } - return undefined; + }); } function serializeCompilerOptions(options) { - var result = ts.createMap(); + var result = {}; var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_5 in options) { - if (ts.hasProperty(options, name_5)) { - switch (name_5) { + for (var name in options) { + if (ts.hasProperty(options, name)) { + switch (name) { case "init": case "watch": case "version": @@ -5506,12 +5626,12 @@ var ts; case "project": break; default: - var value = options[name_5]; - var optionDefinition = optionsNameMap[name_5.toLowerCase()]; + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { - result[name_5] = value; + result[name] = value; } else { if (optionDefinition.type === "list") { @@ -5520,10 +5640,10 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_5] = convertedValue; + result[name] = convertedValue; } else { - result[name_5] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -5730,8 +5850,8 @@ var ts; } var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; + var opt = optionNameMap.get(id); + if (opt) { defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); } else { @@ -5765,8 +5885,9 @@ var ts; } function convertJsonOptionOfCustomType(opt, value, errors) { var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; + var val = opt.type.get(key); + if (val !== undefined) { + return val; } else { errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); @@ -5800,7 +5921,7 @@ var ts; for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { var fileName = fileNames_1[_i]; var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; + literalFileMap.set(keyMapper(file), file); } } if (include && include.length > 0) { @@ -5811,14 +5932,13 @@ var ts; } removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; + if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) { + wildcardFileMap.set(key, file); } } } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); + var literalFiles = ts.arrayFrom(literalFileMap.values()); + var wildcardFiles = ts.arrayFrom(wildcardFileMap.values()); return { fileNames: literalFiles.concat(wildcardFiles), wildcardDirectories: wildcardDirectories @@ -5826,8 +5946,8 @@ var ts; } function validateSpecs(specs, errors, allowTrailingRecursion) { var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + var spec = specs_1[_i]; if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); } @@ -5846,7 +5966,7 @@ var ts; function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); + var wildcardDirectories = {}; if (include !== undefined) { var recursiveKeys = []; for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { @@ -5867,14 +5987,16 @@ var ts; } } } - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; + for (var key in wildcardDirectories) + if (ts.hasProperty(wildcardDirectories, key)) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } } } - } + ; } return wildcardDirectories; } @@ -5893,11 +6015,11 @@ var ts; } function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); + var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions); for (var i = 0; i < adjustedExtensionPriority; i++) { var higherPriorityExtension = extensions[i]; var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { return true; } } @@ -5905,17 +6027,13 @@ var ts; } function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions); for (var i = nextExtensionPriority; i < extensions.length; i++) { var lowerPriorityExtension = extensions[i]; var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; + wildcardFiles.delete(lowerPriorityPath); } } - function addFileToOutput(output, file) { - output.push(file); - return output; - } function caseSensitiveKeyMapper(key) { return key; } @@ -5951,7 +6069,7 @@ var ts; }); if (!safeList) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = result.config ? ts.createMap(result.config) : EmptySafeList; + safeList = result.config ? ts.createMapFromTemplate(result.config) : EmptySafeList; } var filesToWatch = []; var searchDirs = []; @@ -5976,31 +6094,31 @@ var ts; if (unresolvedImports) { for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { var moduleId = unresolvedImports_1[_a]; - var typingName = moduleId in nodeCoreModules ? "node" : moduleId; - if (!(typingName in inferredTypings)) { - inferredTypings[typingName] = undefined; + var typingName = nodeCoreModules.has(moduleId) ? "node" : moduleId; + if (!inferredTypings.has(typingName)) { + inferredTypings.set(typingName, undefined); } } } - for (var name_6 in packageNameToTypingLocation) { - if (name_6 in inferredTypings && !inferredTypings[name_6]) { - inferredTypings[name_6] = packageNameToTypingLocation[name_6]; + packageNameToTypingLocation.forEach(function (typingLocation, name) { + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined) { + inferredTypings.set(name, typingLocation); } - } + }); for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { var excludeTypingName = exclude_1[_b]; - delete inferredTypings[excludeTypingName]; + inferredTypings.delete(excludeTypingName); } var newTypingNames = []; var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); + inferredTypings.forEach(function (inferred, typing) { + if (inferred !== undefined) { + cachedTypingPaths.push(inferred); } else { newTypingNames.push(typing); } - } + }); return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; function mergeTypings(typingNames) { if (!typingNames) { @@ -6008,8 +6126,8 @@ var ts; } for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { var typing = typingNames_1[_i]; - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; + if (!inferredTypings.has(typing)) { + inferredTypings.set(typing, undefined); } } } @@ -6039,7 +6157,7 @@ var ts; var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); if (safeList !== EmptySafeList) { - mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return safeList.has(f); })); } var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); if (hasJsxFile) { @@ -6072,7 +6190,7 @@ var ts; } if (packageJson.typings) { var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; + inferredTypings.set(packageJson.name, absolutePath); } else { typingNames.push(packageJson.name); @@ -6145,37 +6263,28 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { + function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); - switch (extensions) { - case Extensions.DtsOnly: - case Extensions.TypeScript: - return tryReadFromField("typings") || tryReadFromField("types"); - case Extensions.JavaScript: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; - } + return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); - } - return typesFilePath; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } + if (!ts.hasProperty(jsonContent, fieldName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName); } + return; } + var fileName = jsonContent[fieldName]; + if (typeof fileName !== "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof fileName); + } + return; + } + var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path); + } + return path; } } function readJson(path, host) { @@ -6347,9 +6456,10 @@ var ts; if (!moduleHasNonRelativeName(nonRelativeModuleName)) { return undefined; } - var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); if (!perModuleNameCache) { - moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + perModuleNameCache = createPerModuleNameCache(); + moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); } return perModuleNameCache; } @@ -6369,12 +6479,12 @@ var ts; var commonPrefix = getCommonPrefix(path, resolvedFileName); var current = path; while (true) { - var parent_1 = ts.getDirectoryPath(current); - if (parent_1 === current || directoryPathMap.contains(parent_1)) { + var parent = ts.getDirectoryPath(current); + if (parent === current || directoryPathMap.contains(parent)) { break; } - directoryPathMap.set(parent_1, result); - current = parent_1; + directoryPathMap.set(parent, result); + current = parent; if (current == commonPrefix) { break; } @@ -6405,7 +6515,7 @@ var ts; } var containingDirectory = ts.getDirectoryPath(containingFile); var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); - var result = perFolderCache && perFolderCache[moduleName]; + var result = perFolderCache && perFolderCache.get(moduleName); if (result) { if (traceEnabled) { trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); @@ -6433,7 +6543,7 @@ var ts; break; } if (perFolderCache) { - perFolderCache[moduleName] = result; + perFolderCache.set(moduleName, result); var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); if (perModuleNameCache) { perModuleNameCache.set(containingDirectory, result); @@ -6564,18 +6674,24 @@ var ts; } } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, false); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, jsOnly) { + if (jsOnly === void 0) { jsOnly = false; } var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + var result = jsOnly ? tryResolve(Extensions.JavaScript) : (tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript)); if (result && result.value) { var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { - var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + var loader = function (extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, true); }; + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); if (resolved) { return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } @@ -6588,12 +6704,12 @@ var ts; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state, true); return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } - ts.nodeModuleNameResolver = nodeModuleNameResolver; + ts.nodeModuleNameResolverWorker = nodeModuleNameResolverWorker; function realpath(path, host, traceEnabled) { if (!host.realpath) { return path; @@ -6604,7 +6720,7 @@ var ts; } return real; } - function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } @@ -6632,7 +6748,7 @@ var ts; onlyRecordFailures = true; } } - return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); @@ -6689,45 +6805,48 @@ var ts; failedLookupLocations.push(fileName); return undefined; } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { + if (considerPackageJson === void 0) { considerPackageJson = true; } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); - if (mainOrTypesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); - var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromExactFile) { - var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); - if (resolved_3) { - return resolved_3; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); - } - } - var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); - if (resolved) { - return resolved; + if (considerPackageJson) { + var packageJsonPath = pathToPackageJson(candidate); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; } } else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); + if (directoryExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + failedLookupLocations.push(packageJsonPath); } } - else { - if (directoryExists && state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - failedLookupLocations.push(packageJsonPath); - } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + if (!file) { + return undefined; + } + var onlyRecordFailures = !directoryProbablyExists(ts.getDirectoryPath(file), state.host); + var fromFile = tryFile(file, failedLookupLocations, onlyRecordFailures, state); + if (fromFile) { + var resolved = fromFile && resolvedIfExtensionMatches(extensions, fromFile); + if (resolved) { + return resolved; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile); + } + } + var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; + return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, false); + } function resolvedIfExtensionMatches(extensions, path) { var extension = ts.tryGetExtensionFromPath(path); return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; @@ -6814,7 +6933,7 @@ var ts; } var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { - var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); if (resolutionFromCache) { return resolutionFromCache; @@ -6822,8 +6941,8 @@ var ts; var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); - if (resolved_4) { - return resolved_4; + if (resolved_3) { + return resolved_3; } if (extensions === Extensions.TypeScript) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); @@ -6946,7 +7065,7 @@ var ts; if (this.log.isEnabled()) { this.log.writeLine("Closing file watchers for project '" + projectName + "'"); } - var watchers = this.projectWatchers[projectName]; + var watchers = this.projectWatchers.get(projectName); if (!watchers) { if (this.log.isEnabled()) { this.log.writeLine("No watchers are registered for project '" + projectName + "'"); @@ -6957,7 +7076,7 @@ var ts; var w = watchers_1[_i]; w.close(); } - delete this.projectWatchers[projectName]; + this.projectWatchers.delete(projectName); if (this.log.isEnabled()) { this.log.writeLine("Closing file watchers for project '" + projectName + "' - done."); } @@ -6991,7 +7110,7 @@ var ts; if (this.log.isEnabled()) { this.log.writeLine("Processing cache location '" + cacheLocation + "'"); } - if (this.knownCachesSet[cacheLocation]) { + if (this.knownCachesSet.get(cacheLocation)) { if (this.log.isEnabled()) { this.log.writeLine("Cache location was already processed..."); } @@ -7014,10 +7133,10 @@ var ts; } var typingFile = typingToFileName(cacheLocation, packageName, this.installTypingHost, this.log); if (!typingFile) { - this.missingTypingsSet[packageName] = true; + this.missingTypingsSet.set(packageName, true); continue; } - var existingTypingFile = this.packageNameToTypingLocation[packageName]; + var existingTypingFile = this.packageNameToTypingLocation.get(packageName); if (existingTypingFile === typingFile) { continue; } @@ -7029,14 +7148,14 @@ var ts; if (this.log.isEnabled()) { this.log.writeLine("Adding entry into typings cache: '" + packageName + "' => '" + typingFile + "'"); } - this.packageNameToTypingLocation[packageName] = typingFile; + this.packageNameToTypingLocation.set(packageName, typingFile); } } } if (this.log.isEnabled()) { this.log.writeLine("Finished processing cache location '" + cacheLocation + "'"); } - this.knownCachesSet[cacheLocation] = true; + this.knownCachesSet.set(cacheLocation, true); }; TypingsInstaller.prototype.filterTypings = function (typingsToInstall) { if (typingsToInstall.length === 0) { @@ -7045,12 +7164,12 @@ var ts; var result = []; for (var _i = 0, typingsToInstall_1 = typingsToInstall; _i < typingsToInstall_1.length; _i++) { var typing = typingsToInstall_1[_i]; - if (this.missingTypingsSet[typing] || this.packageNameToTypingLocation[typing]) { + if (this.missingTypingsSet.get(typing) || this.packageNameToTypingLocation.get(typing)) { continue; } var validationResult = validatePackageName(typing); if (validationResult === PackageNameValidationResult.Ok) { - if (typing in this.typesRegistry) { + if (this.typesRegistry.has(typing)) { result.push(typing); } else { @@ -7060,7 +7179,7 @@ var ts; } } else { - this.missingTypingsSet[typing] = true; + this.missingTypingsSet.set(typing, true); if (this.log.isEnabled()) { switch (validationResult) { case PackageNameValidationResult.EmptyName: @@ -7106,8 +7225,7 @@ var ts; this.log.writeLine("Installing typings " + JSON.stringify(typingsToInstall)); } var filteredTypings = this.filterTypings(typingsToInstall); - var scopedTypings = filteredTypings.map(function (x) { return "@types/" + x; }); - if (scopedTypings.length === 0) { + if (filteredTypings.length === 0) { if (this.log.isEnabled()) { this.log.writeLine("All typings are known to be missing or invalid - no need to go any further"); } @@ -7122,6 +7240,7 @@ var ts; typingsInstallerVersion: ts.version, projectName: req.projectName }); + var scopedTypings = filteredTypings.map(typingsName); this.installTypingsAsync(requestId, scopedTypings, cachePath, function (ok) { try { if (!ok) { @@ -7130,7 +7249,7 @@ var ts; } for (var _i = 0, filteredTypings_1 = filteredTypings; _i < filteredTypings_1.length; _i++) { var typing = filteredTypings_1[_i]; - _this.missingTypingsSet[typing] = true; + _this.missingTypingsSet.set(typing, true); } return; } @@ -7142,11 +7261,11 @@ var ts; var packageName = filteredTypings_2[_a]; var typingFile = typingToFileName(cachePath, packageName, _this.installTypingHost, _this.log); if (!typingFile) { - _this.missingTypingsSet[packageName] = true; + _this.missingTypingsSet.set(packageName, true); continue; } - if (!_this.packageNameToTypingLocation[packageName]) { - _this.packageNameToTypingLocation[packageName] = typingFile; + if (!_this.packageNameToTypingLocation.has(packageName)) { + _this.packageNameToTypingLocation.set(packageName, typingFile); } installedTypingFiles.push(typingFile); } @@ -7197,7 +7316,7 @@ var ts; }, 2000); watchers.push(w); } - this.projectWatchers[projectName] = watchers; + this.projectWatchers.set(projectName, watchers); }; TypingsInstaller.prototype.createSetTypings = function (request, typings) { return { @@ -7215,7 +7334,7 @@ var ts; }; TypingsInstaller.prototype.executeWithThrottling = function () { var _this = this; - var _loop_2 = function () { + var _loop_3 = function () { this_1.inFlightRequestCount++; var request = this_1.pendingRunRequests.pop(); this_1.installWorker(request.requestId, request.args, request.cwd, function (ok) { @@ -7226,12 +7345,17 @@ var ts; }; var this_1 = this; while (this.inFlightRequestCount < this.throttleLimit && this.pendingRunRequests.length) { - _loop_2(); + _loop_3(); } }; return TypingsInstaller; }()); typingsInstaller.TypingsInstaller = TypingsInstaller; + function typingsName(packageName) { + return "@types/" + packageName + "@ts" + versionMajorMinor; + } + typingsInstaller.typingsName = typingsName; + var versionMajorMinor = ts.version.split(".").slice(0, 2).join("."); })(typingsInstaller = server.typingsInstaller || (server.typingsInstaller = {})); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); @@ -7272,7 +7396,7 @@ var ts; } try { var content = JSON.parse(host.readFile(typesRegistryFilePath)); - return ts.createMap(content.entries); + return ts.createMapFromTemplate(content.entries); } catch (e) { if (log.isEnabled()) { diff --git a/src/server/tsconfig.json b/src/server/tsconfig.json index 2f17019e2de..b0eb4965ea6 100644 --- a/src/server/tsconfig.json +++ b/src/server/tsconfig.json @@ -3,6 +3,7 @@ "compilerOptions": { "removeComments": true, "outFile": "../../built/local/tsserver.js", + "preserveConstEnums": true, "types": [ "node" ]